0 Replies Latest reply on Feb 13, 2004 12:45 PM by Barry M. Caceres

    Javassist integration with J2EE app

    Barry M. Caceres Newbie

      I need the ability to intercept an attempt to load a class by the
      class ClassLoader associated with my J2EE application, and then
      generate the class on-the-fly and provide it to the ClassLoader.

      The problem is that the example shows a means of supplanting the
      base class loader by wrapping one class' "main()" method in the
      "main()" method of another class which first replaces the class

      If I did this then all of my classes would load in the application
      server's class loader since it is the "main()" class that I am
      executing. Further, it would not work because the classes I am
      generating on the fly depend on interfaces and classes contained
      within my J2EE app (and are not visible to the ClassLoader that
      started the J2EE application server).

      Is there a way to do this elegantly?

      Essentially I need functionality similar to "Proxy.getProxyClass(...)"
      (where I pass in the ClassLoader) EXCEPT that I need it to generate a
      class that has a public no-arg constructor and knows how to build its
      InvocationHandler itself.

      The classes generated by "Proxy.getProxyClass(...)" all require a
      an InvocationHandler be passed to the constructor.