org.andromda.core.metafacade
Class MetafacadeFactory

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

public class MetafacadeFactory
extends Object
implements 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, Bob Fields
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(String interfaceName, Object mappingObject, String context)
          Create a facade implementation object for a mappingObject.
 MetafacadeBase createMetafacade(Object mappingObject)
          Returns a metafacade for a mappingObject, depending on its mappingClass.
protected  MetafacadeBase createMetafacade(Object mappingObject, MetafacadeMapping mapping)
          Creates a metafacade from the passed in mappingObject, and mapping instance.
 MetafacadeBase createMetafacade(Object mappingObject, String context)
          Returns a metafacade for a mappingObject, depending on its mappingClass and (optionally) its stereotypes and context.
 Collection<MetafacadeBase> createMetafacades(Collection mappingObjects)
          Returns a metafacade for each mappingObject, contained within the mappingObjects collection depending on its mappingClass.
protected  Collection<MetafacadeBase> createMetafacades(Collection mappingObjects, String contextName)
          Returns a metafacade for each mappingObject, contained within the mappingObjects collection depending on its mappingClass and (optionally) its stereotypes, and contextName.
 Collection<MetafacadeBase> getAllMetafacades()
           Gets all metafacades for the entire model for the current namespace set within the factory.
static MetafacadeFactory getInstance()
          Returns the facade factory singleton.
(package private)  Logger getLogger()
          Gets the correct logger based on whether or not an namespace logger should be used
 Collection<MetafacadeBase> getMetafacadesByStereotype(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.
 String getNamespace()
          Returns the name of the active namespace.
(package private)  Object getRegisteredProperty(MetafacadeBase metafacade, String name)
          Gets the registered property registered under the namespace with the name
 List<ModelValidationMessage> getValidationMessages()
          Gets the list of all validation messages collection during model processing.
 void initialize()
          Performs any initialization required by the factory (i.e.
(package private)  boolean isPropertyRegistered(MetafacadeBase metafacade, String name)
          Returns true if this property is registered under the given namespace, false otherwise.
(package private)  void registerProperty(String metafacadeName, String name, Object value)
          Registers a property with the specified name in the namespace that is currently set within the factory.
(package private)  void registerProperty(String namespace, String metafacadeName, String name, Object value)
          Registers a property with the specified name in the given namespace.
 void reset()
          Entirely resets all the internal resources within this factory instance (such as the caches, etc).
 void setModel(ModelAccessFacade model, String metafacadeModelNamespace)
          The model access facade instance (provides access to the meta model).
 void setNamespace(String namespace)
          Sets the active namespace.
 void shutdown()
          Performs shutdown procedures for the factory.
 void validateAllMetafacades()
          Validates all metafacades for the current namespace and collects the messages in the internal 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(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 String getNamespace()
Returns the name of the active namespace.

Returns:
String the namespace name

createMetafacade

public MetafacadeBase createMetafacade(Object mappingObject,
                                       String context)
Returns a metafacade for a mappingObject, depending on its mappingClass and (optionally) its stereotypes 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 metafacades for the current namespace and collects the messages in the internal validation messages collection.

See Also:
getValidationMessages()

createMetafacade

protected MetafacadeBase createMetafacade(Object mappingObject,
                                          MetafacadeMapping mapping)
Creates a metafacade 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(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(String interfaceName,
                                       Object mappingObject,
                                       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 Collection<MetafacadeBase> createMetafacades(Collection mappingObjects,
                                                       String contextName)
Returns a metafacade for each mappingObject, contained within the mappingObjects collection depending on its mappingClass and (optionally) its stereotypes, 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 Collection<MetafacadeBase> createMetafacades(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,
                     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.

getLogger

final Logger getLogger()
Gets the correct logger based on whether or not an namespace logger should be used

Returns:
the logger

registerProperty

final void registerProperty(String namespace,
                            String metafacadeName,
                            String name,
                            Object value)
Registers a property with the specified name in the given namespace.

Parameters:
namespace - the namespace in which the property is stored.
metafacadeName - the name of the metafacade under which the property is registered
name - the name of the property
value - to give the property

registerProperty

final void registerProperty(String metafacadeName,
                            String name,
                            Object value)
Registers a property with the specified name in the namespace that is currently set within the factory.

Parameters:
metafacadeName - the name of the metafacade under which the property is registered
name - the name of the property
value - to give the property

isPropertyRegistered

final boolean isPropertyRegistered(MetafacadeBase metafacade,
                                   String name)
Returns true if this property is registered under the given namespace, false otherwise.

Parameters:
metafacade - the metafacade to search.
name - the name of the property.
Returns:
true if the property is registered, false otherwise.

getRegisteredProperty

final Object getRegisteredProperty(MetafacadeBase metafacade,
                                   String name)
Gets the registered property registered under the namespace with the name

Parameters:
metafacade - the metafacade to search
name - the name of the property to check.
Returns:
the registered property

getValidationMessages

public List<ModelValidationMessage> getValidationMessages()
Gets the list of all validation messages collection during model processing.

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

getAllMetafacades

public Collection<MetafacadeBase> 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 Collection<MetafacadeBase> getMetafacadesByStereotype(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-2010 AndroMDA.org. All Rights Reserved.