org.andromda.core.metafacade
Class MetafacadeFactory

java.lang.Object
  extended by org.andromda.core.metafacade.MetafacadeFactory
All Implemented Interfaces:
java.io.Serializable

public class MetafacadeFactory
extends java.lang.Object
implements java.io.Serializable

The factory in charge of constructing Metafacade instances. In order for a metafacade (i.e. a facade around a meta model element) to be constructed, it must be constructed through this factory.

Author:
Matthias Bohlen , Chad Brandon, Peter Friese
See Also:
Serialized Form

Method Summary
 void clearCaches()
          Clears out the factory's internal caches (other than namespace properties, which can be cleared by calling Namespaces.clear().
 MetafacadeBase createFacadeImpl(java.lang.String interfaceName, java.lang.Object mappingObject, java.lang.String context)
          Create a facade implementation object for a mappingObject.
 MetafacadeBase createMetafacade(java.lang.Object mappingObject)
          Returns a metafacade for a mappingObject, depending on its mappingClass.
protected  MetafacadeBase createMetafacade(java.lang.Object mappingObject, MetafacadeMapping mapping)
          Creates a metacade from the passed in mappingObject, and mapping instance.
 MetafacadeBase createMetafacade(java.lang.Object mappingObject, java.lang.String context)
          Returns a metafacade for a mappingObject, depending on its mappingClass and (optionally) its sterotypes and context.
 java.util.Collection createMetafacades(java.util.Collection mappingObjects)
          Returns a metafacade for each mappingObject, contained within the mappingObjects collection depending on its mappingClass.
protected  java.util.Collection createMetafacades(java.util.Collection mappingObjects, java.lang.String contextName)
          Returns a metafacade for each mappingObject, contained within the mappingObjects collection depending on its mappingClass and (optionally) its sterotypes, and contextName.
 java.util.Collection getAllMetafacades()
           Gets all metafacades for the entire model for the current namespace set within the factory.
static MetafacadeFactory getInstance()
          Returns the facade factory singleton.
 java.util.Collection getMetafacadesByStereotype(java.lang.String stereotype)
           Gets all metafacades for the entire model having the given stereotype.
 ModelAccessFacade getModel()
          Gets the model which provides access to the underlying model and is used to construct metafacades.
 java.lang.String getNamespace()
          Returns the name of the active namespace.
 java.util.List getValidationMessages()
          Gets the list of all validation messages collection during model processing.
 void initialize()
          Performs any initialization required by the factory (i.e.
 void reset()
          Entirely resets all the internal resources within this factory instance (such as the caches, etc).
 void setModel(ModelAccessFacade model, java.lang.String metafacadeModelNamespace)
          The model access facade instance (provides access to the meta model).
 void setNamespace(java.lang.String namespace)
          Sets the active namespace.
 void shutdown()
          Performs shutdown procedures for the factory.
 void validateAllMetafacades()
          Validates all metafacdes for the current namespace and collects the messages in the interal validation messages collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MetafacadeFactory getInstance()
Returns the facade factory singleton.

Returns:
the only instance

initialize

public void initialize()
Performs any initialization required by the factory (i.e. discovering all metafacade mappings, etc).


setNamespace

public void setNamespace(java.lang.String namespace)
Sets the active namespace. The AndroMDA core and each cartridge have their own namespace for metafacade registration.

Parameters:
namespace - the name of the active namespace.

getNamespace

public java.lang.String getNamespace()
Returns the name of the active namespace.

Returns:
String the namespace name

createMetafacade

public MetafacadeBase createMetafacade(java.lang.Object mappingObject,
                                       java.lang.String context)
Returns a metafacade for a mappingObject, depending on its mappingClass and (optionally) its sterotypes and context.

Parameters:
mappingObject - the object used to map the metafacade (a meta model object or a metafacade itself).
context - the name of the context the meta model element is registered under.
Returns:
the new metafacade

validateAllMetafacades

public void validateAllMetafacades()
Validates all metafacdes for the current namespace and collects the messages in the interal validation messages collection.

See Also:
getValidationMessages()

createMetafacade

protected MetafacadeBase createMetafacade(java.lang.Object mappingObject,
                                          MetafacadeMapping mapping)
Creates a metacade from the passed in mappingObject, and mapping instance.

Parameters:
mappingObject - the mapping object for which to create the metafacade.
mapping - the mapping from which to create the metafacade
Returns:
the metafacade, or null if it can't be created.

createMetafacade

public MetafacadeBase createMetafacade(java.lang.Object mappingObject)
Returns a metafacade for a mappingObject, depending on its mappingClass.

Parameters:
mappingObject - the object which is used to map to the metafacade
Returns:
MetafacadeBase the facade object (not yet attached to mappingClass object)

createFacadeImpl

public MetafacadeBase createFacadeImpl(java.lang.String interfaceName,
                                       java.lang.Object mappingObject,
                                       java.lang.String context)
Create a facade implementation object for a mappingObject. The facade implementation object must be found in a way that it implements the interface interfaceName.

Parameters:
interfaceName - the name of the interface that the implementation object has to implement
mappingObject - the mappingObject for which a facade shall be created
context - the context in which this metafacade will be created.
Returns:
MetafacadeBase the metafacade

createMetafacades

protected java.util.Collection createMetafacades(java.util.Collection mappingObjects,
                                                 java.lang.String contextName)
Returns a metafacade for each mappingObject, contained within the mappingObjects collection depending on its mappingClass and (optionally) its sterotypes, and contextName.

Parameters:
mappingObjects - the meta model element.
contextName - the name of the context the meta model element is registered under.
Returns:
the Collection of newly created Metafacades.

createMetafacades

public java.util.Collection createMetafacades(java.util.Collection mappingObjects)
Returns a metafacade for each mappingObject, contained within the mappingObjects collection depending on its mappingClass.

Parameters:
mappingObjects - the objects used to map the metafacades (can be a meta model element or an actual metafacade itself).
Returns:
Collection of metafacades

getModel

public ModelAccessFacade getModel()
Gets the model which provides access to the underlying model and is used to construct metafacades.

Returns:
the model access facade.

setModel

public void setModel(ModelAccessFacade model,
                     java.lang.String metafacadeModelNamespace)
The model access facade instance (provides access to the meta model).

Parameters:
model - the model
metafacadeModelNamespace - the namespace that contains the metafacade facade implementation.

getValidationMessages

public java.util.List getValidationMessages()
Gets the list of all validation messages collection during model processing.

Returns:
Returns the validationMessages.
See Also:
validateAllMetafacades()

getAllMetafacades

public java.util.Collection getAllMetafacades()

Gets all metafacades for the entire model for the current namespace set within the factory.

NOTE: The model package filter is applied before returning the results (if defined within the factory).

Returns:
all metafacades

getMetafacadesByStereotype

public java.util.Collection getMetafacadesByStereotype(java.lang.String stereotype)

Gets all metafacades for the entire model having the given stereotype.

NOTE: The model package filter is applied before returning the results (if defined within the factory).

Parameters:
stereotype - the stereotype by which to perform the search.
Returns:
the metafacades having the given stereotype.

shutdown

public void shutdown()
Performs shutdown procedures for the factory. This should be called ONLY when model processing has completed.


reset

public void reset()
Entirely resets all the internal resources within this factory instance (such as the caches, etc).


clearCaches

public void clearCaches()
Clears out the factory's internal caches (other than namespace properties, which can be cleared by calling Namespaces.clear().



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