|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jbpm.pvm.internal.util.DefaultObservable
org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor
org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor
public class ObjectDescriptor
This Descriptor creates and initializes an object.
Objects can be instantiated from a constructor or from a method invocation.
The way to create an object is specified one of these methods (see creating objects):
setClassName(String))setFactoryObjectName(String))setFactoryDescriptor(Descriptor))This method is used when .getClassName()!=null && getMethodName()==null
The construct(WireContext) method creates a new object
from a constructor matching the given arguments
(specified with setArgDescriptors(List)).
The name of the method to call is specified by the method attribute.
getClassName().getFactoryObjectName()!=null: the object with the name factoryObjectName will be fetched from the context.getFactoryDescriptor()!=null: the object will be created from the factory descriptor.The object returned by construct(WireContext) is the object returned by the method invocation.
If the auto wiring is enabled for the object (),
the WireContext will try to look for objects with the same name as the fields in the class.
If it finds an object with that name, and if it is assignable to the field's type, it is automatically injected,
without the need for explicit isAutoWireEnabled()==trueFieldOperation that specifies the injection in the wiring xml.
If the auto wiring is enabled and the WireContext finds an object with the name of a field, but not assignable to this field, a warning message is generated.
Auto-wiring is disabled by default.
Field injection or property injection are done after the auto-wiring. For more information, see Operation.
If a field was injected by auto-wiring, its value can be overridden by specifying
a FieldOperation or PropertyOperation operation.
| Field Summary | |
|---|---|
protected java.util.List<ArgDescriptor> |
argDescriptors
map to db as a component |
protected java.lang.String |
className
|
protected Expression |
expression
|
protected Descriptor |
factoryDescriptor
specifies the object on which to invoke the method. |
protected boolean |
isAutoWireEnabled
True if autowiring is enabled. |
protected java.lang.String |
methodName
|
protected java.util.List<Operation> |
operations
list of operations to perform during initialization. |
| Fields inherited from class org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor |
|---|
dbid, dbversion, init, INIT_EAGER, INIT_IMMEDIATE, INIT_LAZY, INIT_REQUIRED, name, version |
| Fields inherited from class org.jbpm.pvm.internal.util.DefaultObservable |
|---|
listeners |
| Fields inherited from interface org.jbpm.pvm.internal.wire.Descriptor |
|---|
EVENT_CONSTRUCTED, EVENT_CONSTRUCTING, EVENT_INITIALIZING, EVENT_REMOVE, EVENT_SET |
| Constructor Summary | |
|---|---|
ObjectDescriptor()
|
|
ObjectDescriptor(java.lang.Class<?> clazz)
|
|
ObjectDescriptor(java.lang.String className)
|
|
| Method Summary | |
|---|---|
void |
addArgDescriptor(ArgDescriptor argDescriptor)
Adds a argument descriptor to the list of arguments descriptor to used when invoking the specified method. |
void |
addInjection(java.lang.String fieldName,
Descriptor descriptor)
add a field injection based on a descriptor |
void |
addOperation(Operation operation)
Adds an operation to perform during initialization. |
void |
addPropertyInjection(java.lang.String propertyName,
Descriptor valueDescriptor)
add a property injection based on a descriptor |
void |
addTypedInjection(java.lang.String fieldName,
java.lang.Class<?> type)
convenience method to add a type based field injection |
protected void |
autoWire(java.lang.Object object,
WireContext wireContext)
Auto wire object present in the context and the specified object's fields. |
java.lang.Object |
construct(WireContext wireContext)
This method constructs a new Object from the ObjectDefinition. |
java.util.List<ArgDescriptor> |
getArgDescriptors()
|
static java.lang.Object[] |
getArgs(WireContext wireContext,
java.util.List<ArgDescriptor> argDescriptors)
Creates a list of arguments (objects) from a list of argument descriptors. |
java.lang.String |
getClassName()
|
Expression |
getExpression()
|
Descriptor |
getFactoryDescriptor()
|
java.lang.String |
getFactoryObjectName()
|
java.lang.String |
getMethodName()
|
java.util.List<Operation> |
getOperations()
|
java.lang.Class<?> |
getType(WireDefinition wireDefinition)
the type of the produced object or null if that is not available |
void |
initialize(java.lang.Object object,
WireContext wireContext)
Initializes the specified object. |
static java.lang.Object |
invokeMethod(java.lang.String methodName,
java.util.List<ArgDescriptor> argDescriptors,
WireContext wireContext,
java.lang.Object object,
java.lang.Class<?> clazz)
|
boolean |
isAutoWireEnabled()
|
void |
setArgDescriptors(java.util.List<ArgDescriptor> argDescriptors)
|
void |
setAutoWireEnabled(boolean isAutoWireEnabled)
|
void |
setClassName(java.lang.String className)
|
void |
setExpression(Expression expr)
|
void |
setFactoryDescriptor(Descriptor factoryDescriptor)
|
void |
setFactoryObjectName(java.lang.String factoryObjectName)
|
void |
setMethodName(java.lang.String methodName)
|
void |
setOperations(java.util.List<Operation> operations)
|
| Methods inherited from class org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor |
|---|
getDbid, getName, isDelayable, isEagerInit, setInit, setName |
| Methods inherited from class org.jbpm.pvm.internal.util.DefaultObservable |
|---|
addListener, addListener, addListener, fire, fire, getListeners, removeListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.jbpm.pvm.internal.util.Observable |
|---|
addListener, addListener, addListener, fire, fire, removeListener |
| Field Detail |
|---|
protected java.lang.String className
protected Expression expression
protected Descriptor factoryDescriptor
protected java.lang.String methodName
protected java.util.List<ArgDescriptor> argDescriptors
protected java.util.List<Operation> operations
protected boolean isAutoWireEnabled
| Constructor Detail |
|---|
public ObjectDescriptor()
public ObjectDescriptor(java.lang.String className)
public ObjectDescriptor(java.lang.Class<?> clazz)
| Method Detail |
|---|
public java.lang.Object construct(WireContext wireContext)
wireContext - WireContext in which the object is created. This is also the WireContext
where the object will search for other object that may be needed during the initialization phase.
WireException - one of the following exception occurred:
ObjectDescriptor
public static java.lang.Object invokeMethod(java.lang.String methodName,
java.util.List<ArgDescriptor> argDescriptors,
WireContext wireContext,
java.lang.Object object,
java.lang.Class<?> clazz)
throws java.lang.Exception
java.lang.Exception
public void initialize(java.lang.Object object,
WireContext wireContext)
true, auto-wiring is performed (see autoWire(Object, WireContext)). Fields and properties injections are then performed.
initialize in interface Descriptorinitialize in class AbstractDescriptorobject - object to initialize.wireContext - the context in which the object will be initialized.public java.lang.Class<?> getType(WireDefinition wireDefinition)
Descriptor
getType in interface DescriptorgetType in class AbstractDescriptor
protected void autoWire(java.lang.Object object,
WireContext wireContext)
object - object on which auto-wiring is performed.wireContext - context in which the wiring objects are searched.
public static java.lang.Object[] getArgs(WireContext wireContext,
java.util.List<ArgDescriptor> argDescriptors)
throws java.lang.Exception
wireContext - context used to create objects.argDescriptors - list of argument descriptors.
java.lang.Exceptionpublic void addArgDescriptor(ArgDescriptor argDescriptor)
argDescriptor - argument descriptor to add.public void addOperation(Operation operation)
operation - operation to add.
public void addTypedInjection(java.lang.String fieldName,
java.lang.Class<?> type)
public void addInjection(java.lang.String fieldName,
Descriptor descriptor)
public void addPropertyInjection(java.lang.String propertyName,
Descriptor valueDescriptor)
public java.lang.String getClassName()
public void setClassName(java.lang.String className)
public java.util.List<ArgDescriptor> getArgDescriptors()
public void setArgDescriptors(java.util.List<ArgDescriptor> argDescriptors)
public java.util.List<Operation> getOperations()
public void setOperations(java.util.List<Operation> operations)
public Descriptor getFactoryDescriptor()
public void setFactoryDescriptor(Descriptor factoryDescriptor)
public java.lang.String getFactoryObjectName()
public void setFactoryObjectName(java.lang.String factoryObjectName)
public java.lang.String getMethodName()
public void setMethodName(java.lang.String methodName)
public boolean isAutoWireEnabled()
public void setAutoWireEnabled(boolean isAutoWireEnabled)
public Expression getExpression()
public void setExpression(Expression expr)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||