批处理文件如何检测给定项目是否具有 EJB3 接口?

How does the batch file detect if a given project has EJB3 interfaces?

我想用项目的存根创建一个 JAR 文件,因为我将通过外部 Java 客户端访问该服务。

createEJBStubs 在这方面对我很有帮助

For many client-side scenarios, the WebSphere® Application Server Just-In-Time (JIT) deployment feature dynamically generates the RMI-IIOP stub classes that are required for invocation of remote EJB 3.x business interfaces. However, there are some scenarios where the JIT deploy environment is not available to dynamically generate these classes. In these scenarios, the createEJBStubs command must be used instead to generate and embed the client-side stub class files in your client application. If your client environment is one of the following, use the createEJBStubs command: "Bare" Java Standard Edition (SE) clients, where a Java SE Java Virtual Machine (JVM) is the client environment. A WebSphere Application Server container (web container, EJB container, or application client container) from a version earlier than version 7, or without the Feature Pack for EJB 3.0 applied. Non-WebSphere Application Server environments.

我知道执行此命令时可能遇到的问题之一是 -

The createEJBStubs command is not supported for use with a 2.x or 1.x EJB module packaged inside a stand-alone JAR file. The stubs for a 2.x or 1.x EJB module packaged inside a stand-alone JAR file must be generated using the EJBDeploy tool instead. If the createEJBStubs command is run against a 2.x or 1.x EJB module packaged inside a stand-alone JAR file, then the command issues a CNTR9241I message, and does not generate any stubs.

脚本如何确定提供给脚本的参数 (JAR) 是否包含 EJB3 类型的接口?

批处理文件位于 %WAS_HOME%\bin\

createEJBStubs 使用的逻辑与分析 EAR 文件中的 JAR 时使用的逻辑相同。如果 JAR 文件包含 ejb-jar.xml,则从那里检查版本。否则,如果 JAR 文件包含组件定义注释(@Stateless@Stateful@MessageDriven),则它是 EJB 版本 3+ JAR。否则,它不是 EJB JAR 文件。

(您使用了 ejb-3.0 标记和 websphere-8 标记,但 WebSphere Application Server v8 实现了 EJB 3.1,因此 @Singleton 也有资格作为组件定义注释。)