1 Reply Latest reply on Jan 7, 2006 5:55 PM by dogeared

    how to work with multiple business interfaces

    dogeared

      The spec indicates that a bean can implement multiple interfaces. The spec also has annotations to support this as in:


      public interface IState {
      public String getState();
      }

      public interface ICountry {
      public String getCountry();
      }

      @Stateless
      @Remote({IState.class,ICountry.class})
      public class LocationInformation implements IState,ICountry {
      public String getState() {
      ...
      }

      public String getCountry() {
      ...
      }
      }


      The specification is vague on how to interact with a bean defined this way.

      From a standalone client, how is the lookup done? Deploying this to JBoss does not automatically put anything into the JNDI namespace the way it does when you are working with a single remote business interface. If you were interacting with it from within the container, say from another bean, how could you inject a reference to this bean?

      Logically, it seems like you would have to lookup and work with each interface.

      I am curious to know how this should be done in from the perspective of the spec and how (or if) it can be done with JBoss.

        • 1. Re: how to work with multiple business interfaces
          dogeared

          It seems just by observation that JBoss does not yet support the feature from the specification of having multiple business interfaces. At least not in an automated way.

          However, it looks like Glassfish does. Using the example from the original post, I was able to see that Glassfish exposes the business interfaces in the usual EJB 3.0 way, BUT prefixed with a pound sign (#). It looks like this:

          #examples.interfaces.IState
          #examples.interfaces.ICountry

          I don't believe that this automatic binding is part of the specification, but it works - at least with Glassfish. In a client, if I do the following lookup:

          IState is = (IState)ic.lookup("#"+IState.class.getName());
          ICountry ic = (ICountry)ic.lookup("#"+ICountry.class.getName());

          I can then call the methods defined in the interfaces and get the response back from the bean deployed in the application server.