Java Remote Interface

The Remote interface identifies interfaces whose methods may be invoked remotely from a non-local virtual machine.

Java Remote Interface

Java Remote Interface

     

The Remote interface identifies interfaces whose methods may be invoked remotely from a non-local virtual machine. Any remote object must directly or indirectly implement this interface. Implementation classes can implement any number of remote interfaces and can extend other remote implementation classes.

The methods specified in a "remote interface", extends java.rmi.Remote. Therefore, these methods must be defined as being capable of throwing a java.rmi.RemoteException. This exception is thrown by the RMI system from a remote method invocation to indicate that either a communication failure or a protocol error has occurred.

The Enterprise Java Bean (EJB) 2.0 specification also contains a remote client view in cases when you plan to use the bean in distributed environments.

To access a remote object, you first need to find it, which can usually be accomplished through the use of a directory or naming service, such as the RMI registry or JNDI

When you obtain a reference to a remote object through a directory service, you don't receive an actual reference to that object, but rather a reference to a stub object that implements the same interface as the remote object. The stub marshals the method parameters and converts them into a byte-stream representation. Then it sends the marshaled parameters over the network to a skeleton object, which unmarshals them and invokes the actual remote method you wanted to invoke. Then the method returns a value to the skeleton, the skeleton marshals the return value and transports it to the stub, and the stub unmarshals it and returns the value to the caller.

 

Read example at:

http:/www.roseindia.net/javabeans/sessionbeantutorial.shtml