3 Replies Latest reply on Jul 18, 2007 10:43 AM by jerrygauth

    JBAS-4277 Design

      JBAS-4277 notes that HAServiceMBeanSupport should be modified to take advantage of JBAS-4106, which allows association of a classloader with the cluster's RPC handler.

      HAServiceMBeanSupport is a base class intended for extension by cluster services. This class allows extenders to invoke RPC methods on a cluster without having to register the service as a handler, since the base class does this during startService().

      To support invocation of RPC calls in the context of a scoped classloader, it's necessary to provide a reference to the classloader when registering the handler. The purpose of this issue is to modify HAServiceMBeanSupport to allow this registration.

      One simple solution is to modify HAServiceMBeanSupport by adding get/setRPCClassLoader(ClassLoader) to the api and implementation. This will set an instance variable in the base class for the classloader. When the service is registered as an RPCHandler with HAPartition, the classloader registration will be used if the variable is non-null.

      This approach should be fine if the classloader is set before startService() is called on the base class. However services aren't required to explicitly invoke this method so this could require services to override startService() , set the classloader, and then invoke it on the super class.

      To handle services which don't want to override startService(), the setRPCClassLoader() method can re-register the RPC handler if it's already been registered (i.e., by HAServiceMBeanSupport.startService). This is supported by ClusterPartition and will result in the classloader being associated with the service as desired.

      Once the client has set the classloader, subsequent RPC calls will use the designated classloader.

      Thoughts?

        • 1. Re: JBAS-4277 Design

          If a simpler configuration based solution is desirable, we could simply offer the use of the calling thread's context classloader, instead of requiring the caller to provide a classloader. This would be accomplished via a boolean configuration attribute and the startService() method would make the appropriate registration. We wouldn't need to provide a classloader attribute.

          • 2. Re: JBAS-4277 Design
            brian.stansberry

            The boolean configuration approach seems fine. It's implements the most likely registration technique. HAServiceMBeanSupport is just a helper class, so nothing wrong with making people implement more exotic strategies themselves.

            Encapsulate the registration as a method called from startService(). Expose the method as protected. That way if people want to override the behavior, it's easy.

            • 3. Re: JBAS-4277 Design

              Sounds good. I'll make the changes later today unless we receive further input.