1 Reply Latest reply on Apr 27, 2005 1:56 PM by Tom Elrod

    User question: programming model

    Daniel Santos Newbie

      Hello,

      If I have a server side API, with a set of methods, how do I structure the code on the server ? I see it can be done in the following ways:

      option 1 - create a handler per subsystem, and then put conditional code on the handler to select between the various API calls within that subsystem.

      option 2 - create a handler per API call and assign a subsystem to it. This way there is no conditional code on the handlers, but there is one for each API call.

      I prefer the second because there is no conditional code. What did the developers had in mind when they created this framework ?

      Regards

        • 1. Re: User question: programming model
          Tom Elrod Master

          The intention of the remoting framework was to provide a generic way of making remote invocations, regardless of transport or data marshalling (only config change required instead of code changes).

          An example of what you are asking about can be found in org.jboss.mx.remoting.JMXSubsystemInvocationHandler. This class is a JMX subsystem handler which maps the invocations to the proper JMX call. Although it has to have conditional code (just like would have if using a dynamic proxy), it only has to be written once and can change out the protocol over which it is called (http, socket, rmi, etc.) by just making configuration changes, and not code changes.

          If wanted even more flexibility in your handler, could have a concrete API class that the handler uses reflection to call upon based on the invocation object (would use NameBaseInvocation for this).