org.andromda.core.metafacade
Class MetafacadeCache

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

public final class MetafacadeCache
extends java.lang.Object
implements java.io.Serializable

A global cache for metafacades. Used by the MetafacadeFactorywhen constructing or retrieving metafacade instances. If the cache constains the metafacade it should not be constructed again.

Author:
Chad Brandon
See Also:
Serialized Form

Method Summary
 void add(java.lang.Object mappingObject, MetafacadeBase metafacade)
          Adds the metafacade to the cache according to first mappingObject, second the metafacade, and finally by the current namespace.
 void clear()
          Clears the cache of any metafacades
 MetafacadeBase get(java.lang.Object mappingObject, java.lang.Class metafacadeClass)
          

Returns the metafacade from the metafacade cache.

static MetafacadeCache newInstance()
          Constructs a new instance of this class.
 void setNamespace(java.lang.String namespace)
          Sets the namespace to which the cache currently applies.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

newInstance

public static MetafacadeCache newInstance()
Constructs a new instance of this class.

Returns:
the new instance

setNamespace

public final void setNamespace(java.lang.String namespace)
Sets the namespace to which the cache currently applies.

Parameters:
namespace - the current namespace.

get

public final MetafacadeBase get(java.lang.Object mappingObject,
                                java.lang.Class metafacadeClass)

Returns the metafacade from the metafacade cache. The Metafacades are cached first by according to its mappingObject, next the metafacadeClass, and finally by the current namespace.

Metafacades must be cached in order to keep track of the state of its validation. If we keep creating a new one each time, we can never tell whether or not a metafacade has been previously validated. Not to mention tremendous performance gains.

Parameters:
mappingObject - the object to which the mapping applies
metafacadeClass - the class of the metafacade.
Returns:
MetafacadeBase stored in the cache.

add

public final void add(java.lang.Object mappingObject,
                      MetafacadeBase metafacade)
Adds the metafacade to the cache according to first mappingObject, second the metafacade, and finally by the current namespace.

Parameters:
mappingObject - the mappingObject for which to cache the metafacade.
metafacade - the metafacade to cache.

clear

public final void clear()
Clears the cache of any metafacades


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


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