开发者

Is portable jndi syntax (EJB3.1) available across machines?

开发者 https://www.devze.com 2023-02-19 17:35 出处:网络
I was reading about \"Portable Global JNDI names\" in several articles, here and there for example, but I was unable to understand whether this syntax only applies to inbound machine lookups (or mayb

I was reading about "Portable Global JNDI names" in several articles, here and there for example, but I was unable to understand whether this syntax only applies to inbound machine lookups (or maybe inbound server lookup if the server is clustered). I.e, does it only try to solve the problem of lookups between modules and apps on the same machine/server?

Because I keep seeing examples referencing to this feature and using @Remote which I would imagine can very well occur cross-machine/server.

If it indeed only resolves internal lookups to machine/server I'd appreciate it if someone could point me to the right direction with res开发者_开发百科pect to how to use it with @Remote between servers (I'm guessing somewhere I need to prefix the host name).

Thanks,

Ittai


You can call EJB component from another machine that's why @Remote anotation exists.Like

    String host = "10.1.1.111";
    String port = "3700";

    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.enterprise.naming.SerialInitContextFactory");
    props.setProperty("org.omg.CORBA.ORBInitialHost", host);

    props.setProperty("org.omg.CORBA.ORBInitialPort", port);

    InitialContext ctx = new InitialContext(props);
    TestService ejb = (TestService)ctx.lookup("java:global/XXX/XXX/TestEntityFacade!com.test.service.TestService");
    ejb.findAll();


In that case you can use mention it in descriptor file then you can inject it using @EJB

@EJB(name="fooejbref")
private FooRemote fooRemote;

Within sun-web.xml :

<ejb-ref>
  <ejb-ref-name>fooejbref</ejb-ref-name>
  <jndi-name>corbaname:iiop:host2:3700#Foo</jndi-name>
</ejb-ref>

for details please please look this url http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB

0

精彩评论

暂无评论...
验证码 换一张
取 消