EJB spec, page 97 section 7.10.5 states as follows: "The remote interface methods must not expose local interface types, local home interface types, the managed collection classes that are used for entity beans with container-managed persistence as arguments or results".
Can somebody clarify the statement in bold ? Thanks.
If you have a CMR field with abstract getters and setters,
public abstract void setDirector(Director dir); public abstract Director getDirector();
then you know that Director must be a local component interface type. Hence you cannot expose the Director reference through a remote interface. You cannot expose local references through a remote interface because if you were to do that, you would give away a local reference to a different JVM / heap. But references are scoped only to the JVM where they are created, they do not have any meaning on some other JVM. That's why you cannot expose (expose means take as an argument or return as a return type) a local reference through a remote interface. The same applies when the CMR field is a collection
public abstract void setMovies(Collection movies); public abstract Collection getMovies();
In this case, you have a collection of Movie local component interface references (CMR field) and you cannot give them away to a different JVM. Hence you cannot expose this collection through a remote interface (For example, you cannot return this Collection from a remote component interface method of the Director bean)
The line in bold that you have specified explicitly talks about the second scenario as the movie collection is a "managed collection" (It's a CMR field)
posted 14 years ago
Thanks Sathish. The term "managed collection" does it always refer to Collection of CMR local references ? or does it also refer to Collection of remote references ?
Is this term explained in EJB specs ?
posted 14 years ago
You can return a collection of remote references from a remote interface method. The rule is that you cannot return local references / collection of local references from a remote method. It does not matter whether it is container managed (CMR field) or your own collection. If it is local, you cannot expose it through a remote method.
Hope this clarifies.
I have not read the spec, I am not sure about it. But it should be mentioned somewhere in the spec.
machines help you to do more, but experience less. Experience this tiny ad: