views:

411

answers:

1

An example:

@Remote
public interface SomeComponentRemote{

    public Something processStuff();

}

//--

@Local
public interface SomeComponentLocal extends SomeComponentRemote{

}

Is that allowed? Can i do this regularly?

+2  A: 

Your way is not allowed as you can not mark your interface with both @Local and @Remote annotations according to specification. And it is not a good idea from point of code reading.

Recommended solution is

public interface SomeComponent {
    public Something processStuff();
}

@Local
public interface SomeComponentLocal extends SomeComponent {
}

@Remote
public interface SomeComponentRemote extends SomeComponent {
}
Mykola Golubyev
The idea is write less code. In this way I´ll have one more interface for each bean.Thanks anyway man.
The main idea is to write maintainable and expressive code and not tricky one. To make future guys happier do not trick.
Mykola Golubyev
+1 The main idea is to write code that doesn't violate the spec :-) Using @Local and @Remote on the same interface will compile, but won't deploy properly.
ChssPly76
Just because it's possible to expose an interface as both local and remote doesn't always make it a good idea:http://stackoverflow.com/questions/1184354/ejb3-session-bean-calling-method-of-another-bean-interface/1192049#1192049
bkail
Hm, are you really sure this violates the spec? I don't think so: Annotations are not inherited - so you have one local and one remote interface. This is perfectly valid in my eyes.
hackbert