org.andromda.core.metafacade
Class MetafacadeBase

java.lang.Object
  extended by org.andromda.core.metafacade.MetafacadeBase

public class MetafacadeBase
extends java.lang.Object

Base class for all metafacades.

Author:
Matthias Bohlen , Chad Brandon, Wouter Zoons

Field Summary
protected  boolean contextRoot
          The flag indicating whether or not this metafacade is a context root.
protected  org.apache.log4j.Logger logger
          The metafacade logger instance.
 
Constructor Summary
MetafacadeBase(java.lang.Object metaObject, java.lang.String context)
          Constructs a new instance of this class with the given metaObject and context.
 
Method Summary
 boolean equals(java.lang.Object object)
           
protected  java.lang.Object getConfiguredProperty(java.lang.String property)
          Gets a configured property from the container.
 java.lang.String getMetafacadeContext()
          Gets the context for this metafacade.
 java.lang.Object getMetaObject()
          Gets the current meta model object for this metafacade.
 java.lang.String getValidationName()
          Retrieves the name of this metafacade used within the validation messages.
 java.lang.Object getValidationOwner()
          Retrieves the owner of this metafacade (for example: an operation owns its parameters, a class owns its attributes).
 int hashCode()
           
 void initialize()
          A lifecycle method, providing the ability for sub classes to take any action after the factory has completely initialized a metafacade, but before it has been validated for completeness.
protected  boolean isConfiguredProperty(java.lang.String property)
          Returns true or false depending on whether the property is registered or not.
 boolean isMetafacadePropertyCachingEnabled()
          A check to verify whether or not to make use of metafacade property caching.
 void resetMetafacadeContext(java.lang.String context)
          Resets the metafacade context after the metafacade was retrieved from the metafacade cache.
 void setMetafacadeContext(java.lang.String context)
          Sets the context for this metafacade.
protected  void setProperty(java.lang.String name, java.lang.Object value)
          Attempts to set the property with name having the specified value on this metafacade.
protected  MetafacadeBase shieldedElement(java.lang.Object metaObject)
          Returns one facade for a particular metaObject.
protected  java.util.Collection shieldedElements(java.util.Collection metaobjects)
          Returns a collection of facades for a collection of metaobjects.
protected  MetafacadeBase THIS()
          The metafacade instance of this.
 void validate(java.util.Collection validationMessages)
          Validates that this facade's meta object is in a valid state.
 void validateInvariants(java.util.Collection messages)
          

The logic of modeled OCL invariants from derived metafacades will be generated into this method and validation messages created and collected into the messages collection.

 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected org.apache.log4j.Logger logger
The metafacade logger instance.


contextRoot

protected boolean contextRoot
The flag indicating whether or not this metafacade is a context root.

Constructor Detail

MetafacadeBase

public MetafacadeBase(java.lang.Object metaObject,
                      java.lang.String context)
Constructs a new instance of this class with the given metaObject and context. The metaObject is the meta model element which this metafacade insulates. The context is the name of the context for this metafacade instance.

Parameters:
metaObject - the meta object.
context - the context of this meta object.
Method Detail

getValidationOwner

public java.lang.Object getValidationOwner()
Retrieves the owner of this metafacade (for example: an operation owns its parameters, a class owns its attributes).

By default null is returned, however this method is overridden by subclasses which have a parent or owner. This is used to give the model validation messages more context as to where the validation error occurred.

Returns:
the owner of this metafacade.

getValidationName

public java.lang.String getValidationName()
Retrieves the name of this metafacade used within the validation messages.

By default null is returned, however this method is overridden by subclasses model elements that do have a name.

Returns:
the owner of this metafacade.

validate

public final void validate(java.util.Collection validationMessages)
Validates that this facade's meta object is in a valid state.

Validate is called during metafacade creation by the factory. In the lifecycle of a metafacade it is validated only once, this is enforced by the caching within the metafacade factory.

Parameters:
validationMessages - any messages generated during validation.
See Also:
MetafacadeFactory.createMetafacade(Object, String, Class)

validateInvariants

public void validateInvariants(java.util.Collection messages)

The logic of modeled OCL invariants from derived metafacades will be generated into this method and validation messages created and collected into the messages collection. This method is called by validate(Collection)

By default this method is empty.


initialize

public void initialize()
A lifecycle method, providing the ability for sub classes to take any action after the factory has completely initialized a metafacade, but before it has been validated for completeness.


shieldedElement

protected MetafacadeBase shieldedElement(java.lang.Object metaObject)
Returns one facade for a particular metaObject. Contacts the MetafacadeFactory to manufacture the proper metafacade. In certain cases metaObject can also be a metafacade instance; in that case the actual meta model element is retrieved from the metafacade and a metafacade is constructed from that.

Parameters:
metaObject - the underlying meta model element. A metafacade is created for each.
Returns:
MetafacadeBase the facade
See Also:
MetafacadeFactory

shieldedElements

protected java.util.Collection shieldedElements(java.util.Collection metaobjects)
Returns a collection of facades for a collection of metaobjects. Contacts the MetafacadeFactory to manufacture the proper facades.

Parameters:
metaobjects - the objects to decorate
Returns:
Collection of MetafacadeBase-derived objects
See Also:
MetafacadeFactory

setMetafacadeContext

public void setMetafacadeContext(java.lang.String context)
Sets the context for this metafacade. This is used to pass the context along from a metafacade specializing this metafacade (since we use delegate inheritance between shared and non-shared metafacades), as well as to pass the context to a metafacade being created within another.

Parameters:
context - the metafacade interface name representing the context.
See Also:
MetafacadeMapping.isContextRoot(), MetafacadeFactory.createMetafacade(Object, String, Class)

resetMetafacadeContext

public void resetMetafacadeContext(java.lang.String context)
Resets the metafacade context after the metafacade was retrieved from the metafacade cache. DO NOT CALL THIS METHOD BY HAND, it is reserved for use in the MetafacadeFactory.

Parameters:
context - the context defined by MetafacadeFactory
See Also:
MetafacadeFactory

isConfiguredProperty

protected boolean isConfiguredProperty(java.lang.String property)
Returns true or false depending on whether the property is registered or not.

Parameters:
property - the name of the property to check.
Returns:
true/false on whether or not its regisgterd.

getConfiguredProperty

protected java.lang.Object getConfiguredProperty(java.lang.String property)
Gets a configured property from the container. Note that the configured property must be registered first.

Parameters:
property - the property name
Returns:
Object the configured property instance (mappings, etc)

setProperty

protected void setProperty(java.lang.String name,
                           java.lang.Object value)
Attempts to set the property with name having the specified value on this metafacade.


getMetaObject

public final java.lang.Object getMetaObject()
Gets the current meta model object for this metafacade. This is used from MetafacadeFactory when attempting to construct a metafacade from a metafacade. This allows us to get the meta object for this metafacade so that the meta object can be used instead.

Returns:
the underlying model's meta object instance.

getMetafacadeContext

public java.lang.String getMetafacadeContext()
Gets the context for this metafacade. This is either the contextRoot (if one exists), or the regular context.

Returns:
the metafacade's context.
See Also:
setContextRoot(boolean)

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

isMetafacadePropertyCachingEnabled

public final boolean isMetafacadePropertyCachingEnabled()
A check to verify whether or not to make use of metafacade property caching. This method check if the MetafacadeProperties.ENABLE_METAFACADE_PROPERTY_CACHING namespace property has been set, if this is not the case then the caching will be enabled by default.


THIS

protected final MetafacadeBase THIS()
The metafacade instance of this. This should be used when you'd need to check if this was an instance of a given metafacade. For example: THIS() instanceof SomeMetafacade. This MUST be used instead of this in order to access the correct metafacade instance in the hierarchy (since we use delegate inheritance).



Copyright © 2003-2008 AndroMDA.org. All Rights Reserved.