日期:2014-05-19 浏览次数:20914 次
    <bean id="helloService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"> 
        <property name="serviceUrl" value="rmi://192.168.0.109:1099/helloService"/> 
        <property name="serviceInterface" value="com.rmiClient.HelloWorldInterface"/> 
        <!-- setting refresh connect -->  
        <property name="refreshStubOnConnectFailure" value="true"></property>  
        <property name="lookupStubOnStartup" value="false"></property>  
    </bean> 
ApplicationContext context = new ClassPathXmlApplicationContext("xpring.xml");
        RmiProxyFactoryBean helloService = (RmiProxyFactoryBean)context.getBean("&helloService");
public class ABusinessService {
    
    @Autowired(required=true)
    private RmiProxyFactoryBean helloService;
    
    public String execute(){
        return helloService.getServiceUrl();
    }
}
ApplicationContext context = new ClassPathXmlApplicationContext("xpring.xml");
ABusinessService a = (ABusinessService)context.getBean("businessService");
        System.out.println(a.execute());