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

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

public class ProjectMap
extends StandaloneProjectMap

ProjectMap extends StandaloneProjectMap to support polymorphic access in either plugin or standalone environments to EMF resources and EPackages.

Plugin Environment

A resolvable location is perhaps platform:/plugin/org.antlr.runtime/ for a bundle or platform:/resource/org.eclipse.ocl.examples.common/ for an open project.

StandaloneProjectMap.getProjectDescriptors() returns a map of project names, but not bundle names, to resolvable location.

StandaloneProjectMap.initializePackageRegistry(ResourceSet) augments the default EMF startup in a plugin environment whereby the global package registry acquires a registration for each namespace URI (e.g. http://www.eclipse.org/emf/2002/Ecore) defined by the org.eclipse.emf.ecore.generated_package extension point in plugins. The standard reguistration is auugmented where appropriate, by two further registrations for 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). These extra registrations derived from the genPackages.ecorePackage referenced by the genmodel org.eclipse.emf.ecore.generated_package declarations ensure that all three URIs resolve to the same Resource eliminating most opportunities for meta-model schizophrenia.

initializePlatformResourceMap(boolean) does nothing since the standard EMF Platform URI Handler can open platform resources directly.

StandaloneProjectMap.initializeGenModelLocationMap(boolean) does nothing, since the standard EMF startup in a plugin environment populates the EcorePlugin.getEPackageNsURIToGenModelLocationMap().

initializeURIMap(ResourceSet) installs explicit URI mappings into the URIConverter so that for each project so that both platform:/resource/project and platform:/plugin/project reference platform:/resource/project. An additional backstop URI mapping redirects platform:/resource to platform:/plugin.

The explicit mapping ensures that projects are accessible as either platform:/resource/project or platform:/plugin/project. The backstop mapping ensures that plugins, that are not occluded by projects, are accessible as platform:/plugin/project or platform:/resource/project, without needing to create an explicit URI map entry for each of the many hundreds of bundles in typical use.


Nested Class Summary
static class ProjectMap.ProjectDescriptor
           
 
Nested classes/interfaces inherited from class org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap
StandaloneProjectMap.AbstractResourceDescriptor, StandaloneProjectMap.AbstractResourceLoadStatus, StandaloneProjectMap.AbstractResourceLoadStrategy, StandaloneProjectMap.DelegatedMultiplePackageResource, StandaloneProjectMap.DelegatedSinglePackageResource, StandaloneProjectMap.EPackageDescriptor, StandaloneProjectMap.GenModelReader, StandaloneProjectMap.IConflictHandler, StandaloneProjectMap.IPackageDescriptor, StandaloneProjectMap.IPackageLoadStatus, StandaloneProjectMap.IProjectDescriptor, StandaloneProjectMap.IResourceDescriptor, StandaloneProjectMap.IResourceLoadStatus, StandaloneProjectMap.IResourceLoadStrategy, StandaloneProjectMap.LoadBothStrategy, StandaloneProjectMap.LoadDynamicResourceStrategy, StandaloneProjectMap.LoadFirstStrategy, StandaloneProjectMap.LoadGeneratedPackageStrategy, StandaloneProjectMap.LoadingBothLoadedDynamicResourceStrategy, StandaloneProjectMap.MapToFirstConflictHandler, StandaloneProjectMap.MapToFirstConflictHandlerWithLog, StandaloneProjectMap.MultiplePackageResourceDescriptor, StandaloneProjectMap.MultiplePackageResourceLoadStatus, StandaloneProjectMap.PackageDescriptor, StandaloneProjectMap.PackageLoadStatus, StandaloneProjectMap.PluginReader, StandaloneProjectMap.SinglePackageResourceDescriptor, StandaloneProjectMap.SinglePackageResourceLoadStatus
 
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
org.eclipse.emf.common.notify.Adapter.Internal
 
Field Summary
 
Fields inherited from class org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap
initializedPlatformResourceMap, liveStandaloneProjectMaps, nsURI2package, PROJECT_MAP_ADD_EPACKAGE, PROJECT_MAP_ADD_GEN_MODEL, PROJECT_MAP_ADD_GENERATED_PACKAGE, PROJECT_MAP_ADD_URI_MAP, PROJECT_MAP_CONFIGURE, PROJECT_MAP_GET, PROJECT_MAP_INSTALL, PROJECT_MAP_RESOLVE, uri2resource
 
Fields inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
targets
 
Constructor Summary
ProjectMap()
           
 
Method Summary
protected  StandaloneProjectMap.IProjectDescriptor createProjectDescriptor(java.lang.String projectName, org.eclipse.emf.common.util.URI locationURI)
           
static StandaloneProjectMap findAdapter(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
           
static StandaloneProjectMap getAdapter(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
           
 org.eclipse.emf.common.util.URI getLocation(java.lang.String projectName)
          Return the resolveable URI for a given project or bundle name.
 void initializePlatformResourceMap(boolean force)
          Initialize the EcorePlugin.getPlatformResourceMap() so that in a standalone environment and in conjunction with StandaloneProjectMap.initializeURIMap(ResourceSet) URIs such as 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.
 boolean isAdapterForType(java.lang.Object type)
           
protected  void scanClassPath(java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor> projectDescriptors, javax.xml.parsers.SAXParser saxParser)
           
protected  void scanGenModels(javax.xml.parsers.SAXParser saxParser)
           
protected  void scanProjects(java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor> projectDescriptors)
           
 
Methods inherited from class org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap
addResourceDescriptor, configure, dispose, finalize, getExceptionMap, getPackageDescriptor, getPackageRegistry, getProjectDescriptor, getProjectDescriptorInternal, getProjectDescriptors, getResourceFactoryRegistry, getURIConverter, getURIMap, initializeGenModelLocationMap, initializePackageRegistry, initializeResourceSet, initializeURIResourceMap, initStatics, logException, notifyAddedDynamicResource, notifyChanged, registerBundle, registerProject, scanFolder, toString, unload, useGeneratedResource
 
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
 

Constructor Detail

ProjectMap

public ProjectMap()
Method Detail

findAdapter

@Nullable
public static StandaloneProjectMap findAdapter(@NonNull
                                                        org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

getAdapter

@NonNull
public static StandaloneProjectMap getAdapter(@NonNull
                                                      org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

createProjectDescriptor

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

getLocation

public org.eclipse.emf.common.util.URI getLocation(@NonNull
                                                   java.lang.String projectName)
Description copied from class: StandaloneProjectMap
Return the resolveable URI for a given project or bundle name.

Overrides:
getLocation in class StandaloneProjectMap

initializePlatformResourceMap

public void initializePlatformResourceMap(boolean force)
Description copied from class: StandaloneProjectMap
Initialize the EcorePlugin.getPlatformResourceMap() so that in a standalone environment and in conjunction with StandaloneProjectMap.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.

Overrides:
initializePlatformResourceMap in class StandaloneProjectMap

initializeURIMap

public void initializeURIMap(@Nullable
                             org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Description copied from class: StandaloneProjectMap
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.

Overrides:
initializeURIMap in class StandaloneProjectMap

isAdapterForType

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

scanClassPath

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

scanGenModels

protected void scanGenModels(@NonNull
                             javax.xml.parsers.SAXParser saxParser)

scanProjects

protected void scanProjects(@NonNull
                            java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor> projectDescriptors)