ejb@glassfish.java.net

Re: Is it legal for the same bean to have the same local and remoter interface?

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Thu, 23 Feb 2006 21:36:40 +0530

Hi Ken,

Thanks for replying. More questions in line...

Kenneth Saks wrote:

> Sanjeeb Kumar Sahoo wrote:
>
>> Hi Ken,
>>
>> Is the following allowed?
>>
>> /package com.sun.fossdemo;
>>
>> @javax.ejb.Stateless
>> @javax.ejb.Remote(Sless.class)
>> @javax.ejb.Local(Sless.class)
>
>
> Hi Sahoo,
>
> No, the spec doesn't allow this.

Any spec reference on this issue will be really helpful. If it is not
explicitly mentioned, I wish it were.

> Even though the rules for writing
> the 3.0 local and remote business interfaces are more similar than
> they were between the 2.x Remote and Local component interfaces,
> it would be dangerous to use the same interface for both views since
> the behavior could be different due to pass-by-value vs. pass-by-copy
> semantics and the variance in allowed types.

I guess, the above applies to any method that is common to both remote
and local business interface of a bean, right?
e.g. in the following case, although the interface names are different,
they have the same method.
interface SlessLocal {
  void foo(Mutable m); // Mutable is data object.
}

interface SlessRemote {
  void foo(Mutable m); // Mutable is data object.
}

@javax.ejb.Stateless
@javax.ejb.Remote(SlessLocal.class)
@javax.ejb.Local(SlessRemote.class)
public class SlessBean2 {
public void foo(Mutable p){
  ...
}
}

This is a definitely an EJB 3.0 issue as you pointed out because for 2.x
EJB remote interface methods and local interface methods can not be the
same because of conflicting requirement. Did I get it right?

Thanks,
Sahoo

>>
>> public class SlessBean2 implements Sless {
>> public void createPerson(String name){
>> System.out.println("createPerson " + name);
>> }
>> }
>> /
>> Since it uses annotation, will both the remote view and local view
>> not end up having same bean-name which in this case is SlessBean2?
>>
>> Thanks,
>> Sahoo
>>
>
>
>