编辑器加载中...package com.dxz.ejb2; import java.util.Properties; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; public class Test { public static String test_jboss() { System.out .println("==========================================================="); Properties props = new Properties(); props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); props.setProperty("java.naming.provider.url", "localhost:1099"); props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming"); try { InitialContext ctx = new InitialContext(props); Object objRef = ctx.lookup("ejb/helloEJB"); HelloWorldHome home = (HelloWorldHome) PortableRemoteObject.narrow( objRef, HelloWorldHome.class); HelloWorldRemote remote = home.create(); System.out.println(remote.sayHello()); return "OK"; } catch (Exception ex) { ex.printStackTrace(); return "Fail"; } } public static String test_wasce() { System.out .println("==========================================================="); try { InitialContext ctx = new InitialContext(); Object objRef = ctx.lookup("java:comp/env/ejb/helloEJB"); HelloWorldHome home = (HelloWorldHome) PortableRemoteObject.narrow( objRef, HelloWorldHome.class); HelloWorldRemote remote = home.create(); System.out.println(remote.sayHello()); return "OK"; } catch (Exception ex) { ex.printStackTrace(); return "Fail"; } } }
ejb2
最新推荐文章于 2024-04-30 17:28:01 发布