Files used in these examples are located under the src/example directory. S2RMI makes components registered in the S2Container into remote objects. service.Hello interface is a normal interface. Furthermore, service.impl.HelloImpl class is an implementation class (POJO) of Hello interface. Remote objects are released by S2RMI using Hello interface and its implementation class.
service.impl.HelloImpl (implementation class of interface of remote object to be released)
RMIAdaptorImpl class is an adapter that uses ComponentInvokerImpl class to call component registered in the S2Container.
RMIAdaptorDeployer registers RMIAdaptorImpl class into RMI registry.
Port number of rmiregistry. When omitted, default port (1099) is used.
<property name="servicePort">
Port number to be used by RMIAdaptorImpl. When omitted, port is set to the default port (0) and anonymous port is used.
Starting RMIAdaptorDeployer
A component in S2Container can be called remotely by initializing the S2Container. S2Container is initialized by defining <initMethod name="deploy"/> in the dicon file.
server.ServerMain.java
package server;
import org.seasar.framework.container.S2Container;
import org.seasar.framework.container.factory.S2ContainerFactory;
import org.seasar.remoting.common.deployer.Deployer;
public class ServerMain {
public static void main(String[] args) {
S2ContainerFactory.create("server/server.dicon").init();
}
}
To execute ServerMain, right click on ServerMain.java in the package explorer and select [Execute]-[Java Application].
service.Hello (interface to call on a remote object)
RMIConnector call retrieves RMIAdaptorImpl class from RMI registry and calls a component on the server.
RemotingInterceptor class uses RMIConnector to set by AOP an interface (Hello) to call on remote object. Name of remote object to call and name of component to be called (hello) must be the same.
S2RMI is an implementation of S2Remoting.
Therefore, it is possible to switch so remote object are called using S2Axis just be changing connector setting in RemotingInterceptor from RMIConnector to org.seasar.remoting.axis.connector.AxisConnector. Refer to Setting S2Axis Server for information on using S2Axis.