I think there is a problem with Java (extending interfaces)
This is the short explanation:
I have two interfaces. They define the same methods, with only one difference between them, one of them throws Exceptions, and the other doesn't (You might be guessing I'm working with EJBs, right?). If I "mix" them together in a single Interface that implements both of them, It turns out that the methods will throw the Exception. But I think that doesn't make that much sense, because one method that doesn't throw a exception can overide one method that does throw exceptions, but it's not possible to do otherwise. Then why does it throw the exception? :confused: Description of THIS particular problem I (personal taste) like to make one interface that is then extended by the local and the remote interfaces. I extend that interface in a new interface that is the remote one. I extend the same interface in a local interface and override all the methods so that they don't throw any exception (quite a pain in the ass, right? I'm stubburn, what can I say?). I have decided to make a base class that will be extended by a number of EJBs. This base class defines a number of methods. I have declared the methods in one interface (not local, not remote, remember, It's a business logic interface) that throws RemoteExceptions. Then, when I want to create the actual Bean that will extend the base EJB (that doesn't work at all) I have to make the business interface. No problem. I extend the base business interface andd add the business methods. I then create the remote interface extending the extended business interface and implementing EJBObject. Now is the time of the Local Interface. I would have to extend My business Interface and implemente EJBLocalObject.... AND overide every freaken method (base and extended) so that they don't throw RemoteExceptions. I can't avoid having to overide the methods not defined in the base interface.... but I think It makes sence to create one local interface that overrides the base methods and then extend this interface so that I don't have to redeclare all the methods so they don't throw RemoteExceptions. Are you with me? Maybe with code I'll be a little clearer: Base Business interface: Code:
public interface BaseInterface { Code:
public class BaseBean implements SessionBean, BaseInterface { Code:
public interface ExtendedInterface { Code:
public interface Extended implements ExtendedInterface, EJBObject { Code:
public interface BaseLocal extends BaseInterface, EJBLocalObject { Code:
public interface ExtendedLocal extends ExtendedInterface, BaseLocal, EJBLocalObject { |
All times are GMT -5. The time now is 09:27 AM. |