Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Regarding java Proxy object
Raj chiru
Ranch Hand
Posts: 142
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi....
Can Anybody explain to me on
which scenario java.lang.reflect.Proxy
will use?
Rob Spoor
Sheriff
Posts: 22781
131
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
One example from "Java Reflection In Action" is logging method calls without using Aspect4J. For instance, with java.util.List:
// assume we have a List<Integer> called list InvocationHandler handler = new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("Call to " + method + " using arguments " + Arrays.toString(args) + " on object " + list); return method.invoke(list, args); } }; Class[] ifaces = {List.class}; List<Integer> wrappedList = (List<Integer>)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), ifaces, handler);
Whenever you now add something to wrappedList, it will print out the call and then delegate to list.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
Sasparilla and fresh horses for all my men! You will see to it, won't you tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Proxy instance of a class that does not implement any interface.
Java Dynamic Proxy
Proxy class for rmi in java5.0
about the java.lang.reflect.Proxy
Network programming behing proxies - reg.
More...