org.objectweb.fractal.juliak
Class BootstrapComponentImpl

java.lang.Object
  extended by org.objectweb.fractal.juliak.BootstrapComponentImpl
All Implemented Interfaces:
GenericFactory, TypeFactory, Loader

public class BootstrapComponentImpl
extends Object
implements TypeFactory, GenericFactory, Loader

Juliak bootstrap component implementation (aka content class). This component provides three interfaces:

Since:
2.5
Author:
Lionel Seinturier

Field Summary
 
Fields inherited from interface org.objectweb.fractal.api.type.TypeFactory
CLIENT, COLLECTION, MANDATORY, OPTIONAL, SERVER, SINGLE
 
Constructor Summary
BootstrapComponentImpl()
           
 
Method Summary
 InterfaceType createFcItfType(String name, String signature, boolean isClient, boolean isOptional, boolean isCollection)
           
 ComponentType createFcType(InterfaceType[] interfaceTypes)
           
 Tree evalTree(Tree tree, Map context)
          Evaluates the given tree in the given context.
 void init(Map context)
          Initializes this loader.
 Class loadClass(String className, Object loader)
          Loads the class whose name is given.
 Class loadClass(Tree classDescriptor, Object loader)
          Loads or generates the class whose descriptor is given.
 Tree loadTree(String name)
          Loads the tree whose name is given.
 Component newFcInstance(Type type, Object controllerDesc, Object contentDesc)
           
 Object newObject(Tree objectDescriptor, Object loader)
          Creates and returns the object whose description is given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BootstrapComponentImpl

public BootstrapComponentImpl()
Method Detail

createFcItfType

public InterfaceType createFcItfType(String name,
                                     String signature,
                                     boolean isClient,
                                     boolean isOptional,
                                     boolean isCollection)
                              throws InstantiationException
Specified by:
createFcItfType in interface TypeFactory
Throws:
InstantiationException

createFcType

public ComponentType createFcType(InterfaceType[] interfaceTypes)
                           throws InstantiationException
Specified by:
createFcType in interface TypeFactory
Throws:
InstantiationException

newFcInstance

public Component newFcInstance(Type type,
                               Object controllerDesc,
                               Object contentDesc)
                        throws InstantiationException
Specified by:
newFcInstance in interface GenericFactory
Throws:
InstantiationException

evalTree

public Tree evalTree(Tree tree,
                     Map context)
              throws Exception
Description copied from interface: Loader
Evaluates the given tree in the given context. Each leaf node of the given tree whose name begins with ' is replaced by the evaluation of the tree associated to this name in the given context (except if the result of this evaluation is "QUOTE"). For example the evaluation of "('x d)" in a context where x is associated to "(a 'y)", y is associated to "(b 'z)", and z is associated to "QUOTE" gives "((a (b 'z)) d)".

Specified by:
evalTree in interface Loader
Parameters:
tree - the tree to be evaluated.
context - a map associating names to trees.
Returns:
the evaluated tree.
Throws:
Exception - if a name is not found in the given context. The exception's detail is equal to this name.

init

public void init(Map context)
          throws Exception
Description copied from interface: Loader
Initializes this loader.

Specified by:
init in interface Loader
Parameters:
context - the initialization arguments.
Throws:
Exception - if the initialization fails.

loadClass

public Class loadClass(String className,
                       Object loader)
                throws ClassNotFoundException
Description copied from interface: Loader
Loads the class whose name is given.

Specified by:
loadClass in interface Loader
Parameters:
className - the fully qualified name of the class to be returned.
loader - an optional class loader to load auxiliary classes.
Returns:
the class whose name is given.
Throws:
ClassNotFoundException - if the specified class is not found.

loadClass

public Class loadClass(Tree classDescriptor,
                       Object loader)
                throws ClassNotFoundException
Description copied from interface: Loader
Loads or generates the class whose descriptor is given.

Specified by:
loadClass in interface Loader
Parameters:
classDescriptor - the descriptor of the class to be loaded or dynamically generated. This descriptor must be either of the form "className", or of the form "(objectDescriptor arg1 ... argN)". In the first case, "className" must be the fully qualified name of a class. In the second case, "objectDescriptor" must be a valid object descriptor (see newObject), describing an object that implements the ClassGenerator interface. "arg1" ... "argN" can be arbitrary trees.
loader - an optional class loader to load auxiliary classes.
Returns:
the class whose description is given. If this description is of the form "className", this method returns the "className" class. If the description is of the form "(objectDescriptor arg1 ... argN)", the class generator described by "objectDescriptor" is instantiated with the newObject method, and its generateClass method is used to generate a class (this method is called with classDescriptor as second argument), which is finally returned.
Throws:
ClassNotFoundException - is the specified class cannot be loaded or dynamically generated.

loadTree

public Tree loadTree(String name)
              throws Exception
Description copied from interface: Loader
Loads the tree whose name is given.

Specified by:
loadTree in interface Loader
Parameters:
name - a tree name.
Returns:
the tree whose name is given.
Throws:
Exception - if the tree is not found or cannot be loaded.

newObject

public Object newObject(Tree objectDescriptor,
                        Object loader)
                 throws Exception
Description copied from interface: Loader
Creates and returns the object whose description is given.

Specified by:
newObject in interface Loader
Parameters:
objectDescriptor - the descriptor of the object to be created. This descriptor must be either of the form "className", or of the form "(classDescriptor arg1 ... argN)". In the first case, "className" must be the fully qualified name of a class. In the second case, "classDescriptor" must be a valid class descriptor (see loadClass). "arg1" ... "argN" can be arbitrary trees.
loader - an optional class loader to load auxiliary classes.
Returns:
an object created according to the given description. If this description is of the form "className", this method returns a new instance of the "className" class (which must have a default public constructor). If the description is of the form "(classDescriptor arg1 ... argN)", the class described by "classDescriptor" is loaded or generated with the loadClass method, and a new instance of this class is created (this class must have a default public constructor). Then, if the arguments "arg1 ... argN" are not empty, the initialize method is used to initialize the previous instance (in this case, the "classDescriptor" class must implement the Initializable interface; the initialize method is called with (arg1 ... argN) as parameter). Finally the previously created object is returned.
Throws:
Exception - if the specified object cannot be created.