|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jbpm.util.DefaultObservable org.jbpm.wire.descriptor.AbstractDescriptor org.jbpm.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 |
---|
Fields inherited from class org.jbpm.wire.descriptor.AbstractDescriptor |
---|
dbid, dbversion, init, INIT_EAGER, INIT_IMMEDIATE, INIT_LAZY, INIT_REQUIRED, name, version |
Fields inherited from class org.jbpm.util.DefaultObservable |
---|
listeners |
Fields inherited from interface org.jbpm.wire.Descriptor |
---|
EVENT_CONSTRUCTED, EVENT_CONSTRUCTING, EVENT_INITIALIZING, EVENT_REMOVE, EVENT_SET |
Constructor Summary | |
---|---|
ObjectDescriptor()
|
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 an injection based on a descriptor |
void |
addOperation(Operation operation)
Adds an operation to perform during initialization. |
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()
Gets the list of descriptors to use to create method arguments. |
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()
Gets the class name of the object to create. |
Descriptor |
getFactoryDescriptor()
Gets the Descriptor from which the object should be created. |
java.lang.String |
getFactoryObjectName()
Gets the name of the object to get from the WireContext. |
java.lang.String |
getMethodName()
Gets the name of the method to invoke. |
java.util.List<Operation> |
getOperations()
Gets the list of operations to perform during initialization. |
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. |
boolean |
isAutoWireEnabled()
Checks if auto-wiring is enabled |
void |
setArgDescriptors(java.util.List<ArgDescriptor> argDescriptors)
Sets the list of descriptors to use to create method arguments. |
void |
setAutoWireEnabled(boolean isAutoWireEnabled)
Enables/Disables auto wiring mode. |
void |
setClassName(java.lang.String className)
Sets class name of the object to create. |
void |
setFactoryDescriptor(Descriptor factoryDescriptor)
Sets the Descriptor from which the object should be created. |
void |
setFactoryObjectName(java.lang.String factoryObjectName)
Sets name of the object to get from the WireContext. |
void |
setMethodName(java.lang.String methodName)
Sets the name of the method to invoke. |
void |
setOperations(java.util.List<Operation> operations)
Sets the list of operations to perform during initialization. |
Methods inherited from class org.jbpm.wire.descriptor.AbstractDescriptor |
---|
getDbid, getName, isDelayable, isEagerInit, setInit, setName |
Methods inherited from class org.jbpm.util.DefaultObservable |
---|
addListener, addListener, addListener, fire, fire, 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.wire.Descriptor |
---|
getName, isDelayable, isEagerInit |
Methods inherited from interface org.jbpm.util.Observable |
---|
addListener, addListener, addListener, fire, fire, removeListener |
Constructor Detail |
---|
public ObjectDescriptor()
Method Detail |
---|
public java.lang.Object construct(WireContext wireContext)
construct
in interface Descriptor
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 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 Descriptor
initialize
in class AbstractDescriptor
object
- object to initialize.wireContext
- the context in which the object will be initialized.public java.lang.Class<?> getType(WireDefinition wireDefinition)
Descriptor
getType
in interface Descriptor
getType
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.Exception
public 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 java.lang.String getClassName()
public void setClassName(java.lang.String className)
className
- name of the class to use.setFactoryDescriptor(Descriptor)
,
setFactoryObjectName(String)
public java.util.List<ArgDescriptor> getArgDescriptors()
public void setArgDescriptors(java.util.List<ArgDescriptor> argDescriptors)
argDescriptors
- list of descriptors to use to create method arguments.public java.util.List<Operation> getOperations()
public void setOperations(java.util.List<Operation> operations)
operations
- list of operations to perform during initialization.public Descriptor getFactoryDescriptor()
public void setFactoryDescriptor(Descriptor factoryDescriptor)
factoryDescriptor
- the Descriptor from which the object should be created.setClassName(String)
,
setFactoryObjectName(String)
public java.lang.String getFactoryObjectName()
public void setFactoryObjectName(java.lang.String factoryObjectName)
factoryObjectName
- name of the object to get from the WireContext.setClassName(String)
,
setFactoryDescriptor(Descriptor)
public java.lang.String getMethodName()
public void setMethodName(java.lang.String methodName)
methodName
- name of the method to invoke.public boolean isAutoWireEnabled()
true
if auto-wiring is enabled.public void setAutoWireEnabled(boolean isAutoWireEnabled)
isAutoWireEnabled
- true
to enable auto-wiring.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |