users@glassfish.java.net

re : When a session bean has remote as well as local business interface...

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Tue, 22 Apr 2008 17:41:48 -0400

> Subject: When a session bean has remote as well as local business
> interface...
> Date: Tue, 22 Apr 2008 12:06:31 +0200
> From: Witold Szczerba <pljosh.mail_at_gmail.com>
> Reply-To: users_at_glassfish.dev.java.net
> To: users_at_glassfish <users_at_glassfish.dev.java.net>
>
> Hi there,
> I am using NetBeans for JEE development and sometimes it complains
> like this:
> "When a session bean has remote as well as local business interface,
> there should not be any method common to both interfaces."
> Does anyone know why is that?

Hi Witold,

The basis of the warning is that Remote and Local semantics are very
different.
For example :

-- Remote argument types are limited to primitives, Serializable
types, or other Remote references
-- Remote arguments are passed by value (copied) whereas Local
arguments are passed by reference
-- Remote invocations are location transparent
-- Remote invocations typically have higher overhead than Local
invocations
-- Remote invocations are more likely to fail than Local invocations

(Full list available in Section 3.2.3 of the EJB 3.0 Core specification)

The EJB spec doesn't explicitly prohibit any method from being exposed
through both a Local and
Remote view, but it cautions against it. Even if the types fall
within the subset that are allowed by both, in practice
the two views have much different design tradeoffs and therefore tend
to result in different methods.

  --ken


> I think this is very inconvenient, what
> am I suppose to do? Rather ignore that warning or use for example
> special suffix for methods in @Local interface and inside bean
> delegate that method like this:
>
> @Stateful
> public class LoanTxWorkerBean implements
> LoanTxWorkerLocal,LoanTxWorkerRemote {
> .....
> .....
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> public void save(String defaultDocumentNo) {
> ...
> }
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
> public void save_local(String defaultDocumentNo) {
> save(defaultDocumentNo);
> }
> }
>
> What do you think?
>
> Regards,
> Witold Szczerba
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>