|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.iqual.chaplin.SimpleContextHandler
public class SimpleContextHandler
This ContextHandler implementation combines both the map and reflection approaches. It means
that the context fields can be accessed by calling the set/get methods or they can be declared in
the compile time as fields in a subclass.
| Constructor Summary | |
|---|---|
SimpleContextHandler()
|
|
SimpleContextHandler(Object instance)
|
|
SimpleContextHandler(Object instance,
boolean recursive)
Collect all declared fields which hold references to components. |
|
| Method Summary | |
|---|---|
Object |
$$$$$$()
|
void |
$$$$$$(Object context)
|
boolean |
canInvoke(Object component,
String methodName,
Class[] argTypes)
|
Field |
findFieldByType(Class clazz,
Class type)
|
Method |
findInSuperClass(Class clazz,
String methodName,
Class[] argTypes)
|
Method |
findMethod(Class clazz,
String methodName,
Class[] argTypes)
|
Method |
findMethod(String methodName,
Class[] argTypes)
|
Object |
get(String fieldName)
|
Object |
get(String fieldName,
Class fieldType,
Object instance)
|
Field |
getField(String fieldName)
|
Field |
getFieldByType(Class clazz,
Class type)
|
Collection<Field> |
getFields()
|
Object |
getFieldValue(Field field)
|
Object |
getInstance()
|
Method |
getMethod(String methodKey)
|
Collection<Method> |
getMethods()
|
boolean |
hasBehavior(String name,
Class... argTypes)
|
boolean |
hasByName(String fieldName)
|
boolean |
hasByType(Class fieldType)
|
boolean |
hasValue(String fieldName,
Class fieldType)
|
protected boolean |
isIgnoredField(Field field)
This method is called only once for each field. |
protected boolean |
isIgnoredMethod(Method method)
This method is called only once for each method. |
protected boolean |
isIgnoredSuperClass(Class superClass)
|
boolean |
isMessageAcceptable(Message message)
|
void |
onMessageReceived(Message message,
MessageReplies replies,
MessageReceiversChain chain)
Called when a request is made. |
void |
removeBehavior(String name,
Class... argTypes)
Remove the behavior determined by the name and the argument types. |
void |
set(String fieldName,
Class fieldType,
Object value,
Object instance)
|
void |
set(String fieldName,
Object value)
|
void |
setBehavior(Object behavioralObject,
String name,
Class... argTypes)
Add behavior represented by the behavior object. |
void |
setByName(String fieldName,
Object value)
|
void |
setByType(Class fieldType,
Object value)
|
void |
setFieldValue(Field field,
Object value)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleContextHandler()
public SimpleContextHandler(Object instance)
public SimpleContextHandler(Object instance,
boolean recursive)
instance - | Method Detail |
|---|
public Object getInstance()
public Object get(String fieldName,
Class fieldType,
Object instance)
throws Exception
Exception
public Object getFieldValue(Field field)
throws IllegalAccessException
IllegalAccessException
public void setFieldValue(Field field,
Object value)
throws IllegalAccessException
IllegalAccessException
public void set(String fieldName,
Class fieldType,
Object value,
Object instance)
throws IllegalAccessException
IllegalAccessException
public void setByName(String fieldName,
Object value)
throws IllegalAccessException
IllegalAccessException
public void setByType(Class fieldType,
Object value)
throws IllegalAccessException
IllegalAccessException
public Object get(String fieldName)
throws Exception
Exception
public void set(String fieldName,
Object value)
throws IllegalAccessException
IllegalAccessException
public boolean hasValue(String fieldName,
Class fieldType)
public boolean hasByName(String fieldName)
public boolean hasByType(Class fieldType)
public void setBehavior(Object behavioralObject,
String name,
Class... argTypes)
ContextHandler or an object which owns the adequate method.
behavioralObject - the behavioral objectname - the behavior name. If the behavioral object is an object it must have a method with that name. If
the behavioral object is a context handler it must support that behavior in its invoke method.argTypes - the argument types
public void removeBehavior(String name,
Class... argTypes)
name - the behavior nameargTypes - the argument types
public boolean hasBehavior(String name,
Class... argTypes)
name - the behavior nameargTypes - the argument types
public boolean isMessageAcceptable(Message message)
isMessageAcceptable in interface FilterableMessageReceiver
public void onMessageReceived(Message message,
MessageReplies replies,
MessageReceiversChain chain)
throws Throwable
MessageReceiverprocess method so that the subsequent
receivers could be called. The receiver may manipulate with the arguments passed to that method. For example it may
change the message that will be processed by the subsequent receivers in the chain or change
the results of the subsequent message processing.
onMessageReceived in interface MessageReceiverThrowable
public Method findMethod(String methodName,
Class[] argTypes)
public Method getMethod(String methodKey)
public Field getField(String fieldName)
public Collection<Method> getMethods()
public Collection<Field> getFields()
public Method findMethod(Class clazz,
String methodName,
Class[] argTypes)
public Method findInSuperClass(Class clazz,
String methodName,
Class[] argTypes)
public boolean canInvoke(Object component,
String methodName,
Class[] argTypes)
public Field getFieldByType(Class clazz,
Class type)
protected boolean isIgnoredSuperClass(Class superClass)
protected boolean isIgnoredField(Field field)
field -
protected boolean isIgnoredMethod(Method method)
method -
public Field findFieldByType(Class clazz,
Class type)
public Object $$$$$$()
$$$$$$ in interface Injectedpublic void $$$$$$(Object context)
$$$$$$ in interface Injected
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||