简体   繁体   English

从EJB2库调用EJB3库

[英]Calling an EJB3 library from an EJB2 library

I have an existing application that is written in EJB2.1. 我有一个用EJB2.1编写的现有应用程序。 This is deployed on jboss-5.1.0.GA as an EAR. 这部署在jboss-5.1.0.GA上作为EAR。

I now have a new requirement to implement a process which is supposed to be used by the EJB2.1 application. 我现在有了一个新的要求来实现一个应该由EJB2.1应用程序使用的进程。 Both will be in their own ear files but will both be running on the same jboss-5.1.0 instance. 两者都将在他们自己的ear文件中,但都将在同一个jboss-5.1.0实例上运行。

My questions are: 我的问题是:

  • Is it possible to call the services of the EJB3 ear from the EJB2.1 ear? 是否可以从EJB2.1耳中调用EJB3 ear的服务?
  • If the answer to the above is yes, is it possible to manage the transactions? 如果上述答案是肯定的,是否可以管理交易? ie only have the EJB2.1 application commit any transactions. 即只有EJB2.1应用程序提交任何事务。
  • Migrating the existing 2.1 application to v3 is out of the question. 将现有的2.1应用程序迁移到v3是不可能的。 Is creating the new process as v3 worth the effort or am i likely to come across problems with the integration between the two? 创建新流程作为v3值得努力还是我可能会遇到两者之间的集成问题?
  • I have been looking around for a simple hello world type example that demonstrate the above but have not been able to find any. 我一直在寻找一个简单的hello world类型示例,它演示了上述内容但未能找到任何内容。 Anyone know of a good example? 有人知道一个很好的例子吗?
  • The EJB3 services will be called from session beans in the EJB2 application. EJB3服务将从EJB2应用程序中的会话bean调用。 Is this the wrong way to do it? 这是错误的方法吗? (ie the session bean is not a client). (即会话bean不是客户端)。

The EJB3 specification allows a smooth transition,defining methods for EJB2/EJB3 interoperability, it's sometimes bulky and you will need artifacts not necessary in a 'normal' EJB3 app ( @RemoteHome ) EJB3规范允许平滑过渡,定义EJB2 / EJB3互操作性的方法,它有时很笨重,你需要在“普通”EJB3应用程序中不需要的工件( @RemoteHome

  • Is it possible to call the services of the EJB3 ear from the EJB2.1 ear? 是否可以从EJB2.1耳中调用EJB3 ear的服务?

Yes, it is possible, see: Referencing EJB3 beans in EJB2.1 and Introduction to using EJB2.1 client adaptors and the sample project "ejb21_client_adaptors" 是的,有可能,请参阅: 在EJB2.1中引用EJB3 bean以及使用EJB2.1客户端适配器和示例项目“ejb21_client_adaptors”的简介

  • If the answer to the above is yes, is it possible to manage the transactions? 如果上述答案是肯定的,是否可以管理交易? ie only have the EJB2.1 application commit any transactions. 即只有EJB2.1应用程序提交任何事务。

Yes, just remember to annotate your EJB3 method with @TransactionAttribute(TransactionAttributeType.MANDATORY) 是的,只需记住使用@TransactionAttribute(TransactionAttributeType.MANDATORY)注释EJB3方法

  • The EJB3 services will be called from session beans in the EJB2 application. EJB3服务将从EJB2应用程序中的会话bean调用。 Is this the wrong way to do it? 这是错误的方法吗? (ie the session bean is not a client). (即会话bean不是客户端)。

I see no problem here, session beans can call other beans' services. 我认为这里没有问题,会话bean可以调用其他bean的服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM