org.apache.cayenne.util
Class Invocation

java.lang.Object
  extended by org.apache.cayenne.util.Invocation

public class Invocation
extends java.lang.Object

Invocation represents a dynamic method invocation bound to a specific target. The target is kept with a WeakReference and can therefore be reclaimed by the Garbage Collector.

Author:
Holger Hoffstaette, Dirk Olmes

Constructor Summary
Invocation(java.lang.Object target, java.lang.String methodName)
          Constructor for an Invocation without arguments in the target's method.
Invocation(java.lang.Object target, java.lang.String methodName, java.lang.Class parameterType)
          Constructor for an Invocation with a single argument in the target's method.
Invocation(java.lang.Object target, java.lang.String methodName, java.lang.Class[] parameterTypes)
          Constructor for an Invocation with arbitrary arguments in the target's method.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 boolean fire()
          Invoke the target's method without any arguments.
 boolean fire(java.lang.Object argument)
          Invoke the target's method with a single argument.
 boolean fire(java.lang.Object[] arguments)
          Invoke the target's method with an arbitrary number of arguments.
 java.lang.reflect.Method getMethod()
           
 java.lang.Class[] getParameterTypes()
           
 java.lang.Object getTarget()
           
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Invocation

public Invocation(java.lang.Object target,
                  java.lang.String methodName)
           throws java.lang.NoSuchMethodException
Constructor for an Invocation without arguments in the target's method.

Throws:
java.lang.NoSuchMethodException
See Also:
Invocation(Object, String, Class[])

Invocation

public Invocation(java.lang.Object target,
                  java.lang.String methodName,
                  java.lang.Class parameterType)
           throws java.lang.NoSuchMethodException
Constructor for an Invocation with a single argument in the target's method.

Throws:
java.lang.NoSuchMethodException
See Also:
Invocation(Object, String, Class[])

Invocation

public Invocation(java.lang.Object target,
                  java.lang.String methodName,
                  java.lang.Class[] parameterTypes)
           throws java.lang.NoSuchMethodException
Constructor for an Invocation with arbitrary arguments in the target's method.

Parameters:
target -
methodName -
parameterTypes -
Throws:
java.lang.NoSuchMethodException - if methodName could not be found in the target
java.lang.IllegalArgumentException - if target or methodName are null, or parameterTypes is empty or contains null elements
Method Detail

fire

public boolean fire()
Invoke the target's method without any arguments.

See Also:
fire(Object[])

fire

public boolean fire(java.lang.Object argument)
Invoke the target's method with a single argument.

Parameters:
argument - an object passed to the target's method
See Also:
fire(Object[])

fire

public boolean fire(java.lang.Object[] arguments)
Invoke the target's method with an arbitrary number of arguments. The number of arguments must be consistent with the arguments given at construction time of this Invocation.

Parameters:
arguments - an array of objects passed to the target's method
Returns:
true if invocation of the method succeeded, otherwise false.
Throws:
java.lang.IllegalArgumentException - if the passed arguments are inconsistent with the arguments passed to this instance's constructor
See Also:
fire(Object[])

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

getMethod

public java.lang.reflect.Method getMethod()
Returns:
the method to be invoked on the target

getTarget

public java.lang.Object getTarget()
Returns:
the target object of this Invocation

getParameterTypes

public java.lang.Class[] getParameterTypes()
Returns:
an array of Classes describing the target method's parameters


Copyright © 2001-2006 Apache.org All Rights Reserved.