6,786
社区成员
发帖
与我相关
我的任务
分享
public interface HelloWorldRemote {
String name();
}
public interface HelloWorldLocal extends HelloWorldRemote{}
@Stateless
@Remote(HelloWorldRemote.class)
@Local(HelloWorldLocal.class)
public class HelloWorld implements HelloWorldRemote, HelloWorldLocal {
@Override
public String name() {
return "getName";
}
}
public static void main(String[] args) throws NamingException {
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.setProperty(Context.PROVIDER_URL, "127.0.0.1:1099");
props.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming");
InitialContext ctx = new InitialContext(props);
HelloWorldRemote remote = (HelloWorldRemote) ctx.lookup("HelloWorld/remote");
System.out.println(remote.name());
}


