public abstract class AbstractItdMetadataProvider extends org.springframework.roo.metadata.AbstractHashCodeTrackingMetadataNotifier implements ItdTriggerBasedMetadataProvider, org.springframework.roo.metadata.MetadataNotificationListener
This abstract class assumes:
metadataTriggersMetadataProvider
are sufficientPhysicalTypeIdentifierMetadataProvider.getProvidesType()Put differently, this abstract class assumes every ITD will have a corresponding "governor". A "governor" is defined as the type which will eventually receive the introduction. The abstract class assumes all metadata identification strings represent the name of the governor, albeit with a metadata class specific to the add-on. When an instance-specific metadata identification request is received, the governor will be obtained and in turn introspected for one of the trigger annotations. If these are detected, or if there is already an ITD file of the same name as would normally be created had a trigger annotation been found, the metadata will be created. The metadata creation method is expected to create, update or delete the ITD file as appropriate.
| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.roo.process.manager.FileManager |
fileManager |
protected ItdDiscoveryService |
itdDiscoveryService |
protected static Logger |
LOGGER |
protected MemberDetailsScanner |
memberDetailsScanner |
protected PersistenceMemberLocator |
persistenceMemberLocator |
protected TypeLocationService |
typeLocationService |
| Constructor and Description |
|---|
AbstractItdMetadataProvider() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
activate(org.osgi.service.component.ComponentContext cContext) |
void |
addMetadataTrigger(org.springframework.roo.model.JavaType javaType)
Registers an additional
JavaType that will trigger metadata
registration. |
void |
addMetadataTriggers(org.springframework.roo.model.JavaType... triggerTypes)
Registers the given
JavaTypes as triggering metadata
registration. |
protected abstract String |
createLocalIdentifier(org.springframework.roo.model.JavaType javaType,
org.springframework.roo.project.LogicalPath path)
Called whenever there is a requirement to produce a local identifier (ie
an instance identifier consistent with
MetadataProvider.getProvidesType()) for
the indicated JavaType and Path. |
org.springframework.roo.metadata.MetadataItem |
get(String metadataIdentificationString) |
org.springframework.roo.process.manager.FileManager |
getFileManager() |
protected abstract String |
getGovernorPhysicalTypeIdentifier(String metadataIdentificationString)
Called whenever there is a requirement to convert a local metadata
identification string (ie an instance identifier consistent with
MetadataProvider.getProvidesType()) into the corresponding governor physical type
identifier. |
String |
getIdForPhysicalJavaType(String physicalJavaTypeIdentifier)
Obtains an identifier that would be validly recognized by this
ItdMetadataProvider instance. |
ItdDiscoveryService |
getItdDiscoveryService() |
protected String |
getLocalMid(MemberHoldingTypeDetails memberHoldingTypeDetails)
Assists creating a local metadata identification string (MID) from any
presented
MemberHoldingTypeDetails implementation. |
protected MemberDetails |
getMemberDetails(ClassOrInterfaceTypeDetails cid)
Returns details of the given class or interface type's members
|
protected MemberDetails |
getMemberDetails(org.springframework.roo.model.JavaType type)
Returns details of the given Java type's members
|
protected MemberDetails |
getMemberDetails(PhysicalTypeMetadata physicalTypeMetadata)
Returns details of the given physical type's members
|
MemberDetailsScanner |
getMemberDetailsScanner() |
protected abstract ItdTypeDetailsProvidingMetadataItem |
getMetadata(String metadataIdentificationString,
org.springframework.roo.model.JavaType aspectName,
PhysicalTypeMetadata governorPhysicalTypeMetadata,
String itdFilename)
Called when it is time to create the actual metadata instance.
|
protected <T extends org.springframework.roo.metadata.MetadataItem> |
getParentMetadata(ClassOrInterfaceTypeDetails child)
Looks up the given type's inheritance hierarchy for metadata of the given
type, starting with the given type's parent and going upwards until the
first such instance is found (i.e. lower level metadata takes priority
over higher level metadata)
|
PersistenceMemberLocator |
getPersistenceMemberLocator() |
TypeLocationService |
getTypeLocationService() |
protected boolean |
isGovernor(ClassOrInterfaceTypeDetails type)
Indicates whether the given type is the governor for this provider.
|
protected boolean |
isIgnoreTriggerAnnotations() |
void |
notify(String upstreamDependency,
String downstreamDependency) |
protected void |
notifyForGenericListener(String upstreamDependency)
Designed to handle events originating from a
MetadataDependencyRegistry.addNotificationListener(MetadataNotificationListener)
registration. |
void |
removeMetadataTrigger(org.springframework.roo.model.JavaType javaType)
Removes a
JavaType metadata trigger registration. |
void |
removeMetadataTriggers(org.springframework.roo.model.JavaType... triggerTypes)
Removes the given
JavaTypes as triggering metadata registration. |
protected String |
resolveDownstreamDependencyIdentifier(String upstreamDependency)
Invoked whenever a "class-level" downstream dependency identifier is
presented in a metadata notification.
|
void |
setDependsOnGovernorBeingAClass(boolean dependsOnGovernorBeingAClass)
If set to true (default is true), ensures the governor type details
represent a class.
|
void |
setDependsOnGovernorTypeDetailAvailability(boolean dependsOnGovernorTypeDetailAvailability)
If set to true (default is true), ensures subclass not called unless the
governor type details are available.
|
protected void |
setIgnoreTriggerAnnotations(boolean ignoreTriggerAnnotations) |
getMetadataDependencyRegistry, getMetadataService, notifyIfRequiredclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetItdUniquenessFilenameSuffixprotected static final Logger LOGGER
protected org.springframework.roo.process.manager.FileManager fileManager
protected ItdDiscoveryService itdDiscoveryService
protected MemberDetailsScanner memberDetailsScanner
protected PersistenceMemberLocator persistenceMemberLocator
protected TypeLocationService typeLocationService
protected void activate(org.osgi.service.component.ComponentContext cContext)
activate in class org.springframework.roo.metadata.AbstractHashCodeTrackingMetadataNotifierpublic void addMetadataTrigger(org.springframework.roo.model.JavaType javaType)
JavaType that will trigger metadata
registration.addMetadataTrigger in interface TriggerBasedMetadataProviderjavaType - the type-level annotation to detect that will cause
metadata creation (required)public void addMetadataTriggers(org.springframework.roo.model.JavaType... triggerTypes)
JavaTypes as triggering metadata
registration.triggerTypes - the type-level annotations to detect that will cause
metadata creationprotected abstract String createLocalIdentifier(org.springframework.roo.model.JavaType javaType, org.springframework.roo.project.LogicalPath path)
MetadataProvider.getProvidesType()) for
the indicated JavaType and Path.javaType - the type (required)path - the path (required)MetadataProvider.getProvidesType() (never null or empty)public final org.springframework.roo.metadata.MetadataItem get(String metadataIdentificationString)
get in interface org.springframework.roo.metadata.MetadataProviderprotected abstract String getGovernorPhysicalTypeIdentifier(String metadataIdentificationString)
MetadataProvider.getProvidesType()) into the corresponding governor physical type
identifier.metadataIdentificationString - the local identifier (required)public final String getIdForPhysicalJavaType(String physicalJavaTypeIdentifier)
ItdMetadataProviderItdMetadataProvider instance. The identifier must represent the
presented physical Java type identifier.
The presented physical Java type identifier need not presently exist in
the MetadataService. Implementations must not rely on the
metadata being available at this moment. Implementations by returning a
value from this method do not guarantee that metadata for the returned
identifier will subsequently made available. As such this method is a
basic conversion method and shouldn't perform any analysis.
getIdForPhysicalJavaType in interface ItdMetadataProviderphysicalJavaTypeIdentifier - to convert into a local metadata
identifier (required)protected String getLocalMid(MemberHoldingTypeDetails memberHoldingTypeDetails)
MemberHoldingTypeDetails implementation. This is
achieved by extracting the
IdentifiableJavaStructure.getDeclaredByMetadataId() and
converting it into a JavaType and Path, then calling
#createLocalIdentifier(JavaType, Path).memberHoldingTypeDetails - the member holder from which the
declaring type information should be extracted (required)#createLocalIdentifier(JavaType, Path)
for the extracted Java type in the extract Path (never null)protected MemberDetails getMemberDetails(ClassOrInterfaceTypeDetails cid)
cid - the physical type for which to get the members (can be
null)null if the member details are unavailableprotected MemberDetails getMemberDetails(org.springframework.roo.model.JavaType type)
type - the type for which to get the members (required)null if the member details are unavailableprotected MemberDetails getMemberDetails(PhysicalTypeMetadata physicalTypeMetadata)
physicalTypeMetadata - the physical type for which to get the
members (can be null)null if the member details are unavailableprotected abstract ItdTypeDetailsProvidingMetadataItem getMetadata(String metadataIdentificationString, org.springframework.roo.model.JavaType aspectName, PhysicalTypeMetadata governorPhysicalTypeMetadata, String itdFilename)
metadataIdentificationString - the local identifier (non-null and
consistent with MetadataProvider.getProvidesType())aspectName - the Java type name for the ITD (non-null and obtained
via
PhysicalTypeMetadata.getItdJavaType(ItdMetadataProvider)
)governorPhysicalTypeMetadata - the governor metadata (non-null and
obtained via
getGovernorPhysicalTypeIdentifier(String))itdFilename - the canonical filename for the ITD (non-null and
obtained via
PhysicalTypeMetadata.getItdCanoncialPath(ItdMetadataProvider)
)protected <T extends org.springframework.roo.metadata.MetadataItem> T getParentMetadata(ClassOrInterfaceTypeDetails child)
T - the type of metadata to look forchild - the child type whose parents to search (required)null if there is no such metadataprotected boolean isGovernor(ClassOrInterfaceTypeDetails type)
dependsOnGovernorBeingAClass
. A more sophisticated implementation could check for the presence of
particular annotations or the implementation of particular interfaces.type - can be nullfalse if the given type is nullprotected boolean isIgnoreTriggerAnnotations()
public final void notify(String upstreamDependency, String downstreamDependency)
notify in interface org.springframework.roo.metadata.MetadataNotificationListenerprotected void notifyForGenericListener(String upstreamDependency)
MetadataDependencyRegistry.addNotificationListener(MetadataNotificationListener)
registration. Such events are always presented with a non-null upstream
dependency indicator and a null downstream dependency indicator. These
events differ from events related to PhysicalTypeIdentifier
registrations, as in those cases the downstream dependency indicator will
be the class-level MetadataProvider.getProvidesType().
This method allows subclasses to specially handle generic
MetadataDependencyRegistry events.
upstreamDependency - the upstream which was modified (guaranteed to
be non-null, but could be class-level or instance-level)public void removeMetadataTrigger(org.springframework.roo.model.JavaType javaType)
JavaType metadata trigger registration. If the type was
never registered, the method returns without an error.removeMetadataTrigger in interface TriggerBasedMetadataProviderjavaType - to remove (required)public void removeMetadataTriggers(org.springframework.roo.model.JavaType... triggerTypes)
JavaTypes as triggering metadata registration.triggerTypes - the type-level annotations to remove as triggersprotected String resolveDownstreamDependencyIdentifier(String upstreamDependency)
MetadataProvider.getProvidesType(). The
downstream dependency identifier must also be instance-specific.
The basic implementation offered in this class will only convert a
PhysicalTypeIdentifier. If a subclass registers a dependency on
an upstream (other than
PhysicalTypeIdentifier.getMetadataIdentiferType()) and presents
their MetadataProvider.getProvidesType() as the downstream (thus meaning only
class-level downstream dependency identifiers will be presented), they
must override this method and appropriately handle instance-specific
downstream dependency identifier resolution.
This method may also return null if it wishes to abort processing of the notification. This may be appropriate if a determination cannot be made at this time for whatever reason (eg too early in a lifecycle etc).
upstreamDependency - the upstream (never null)MetadataProvider.getProvidesType() (or
null if the metadata notification should be aborted)public void setDependsOnGovernorBeingAClass(boolean dependsOnGovernorBeingAClass)
setDependsOnGovernorTypeDetailAvailability(boolean) must also be
true to ensure this can be relied upon.dependsOnGovernorBeingAClass - true means governor type detail must
represent a classpublic void setDependsOnGovernorTypeDetailAvailability(boolean dependsOnGovernorTypeDetailAvailability)
dependsOnGovernorTypeDetailAvailability - true means governor type
details must be availableprotected void setIgnoreTriggerAnnotations(boolean ignoreTriggerAnnotations)
public org.springframework.roo.process.manager.FileManager getFileManager()
public ItdDiscoveryService getItdDiscoveryService()
public MemberDetailsScanner getMemberDetailsScanner()
public TypeLocationService getTypeLocationService()
public PersistenceMemberLocator getPersistenceMemberLocator()
Copyright © 2009–2016. All rights reserved.