|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pfsw.reflect.Dynamic
public abstract class Dynamic
This class supports more dynamic programming than usually possible in Java.
With the class method perform in different variants it provides a
more convenient dynamic method invocation service, than the pure reflection api.
Especially Smalltalk programmers will find some similarities to their language.
To be able using this class, when a security manager is installed, you'll
have to grant
permission java.lang.reflect.ReflectPermission "supressAccessChecks" ;
in the policy file. Otherwise any dynamic method invocation will cause a
AccessControlException.
ReflectPermission
Constructor Summary | |
---|---|
Dynamic()
|
Method Summary | |
---|---|
protected static java.lang.reflect.Method |
findMethod(java.lang.Class aClass,
java.lang.String methodName,
java.lang.Class[] paramTypes)
|
protected static java.lang.Class |
getTypeOf(java.lang.Object object)
|
static java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.reflect.Method method,
java.lang.Object[] args)
Executes the given method on the given object with the specified arguments. |
static java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.String methodName)
Executes the named method on the given object and without any arguments. |
static java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.String methodName,
boolean arg)
Executes the named method on the given object with one boolean argument. |
static java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.String methodName,
int arg)
Executes the named method on the given object with one integer argument. |
static java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object arg)
Executes the named method on the given object with one none primitive argument. |
static java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object[] args)
Executes the named method on the given object with several arguments. |
static java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object[] args,
java.lang.Class[] argTypes)
Executes the named method on the given object with several arguments. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.reflect.Method method,
java.lang.Object[] args)
Executes the given method on the given object with the specified arguments. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.String methodName)
Executes the named method on the given object and without any arguments. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.String methodName,
boolean arg)
Executes the named method on the given object with one boolean argument. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.String methodName,
int arg)
Executes the named method on the given object with one integer argument. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object arg)
Executes the named method on the given object with one none primitive argument. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object[] args)
Executes the named method on the given object with several arguments. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object[] args,
java.lang.Class[] argTypes)
Executes the named method on the given object with several arguments. |
static java.lang.Object |
perform(java.lang.Object receiver,
java.lang.String methodName,
java.lang.Object[] args,
java.lang.String[] signature)
This method allows direct dynamic execution of JMX MBean method invocations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Dynamic()
Method Detail |
---|
public static java.lang.Object invoke(java.lang.Object receiver, java.lang.String methodName)
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.public static java.lang.Object invoke(java.lang.Object receiver, java.lang.String methodName, java.lang.Object arg)
If an exception occurs during this method invocation the result will be the exception rather than the expected value of the method call!
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.arg
- An object, which becomes the only argument for the called methodpublic static java.lang.Object invoke(java.lang.Object receiver, java.lang.String methodName, int arg)
If an exception occurs during this method invocation the result will be the exception rather than the expected value of the method call!
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.arg
- An integer value, which becomes the only argument for the called methodpublic static java.lang.Object invoke(java.lang.Object receiver, java.lang.String methodName, boolean arg)
If an exception occurs during this method invocation the result will be the exception rather than the expected value of the method call!
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.arg
- A boolean value, which becomes the only argument for the called methodpublic static java.lang.Object invoke(java.lang.Object receiver, java.lang.String methodName, java.lang.Object[] args)
If an exception occurs during this method invocation the result will be the exception rather than the expected value of the method call!
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.args
- The arguments for the method invocationpublic static java.lang.Object invoke(java.lang.Object receiver, java.lang.String methodName, java.lang.Object[] args, java.lang.Class[] argTypes)
If an exception occurs during this method invocation the result will be the exception rather than the expected value of the method call!
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.args
- The arguments for the method invocationargTypes
- The types of the arguments as defined in the method signaturepublic static java.lang.Object invoke(java.lang.Object receiver, java.lang.reflect.Method method, java.lang.Object[] args)
If an exception occurs during this method invocation the result will be the exception rather than the expected value of the method call!
receiver
- The object the method should be invoked on.method
- The method to invoke.args
- The arguments for the method invocationpublic static java.lang.Object perform(java.lang.Object receiver, java.lang.String methodName) throws java.lang.Exception
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.
java.lang.Exception
- All kinds of exceptions are passed to the callerpublic static java.lang.Object perform(java.lang.Object receiver, java.lang.String methodName, java.lang.Object arg) throws java.lang.Exception
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.arg
- An object, which becomes the only argument for the called method
java.lang.Exception
- All kinds of exceptions are passed to the callerpublic static java.lang.Object perform(java.lang.Object receiver, java.lang.String methodName, int arg) throws java.lang.Exception
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.arg
- An integer value, which becomes the only argument for the called method
java.lang.Exception
- All kinds of exceptions are passed to the callerpublic static java.lang.Object perform(java.lang.Object receiver, java.lang.String methodName, boolean arg) throws java.lang.Exception
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.arg
- A boolean value, which becomes the only argument for the called method
java.lang.Exception
- All kinds of exceptions are passed to the callerpublic static java.lang.Object perform(java.lang.Object receiver, java.lang.String methodName, java.lang.Object[] args) throws java.lang.Exception
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.args
- The arguments for the method call
java.lang.Exception
- All kinds of exceptions are passed to the callerpublic static java.lang.Object perform(java.lang.Object receiver, java.lang.String methodName, java.lang.Object[] args, java.lang.String[] signature) throws java.lang.Exception
receiver
- The object on which the method must be invokedmethodName
- The name of the method to invokeargs
- The arguments to be passed to the methodsignature
- The qualified class names of the argument types
java.lang.Exception
public static java.lang.Object perform(java.lang.Object receiver, java.lang.String methodName, java.lang.Object[] args, java.lang.Class[] argTypes) throws java.lang.Exception
receiver
- The object the method should be performed on.methodName
- The name of the method to perform.args
- The arguments for the method callargTypes
- The types of the arguments in the args parameter
java.lang.Exception
- All kinds of exceptions are passed to the callerpublic static java.lang.Object perform(java.lang.Object receiver, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Exception
receiver
- The object the method should be performed on.method
- The method to perform.args
- The arguments for the method call
java.lang.Exception
- All kinds of exceptions are passed to the callerprotected static java.lang.Class getTypeOf(java.lang.Object object)
protected static java.lang.reflect.Method findMethod(java.lang.Class aClass, java.lang.String methodName, java.lang.Class[] paramTypes)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |