ejb@glassfish.java.net

Local and Remote

From: Daniel Cavalcanti <dhcavalcanti_at_gmail.com>
Date: Thu, 3 Aug 2006 12:25:17 -0400

Hello,

I have a very simple question.

Say I have a (stateless) session bean that will be accessed from a web app
and and client app. I want the web app to access the bean through the local
interface, and the client app has to access the bean through the remote
interface. Now, here is my question: I want the bean to have a set of
operations but I would like to have to define these operations in a single
interface and not replicate them in the local and remote interfaces. So I
tried this:

public interface Common {
    public int someMethod(String param1, int param2);
}

@Remote()
public interface RemoteCommon {}

@Local()
public interface LocalCommon {}

@Stateless()
public class CommonBean implements RemoteCommon, LocalCommon {
    public int someMethod(String param1, int param2) { /* do something here
*/ }
}

In other words, I tried to use RemoteCommon and LocalCommon just as marker
interfaces, but when I try to use the bean in the web app or client app, the
RemoteCommon and LocalCommon interfaces appear as they have no methods
defined. What I'm trying to avoid is this:

@Remote()
public interface RemoteCommon {
    public int someMethod(String param1, int param2);
}

@Local()
public interface LocalCommon {
    public int someMethod(String param1, int param2);
}

@Stateless()
public class CommonBean implements RemoteCommon, LocalCommon {
    public int someMethod(String param1, int param2) { /* do something here
*/ }
}


thanks,
Daniel.