0

I have an application in Java EE/JSF using a local EJB Interface and I would like to use the business layer with another client application (in a different JVM).

So, I need to use a remote EJB Interface to use dependency injection in the new client application.

But if I change the EJB Interface, I'll also have to change all dependency injection in the managedBean of the "first" client application?

4

1 回答 1

0

Local interfaces use pass-by-reference, but remote interfaces use pass-by-deep-copy. This means (1) all your parameter and return values must be serializable, and (2) you must depend on pass-by-reference, either for performance (very large Maps, etc.) or correctness (pass an object to a method, change the object, expect the result to be visible to the caller.

That said, when you say "local EJB interface", do you mean @Local, or do you mean EJBLocalHome? If the former, then you can try changing to @Remote, and it might just work. If the latter, then you'll need to update your interfaces to use EJBHome/EJBObject, which means you'll need to add RemoteException to all the methods on the interfaces, which means you'll need to at least update callers to handle the exception.

于 2012-09-21T16:17:54.860 回答