public class SetPropertyInvocation extends Invocation implements Invokable
A special Invocation
implementation for setting properties.
This Invocation
implementation is initialized with a property
name and value (the latter one is provided as a Dependency
object. In
its invoke()
method it will set this property on the target
object.
This is more or less a convenience class because similar results could be
achieved by using MethodInvocation
and specifying the name of the set
method corresponding to the property and the property value as parameter
dependency. Setting the property is done using the
InvocationHelper
class. This
ensures that required type conversions are done automatically.
Once initialized, an instance is immutable. So it can easily be shared between multiple components and threads without having to care about synchronization issues.
Constructor and Description |
---|
SetPropertyInvocation(String propName,
Dependency propValue)
Creates a new instance of
SetPropertyInvocation and
initializes it. |
Modifier and Type | Method and Description |
---|---|
String |
getPropertyName()
Returns the name of the property that will be set.
|
protected void |
invocationInfoToString(StringBuilder buf)
Outputs further information about this invocation to the specified
buffer.
|
Object |
invoke(DependencyProvider depProvider,
Object target)
Performs the invocation and sets the property on the specified target
object.
|
checkDependencyProvider, getParameterClasses, getParameterDependencies, getParameterTypes, getResolvedParameters, getTargetClass, isTypeInfoComplete, parametersToString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getParameterDependencies
public SetPropertyInvocation(String propName, Dependency propValue)
SetPropertyInvocation
and
initializes it.propName
- the name of the property to set (must not be null)propValue
- a dependency that defines the property's value (must not
be null)IllegalArgumentException
- if the property name or its value is
undefinedpublic String getPropertyName()
public Object invoke(DependencyProvider depProvider, Object target)
invoke
in interface Invokable
depProvider
- the dependency provider (must not be null)target
- the target instance (must not be null)InjectionException
- if an error occursIllegalArgumentException
- if one of the parameters is nullprotected void invocationInfoToString(StringBuilder buf)
invocationInfoToString
in class Invocation
buf
- the target bufferCopyright © 2016 The JGUIraffe Team. All rights reserved.