org.objectweb.jac.aspects.naming
Class NamingAC

java.lang.Object
  |
  +--org.objectweb.jac.core.AspectComponent
        |
        +--org.objectweb.jac.aspects.naming.NamingAC
All Implemented Interfaces:
BaseProgramListener, Serializable

public class NamingAC
extends AspectComponent

Handles the naming aspect within the JAC system.

This aspect component automatically registers all the created JAC object into the sole instance of NameRepository.

See Also:
NameRepository, Serialized Form

Field Summary
 
Fields inherited from class org.objectweb.jac.core.AspectComponent
application, blockKeywords, cr, currentConfigMethod, currentImports, firstCall, NOT_SHARED, SHARED, startWeavingCCount, startWeavingCount, startWeavingMethod, startWeavingType, systemListener, wrappers
 
Fields inherited from interface org.objectweb.jac.core.BaseProgramListener
FOUND_OBJECT
 
Constructor Summary
NamingAC()
          Creates a naming aspect component.
 
Method Summary
 Map getNameCounters()
          Returns the counters used to generate unique names
 String nameObject(Object object, String name)
          Name a single object by registering it in the name repository (see the NameRepository class).
 void updateNameCounters(Map counters)
           
 void whenRemoteInstantiation(Wrappee newInstance, String name)
          This method is upcalled when a new object is instanciated from a remote site.
 Wrappee whenSerialized(Wrappee orgObject, SerializedJacObject finalObject)
          Add the name to the SerializedJacObject structure when serialized.
 void whenUsingNewInstance(Interaction interaction)
          Name a new instance using the nameObject() and generateName() methods.
 
Methods inherited from class org.objectweb.jac.core.AspectComponent
addWrapper, afterApplicationStarted, afterRunningWrapper, afterWrap, afterWrappeeInit, attr, attrdef, beforeConfiguration, beforeReload, beforeRunningWrapper, beforeWrappeeInit, configure, defines, defineTimer, doRegister, doUnregister, error, getAC, getApplication, getBlockKeywords, getConfigurationMethods, getConfigurationMethodsName, getConfigurationMethodsName, getDefaultConfigs, getName, getNameCounters, getWrappers, init, isConfigurationMethod, isSystemListener, onExit, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, pointcut, setApplication, setAttribute, setAttribute, setAttribute, setSystemListener, simulateUsingNewInstance, unweave, unwrapAll, warning, weave, whenClone, whenCloseDisplay, whenConfigured, whenDeleted, whenDeserialized, whenFree, whenGetObjects, whenNameObject, whenObjectMiss, whenReload, whenTopologyChanged, whenUsingNewClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamingAC

public NamingAC()
Creates a naming aspect component.

It creates the name repository if it does not exist yet.

See Also:
NameRepository
Method Detail

whenUsingNewInstance

public void whenUsingNewInstance(Interaction interaction)
Name a new instance using the nameObject() and generateName() methods.

Specified by:
whenUsingNewInstance in interface BaseProgramListener
Overrides:
whenUsingNewInstance in class AspectComponent
See Also:
nameObject(Object,String), NameGenerator.generateName(String)

whenRemoteInstantiation

public void whenRemoteInstantiation(Wrappee newInstance,
                                    String name)
This method is upcalled when a new object is instanciated from a remote site.

The name that is passed is the name of the remote reference that has been used to create the object. Thus, the default behavior of the naming aspect is to register the new object into the name repository.

Specified by:
whenRemoteInstantiation in interface BaseProgramListener
Overrides:
whenRemoteInstantiation in class AspectComponent
Parameters:
newInstance - the remotly created new instance
name - the name that was forwarded from the creator host
See Also:
NameRepository, Repository.register(String,Object)

nameObject

public String nameObject(Object object,
                         String name)
Name a single object by registering it in the name repository (see the NameRepository class).

If the repository does not exist, it is created.

Parameters:
object - the object to name
name - the given name
Returns:
the new name of the object
See Also:
NameRepository, Repository.register(String,Object)

getNameCounters

public Map getNameCounters()
Returns the counters used to generate unique names


updateNameCounters

public void updateNameCounters(Map counters)
Overrides:
updateNameCounters in class AspectComponent

whenSerialized

public Wrappee whenSerialized(Wrappee orgObject,
                              SerializedJacObject finalObject)
Add the name to the SerializedJacObject structure when serialized.

This allows the name to be serialized with a JAC object so that the object can be named with the same name when deserialized (see BindingAC).

Specified by:
whenSerialized in interface BaseProgramListener
Overrides:
whenSerialized in class AspectComponent
Parameters:
finalObject - the structure corresponding to the object that is being serialized
orgObject - the object being serialized
Returns:
the object being serialized (usually orgObject, but not necessarily).
See Also:
BindingAC.whenDeserialized(SerializedJacObject,Wrappee), SerializedJacObject.setACInfos(String,Object)