org.eclipse.ocl.examples.domain.utilities
Class StandaloneProjectMap

java.lang.Object
  extended by org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
      extended by org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap
All Implemented Interfaces:
org.eclipse.emf.common.notify.Adapter, org.eclipse.emf.common.notify.Adapter.Internal
Direct Known Subclasses:
ProjectMap

public class StandaloneProjectMap
extends org.eclipse.emf.common.notify.impl.SingletonAdapterImpl

StandaloneProjectMap and ProjectMap provide facilities to assist in preparing the URIConverter, the EPackage.Registry, and the and URIResourceMap of a ResourceSet and the global and EcorePlugin.getPlatformResourceMap() and EcorePlugin.getEPackageNsURIToGenModelLocationMap() to support arbitrary and compatible use of dynamically loaded resources such as platform:/plugin and platform:/resource and generated EPackages such as registered namespace URIs in both plugin and standalone environments.

StandaloneProjectMap supports only standalone usage and so is free of dependencies on the Eclipse platform. ProjectMap extends StandaloneProjectMap to provide polymorphic standalone and plugin environments.

As a result, when the current file context is my.project/model/MyModel.ecore, and when the classpath contains only the JAR version of Ecore, referencing a resource as any or all of

results in the same Resource being returned by ResourceSet.getResource(URI, boolean).

If the classpath contains distinct imported project and JAR versions of Ecore, referencing

returns the generated EPackage from the JAR plugin version while referencing returns a dynamically loaded imported project version.

A ProjectMap consists of a map from a project or bundle name to a location that is resolvable by the conventional Platform URL stream opening capabilities. Utility methods support export of the map to initialize the URIMap in a URIConverter and/or the EcorePlugin.getPlatformResourceMap().

Minimal usage to configure aResourceSet is just
new ProjectMap().initializeResourceSet(aResourceSet);
or ProjectMap.getAdapter(aResourceSet);
Thereafter EMF accesses to projects and bundles should just work.

Standalone Environment

A resolvable location is a physical location such as

getProjectDescriptors() returns a map of project names and bundle names to a physical location which is established by searching the classpath for folders and JARs containing .project files. If a manifest is also found, the search has found a bundle and the Bundle-SymbolicName is read from the manifest.

initializePackageRegistry(ResourceSet) populates a registration for each genPackages.ecorePackage referenced from a genmodel referenced from a org.eclipse.emf.ecore.generated_package defined in any plugin.xml found on the classpath. The three declarations ensure that when appropriate, each of the namespace URI (e.g. http://www.eclipse.org/emf/2002/Ecore), the project URI (e.g. platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore) and the plugin URI (e.g. platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore) resolve to the same Resource eliminating most opportunities for meta-model schizophrenia.

initializePlatformResourceMap(boolean) populates EcorePlugin.getPlatformResourceMap() with a project to platform:/resource/project entry for each project and a bundle to platform:/plugin/bundle entry for each bundle.

initializeGenModelLocationMap(boolean) exploits the classpath scan for plugins and projects to identify all plugin.xml files and populate the EcorePlugin.getEPackageNsURIToGenModelLocationMap() from the org.eclipse.emf.ecore.generated_package extension points in the same way as occurs automatically in a plugin environment.

initializeURIMap(ResourceSet) installs a platform:/plugin/project to platform:/resource/project URI mapping for each project and a platform:/resource/bundle to platform:/plugin/bundle URI mapping for each bundle.

Static Instances and Re-Use

No static INSTANCE is provided because different class loaders or dynamic class path changes may result in stale content. Standalone applications are strongly advised to create their own static instance in a stable context and so avoid repeating the significant costs of a full class path search.

The getAdapter(ResourceSet) method may be used to invoke initializeResourceSet(ResourceSet) if not already invoked and to install the ProjectMap as a ResourceSet adapter allowing an invocation of findAdapter(ResourceSet) to find it for subsequent re-use.

Conflicts

Use of both generated and dynamically loaded models normally results in obscure metamodel schizophrenia problems SyadaloneProjectMap allows a ResourceLoadStrategy to be independently specified for each resource to select just LoadGeneratedPackagSttrategye or just LoadDynamicResourceStrategy to force a particular usage. LoadFirstStrategy uses whichever is first used. LoadBothStrategy allows both generated and dynamically loaded resources to co-exist. When only one form is in use a conflicting access is resolved by an IConflictHandler. The default behaviour is the LoadFirstStrategy with conflicts silently resolved to whichever was first loaded.

Conflicts can only be diagnosed if the StandaloneProjectMap is aware of the conflict, so useGeneratedResource must be invoked if a GeneratedPackage is used without being loaded in the ResourceSet.

Shared Model

The classpath is analyzed to identify an IProjectDescriptor per project/bundle within which a plugin.xml is analyzed to identify generated_package extension points leading to a an IResourceDescriptor per genmodel and an IPackageDescriptor per nsURI/className within the IResorceDescriptor. There is usually only one nsURI per genmodel but the greater generality has to be accommodated. The foregoing constitute a shared model that can be re-used by multiple applications, so long as the classpath content is unchanged.

Per-ResourceSet Model

The actual state is maintained on a per-ResourceSet basis with an IResourceLoadStatus and one or more IPackageDescriptors for in use IResourceDescriptors and IPackageDescriptors. The IResourceLoadStatus is confugured with an IResourceLoadStrategy and an IConflictHandler.


Nested Class Summary
static class StandaloneProjectMap.AbstractResourceDescriptor
          PackageDescriptor supports lazy class loading and initialization of a compiled Ecore package.
static class StandaloneProjectMap.AbstractResourceLoadStatus
           
protected static class StandaloneProjectMap.AbstractResourceLoadStrategy
           
static class StandaloneProjectMap.DelegatedMultiplePackageResource
          A DelegatedMultiplePackageResource may be installed in a ResourceSet.uriResourceMap so that the appropriate generated EPackage is resolved as the fragment of a dynamically loaded resource.
static class StandaloneProjectMap.DelegatedSinglePackageResource
          A DelegatedSinglePackageResource may be installed in a ResourceSet.uriResourceMap so that the generated EPackage is resolved as a dynamically loaded resource.
protected static class StandaloneProjectMap.EPackageDescriptor
          EPackageDescriptor is an EPackage.Descriptor that loads the appropriate EPackage to resolve a Namespace URI reference to a generated or dynamically loaded EPackage in accordance with the configured ResourceLoadStrategy.
protected static class StandaloneProjectMap.GenModelReader
          GenModelReader provides the SAX callbacks to support reading the genPackages element in a genmodel file.
static interface StandaloneProjectMap.IConflictHandler
          An IConflictHandler confligures the hanling of conflicting access between generated packages and dynamically loaded resources.
static interface StandaloneProjectMap.IPackageDescriptor
          An IPackageDescriptor describes the modeling capabilities of a known model package and may be installed under a variety of synonyms in an EPackage.Registry to map multiple URIs to a single EPackage.
static interface StandaloneProjectMap.IPackageLoadStatus
          An IPackageLoadStatus maintains the lazy load state of a package within an EPackage.Registry
static interface StandaloneProjectMap.IProjectDescriptor
          An IProjectDescriptor describes the capabilities of a project.
static interface StandaloneProjectMap.IResourceDescriptor
          An IResourceDescriptor describes the modeling capabilities of one or more known model packages in a genmodel.
static interface StandaloneProjectMap.IResourceLoadStatus
          An IResourceLoadStatus maintains the lazy load state of a resource associated with a genmodel identified by an IResourceDescriptor within a ResourceSet.
static interface StandaloneProjectMap.IResourceLoadStrategy
          An IResourceLoadStrategy determines how each of the possible forms of URI reference to an EPackage should loaded.
static class StandaloneProjectMap.LoadBothStrategy
          The LoadBothStrategy permits metamodel schizophrenia and so access to the namespace URI resolves to an installed resource while access to the platform plugin or resource URI resolve to a dynamically loaded resource.
static class StandaloneProjectMap.LoadDynamicResourceStrategy
          The LoadDynamicResourceStrategy uses the dynamic EPackage referenced by the platform resource/plugin URI for all kinds of access, and then changes the strategy to LoadedStrategy for all further accesses.
static class StandaloneProjectMap.LoadFirstStrategy
          The LoadFirstStrategy uses the EPackage corresponding to the first access as either a namespace URI or platform plugin.resource URI.Thereafter accesses to the same URI use the first loaded EPackage.
static class StandaloneProjectMap.LoadGeneratedPackageStrategy
          The LoadGeneratedPackageStrategy uses the generated EPackage referenced by the namespace URI for all kinds of access, and then changes the strategy to the LoadedStrategy for all further accesses.
static class StandaloneProjectMap.LoadingBothLoadedDynamicResourceStrategy
          The LoadingBothLoadedDynamicResourceStrategy supports the using-model behaviour following a LoadBothStrategy that has loaded a dynamic resource.
static class StandaloneProjectMap.MapToFirstConflictHandler
          MapToFirstConflictHandler resolves conflicts by returning the first loaded EPackage.
static class StandaloneProjectMap.MapToFirstConflictHandlerWithLog
          MapToFirstConflictHandler resolves conflicts by returning the first loaded EPackage.
static class StandaloneProjectMap.MultiplePackageResourceDescriptor
          PackageDescriptor supports lazy class loading and initialization of a compiled Ecore package.
static class StandaloneProjectMap.MultiplePackageResourceLoadStatus
           
static class StandaloneProjectMap.PackageDescriptor
          PackageDescriptor supports lazy class loading and initialization of a compiled Ecore package.
static class StandaloneProjectMap.PackageLoadStatus
           
protected static class StandaloneProjectMap.PluginReader
          PluginReader provides the SAX callbacks to support reading the org.eclipse.emf.ecore.generated_package extension point in a plugin.xml file and activating the GenModelReader to process the ecorePackage locations.
static class StandaloneProjectMap.ProjectDescriptor
           
static class StandaloneProjectMap.SinglePackageResourceDescriptor
          PackageDescriptor supports lazy class loading and initialization of a compiled Ecore package.
static class StandaloneProjectMap.SinglePackageResourceLoadStatus
           
 
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
org.eclipse.emf.common.notify.Adapter.Internal
 
Field Summary
protected  boolean initializedPlatformResourceMap
           
static java.util.WeakHashMap<StandaloneProjectMap,java.lang.Object> liveStandaloneProjectMaps
          Leak debugging aid.
protected  java.util.Map<org.eclipse.emf.common.util.URI,StandaloneProjectMap.IPackageDescriptor> nsURI2package
          The map of package nsURI to package descriptor.
static TracingOption PROJECT_MAP_ADD_EPACKAGE
           
static TracingOption PROJECT_MAP_ADD_GEN_MODEL
           
static TracingOption PROJECT_MAP_ADD_GENERATED_PACKAGE
           
static TracingOption PROJECT_MAP_ADD_URI_MAP
           
static TracingOption PROJECT_MAP_CONFIGURE
           
static TracingOption PROJECT_MAP_GET
           
static TracingOption PROJECT_MAP_INSTALL
           
static TracingOption PROJECT_MAP_RESOLVE
           
protected  java.util.Map<org.eclipse.emf.common.util.URI,StandaloneProjectMap.IResourceDescriptor> uri2resource
          The map of document URI to resource descriptor.
 
Fields inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
targets
 
Constructor Summary
StandaloneProjectMap()
           
 
Method Summary
 void addResourceDescriptor(StandaloneProjectMap.IResourceDescriptor resourceDescriptor)
          Call-back to add a resourceDescriptor.
 void configure(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, StandaloneProjectMap.IResourceLoadStrategy resourceLoadStrategy, StandaloneProjectMap.IConflictHandler conflictHandler)
          Configure the PackageRegistry associated with ResourceSet to use a resourceLoadStrategy and conflictHandler when resolving namespace ansd platform URIs.
protected  StandaloneProjectMap.IProjectDescriptor createProjectDescriptor(java.lang.String projectName, org.eclipse.emf.common.util.URI locationURI)
           
static void dispose(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Eliminate all facilities used by the ProjectMap for the resourceSet.
protected  void finalize()
           
static StandaloneProjectMap findAdapter(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Return any StandaloneProjectMap already installed as an adapter on a resourceSet.
static StandaloneProjectMap getAdapter(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Return the StandaloneProjectMap already installed as an adapter on a resourceSet if one exists, else creates, installs, initializes and returns a new StandaloneProjectMap.
 java.util.Map<java.lang.String,java.lang.Exception> getExceptionMap()
          Return the mapping of problem files to exceptions, or null if not yet computed or if no exceptions thrown.
 org.eclipse.emf.common.util.URI getLocation(java.lang.String projectName)
          Return the resolveable URI for a given project or bundle name.
 StandaloneProjectMap.IPackageDescriptor getPackageDescriptor(org.eclipse.emf.common.util.URI nsURI)
          Return the IPackageDescriptor for a given nsURI.
static org.eclipse.emf.ecore.EPackage.Registry getPackageRegistry(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Return the EPackage.Registry for a resourceSet or the Global EPackage.Registry.INSTANCE if resourceSet is null.
 StandaloneProjectMap.IProjectDescriptor getProjectDescriptor(java.lang.String projectName)
          Return the IProjectDescriptor for a given project or bundle name.
protected  StandaloneProjectMap.IProjectDescriptor getProjectDescriptorInternal(org.eclipse.emf.common.util.URI platformURI)
           
protected  java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor> getProjectDescriptors()
          Return the mapping of project name or bundle name, as defined in a manifest file to the location of that project as determined by scanning the classpath.
static org.eclipse.emf.ecore.resource.Resource.Factory.Registry getResourceFactoryRegistry(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Return the Resource.Factory.Registry for a resourceSet or the Global Resource.Factory.Registry.INSTANCE if resourceSet is null.
static org.eclipse.emf.ecore.resource.URIConverter getURIConverter(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Return the URIConverter for a resourceSet or the Global URIConverter.INSTANCE if resourceSet is null.
static java.util.Map<org.eclipse.emf.common.util.URI,org.eclipse.emf.common.util.URI> getURIMap(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Return the URI Map for a resourceSet or the Global URIConverter.URI_MAP if resourceSet is null.
 void initializeGenModelLocationMap(boolean force)
          Initialize the EcorePlugin.getEPackageNsURIToGenModelLocationMap() so that in a standalone environment the locations of all genmodels are available.
 void initializePackageRegistry(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Install lazy EPackageDescriptors in the EPackage.Registry for all registered packages and their platform:/plugin and platform:/resource synonyms, which are determined by examining the genPackages.ecorePackage attribute in all genModels.
 void initializePlatformResourceMap(boolean force)
          Initialize the EcorePlugin.getPlatformResourceMap() so that in a standalone environment and in conjunction with initializeURIMap(ResourceSet) URIs such as platform:/resource/project and platform:/plugin/project are useable.
 void initializeResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Ensure that both the EcorePlugin.getPlatformResourceMap() and ResourceSet.getURIConverter() are initialized so that platform:/resource/project and platform:/plugin/project are useable..
 void initializeURIMap(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Initialize the uriMap of a uriConverter so that each of platform:/resource/project and platform:/plugin/project resolve the workspace project resource else the plugin bundle for use in either standalone or plugin environment.
static void initializeURIResourceMap(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Activate any ResourceSetImpl.uriResourceMap so that repeated lookups use a hash rather than linear search.
static void initStatics()
          A simple public static method that may be used to force class initialization.
 boolean isAdapterForType(java.lang.Object type)
           
protected  void logException(java.lang.String message, java.lang.Exception e)
           
protected  void notifyAddedDynamicResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.ecore.resource.Resource resource)
          When a new Resource is added to a watched ResourceSet notify the resourceDescriptor that there is a new (ResourceSet, Resource) pair so that it install both platform:/plugin and platform:/resource entries in the ResourceSet's uriResourceMap and install a listener to detect when the Resource is loaded.
 void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
          Internal call-back to observe Resource addition to a ResourceSet..
protected  StandaloneProjectMap.IProjectDescriptor registerBundle(java.io.File file, javax.xml.parsers.SAXParser saxParser)
           
protected  StandaloneProjectMap.IProjectDescriptor registerProject(java.io.File file)
           
protected  void scanClassPath(java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor> projectDescriptors, javax.xml.parsers.SAXParser saxParser)
           
protected  boolean scanFolder(java.io.File f, javax.xml.parsers.SAXParser saxParser, java.util.Set<java.lang.String> alreadyVisited, int depth)
           
 java.lang.String toString()
           
 void unload(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
           
 void useGeneratedResource(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Use a registered resource for use in conjunction with resourceSet.
 
Methods inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
dispose, getTarget, setTarget, unsetTarget
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROJECT_MAP_ADD_EPACKAGE

@NonNull
public static final TracingOption PROJECT_MAP_ADD_EPACKAGE

PROJECT_MAP_ADD_GEN_MODEL

@NonNull
public static final TracingOption PROJECT_MAP_ADD_GEN_MODEL

PROJECT_MAP_ADD_GENERATED_PACKAGE

@NonNull
public static final TracingOption PROJECT_MAP_ADD_GENERATED_PACKAGE

PROJECT_MAP_ADD_URI_MAP

@NonNull
public static final TracingOption PROJECT_MAP_ADD_URI_MAP

PROJECT_MAP_CONFIGURE

@NonNull
public static final TracingOption PROJECT_MAP_CONFIGURE

PROJECT_MAP_GET

@NonNull
public static final TracingOption PROJECT_MAP_GET

PROJECT_MAP_INSTALL

@NonNull
public static final TracingOption PROJECT_MAP_INSTALL

PROJECT_MAP_RESOLVE

@NonNull
public static final TracingOption PROJECT_MAP_RESOLVE

liveStandaloneProjectMaps

public static java.util.WeakHashMap<StandaloneProjectMap,java.lang.Object> liveStandaloneProjectMaps
Leak debugging aid. Set non-null to diagnose MetaModelManager construction and finalization.


initializedPlatformResourceMap

protected boolean initializedPlatformResourceMap

nsURI2package

@Nullable
protected java.util.Map<org.eclipse.emf.common.util.URI,StandaloneProjectMap.IPackageDescriptor> nsURI2package
The map of package nsURI to package descriptor.


uri2resource

@Nullable
protected java.util.Map<org.eclipse.emf.common.util.URI,StandaloneProjectMap.IResourceDescriptor> uri2resource
The map of document URI to resource descriptor.

Constructor Detail

StandaloneProjectMap

public StandaloneProjectMap()
Method Detail

findAdapter

@Nullable
public static StandaloneProjectMap findAdapter(@NonNull
                                                        org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Return any StandaloneProjectMap already installed as an adapter on a resourceSet. Returns null if there is no such adapter.


getAdapter

@NonNull
public static StandaloneProjectMap getAdapter(@NonNull
                                                      org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Return the StandaloneProjectMap already installed as an adapter on a resourceSet if one exists, else creates, installs, initializes and returns a new StandaloneProjectMap.


dispose

public static void dispose(@NonNull
                           org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Eliminate all facilities used by the ProjectMap for the resourceSet.


getPackageRegistry

@NonNull
public static org.eclipse.emf.ecore.EPackage.Registry getPackageRegistry(@Nullable
                                                                                 org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Return the EPackage.Registry for a resourceSet or the Global EPackage.Registry.INSTANCE if resourceSet is null.


getResourceFactoryRegistry

public static org.eclipse.emf.ecore.resource.Resource.Factory.Registry getResourceFactoryRegistry(@Nullable
                                                                                                  org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Return the Resource.Factory.Registry for a resourceSet or the Global Resource.Factory.Registry.INSTANCE if resourceSet is null.


getURIConverter

@NonNull
public static org.eclipse.emf.ecore.resource.URIConverter getURIConverter(@Nullable
                                                                                  org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Return the URIConverter for a resourceSet or the Global URIConverter.INSTANCE if resourceSet is null.


getURIMap

@NonNull
public static java.util.Map<org.eclipse.emf.common.util.URI,org.eclipse.emf.common.util.URI> getURIMap(@Nullable
                                                                                                               org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Return the URI Map for a resourceSet or the Global URIConverter.URI_MAP if resourceSet is null.


initStatics

public static void initStatics()
A simple public static method that may be used to force class initialization.


initializeURIResourceMap

public static void initializeURIResourceMap(@Nullable
                                            org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Activate any ResourceSetImpl.uriResourceMap so that repeated lookups use a hash rather than linear search.


addResourceDescriptor

public void addResourceDescriptor(@NonNull
                                  StandaloneProjectMap.IResourceDescriptor resourceDescriptor)
Call-back to add a resourceDescriptor.


configure

public void configure(@Nullable
                      org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                      @NonNull
                      StandaloneProjectMap.IResourceLoadStrategy resourceLoadStrategy,
                      @Nullable
                      StandaloneProjectMap.IConflictHandler conflictHandler)
Configure the PackageRegistry associated with ResourceSet to use a resourceLoadStrategy and conflictHandler when resolving namespace ansd platform URIs.


createProjectDescriptor

@NonNull
protected StandaloneProjectMap.IProjectDescriptor createProjectDescriptor(@NonNull
                                                                                  java.lang.String projectName,
                                                                                  @NonNull
                                                                                  org.eclipse.emf.common.util.URI locationURI)

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getPackageDescriptor

@Nullable
public StandaloneProjectMap.IPackageDescriptor getPackageDescriptor(@NonNull
                                                                             org.eclipse.emf.common.util.URI nsURI)
Return the IPackageDescriptor for a given nsURI.


getProjectDescriptor

@Nullable
public StandaloneProjectMap.IProjectDescriptor getProjectDescriptor(@NonNull
                                                                             java.lang.String projectName)
Return the IProjectDescriptor for a given project or bundle name.


getProjectDescriptorInternal

@NonNull
protected StandaloneProjectMap.IProjectDescriptor getProjectDescriptorInternal(@NonNull
                                                                                       org.eclipse.emf.common.util.URI platformURI)

getExceptionMap

@Nullable
public java.util.Map<java.lang.String,java.lang.Exception> getExceptionMap()
Return the mapping of problem files to exceptions, or null if not yet computed or if no exceptions thrown.


getLocation

@Nullable
public org.eclipse.emf.common.util.URI getLocation(@NonNull
                                                            java.lang.String projectName)
Return the resolveable URI for a given project or bundle name.


getProjectDescriptors

@Nullable
protected java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor> getProjectDescriptors()
Return the mapping of project name or bundle name, as defined in a manifest file to the location of that project as determined by scanning the classpath.

e.g. entries such as
org.antlr.runtime => archive:file:/C:/Tools/Eclipse/3.7.1/plugins/org.antlr .runtime_3.2.0.v201101311130.jar!/
org.eclipse.ocl.examples.common => file:/C:/GIT/org.eclipse.ocl/examples/org.eclipse.ocl.examples.common/

Any problems arising while creating the project map are gathered into the exception map accessible using getExceptionMap(). An overall problem may be attributed to the null file.


initializeGenModelLocationMap

public void initializeGenModelLocationMap(boolean force)
Initialize the EcorePlugin.getEPackageNsURIToGenModelLocationMap() so that in a standalone environment the locations of all genmodels are available.

Initialization is only necessary once and for a standalone environment. If force is true a re-initialization or plugin initialization may be forced.


initializePackageRegistry

public void initializePackageRegistry(@Nullable
                                      org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Install lazy EPackageDescriptors in the EPackage.Registry for all registered packages and their platform:/plugin and platform:/resource synonyms, which are determined by examining the genPackages.ecorePackage attribute in all genModels.


initializePlatformResourceMap

public void initializePlatformResourceMap(boolean force)
Initialize the EcorePlugin.getPlatformResourceMap() so that in a standalone environment and in conjunction with initializeURIMap(ResourceSet) URIs such as platform:/resource/project and platform:/plugin/project are useable.

Initialization is only necessary once and for a standalone environment. If force is true a re-initialization or plugin initialization may be forced.


initializeResourceSet

public void initializeResourceSet(@Nullable
                                  org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Ensure that both the EcorePlugin.getPlatformResourceMap() and ResourceSet.getURIConverter() are initialized so that platform:/resource/project and platform:/plugin/project are useable.. A null ResourceSet may be used to provoke initialization of the global EPackage.Registry.INSTANCE and URIConverter.URI_MAP.


initializeURIMap

public void initializeURIMap(@Nullable
                             org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Initialize the uriMap of a uriConverter so that each of platform:/resource/project and platform:/plugin/project resolve the workspace project resource else the plugin bundle for use in either standalone or plugin environment.

Note that in a plugin environment, a single platform:/resource/ to platform:/plugin/ mapping is sufficient since platform:/plugin/ is directly resolveable by the Eclipse Platform.


isAdapterForType

public boolean isAdapterForType(java.lang.Object type)
Specified by:
isAdapterForType in interface org.eclipse.emf.common.notify.Adapter
Overrides:
isAdapterForType in class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl

logException

protected void logException(@NonNull
                            java.lang.String message,
                            @NonNull
                            java.lang.Exception e)

notifyChanged

public void notifyChanged(org.eclipse.emf.common.notify.Notification notification)
Internal call-back to observe Resource addition to a ResourceSet..

Specified by:
notifyChanged in interface org.eclipse.emf.common.notify.Adapter
Overrides:
notifyChanged in class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl

notifyAddedDynamicResource

protected void notifyAddedDynamicResource(@NonNull
                                          org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                          @NonNull
                                          org.eclipse.emf.ecore.resource.Resource resource)
When a new Resource is added to a watched ResourceSet notify the resourceDescriptor that there is a new (ResourceSet, Resource) pair so that it install both platform:/plugin and platform:/resource entries in the ResourceSet's uriResourceMap and install a listener to detect when the Resource is loaded.


registerBundle

@Nullable
protected StandaloneProjectMap.IProjectDescriptor registerBundle(@NonNull
                                                                          java.io.File file,
                                                                          @NonNull
                                                                          javax.xml.parsers.SAXParser saxParser)

registerProject

@Nullable
protected StandaloneProjectMap.IProjectDescriptor registerProject(@NonNull
                                                                           java.io.File file)

scanClassPath

protected void scanClassPath(@NonNull
                             java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor> projectDescriptors,
                             @NonNull
                             javax.xml.parsers.SAXParser saxParser)

scanFolder

protected boolean scanFolder(@NonNull
                             java.io.File f,
                             @NonNull
                             javax.xml.parsers.SAXParser saxParser,
                             @NonNull
                             java.util.Set<java.lang.String> alreadyVisited,
                             int depth)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unload

public void unload(@NonNull
                   org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

useGeneratedResource

public void useGeneratedResource(@NonNull
                                 org.eclipse.emf.ecore.resource.Resource resource,
                                 @NonNull
                                 org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Use a registered resource for use in conjunction with resourceSet. This must be invoked explicitly to ensure that conflicting generated/model access is resolved consistently.