2 Replies Latest reply on Nov 22, 2003 7:18 AM by martin_kersten

    Using Local and LocalHome Interfaces

    tdsdev

      Hi,

      can anybody give me an example for using the Local- and LocalHome Intefaces to access EntityBeans?

      Everybody says: "....use Local Intefaces they are faster..." but in every example I saw, they are usig only the Remote Interface.

      Please help!

      Thanx

        • 1. Re: Using Local and LocalHome Interfaces
          websel

          Hi!

          The trick is that the JNDI name is changed for your local access.

          If you have a working version of a remote bean, change the following in your client (which of course should run in the same VM ans your entity beans)

          Old: Object objref = ctx.lookup("ejb/HelloWorldBean");
          New: Object objref = ctx.lookup("HelloWorldLocal");

          Then change the the init of the classes as following:

          Old: HelloWorld helloWorld=null;
          New: HelloWorldLocalHome helloWorld=null;

          Old: (HelloWorldHome)PortableRemoteObject.narrow(objref, JMSRoutingHome.class);
          New: (HelloWorldLocalHome)PortableRemoteObject.narrow(objref, HelloWorldLocalHome.class);

          Etc. you get the idea don't forget to instruct Xdoclet to generate the localhome and local interfaces.

          Wessel

          • 2. Re: Using Local and LocalHome Interfaces
            martin_kersten

            You dont need to use narrow on local homes.