public class SulisReflectionMagic
extends Object
implements RemoteAccess
Modifier and Type | Field and Description |
---|---|
static boolean |
checkReload |
static int |
CMCALLCHECK_BAD_CLASS |
static int |
CMCALLCHECK_INVALID_CLASS |
static int |
CMCALLCHECK_NO_SUCH_METHOD |
static int |
CMCALLCHECK_OK |
static int |
CMCALLCHECK_UNKNOWN_ERROR |
static int |
MAJOR |
static int |
MINOR |
Constructor and Description |
---|
SulisReflectionMagic() |
Modifier and Type | Method and Description |
---|---|
static Object |
callMOnO(Object o,
String m)
call no-argument version of named method on object passed (see 5-argument version of method for full description)
|
static Object |
callMOnO(Object o,
String m,
Class[] argTypes,
Object[] args)
call named method on object passed (see 5-argument version of method for full description)
|
static Object |
callMOnO(Object o,
String m,
Class[] argTypes,
Object[] args,
boolean force)
call named method on object passed - if the name of the method contains one or more periods (.), the calls are chained, allowing constructs like getCreator.getFullName.toUpperCase Note that in this case all methods must have the same signature which usually means you chain getter methods.
|
static List<Object[]> |
classVersions() |
static void |
flush() |
static void |
forceFieldValue(Class c,
Object o,
String field,
Object value)
force setting a field ignoring private/protected/final flags (unless hindered by security manager)
|
static Class |
getClass(String className)
return a class from the classname, reloading the class file if it changed
|
static String |
getErrorMessage(int errorCode) |
static Field |
getFOfO(Object obj,
String field)
get the field of an object(s class)
|
static Field |
getFOfO(Object obj,
String field,
boolean force)
get the field of an object(s class)
|
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method (with a no-argument signature) is called passing a newly created instance of the class if the method is not static. |
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName,
boolean server)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method (with a no-argument signature) is called passing a newly created instance of the class if the method is not static˙ optionally the method is invoked in the MethodServer. |
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName,
Class[] types,
Object[] args)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method is called passing a newly created instance of the class if the method is not static. |
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName,
Class[] types,
Object[] args,
boolean server)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method is called passing a newly created instance of the class if the method is not static˙ optionally the method is invoked in the MethodServer. |
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName,
Class[] types,
Object[] args,
Boolean server)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method is called passing a newly created instance of the class if the method is not static˙ optionally the method is invoked in the MethodServer, and the user to run as can be passed as well. |
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName,
Class[] types,
Object[] args,
Boolean server,
String suTo)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method is called passing a newly created instance of the class if the method is not static˙ optionally the method is invoked in the MethodServer, and the user to run as can be passed as well. |
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName,
Class[] types,
Object[] args,
Boolean server,
String suTo,
Boolean want)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method is called passing a newly created instance of the class if the method is not static˙ optionally the method is invoked in the MethodServer, and the user to run as can be passed as well. |
static Object |
invokeMethodWithUp2DateClass(String className,
String methodName,
Class[] types,
Object[] args,
String user,
String password)
first a test is made if the class file changed on disk since it was last loaded, in which case the class is reloaded from disk˙
then the method is called passing a newly created instance of the class if the method is not static˙ optionally the method is invoked in the MethodServer, and the user to run as can be passed as well. |
static int |
isMethodValid(String className,
String methodName,
Class[] paramList) |
static void |
main(String[] a)
print program usage info or invoke test cases
|
static void |
setFOnO(Object obj,
String field,
Object value)
set the value of an object's (internal) field (=attribute)
|
static void |
setFOnO(Object obj,
String field,
Object value,
boolean force)
set the value of an object's (internal) field (=attribute)
|
static void |
setReload(Map in) |
public static final int MAJOR
public static final int MINOR
public static final int CMCALLCHECK_UNKNOWN_ERROR
public static final int CMCALLCHECK_BAD_CLASS
public static final int CMCALLCHECK_INVALID_CLASS
public static final int CMCALLCHECK_NO_SUCH_METHOD
public static final int CMCALLCHECK_OK
public static boolean checkReload
public static void main(String[] a) throws Exception
a
- commandline argsException
public static void setReload(Map in)
public static List<Object[]> classVersions() throws Exception
Exception
public static Object invokeMethodWithUp2DateClass(String className, String methodName) throws Exception
className
- fully qualified name of class to [re]loadmethodName
- name of method to invokeException
public static Object invokeMethodWithUp2DateClass(String className, String methodName, boolean server) throws Exception
className
- fully qualified name of class to [re]loadmethodName
- name of method to invokeserver
- flag if method must run in MethodServerException
public static Object invokeMethodWithUp2DateClass(String className, String methodName, Class[] types, Object[] args) throws Exception
className
- fully qualified name of class to [re]loadmethodName
- name of method to invoketypes
- method parameter typesargs
- method call argumentsException
public static Object invokeMethodWithUp2DateClass(String className, String methodName, Class[] types, Object[] args, boolean server) throws Exception
className
- fully qualified name of class to [re]loadmethodName
- name of method to invoketypes
- method parameter typesargs
- method call argumentsserver
- flag if method must run in MethodServerException
public static Object invokeMethodWithUp2DateClass(String className, String methodName, Class[] types, Object[] args, String user, String password) throws Exception
className
- fully qualified name of class to [re]loadmethodName
- name of method to invoketypes
- method parameter typesargs
- method call argumentsuser
- user to run aspassword
- authenticate the userException
public static Object invokeMethodWithUp2DateClass(String className, String methodName, Class[] types, Object[] args, Boolean server) throws Exception
className
- fully qualified name of class to [re]loadmethodName
- name of method to invoketypes
- method parameter typesargs
- method call argumentsserver
- flag if method must run in MethodServerException
public static Object invokeMethodWithUp2DateClass(String className, String methodName, Class[] types, Object[] args, Boolean server, String suTo) throws Exception
className
- fully qualified name of class to [re]loadmethodName
- name of method to invoketypes
- method parameter typesargs
- method call argumentsserver
- flag if method must run in MethodServersuTo
- if not null contains the name of the user we need to switch to before the method is invokedException
public static Object invokeMethodWithUp2DateClass(String className, String methodName, Class[] types, Object[] args, Boolean server, String suTo, Boolean want) throws Throwable
className
- fully qualified name of class to [re]loadmethodName
- name of method to invoketypes
- method parameter typesargs
- method call argumentsserver
- flag if method must run in MethodServersuTo
- if not null contains the name of the user we need to switch to before the method is invokedException
Throwable
public static void flush()
public static Class getClass(String className) throws Exception
className
- fully qualified class nameException
public static void setFOnO(Object obj, String field, Object value) throws Exception
obj
- the object to set value offield
- the name of the fieldvalue
- the value to set - make sure it is of the correct type.Exception
- if anything goes wrong (name bad, value bad, field protected or private etc.)public static void setFOnO(Object obj, String field, Object value, boolean force) throws Exception
obj
- the object to set value offield
- the name of the fieldvalue
- the value to set - make sure it is of the correct type.force
- if true will ignore private/protected flag (unless hindered by security manager)Exception
- if anything goes wrong (name bad, value bad etc.)public static void forceFieldValue(Class c, Object o, String field, Object value) throws Exception
c
- class holding fieldo
- instance object (can be null for static fields)field
- field namevalue
- new field valueException
public static Field getFOfO(Object obj, String field) throws Exception
obj
- the object to retrieve the field fromfield
- the name of the fieldException
- if anything goes wrong (name bad?)public static Field getFOfO(Object obj, String field, boolean force) throws Exception
obj
- the object to retrieve the field fromfield
- the name of the fieldforce
- if true will ignore private/protected flag and return an accessible Field (unless hindered by security manager)Exception
- if anything goes wrong (name bad?)public static Object callMOnO(Object o, String m) throws Exception
o
- the object to invoke method onm
- the name of the methodException
public static Object callMOnO(Object o, String m, Class[] argTypes, Object[] args) throws Exception
o
- the object to invoke method onm
- the name of the methodargTypes
- argument types for the method to find/callargs
- the arguments to passException
public static Object callMOnO(Object o, String m, Class[] argTypes, Object[] args, boolean force) throws Exception
o
- the object to invoke method onm
- the name of the methodargTypes
- argument types for the method to find/callargs
- the arguments to passforce
- flag if private/protected access should be overriddenException
public static int isMethodValid(String className, String methodName, Class[] paramList)
public static String getErrorMessage(int errorCode)