Skip to main content

@Local extends @Remote

5 replies [Last post]
jassi_saggu
Offline
Joined: 2004-03-29

Hi,
I am designing a new application using EJB3.
I was just wonderning if its leagal and won't have any drawback.

@Remote
public interface OrderManagerRemote
{
public void addOrder(OrderTO orderData);
public List getOrders();
}

@Local
public interface OrderManagerLocal extends OrderManagerRemote
{
//Only available in local interface.
public List deleteOrders(List orders);
}

I have tried this in Glassfish and it's working fine but I don't know what's going inside the system.

I could try other approach i.e.

public interface OrderMethods
{
public void addOrder();
}

@Remote
public interface OrderManagerRemote extends OrderMethods
{
}

@Local
public interface OrderManagerLocal extends OrderMethods
{
}
...but I just want to reduce the number of classes I'm creating.

Thanks in Advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
krokodylowy
Offline
Joined: 2009-05-27

I think that better solution is local extension

@Remote
public interface OrderManagerRemote extends OrderManagerLocal

@Local
public interface OrderManagerLocal

In other cases you may see

org.jboss.ejb3.common.resolvers.spi.NonDeterministicInterfaceException: beanInterface xxxx, is not unique within EJB xxxBean

Sahoo

IMO, it's a bad design, because typically the semantics of remote
methods differ from that of local methods. e.g., remote methods use
pass-by-value, where as local ones use pass-by-reference. There are
restrictions of what exceptions can appear in method signatures as well.
Both your approaches suffer from this.

See section #3.2 of EJB 3.0 Simplified spec, where it says the following:

/The same business interface cannot be both a local and a remote
business interface of the bean. [4]/

Thanks,
Sahoo
glassfish@javadesktop.org wrote:
> Hi,
> I am designing a new application using EJB3.
> I was just wonderning if its leagal and won't have any drawback.
>
> @Remote
> public interface OrderManagerRemote
> {
> public void addOrder(OrderTO orderData);
> public List getOrders();
> }
>
> @Local
> public interface OrderManagerLocal extends OrderManagerRemote
> {
> //Only available in local interface.
> public List deleteOrders(List orders);
> }
>
> I have tried this in Glassfish and it's working fine but I don't know what's going inside the system.
>
> I could try other approach i.e.
>
> public interface OrderMethods
> {
> public void addOrder();
> }
>
> @Remote
> public interface OrderManagerRemote extends OrderMethods
> {
> }
>
> @Local
> public interface OrderManagerLocal extends OrderMethods
> {
> }
> ...but I just want to reduce the number of classes I'm creating.
>
> Thanks in Advance.
> [Message sent by forum member 'jassi_saggu' (jassi_saggu)]
>
> http://forums.java.net/jive/thread.jspa?messageID=291144
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

jassi_saggu
Offline
Joined: 2004-03-29

Humm...thx for the reply but that's not the case and I dont agree on it.
The EJB Spec says that same business interface can not be marked as both @Remote as well @Local but it does not say that one or other can not extend it. Here extending Remote won't carry all all the Remote semantics to Local interface.
As I said before that I don't see any error/info/warning logs in server.log.
I also tried tarcing as much other logs possible but didnt get any clue that its upsating the appserver.

I need to do more research on that.
Can I please ask some body from Glassfish devlopment team to put some light on this please.

Thanks.

moenzie
Offline
Joined: 2008-02-13

I tried the 2nd approach, with a "helping" interface where both Local and Remote interface extend from.
But NetBeans gives a warning on
@Stateless(mappedName="FooEJB")
public class FooBean implements FooLocal, FooRemote {
...
}
saying
"When a session bean has remote as well as local business interface, there should not be any method common to both the interfaces"

Although this warning the deployed project behaves like expected when accessing both Local and Remote interfaces.

Anyone with some more expertise/experience on this topic?

Thanks

Kris

Sahoo

Yes, that's a correct warning. Remote methods and local methods have
very different invocation semantics (e.g., pass-by-value vs.
pass-by-reference) and sharing them is a bad practice. Imagine, the
method implementation assumes pass-by-reference semantics and hence
modifies the argument only to realize that the changes to argument are
not visible for remote calls.

Thanks,
Sahoo

glassfish@javadesktop.org wrote:
> I tried the 2nd approach, with a "helping" interface where both Local and Remote interface extend from.
> But NetBeans gives a warning on
> @Stateless(mappedName="FooEJB")
> public class FooBean implements FooLocal, FooRemote {
> ...
> }
> saying
> "When a session bean has remote as well as local business interface, there should not be any method common to both the interfaces"
>
> Although this warning the deployed project behaves like expected when accessing both Local and Remote interfaces.
>
> Anyone with some more expertise/experience on this topic?
>
> Thanks
>
> Kris
> [Message sent by forum member 'moenzie' (moenzie)]
>
> http://forums.java.net/jive/thread.jspa?messageID=299339
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net