|
20110223, rgf | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.rexxla.bsf.engines.rexx.ProxiedJavaClassTool
public class ProxiedJavaClassTool
This class creates a proxied Java class on the fly, which has concrete implementations for all abstract (inherited or not) methods. Additionally it allows for creating proxy methods for concrete methods and matching <">_forwardToSuper<"> methods to allow ooRexx to forward proxied Java method invocations to their original target on the Java side.
------------------------ Apache Version 2.0 license ------------------------- Copyright (C) 2010 Rony G. Flatscher Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------
Nested Class Summary | |
---|---|
(package private) static class |
ProxiedJavaClassTool.RunInfos
Inner class to make maintenance and access to management data structures easy. |
Field Summary | |
---|---|
static boolean |
bDoNotProxySyntheticMethods
|
static boolean |
bss
|
static boolean |
bTiming
|
Method Summary | |
---|---|
(package private) static java.lang.String[] |
createArgumentHead(java.lang.Class[] paramTypes,
boolean bCreateForConstructor,
boolean bCreateInvokeArg)
Creates an argument list as a String from the supplied array of Classes representing the types. |
(package private) static void |
createConstructors(java.lang.StringBuffer sb,
java.lang.String newClzName,
java.lang.Class javaClassToProxy,
boolean bProxyConstructors,
ProxiedJavaClassTool.RunInfos ri)
|
(package private) static void |
createConstructorsBase(java.lang.StringBuffer sb,
java.lang.String newClzName,
java.lang.Class javaClassToProxy,
boolean bProxyConstructors,
ProxiedJavaClassTool.RunInfos ri)
Creates the base constructor (the default constructor and the default constructor with a RexxProxy argument) statements, if possible. |
(package private) static void |
createEpilog(java.lang.StringBuffer sb)
Creates the epilog statement. |
(package private) static java.lang.String |
createListOfClassNames(java.lang.Class[] paramTypes,
int kind)
Create comma-separated list of parameter types, enclosed in round parenthesis. |
(package private) static void |
createMethod(java.lang.StringBuffer sb,
java.lang.reflect.Method m,
java.lang.String newClzName,
ProxiedJavaClassTool.RunInfos ri)
Creates a public method proxy for the supplied Method object. |
(package private) static void |
createMethods(java.lang.StringBuffer sb,
java.lang.String newClzName,
java.lang.Class javaClassToProxy,
java.lang.String[] methods2proxy,
ProxiedJavaClassTool.RunInfos ri)
Controls which public methods get created on the fly. |
(package private) static void |
createProlog(java.lang.StringBuffer sb,
java.lang.String newClzName,
java.lang.Class javaClassToProxy,
ProxiedJavaClassTool.RunInfos ri)
Creates the prolog statements (import, class definition, fields, getter/setter for default RexxProxy handlers. |
static java.lang.Class |
createProxiedJavaClass(java.lang.Class javaClassToProxy,
java.lang.String newClzName,
java.lang.String[] methodNames2proxy)
Creates and returns a proxy class in which Java method invocations get forwarded to a RexxProxy. |
(package private) static java.lang.String |
createReturnStatements(java.lang.Class returnType)
Creates the statements for returning the result of invoking the RexxProxy, possibly cast to primitive types. |
(package private) static java.lang.String[] |
createThrowsClause(java.lang.Class[] excTypes)
Create comma-separated list of parameter types, enclosed in round parenthesis. |
(package private) static java.lang.String |
getEditedClassName(java.lang.Class clz)
Creates and returns the name of the supplied class, taking array classes into consideration. |
static void |
main(java.lang.String[] args)
|
(package private) static java.lang.String[] |
parseMethod2Proxy(java.lang.String val)
Parses a string from Rexx that consists of "[Java_Class_Name ]method_name". |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean bTiming
public static boolean bss
public static boolean bDoNotProxySyntheticMethods
Method Detail |
---|
public static void main(java.lang.String[] args) throws org.apache.bsf.BSFException
org.apache.bsf.BSFException
public static java.lang.Class createProxiedJavaClass(java.lang.Class javaClassToProxy, java.lang.String newClzName, java.lang.String[] methodNames2proxy) throws org.apache.bsf.BSFException
javaClassToProxy
- Class object to use for proxyingnewClzName
- null
or name for proxy class to createmethodNames2proxy
- null
or array of Strings denoting the names of methods to proxy
(each entry either the method name, or the class name blank-delimited with the method name)
org.apache.bsf.BSFException
static void createProlog(java.lang.StringBuffer sb, java.lang.String newClzName, java.lang.Class javaClassToProxy, ProxiedJavaClassTool.RunInfos ri) throws org.apache.bsf.BSFException
sb
- the StringBuffer to append the statements tonewClzName
- the new name of the new classjavaClassToProxy
- the Java (abstract) class that gets extendedri
- RunInfos runtime infos for managing the process
org.apache.bsf.BSFException
static void createEpilog(java.lang.StringBuffer sb)
sb
- the StringBuffer to append the statements tostatic void createConstructorsBase(java.lang.StringBuffer sb, java.lang.String newClzName, java.lang.Class javaClassToProxy, boolean bProxyConstructors, ProxiedJavaClassTool.RunInfos ri)
sb
- the StringBuffer to append the statements tonewClzName
- the new name of the new classjavaClassToProxy
- the Java (abstract) class that gets extendedbProxyConstructors
- determines whether constructor invocations get proxied to the RexxProxy (true
)ri
- RunInfos runtime infos for managing the processstatic void createConstructors(java.lang.StringBuffer sb, java.lang.String newClzName, java.lang.Class javaClassToProxy, boolean bProxyConstructors, ProxiedJavaClassTool.RunInfos ri)
static void createMethods(java.lang.StringBuffer sb, java.lang.String newClzName, java.lang.Class javaClassToProxy, java.lang.String[] methods2proxy, ProxiedJavaClassTool.RunInfos ri) throws org.apache.bsf.BSFException
methods2proxy
argument. As each method must have a
unique signature, hence no method with a unique signature is created more than once.
sb
- the StringBuffer to append the statements tonewClzName
- the new name of the new classjavaClassToProxy
- the Java (abstract) class that gets extendedmethods2proxy
- String list of method names to create proxies for; a method name
may be prepended with the name of a superclass delimited with a blankri
- RunInfos runtime infos for managing the process
org.apache.bsf.BSFException
static void createMethod(java.lang.StringBuffer sb, java.lang.reflect.Method m, java.lang.String newClzName, ProxiedJavaClassTool.RunInfos ri)
sb
- the StringBuffer to append the statements tom
- a Method object which needs to get proxiednewClzName
- the new name of the new classjavaClassToProxy
- the Java (abstract) class that gets extendedri
- RunInfos runtime infos for managing the processstatic java.lang.String[] parseMethod2Proxy(java.lang.String val)
val
- a String value which denotes an optional Java class name, followed by a blank,
followed by a mandatory method name. All methods with the same name in the given
class will get proxied. If no class name is given, the method name relates to the
extended Java class.
null
, if supplied argument is null or empty, else a
String array, containing
0
1
2
3
static java.lang.String[] createArgumentHead(java.lang.Class[] paramTypes, boolean bCreateForConstructor, boolean bCreateInvokeArg)
paramTypes
- array of Class objects representing the typesbCreateForConstructor
- first String should inject as first argument the RexxProxy to forward tobCreateInvokeArg
- determines whether the invocations of constructors get forwarded to the RexxProxy
0
represents the parenthized argument list,
index 1
represents the parenthized argument list without the RexxProxy argument,
index 2
is either null or defines an array of type Object to allow the received
arguments to be forwarded to the rexxProxystatic java.lang.String createReturnStatements(java.lang.Class returnType)
returnType
- the class object of the return type
static java.lang.String createListOfClassNames(java.lang.Class[] paramTypes, int kind)
paramTypes
- array of Class objectsbMethodSignature
- static java.lang.String[] createThrowsClause(java.lang.Class[] excTypes)
excTypes
- array of Class objects representing the exceptions that may be thrown
BSFException
static java.lang.String getEditedClassName(java.lang.Class clz)
clz
- the class to create a name for
|
20110223, rgf | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |