public class MetafacadeMappings extends BaseNamespaceComponent implements Serializable
metafacade
objects
to metamodel
objects.MetafacadeMapping
,
XmlObjectFactory
,
Serialized FormModifier and Type | Class and Description |
---|---|
(package private) static interface |
MetafacadeMappings.Condition
Provides a means to evaluate whether or not a condition is true.
|
Modifier and Type | Field and Description |
---|---|
protected Collection<MetafacadeMapping> |
inProcessMappings
Stores the mappings which are currently "in process" (within the
getMapping(Object, String, Collection) . |
protected Collection<MetafacadeBase> |
inProcessMetafacades
Stores the metafacades which are currently "in process" (within the
getMapping(Object, String, Collection) . |
Constructor and Description |
---|
MetafacadeMappings() |
Modifier and Type | Method and Description |
---|---|
void |
addMapping(MetafacadeMapping mapping)
Adds a MetafacadeMapping instance to the set of current mappings.
|
void |
addPropertyReference(String reference)
Adds a language mapping reference.
|
(package private) static Map<Class,Set<String>> |
getAllMetafacadeMappingInstances()
Stores every metafacade mapping instance, this is used from
MetafacadeUtils.getInheritedMappingClassNames(MetafacadeMapping) . |
protected List<String> |
getContextHierarchy(String context)
Retrieves all inherited contexts (including the root
context )
from the given context and returns a list containing all
of them. |
(package private) Class |
getDefaultMetafacadeClass(String namespace)
Gets the defaultMetafacadeClass, first looks for it in the namespace
mapping, if it can't find it it then takes the default mappings, setting.
|
protected MetafacadeMapping |
getMapping(Object mappingObject,
String context,
Collection<String> stereotypes)
Retrieves the MetafacadeMapping belonging to the unique
key created from the mappingObject 's
class, context and given stereotypes . |
protected Collection<String> |
getMappingObjectHierarchy(Object mappingObject)
Retrieves the hierarchy of class names of the given
mappingObject . |
protected Collection<MetafacadeMapping> |
getMappings()
Retrieves all child
MetafacadeMapping instances belonging to this
metafacade mappings instance. |
Class |
getMetafacadeInterface(Class metafacadeClass)
Gets the class of the metafacade interface that belongs to the given
metafacadeClass . |
MetafacadeMapping |
getMetafacadeMapping(Object mappingObject,
String namespace,
String context,
Collection<String> stereotypes)
Attempts to get the MetafacadeMapping identified by the given
mappingClass ,context and
stereotypes |
MetafacadeMappings |
getModelMetafacadeMappings(String metafacadeModelNamespace)
Should be used used instead of "this", retrieves the appropriate
metafacade mappings instance based on the current model type.
|
Collection<String> |
getPropertyReferences()
Gets all property references defined in this mappings instance.
|
void |
initialize()
Initializes this mappings instance, which includes discovery of all
metafacade mappings instances on the classpath.
|
static MetafacadeMappings |
newInstance()
Constructs a new instance of this class.
|
(package private) void |
registerAllProperties()
Registers all namespace properties in the shared
MetafacadeFactory instance. |
(package private) void |
registerProperties(String namespace,
Collection<String> propertyReferences,
String metafacadeName)
Registers the defined property references properties in the metafacade
factory.
|
void |
setDefaultMetafacadeClass(String defaultMetafacadeClass)
Sets the default metafacade class to use if no other is found for the
mapping class.
|
void |
setMetaclassPattern(String metaclassPattern)
Sets the pattern of the metaclass implementations based on a metaclass
interface name.
|
(package private) void |
shutdown()
Performs shutdown procedures for the factory.
|
String |
toString() |
getNamespace, getResource, setNamespace, setResource
protected final Collection<MetafacadeMapping> inProcessMappings
Stores the mappings which are currently "in process" (within the
getMapping(Object, String, Collection)
. This means the mapping
is being processed by the getMapping(Object, String, Collection)
operation. We store these "in process" mappings in order to keep track of
the mappings currently being evaluated so we avoid stack over flow errors
getMapping(Object, String, Collection)
when finding mappings
that are mapped to super metafacade properties.
Note: visibility is defined as protected
in order to
improve inner class access performance.
protected final Collection<MetafacadeBase> inProcessMetafacades
Stores the metafacades which are currently "in process" (within the
getMapping(Object, String, Collection)
. This means the
metafacade being processed by the getMapping(Object, String,
Collection)
operation. We store these "in process" metafacades in order
to keep track of the metafacades currently being evaluated so we avoid
stack over flow errors getMapping(Object, String, Collection)
when
finding metafacades that are mapped to super metafacade properties.
Note: visibility is defined as protected
in order to
improve inner class access performance.
public MetafacadeMappings()
public static MetafacadeMappings newInstance()
public void addMapping(MetafacadeMapping mapping)
mapping
- the MetafacadeMapping instance.public Class getMetafacadeInterface(Class metafacadeClass)
metafacadeClass
.metafacadeClass
- public Collection<String> getPropertyReferences()
protected MetafacadeMapping getMapping(Object mappingObject, String context, Collection<String> stereotypes)
Retrieves the MetafacadeMapping belonging to the unique
key
created from the mappingObject
's
class, context
and given stereotypes
. It's
IMPORTANT to note that contexts have a higher priority
than stereotypes. This allows us to retrieve mappings based on the
following combinations:
NOTE: mapping properties are inherited from super metafacades.
mappingObject
- an instance of the class to which the mapping
applies.stereotypes
- the stereotypes to check.context
- the context within the namespace for which the mapping
applies (has 'root' in the name because of the fact that we also
search the context inheritance hierarchy started with this 'root'
context).protected Collection<String> getMappingObjectHierarchy(Object mappingObject)
mappingObject
.mappingObject
- the object from which to retrieve the hierarchy.protected final List<String> getContextHierarchy(String context)
context
)
from the given context
and returns a list containing all
of them. Note that the visibility of this operation is protected to
improve inner class access performance.context
- the root contextspublic void addPropertyReference(String reference)
reference
- the name of the reference.public MetafacadeMapping getMetafacadeMapping(Object mappingObject, String namespace, String context, Collection<String> stereotypes)
Attempts to get the MetafacadeMapping identified by the given
mappingClass
,context
and
stereotypes
, from the mappings for the given
namespace
. If it can not
be found, it will search the default mappings and return that instead.
IMPORTANT: The context
will take precedence over any stereotypes
with
the mapping.
mappingObject
- the meta object for the mapping we are trying to find.namespace
- the namespace (i.e. a cartridge, name, etc.)context
- to which the mapping applies (note this takes precedence over stereotypes).stereotypes
- collection of stereotype names. We'll check to see if the mapping for the given
mappingClass
is defined for it.public void initialize()
final void registerAllProperties()
MetafacadeFactory
instance.public void setMetaclassPattern(String metaclassPattern)
metaclassPattern
- the pattern for the meta classes.static Map<Class,Set<String>> getAllMetafacadeMappingInstances()
MetafacadeUtils.getInheritedMappingClassNames(MetafacadeMapping)
.public MetafacadeMappings getModelMetafacadeMappings(String metafacadeModelNamespace)
metafacadeModelNamespace
- the namespace that contains a metafacade model facade implementation.MetafacadeMappings
instance.final Class getDefaultMetafacadeClass(String namespace)
namespace
- mapping to check for defaultMetafacadeClasspublic void setDefaultMetafacadeClass(String defaultMetafacadeClass)
defaultMetafacadeClass
- the default metafacade class.protected Collection<MetafacadeMapping> getMappings()
MetafacadeMapping
instances belonging to this
metafacade mappings instance.MetafacadeMapping
instancesfinal void registerProperties(String namespace, Collection<String> propertyReferences, String metafacadeName)
propertyReferences
- the property references to register.metafacadeName
- the name of the metafacade under which to register
the properties.namespace
- the namespace of the property reference.final void shutdown()
MetafacadeFactory.shutdown()
is called.public String toString()
toString
in class Object
Object.toString()
Copyright © 2003–2014 AndroMDA.org. All rights reserved.