|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.emf.common.notify.impl.SingletonAdapterImpl org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap
public class StandaloneProjectMap
StandaloneProjectMap and ProjectMap
provides facilities to assist in
preparing the URIConverter
and the EPackage.Registry
of a
ResourceSet
and the global and
EcorePlugin.getPlatformResourceMap()
and
EcorePlugin.getEPackageNsURIToGenModelLocationMap()
to support
arbitrary and compatible use of platform:/plugin,
platform:/resource and registered 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
ResourceSet.getResource()
.
If the classpath contains distinct imported project and JAR versions of Ecore, referencing
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.
#getProjectMap()
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 trio of
registrations 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()
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(ResourceSet)
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(URIConverter)
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.
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.
Nested Class Summary | |
---|---|
protected static class |
StandaloneProjectMap.GenModelEcorePackageHandler
GenModelEcorePackageHandler provides the SAX callbacks to support reading the genPackages element in a genmodel file and invoking addEcorePackage() for each encounter. |
static interface |
StandaloneProjectMap.IPackageDescriptor
An IPackageDescriptor describes the modeling capabilities of a known model package and may be installed under av variety of synonyms in an EPackage.Registry to map multiple URIs to a single EPackage. |
static interface |
StandaloneProjectMap.IProjectDescriptor
An IProjectDescriptor describes the capabilities of a project. |
static class |
StandaloneProjectMap.PackageDescriptor
PackageDescriptor supports lazy class loading and initialization of a compiled Ecore package. |
protected static class |
StandaloneProjectMap.PluginGenModelHandler
PluginGenModelHandler provides the SAX callbacks to support reading the org.eclipse.emf.ecore.generated_package extension point in a plugin.xml file and activating the GenModelEcorePackageHandler to process the ecorePackage locations and invoking addGenModel() for each
encounter. |
static class |
StandaloneProjectMap.ProjectDescriptor
|
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter |
---|
org.eclipse.emf.common.notify.Adapter.Internal |
Field Summary | |
---|---|
protected boolean |
initializedGenModelLocationMap
|
protected boolean |
initializedPlatformResourceMap
|
Fields inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl |
---|
targets |
Constructor Summary | |
---|---|
StandaloneProjectMap()
|
Method Summary | |
---|---|
protected StandaloneProjectMap.IProjectDescriptor.Internal |
createProjectDescriptor(java.lang.String projectName,
org.eclipse.emf.common.util.URI locationURI)
|
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.io.File,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. |
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.Internal |
getProjectDescriptorInternal(org.eclipse.emf.common.util.URI platformURI)
|
protected java.util.Map<java.lang.String,? extends 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 IPackageDescriptors 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(URIConverter) 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.io.File file,
java.lang.Exception e)
|
protected StandaloneProjectMap.IProjectDescriptor |
registerBundle(java.io.File file,
javax.xml.parsers.SAXParser saxParser)
|
protected StandaloneProjectMap.IProjectDescriptor.Internal |
registerProject(java.io.File file)
|
protected void |
scanClassPath(java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor.Internal> 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()
|
Methods inherited from class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl |
---|
dispose, getTarget, notifyChanged, setTarget, unsetTarget |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected boolean initializedGenModelLocationMap
protected boolean initializedPlatformResourceMap
Constructor Detail |
---|
public StandaloneProjectMap()
Method Detail |
---|
@Nullable public static StandaloneProjectMap findAdapter(@NonNull org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
@NonNull public static StandaloneProjectMap getAdapter(@NonNull org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
@NonNull public static org.eclipse.emf.ecore.EPackage.Registry getPackageRegistry(@Nullable org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
EPackage.Registry.INSTANCE
if resourceSet is null.
public static org.eclipse.emf.ecore.resource.Resource.Factory.Registry getResourceFactoryRegistry(@Nullable org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Resource.Factory.Registry.INSTANCE
if resourceSet is null.
public static org.eclipse.emf.ecore.resource.URIConverter getURIConverter(@Nullable org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
URIConverter.INSTANCE
if resourceSet is null.
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)
URIConverter.URI_MAP
if resourceSet is null.
public static void initStatics()
public static void initializeURIResourceMap(@Nullable org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
protected StandaloneProjectMap.IProjectDescriptor.Internal createProjectDescriptor(java.lang.String projectName, org.eclipse.emf.common.util.URI locationURI)
public StandaloneProjectMap.IProjectDescriptor getProjectDescriptor(java.lang.String projectName)
protected StandaloneProjectMap.IProjectDescriptor.Internal getProjectDescriptorInternal(org.eclipse.emf.common.util.URI platformURI)
public java.util.Map<java.io.File,java.lang.Exception> getExceptionMap()
public org.eclipse.emf.common.util.URI getLocation(java.lang.String projectName)
protected java.util.Map<java.lang.String,? extends StandaloneProjectMap.IProjectDescriptor> getProjectDescriptors()
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.
public void initializeGenModelLocationMap(boolean force)
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.
public void initializePackageRegistry(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
public void initializePlatformResourceMap(boolean force)
EcorePlugin.getPlatformResourceMap()
so that in a
standalone environment and in conjunction with initializeURIMap(URIConverter)
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.
public void initializeResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
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.
public void initializeURIMap(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
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.
public boolean isAdapterForType(java.lang.Object type)
isAdapterForType
in interface org.eclipse.emf.common.notify.Adapter
isAdapterForType
in class org.eclipse.emf.common.notify.impl.SingletonAdapterImpl
protected void logException(java.io.File file, java.lang.Exception e)
protected StandaloneProjectMap.IProjectDescriptor registerBundle(java.io.File file, javax.xml.parsers.SAXParser saxParser)
protected StandaloneProjectMap.IProjectDescriptor.Internal registerProject(java.io.File file)
protected void scanClassPath(java.util.Map<java.lang.String,StandaloneProjectMap.IProjectDescriptor.Internal> 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)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |