1 Reply Latest reply on Jan 16, 2003 10:42 PM by marc fleury

    Dynamically glueing an interface to an instance

    Bela Ban Master


      Is the following possible with the AOP framework ?

      I have an instance of CacheImpl:

      CacheImpl cache=new CacheImpl(...);

      CacheImpl is *not* an MBean, and only implements interface Cache.

      Now I want to say "make CacheImpl implement the DynamicMBean interface and provide some code that implements it". Is this possible ?

      The code which implements the DynamicMBean interface would be done with a DynamicProxy, which uses reflection to provide metadata for getters, setters and all public methods of CacheImpl. However, is it possible to dynamically make CacheImpl implement DynamicMBean ?


      Bela


        • 1. Re: Dynamically glueing an interface to an instance
          marc fleury Master

          > Is the following possible with the AOP framework ?
          >
          > I have an instance of CacheImpl:
          >
          > CacheImpl cache=new CacheImpl(...);
          >
          > CacheImpl is *not* an MBean, and only implements
          > interface Cache.
          >
          > Now I want to say "make CacheImpl implement the
          > DynamicMBean interface and provide some code that
          > implements it". Is this possible ?

          Yes, you would have to define your component as AOP of class management. See Ebro's presentation on that class alongside the EJB class of objects. Then we know to augment your object with the management implementation in an aspect's interceptor. Also it is our classloaders take care of that. See the work commited by Bill already.

          At least that is the goal.

          > The code which implements the DynamicMBean interface
          > would be done with a DynamicProxy,

          yes but in that case your base object must have an interface. We support interface and POJO access with metadata.

          > reflection to provide metadata for getters, setters
          > and all public methods of CacheImpl. However, is it
          > possible to dynamically make CacheImpl implement
          > DynamicMBean ?

          You could in theory. with jdk1.4 you could replace the references to existing objects as you define them of class management dynamically. I hear (see other thread in this forum) that the state of the implementation varies. Of course the new instances would be classes of instance (AOPManagement) and would support the signature. It also means that the clients are calling using reflection.

          >
          >
          > Bela
          >
          >