SpringFramework

SpringFramework Homepage.

A short example, how you can invoke with the SpringFramework a XML-RPC service. First you create a instance from the ApplicationContext to load the configuration file. The context create in a second step a proxy object for the service interface. The proxy object delegate all calls from the service interface method to the net.sf.crispy.impl.XmlRpcExecutor. The XmlRpcExecutor make the remote calls to the MiniServer and send back the result.

MiniServer server = new MiniXmlRpcServer(8080);
try {
	server.addService(Echo.class.getName(), EchoImpl.class.getName());
	server.addService(Calculator.class.getName(), CalculatorImpl.class.getName());

	server.start();

	ApplicationContext ctx = new ClassPathXmlApplicationContext("/spring_example_1.xml");
	Calculator calculator = (Calculator) ctx.getBean("calculator");
	System.out.println("add: 5+7 = " + calculator.add(5, 7));
	System.out.println("subtract: 9-3 = " + calculator.subtract(9, 3));
			
} catch (Exception e) {
	e.printStackTrace();
}
finally {
	server.stop();
}

In the example you load a configuration file (spring_example_1.xml). This file is description here:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC 
   "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">


<beans>

	<bean id="calculator" class="net.sf.crispy.extension.spring.CrispyFactoryBean">
		<property name="props">
		  <props>
		    <prop key="crispy.prop.static.proxy.class">
		      net.sf.crispy.impl.XmlRpcExecutor
		    </prop>
		  </props>
		</property>		
		<property name="serviceInterface">
		  <value>test.crispy.example.service.Calculator</value>
		</property>		
		<property name="serviceUrl">
		  <value>http://localhost:8080/</value>
		</property>		
	</bean>

	
</beans>