EJB 3存根生成 [英] EJB 3 Stub generation
问题描述
我有一个ejb-3兼容ejb,说
I have an ejb-3 compatible ejb, say
@Remote
interface Hai{
String sayHai();
}
Stateless(name = "xxx", mappedname="yyy")
public class HaiImpl implements Hai{
public String sayHai(){
return "Hai";
}
}
我需要为此EJB生成存根。但我不想使用websphere工具或maven工具。
有没有办法使用jdk生成存根?
And I need to generate stub for this EJB. but I dont want to use websphere tool or maven tool. Is there any way to generate stub using jdk?
当您创建远程客户端
Hai hai = (Hai)ctx.lookup("yyy#com.zz.Hai");
System.out.println(hai.sayHai());
将在weblogic或jboss中工作,但在websphere中,即使是ejb 3,您需要像这个
will work in weblogic or jboss, but in websphere, even it is ejb 3 you need to write like this
Object o = ctx.lookup("yyy");
Hai hai = (Hai)javax.rmi.PortableRemoteObject.narrow(o,Hai.class);
System.out.println(hai.sayHai());
在这种情况下,如果存根不在客户端显示,将抛出异常,使用websphere ejb存根生成器工具生成存根的方式。但是我不想使用任何平台特定的工具。
In this case, if the stub is not presents at the client it will throw exception, there is a way to generate stub using websphere ejb stub generater tool. But I dont want to use any platform specific tools.
推荐答案
不,您必须使用WAS_HOME / bin / createEJBStubs。 Java SDK中包含的rmic命令(通常用于生成存根)不能在不扩展java.rmi.Remote的纯EJB 3远程接口上使用。
No, you must use WAS_HOME/bin/createEJBStubs. The rmic command included in the Java SDK, which would normally be used to generate stubs, cannot be used on "pure" EJB 3 remote interfaces that do not extend java.rmi.Remote.
请注意,如果您使用应用程序客户端容器(WAS_HOME / bin / launchClient)或您的客户端是另一台服务器,则不需要生成存根:容器将为您生成一个。如果您使用非托管的瘦客户端,则只需使用createEJBStub。
Note that if you use the application client container (WAS_HOME/bin/launchClient) or your "client" is another server, then you do not need to generate stubs: the container will generate one for you. You only need to use createEJBStubs if you're using an unmanaged thinclient.
这篇关于EJB 3存根生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!