tw.net.ocs
Class OCSClassProxyFactory
java.lang.Object
tw.net.ocs.OCSClassProxyFactory
public class OCSClassProxyFactory
- extends java.lang.Object
Generates source code for class proxies
communicating transparently with server-side subjects.
- Author:
- Tillmann Wegst
Method Summary |
static void |
generateProxyCodeFor(java.lang.Class c,
java.lang.String[] excludeMethods,
java.lang.String[] cacheMethods,
java.lang.String directory)
Generates source code for a proxy class of a given (subject) class. |
static void |
main(java.lang.String[] args)
Generates source code for a proxy class of a given (subject) class. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
OCSClassProxyFactory
public OCSClassProxyFactory()
generateProxyCodeFor
public static void generateProxyCodeFor(java.lang.Class c,
java.lang.String[] excludeMethods,
java.lang.String[] cacheMethods,
java.lang.String directory)
throws java.lang.NoSuchMethodException
Generates source code for a proxy class of a given (subject) class.
Client-side proxies are associated with server-side subjects,
i.e. method calls on a proxy are transparently transformed into
method calls on the associated remote subject.
The generated class is a subclass of the subject class
and hence can be used in the subject's place in every situation.
The name of the proxy class and its package are determined
automatically, like this:
the original package directory names are capitalized,
the dots are removed,
and the new class is placed in package "tw.net.ocs.proxy".
Example:
If the class is
"my.pack.Clazz",
the generated proxy derivation will be
"tw.net.ocs.proxy.MyPackClazz"
Accordingly, the code for the class will be written in file
"tw/net/ocs/proxy/MyPackClazz.java".
Use option "directory" to specify where to root the package path.
If no other value is specified, the current directory is assumed.
Selected methods can be made to cache their results, so that
repeated executions with identical parameter values save networking.
Use parameter "cacheMethods" for the purpose.
Specify the methods by their signature, e.g.
"method(java.lang.String,int,char)"
Also, selected methods may be excluded from the proxy class. Use parameter
"excludeMethods" for the purpose.
(Specify methods in the same way as with 'cacheMethods'.)
When specifying classes make sure to use their qualified names,
like "my.pack.Clazz", instead of just "Clazz".
Note that you can run the OCSClassProxyFactory conveniently from
the command-line!
See main()
or run "java tw.net.ocs.OCSClassProxyFactory" for
usage information!
- Parameters:
c
- the class for which proxy class code should be generatedexcludeMethods
- signatures of methods to be excluded from the proxy classcacheMethods
- signatures of methods whose results should be reuseddirectory
- the directory where to root the proxy class package tw.net.ocs.proxy
- Throws:
java.lang.NoSuchMethodException
- See Also:
main(java.lang.String[])
main
public static void main(java.lang.String[] args)
Generates source code for a proxy class of a given (subject) class.
The generated class is a subclass of the subject class
and hence can be used in the subject's place in every situation.
Every proxy class is a member of package tw.net.ocs.proxy.
Accordingly, the source code will be placed in directory
"tw/net/ocs/proxy". Use option "directory" to specify
where to root this package path. If no value is specified,
the current directory is assumed.
Selected methods can be made to cache their results, so that
repeated executions with identical parameter values save networking.
Use option "cacheMethod" for the purpose.
Specify the methods by their signature, e.g.
-cacheMethod "method(java.lang.String,int,char)"
Use + to separate several signatures, e.g.
-cacheMethod "method(java.lang.String,int,char)+anotherMethod(byte)"
Methods may also be read from a file: Specify the path
of the file prepended with an @, like
-cacheMethod @cachemethods.txt
In the file, list the method signatures one per line or like at
the command-line separated with a +. Use # or // to comment out lines.
Also, selected methods may be excluded from the proxy class. Use option
"excludeMethod" for the purpose.
(Specify methods in the same way as with -cacheMethod.)
When specifying classes make sure to use their qualified names,
like "java.io.File", instead of just "File".
Usage:
java tw.net.ocs.OCSClassProxyFactory {parameters...}
-class Name of the (subject) class to generate a proxy for
-directory Directory where to root the proxy class package path
-cacheMethod Method whose result should be saved and reused
-excludeMethod Method to be excluded from the proxy class
- See Also:
generateProxyCodeFor(java.lang.Class, java.lang.String[], java.lang.String[], java.lang.String)
www.ocselot.net