3 Replies Latest reply on Feb 24, 2006 8:21 AM by Adrian Brock

    Hollow proxies

    Adrian Brock Master

      The hollow proxies are not working properly with instance advices.
      It assumes that the null target is a static method/field invocation and tries
      to invoke on the null target.

      I'd suggest fixing it by having a "special singleton object" in the proxy factory
      that can be used as a replacement for the target in invocations
      so it doesn't confuse no target on the invocation with a static invocation.

      Also, when I wrote the tests for hollow proxies, I explicitly passed
      Object.class as the target class. This seems redundant to me.
      Without it, it fails on not finding the default constructor (which is never used).

        • 1. Re: Hollow proxies
          Adrian Brock Master

          To put this in context, Hollow proxies are a bit like mixins
          except they redirect invocations on an interface.

          e.g. the proxy implements javax.sql.DataSource which is redirected to
          There is no object that actually implements DataSource.

          I don't know whether it is worth making this a first class construct in AOP
          (i.e. configurable in xml) rather than having to write a redirecting interceptor to do this?

          Some of the use cases can be complicated/domain specific.

          e.g. in the DataSource case, the redirect actually does

          public Object invoke(Invocation invoke) throws Throwable
           ConnectionRequestInfo cri = makeCRIFromArgs(invocation);
           ManagedConnectionFactory mcf = getFromInstanceMetaData(invocation);
           return connectionManager.allocationConnection(mcf, cri);

          • 2. Re: Hollow proxies
            Kabir Khan Master

            I changed the API so that there is no need to pass in Object.class for these hollow proxies. For now I am using Object.class internally in the factory.

            If target is null, I make the target a new instance of Object so that the PerInstanceInterceptor has something to match on.

            This is until I figure out what you mean by the rest of your post :-)

            • 3. Re: Hollow proxies
              Adrian Brock Master


              "kabir.khan@jboss.com" wrote:

              This is until I figure out what you mean by the rest of your post :-)

              I was just thinking out load whether the redirect of the hollow proxy
              is something that is generic enough to be made into a "declarative AOP pattern".
              Probably not...?