Results 1 to 1 of 1
-
Exporting RMI Service in Spring framework
First write Interface and Implementation Class you don’t need to implement 'java.rmi.Remote' interface as well no need to throw RemoteException.
RmiSampleService.xmlJava Code:public interface RmiSampleService { String getValue(String s); } public class RmiSampleServiceImpl implements RmiSampleService { public static void main(String args[]) { System.out.println("hi from RMI Spring "); } publicRmiSampleServiceImpl() { System.out.println("constructor rmi"); } public String getValue(String s) { return "Hi From RMI Service " + a; } }
Now Write Client CodeJava Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/ spring-beans.dtd"> <beans> <bean class="org.springframework.remoting.rmi.RmiServiceExporter"> <property name="service"> <value>rmiservice</value> </property> <property name="serviceName"> <value>service1</value> </property> <property name="serviceInterface"> <value>RmiSampleService</value> </property> </bean> <bean id="rmservice" class="RmiSampleServiceImpl"> </bean> </beans>
RmiSampleServiceImpl.java
Now you need to compile and run client you will get the output.Java Code:import java.io.*; import org.springframework.beans.factory.*; import org.springframework.beans.factory.xml.*; import org.springframework.core.io.*; class RmiSampleServiceClient { public static void main(String args[]) { try { System.out.println("Wait. for start uo."); Resource res = new ClassPathResource("RmiSampleService.xml"); BeanFactory factory = new XmlBeanFactory(res); System.out.println(" Bean factory created"); rmservice bean1 = (rmservice) factory.getBean("rmservice"); String s = bean1.getValue(args[0]); System.out.println(s); } catch (Exception e1) { System.out.println("" + e1); } } }
Similar Threads
-
How to use RmiProxyFactoryBean for Importing RMI Service in Spring framework
By Java Tip in forum Spring FrameworkReplies: 0Last Post: 04-02-2008, 10:49 AM -
What is weaving in Spring Framework
By Java Tip in forum Java TipReplies: 0Last Post: 03-29-2008, 12:39 PM -
How to use RmiProxyFactoryBean for Importing RMI Service in Spring framework
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:24 PM -
Exporting RMI Service in Spring framework
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:23 PM -
What is weaving in Spring Framework
By JavaBean in forum Java TipReplies: 0Last Post: 09-26-2007, 08:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks