Java Reference
In-Depth Information
public class RmiServer {
public static void main(String[] args) {
new ClassPathXmlApplicationContext("rmi-server.xml");
In this configuration, the server will launch; among the output you should see a message indicating
that an existing RMI registry could not be found.
Invoking an RMI Service
By using Spring's remoting facilities, you can invoke a remote service just like a local bean. For example,
you can create a client that refers to the weather service by its interface.
public class WeatherServiceClient {
private WeatherService weatherService;
public void setWeatherService(WeatherService weatherService) {
this.weatherService = weatherService;
public TemperatureInfo getTodayTemperature(String city) {
List<Date> dates = Arrays.asList(new Date[] { new Date() });
List<TemperatureInfo> temperatures =
weatherService.getTemperatures(city, dates);
return temperatures.get(0);
In a client bean configuration file, such as client.xml located in the classpath root, you can use
RmiProxyFactoryBean to create a proxy for the remote service. Then you can use this service as if it were
a local bean (e.g., inject it into the weather service client).
<beans xmlns=""
<bean id="client"
<property name="weatherService" ref="weatherService" />
Search WWH ::

Custom Search