[Clev-jug] Help with java proxy and method injection

Eric Williams eric_r_williams at hotmail.com
Sat Jul 21 20:54:12 CDT 2007


Ashok,
 
This should just work. To demonstrate, I put together this code snippet:
 
public static void main(String[] args) throws Exception {
    Runnable r = (Runnable)Proxy.newProxyInstance(ProxyTest.class.getClassLoader(), new Class[] { Runnable.class }, new InvocationHandler() {
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
           System.out.println(method.getName());
              return null;
      }
    });
    
    r.toString();
}
The code, when it runs, prints out:
 
toString
 
So, you should be able to override toString without much fanfare.
-eric


Date: Sat, 21 Jul 2007 12:53:01 -0700From: pappuashokkumar at yahoo.comTo: clev-jug at lists.urbancode.comSubject: [Clev-jug] Help with java proxy and method injection




Hi All,I have a problem and I am trying to find the best solution to it.  In a project I am working on we use java proxy to create all concrete classes from interfaces.  say for example I write code like thishow to override the toString() method for an object returned by java Proxy.  Say for exampleCustomerIntf custIntf = javaproxy.newInstance(CustomerIntf.class);I want to be able to implement the toString() method  to the concrete object returned  by the   java proxy. Any help will be appreciated.ThanksAshok Pappu

Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/clev-jug/attachments/20070721/e8c73caf/attachment.htm


More information about the Clev-jug mailing list