Hi to all, I\'m tring to understand how create and use dynamic proxies in JAVA.
ID: 3621472 • Letter: H
Question
Hi to all,I'm tring to understand how create and use dynamic proxies in JAVA. I'm using Eclipse for write the code and as school exercice I must create proxies with the JAVA library as this link: http://commons.apache.org/proxy/ .
I read that proxies can make classes that can be an interface for the communication between other classes. Unfortunately I do not undersood how start create the first proxy class. I've made a really banal program with the classes main, client and server. The main initializes tho objects, one declared as client and one as server. Calls on the client object a method that generate a integer random number, catchs it and pass it to the server object, invoking a method that return the banal operation number*number, where number is the numbr passed to the server.
At this point, I would create communication between these classes by a proxy object.
I've seen that in commons proxy library it can have 3 kind of proxies: delegator, invoker and interceptor. For starting I've taken the definition of the method (one of the two) that permits to declare a delegator proxy.
createDelegatorProxy(ClassLoader classLoader, ObjectProvider delegateProvider, Class[] proxyClasses)
So I've created a ProxyFactory object and I'm tring to call on it createDelegatorProxy method, but I haven't idea of what ClassLoader, ObjectProvider and Class[] (array) arguments pass to it.
So I start think that there are some things that I cannot see under the proxy logic and search examples online for understand the usage of this library, but I do not found anything.
I really need an example that shows me all steps I must do to create a working proxy in this library. After that I think to be ready for do exercices and tests to study in deep this argument.
Eventually for others questions I wll open new topics.
Thanks very much.