All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface com.ibm.beans.tools.assembly.SubAssemblyGen

public interface interface SubAssemblyGen
This interface defines the methods that a subassembly model must support to generate code for or initialize the bean being created.

When it is time to create the new bean class and associated instance, the assembly asks each subassembly object if it has an associated subassembly generator object. If so, it calls methods on that object at various times during the code generation process used to create the new bean class.

Similarly, once the new bean class is compiled, the assembly loads the class, creates an instance, and then allows each subassembly generator to initialize the object with whatever data needs to be serialized with the instance.

See Also:
Assembly, SubAssembly

Method Index

 o genBean(String)
Generates the source code needed to implement the bean.
 o getInterface()
Returns an array of interfaces that the generated bean implements.
 o getParentClass()
Returns the parent class of the generated bean.
 o initBean(Object)
Initializes the specified bean.
 o resetBean()
Resets temporarilly removed state and listeners from a previous initBean() method call.

Methods

 o getParentClass
 public abstract Class getParentClass()
Returns the parent class of the generated bean. This method is called by the assembly at the start of the code generation phase for the bean being assembled to determine if the model requires the generated bean to be a subclass of a specific class.

If it does, the required class should be returned. If it does not have any specific requirement, then null should be returned.

It is considered an error if two or more models return classes that are not related by inheritance.

Returns:
The class the generated bean extends.
 o getInterface
 public abstract Class[] getInterface()
Returns an array of interfaces that the generated bean implements. This method is called by the assembly at the start of the code generation phase for the bean being assembled to determine which interfaces the model intends to implement.

If the model does not implement any interfaces, it should return null; otherwise it should return an array containing each of the interfaces it intends to implement.

It is considered an error if two or more models implement the same interface or interfaces related by extension.

Returns:
The array of interfaces the generated bean implements.
 o genBean
 public abstract void genBean(String prefix)
Generates the source code needed to implement the bean. This method is called by the assembly during the code generation phase for the bean being assembled. The subassembly generator should respond by generating whatever code it needs to implement the bean.

In particular, this method can call the assembly genImports(), genFields(), genInit(), genStart(), genMethods(), genClasses(), and genManifest() methods to add whatever Java source code it needs to the class being generated.

This method should generate whatever additional files or classes it needs to implement the new bean. It can use the assembly getPackageName(), getClassName(), getPathName(), and getPackagePathName() methods to determine where any files it needs to create should be stored.

Parameters:
prefix - A unique prefix associated with this code generator which the model can use to distinguish any private fields or methods it needs to generate from those generated by any other subassembly model used by the assembly. The model should prepend the string to any private fields or methods it generates 2or references.

Note that public fields or methods the model wants to expose as part of the new bean's interface should not prepend this string.

 o initBean
 public abstract void initBean(Object bean)
Initializes the specified bean. This method is called by the assembly after the class for the bean is generated, compiled, loaded, and an instance of the class created. The created bean instance is passed as the bean argument.

If the model needs to initialize the bean with some instance data prior to the assembly serializing it, it can use the introspection APIs to add the data to the bean.

Note that if the model associated with the subassembly generator has established listeners to any of the beans in the current assembly, it should remove them at this time if it wants to prevent the listeners from being saved as part of the new bean persistent state. The assembly invokes the subassembly generator resetBean() method after the new bean has been serialized to allow the model to reattach any removed listeners.

Note that the subassembly should not save the reference to the bean, because it can interfere with the user's ability to create another version of the bean.

Parameters:
bean - The bean to be initialized.
 o resetBean
 public abstract void resetBean()
Resets temporarilly removed state and listeners from a previous initBean() method call. This method is called by the assembly after a new bean has been serialized to allow the model associated with the subassembly generator to restore any listeners or other state temporarilly removed as part of the preceding initBean() method.


All Packages  Class Hierarchy  This Package  Previous  Next  Index