org.eclipse.wst.common.componentcore
Class ModuleCoreNature

java.lang.Object
  extended byorg.eclipse.wst.common.componentcore.ModuleCoreNature

public class ModuleCoreNature
extends java.lang.Object

Allows projects to support flexible project structures. The ModuleCoreNature manages the configuration of a module structural builder that prepares WorkbenchModules for deployment.

To determine if a project supports flexible project structures, check for the existence of the ModuleCoreNature:

(ModuleCoreNature.getModuleCoreNature(project) != null)

If the project has a ModuleCoreNature, then the project supports flexible module structures.

In general, clients are expected to use the utility methods available on this class to acquire the ModuleCoreNature instance from a given project (getModuleCoreNature(IProject)  or to make a flexible project flexible by adding a ModuleCoreNature ( addModuleCoreNatureIfNecessary(IProject, IProgressMonitor)).

Each ModuleCoreNature from a given project can provide access to the org.eclipse.wst.common.modulecore.ModuleStructuralModel  of the project. org.eclipse.wst.common.modulecore.ModuleStructuralModel  is a subclass of EditModel that manages resources associated with the Module Structural Metamodel. As an EditModel, the org.eclipse.wst.common.modulecore.ModuleStructuralModel  references EMF resources, that contain EMF models -- in this case, the EMF model of .wtpmodules file.

Clients are encouraged to use the Edit Facade pattern (via org.eclipse.wst.common.modulecore.ArtifactEdit  or one if its relevant subclasses) to work directly with the Module Structural Metamodel.

Each ModuleCoreNature from a given project can also provide access to the org.eclipse.wst.common.modulecore.ArtifactEditModel  for each org.eclipse.wst.common.modulecore.WorkbenchComponent  contained by the project. Like org.eclipse.wst.common.modulecore.ModuleStructuralModel, org.eclipse.wst.common.modulecore.ArtifactEditModel  is a subclass of EditModel  that contains EMF resources, which in turn contain the EMF models of module metadata files (such as J2EE deployment descriptors).

The following diagram highlights the relationships of these subclasses of EditModel, and the relationship of the EditModel to the EMF resources. In the diagram, "MetamodelResource" and "MetamodelObject" are used as placeholders for the specific subclasses of Resource and EObject  respectively.

Figure 1: A component diagram of the Module Edit Models.

Clients are encouraged to use the Edit Facade pattern (via org.eclipse.wst.common.modulecore.ArtifactEdit  or what if its relevant subclasses) to work directly with the Module Structural Metamodel.

All EditModels have a lifecycle that must be enforced to keep the resources loaded that are in use, and to unload resources that are not in use. To access an EditModel, clients are required to supply an object token referred to as an accessor key. The accessor key allows the framework to better track which clients are using the EditModel, and to ensure that only a client which has accessed the EditModel with an accessor key may invoke save*()s on that EditModel.

Since:
1.0
See Also:
StructureEdit, StructureEdit.getStructureEditForRead(IProject), StructureEdit.getStructureEditForWrite(IProject), ArtifactEdit, org.eclipse.wst.common.componentcore.ArtifactEdit#getArtifactEditForRead(WorkbenchComponent), org.eclipse.wst.common.componentcore.ArtifactEdit#getArtifactEditForWrite(WorkbenchComponent)

Method Summary
static ModuleCoreNature addModuleCoreNatureIfNecessary(IProject aProject, IProgressMonitor aMonitor)
           Adds a ModuleCoreNature to the project.
 void configure()
           This method should not be invoked by clients.
 org.eclipse.wst.common.componentcore.internal.ArtifactEditModel getArtifactEditModelForRead(URI aModuleURI, java.lang.Object anAccessorKey)
           Returns an ArtifactEditModel  to work with the underlying content of an individual WorkbenchComponent  contained in the project.
 org.eclipse.wst.common.componentcore.internal.ArtifactEditModel getArtifactEditModelForWrite(URI aModuleURI, java.lang.Object anAccessorKey)
           Returns an ArtifactEditModel  to work with the underlying content of an individual WorkbenchComponent  contained in the project.
static ModuleCoreNature getModuleCoreNature(IProject aProject)
           Find and return the ModuleCoreNature of aProject, if available.
 org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel getModuleStructuralModelForRead(java.lang.Object anAccessorKey)
           Return a ModuleStructuralModel for read-only access.
 org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel getModuleStructuralModelForWrite(java.lang.Object anAccessorKey)
           Return a ModuleStructuralModel for write access.
 java.lang.String getNatureID()
           
 ResourceSet getResourceSet()
           This method should not be invoked by clients.
 void primaryContributeToContext(EMFWorkbenchContextBase aNature)
           This method should not be invoked by clients.
 void secondaryContributeToContext(EMFWorkbenchContextBase aNature)
           This method should not be invoked by clients.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getModuleCoreNature

public static ModuleCoreNature getModuleCoreNature(IProject aProject)

Find and return the ModuleCoreNature of aProject, if available.

This method may return null.

Parameters:
aProject - An accessible project
Returns:
The ModuleCoreNature of aProject, if it exists

addModuleCoreNatureIfNecessary

public static ModuleCoreNature addModuleCoreNatureIfNecessary(IProject aProject,
                                                              IProgressMonitor aMonitor)

Adds a ModuleCoreNature to the project.

This method may return null.

Parameters:
aProject - A accessible project.
aMonitor - A progress monitor to track the time to completion
Returns:
The ModuleCoreNature of aProject, if it exists

getModuleStructuralModelForRead

public org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel getModuleStructuralModelForRead(java.lang.Object anAccessorKey)

Return a ModuleStructuralModel for read-only access.

Clients are encouraged to use ModuleCore#getModuleCoreForRead(IProject) to work with the Module Structural Metamodels of flexible projects.

See the discussion what a ModuleStructuralModel  is and how it relates to the Module Structural Metamodel .

Also see the discussion of the purpose of an accessor key .

Parameters:
anAccessorKey - Typically client supplies the object that invoked this method, or a proxy ( new Object()) in the case of other static methods requesting a ModuleStructuralModel.
Returns:
A ModuleStructuralModelfor the project of the current nature.

getModuleStructuralModelForWrite

public org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel getModuleStructuralModelForWrite(java.lang.Object anAccessorKey)

Return a ModuleStructuralModel for write access.

Clients are encouraged to use ModuleCore#getModuleCoreForWrite(IProject) to work with the Module Structural Metamodels of flexible projects.

See the discussion what a ModuleStructuralModel  is and how it relates to the Module Structural Metamodel .

Also see the discussion of the purpose of an accessor key .

Parameters:
anAccessorKey - Typically client supplies the object that invoked this method, or a proxy ( new Object()) in the case of other static methods requesting a ModuleStructuralModel.
Returns:
A ModuleStructuralModelfor the project of the current nature.

getArtifactEditModelForRead

public org.eclipse.wst.common.componentcore.internal.ArtifactEditModel getArtifactEditModelForRead(URI aModuleURI,
                                                                                                   java.lang.Object anAccessorKey)

Returns an ArtifactEditModel  to work with the underlying content of an individual WorkbenchComponent  contained in the project. ArtifactEditModels are used to manipulate the content models for individual WorkbenchComponents. In general, a content model will contain an EMF representation of the module's relevant deployment descriptor, and possibly other EMF resources as well.

ArtifactEditModels that are returned from this method may not be used to modify and persist changes to the underlying Module Content Metamodel. Clients that need to make changes to the underlying Module Content Module, and that choose to work directly with the ArtifactEditModel  should use getArtifactEditModelForWrite(URI, Object).

Clients are encouraged to use ArtifactEdit or one of its relevant subclasses to work with the module content model, instead of working with directly with the EditModel:

ArtifactEdit editFacade = ArtifactEdit.getArtifactEditForRead(aWorkbenchModule);

When a client is aware of the underlying type of module, more specific Edit Facades may be acquired:

WebEdit editFacade = WebEdit.getWebEditForRead(aWorkbenchModule);

If a particular Edit Facade is not applicable to the supplied WorkbenchComponent, then null will be returned.

See the discussion what a ArtifactEditModel  is and how it relates to the Module Content Metamodel .

Also see the discussion of the purpose of an accessor key .

Parameters:
aModuleURI - A fully qualified URI of the form "module:/resource/ / "
anAccessorKey - Typically client supplies the object that invoked this method, or a proxy ( new Object()) in the case of other static methods requesting a ModuleStructuralModel.
Returns:
See Also:
ArtifactEdit, ArtifactEdit#getArtifactEditForRead(WorkbenchComponent)

getArtifactEditModelForWrite

public org.eclipse.wst.common.componentcore.internal.ArtifactEditModel getArtifactEditModelForWrite(URI aModuleURI,
                                                                                                    java.lang.Object anAccessorKey)

Returns an ArtifactEditModel  to work with the underlying content of an individual WorkbenchComponent  contained in the project. ArtifactEditModels are used to manipulate the content models for individual WorkbenchComponents. In general, a content model will contain an EMF representation of the module's relevant deployment descriptor, and possibly other EMF resources as well.

ArtifactEditModels that are returned from this method may be used to modify and persist changes to the underlying Module Content Metamodel. For clients that do not expect to make modifications are encouraged to use getArtifactEditModelForRead(URI, Object)   instead.

Clients are encouraged to use ArtifactEdit or one of its relevant subclasses to work with the module content model, instead of working with directly with the EditModel:

ArtifactEdit editFacade = ArtifactEdit.getArtifactEditForWrite(aWorkbenchModule);

When a client is aware of the underlying type of module, more specific Edit Facades may be acquired:

WebEdit editFacade = WebEdit.getWebEditForWrite(aWorkbenchModule);

If a particular Edit Facade is not applicable to the supplied WorkbenchComponent, then null will be returned.

See the discussion what a ArtifactEditModel  is and how it relates to the Module Content Metamodel .

Also see the discussion of the purpose of an accessor key .

Parameters:
aModuleURI - A fully qualified URI of the form "module:/resource/ / "
anAccessorKey - Typically client supplies the object that invoked this method, or a proxy ( new Object()) in the case of other static methods requesting a ModuleStructuralModel.
Returns:
See Also:
ArtifactEdit, ArtifactEdit#getArtifactEditForRead(WorkbenchComponent)

getNatureID

public java.lang.String getNatureID()

primaryContributeToContext

public void primaryContributeToContext(EMFWorkbenchContextBase aNature)

This method should not be invoked by clients.

See Also:
org.eclipse.jem.util.emf.workbench.IEMFContextContributor#primaryContributeToContext(org.eclipse.jem.util.emf.workbench.EMFWorkbenchContextBase)

getResourceSet

public ResourceSet getResourceSet()

This method should not be invoked by clients.


secondaryContributeToContext

public void secondaryContributeToContext(EMFWorkbenchContextBase aNature)

This method should not be invoked by clients.

See Also:
org.eclipse.jem.util.emf.workbench.IEMFContextContributor#secondaryContributeToContext(org.eclipse.jem.util.emf.workbench.EMFWorkbenchContextBase)

configure

public void configure()
               throws CoreException

This method should not be invoked by clients.

Throws:
CoreException
See Also:
org.eclipse.jem.util.emf.workbench.nature.EMFNature#configure()