The remote interface is the starting point for creating an RMI application. It is written as a standard Java interface. The following rules must be followed whether J2SE or WebLogic is being used for development:
In addition to these common requirements, J2SE and WebLogic have individual requirements or enhancements that must be followed. To maximize portability, follow the J2SE requirements. The WebLogic implementation is compatible with J2SE and only the import statement would need to be changed. Java 2 Standard Edition Remote InterfaceFor a J2SE implementation, the remote interface must extend the java.rmi.Remote interface to ensure that this new interface can be cast to a Remote interface. All methods defined by the remote interface must be declared to throw java.rmi.RemoteException . The IHitCounter in the sample RMI application shown later in this chapter is a remote interface. WebLogic Remote InterfaceThe WebLogic remote interface provides ease-of-use extensions for remote interfaces and code generation. For a WebLogic implementation, the remote interface must extend weblogic.rmi.Remote . Each method in the interface does not need to declare a java.rmi.RemoteException in its throws block. This allows more freedom for your application to throw specific exceptions. The exceptions can extend Exception or RuntimeException depending upon the needs of the application. |