JFox(J2EE Application Server Implementation Project)

Last Modified: 2003.12.03

JFox Transmission protocol


JFox uses the invoke style of protocol late-decided. When getting the EJB home, it does not bind protocol for the next invoke. Until the methods of EJB components are invoked, it binds a exact protocol for the method invocation. For the moment Jfox only supports JRMP and Local protocols, the more protocols such as SOAP HTTP IIOP will be supported in future editions.

By default, remote client will use JRMP protocol to invoke EJB components in the J2EE Server, but the invokes among EJB components in the same J2EE Server will use local java invoke, it will improve the running speed.
But in some special circumstances, for example the invokes among EJB components want to use JRMP protocol, at that time it need to enforce the conversion of invoke protocol, Jfox provides the interfaces for the enforcement conversion of invoke protocol. Details can be found in examples below, the whole code in: org.jfox.ejb.examples.protocol.HelloBean

	  public String getWordByLocal() throws RemoteException {
    try {
      Context ctx = new InitialContext();
      Object obj = ctx.lookup("" + WorldHome.class.getName().replace('.','/'));
      WorldHome home = (WorldHome)javax.rmi.PortableRemoteObject.narrow(obj,WorldHome.class);
      // can be omitted,the invoke between EJB components will use Local protocol by default.
((ExtendedEJBHome)home).useProtocol("LOCAL"); 
      World world = home.create();
      return world.getWord();
    }
    catch(Exception e){
      throw new RemoteException(e.getMessage(),e);
    }
  }

  public String getWordByJRMP() throws RemoteException {
    try {
      Context ctx = new InitialContext();
      Object obj = ctx.lookup("" + WorldHome.class.getName().replace('.','/'));
      WorldHome home = (WorldHome)javax.rmi.PortableRemoteObject.narrow(obj,WorldHome.class);
      ((ExtendedEJBHome)home).useProtocol("JRMP");  // the invoke between EJB components enforces to use JRMP protocol
      World world = home.create();
      return world.getWord();
    }
    catch(Exception e){
      throw new RemoteException(e.getMessage(),e);
    }
  }


Now valid parameters of method ExtendedEJBHome.useProtocol() only have JRMP and LOCAL, protocols are not case sensitive.

Because Jfox has choose the best invoke protocol automatically, and the enforced conversion of invoke protocols have exceeded the content of EJB specification, we wish you not to do that generally.