Java源码示例:org.springframework.remoting.rmi.RmiProxyFactoryBean

示例1
@Override
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
    final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
    // RMI needs extra parameter since it uses customized remote invocation object
    if (url.getParameter(Constants.DUBBO_VERSION_KEY, Version.getProtocolVersion()).equals(Version.getProtocolVersion())) {
        // Check dubbo version on provider, this feature only support
        rmiProxyFactoryBean.setRemoteInvocationFactory(new RemoteInvocationFactory() {
            @Override
            public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
                return new RmiRemoteInvocation(methodInvocation);
            }
        });
    }
    rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
    rmiProxyFactoryBean.setServiceInterface(serviceType);
    rmiProxyFactoryBean.setCacheStub(true);
    rmiProxyFactoryBean.setLookupStubOnStartup(true);
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
    rmiProxyFactoryBean.afterPropertiesSet();
    return (T) rmiProxyFactoryBean.getObject();
}
 
示例2
@Bean RmiProxyFactoryBean userService(@Value("${rmi.server.host:0.0.0.0}") final String rmiServerHost) {
  final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
  rmiProxyFactoryBean.setServiceUrl(format("rmi://%s:1199/UserService", rmiServerHost));
  rmiProxyFactoryBean.setServiceInterface(UserService.class);
  rmiProxyFactoryBean.setLookupStubOnStartup(false); // fail safe on startup
  return rmiProxyFactoryBean;
}
 
示例3
/**
 * Utility method to lookup a remote stream peer over RMI.
 */
public static RemoteInputStreamServer obtain(String host, int port, String name) throws RemoteException
{
    RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
    rmiProxyFactoryBean.setServiceUrl("rmi://" + host + ":" + port + "/" + name);
    rmiProxyFactoryBean.setServiceInterface(RemoteInputStreamServer.class);
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
    try
    {
        rmiProxyFactoryBean.afterPropertiesSet();
    }
    catch (Exception e)
    {
        throw new RemoteException("Error create rmi proxy");
    }
    return (RemoteInputStreamServer) rmiProxyFactoryBean.getObject();
}
 
示例4
@Bean
public UserService userService() {
    final RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
    factoryBean.setServiceInterface(UserService.class);
    factoryBean.setServiceUrl("rmi://localhost:1098/userService");
    factoryBean.afterPropertiesSet();
    return (UserService) factoryBean.getObject();
}
 
示例5
@Bean
public UserService userService() {
    final RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
    factoryBean.setServiceInterface(UserService.class);
    factoryBean.setServiceUrl("rmi://localhost:1099/userService");
    factoryBean.afterPropertiesSet();
    return (UserService) factoryBean.getObject();
}
 
示例6
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
    final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
    rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
    rmiProxyFactoryBean.setServiceInterface(serviceType);
    rmiProxyFactoryBean.setCacheStub(true);
    rmiProxyFactoryBean.setLookupStubOnStartup(true);
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
    rmiProxyFactoryBean.afterPropertiesSet();
    return (T) rmiProxyFactoryBean.getObject();
}
 
示例7
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
    final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
    rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
    rmiProxyFactoryBean.setServiceInterface(serviceType);
    rmiProxyFactoryBean.setCacheStub(true);
    rmiProxyFactoryBean.setLookupStubOnStartup(true);
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
    rmiProxyFactoryBean.afterPropertiesSet();
    return (T) rmiProxyFactoryBean.getObject();
}
 
示例8
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
    final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
    rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
    rmiProxyFactoryBean.setServiceInterface(serviceType);
    rmiProxyFactoryBean.setCacheStub(true);
    rmiProxyFactoryBean.setLookupStubOnStartup(true);
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
    rmiProxyFactoryBean.afterPropertiesSet();
    return (T) rmiProxyFactoryBean.getObject();
}
 
示例9
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
    final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
    rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
    rmiProxyFactoryBean.setServiceInterface(serviceType);
    rmiProxyFactoryBean.setCacheStub(true);
    rmiProxyFactoryBean.setLookupStubOnStartup(true);
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
    rmiProxyFactoryBean.afterPropertiesSet();
    return (T) rmiProxyFactoryBean.getObject();
}
 
示例10
@Bean
public RmiProxyFactoryBean stockService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/StockService");
	rmiProxy.setServiceInterface(StockService.class);
	return rmiProxy;
}
 
示例11
@Bean
public RmiProxyFactoryBean warehouseService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/WarehouseService");
	rmiProxy.setServiceInterface(WarehouseService.class);
	return rmiProxy;
}
 
示例12
@Bean
public RmiProxyFactoryBean stockKeeperService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/StockKeeperService");
	rmiProxy.setServiceInterface(StockKeeperService.class);
	return rmiProxy;
}
 
示例13
@Bean
public RmiProxyFactoryBean vendorService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/VendorService");
	rmiProxy.setServiceInterface(VendorService.class);
	return rmiProxy;
}
 
示例14
@Bean
public RmiProxyFactoryBean customerService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/CustomerService");
	rmiProxy.setServiceInterface(CustomerService.class);
	return rmiProxy;
}
 
示例15
@Bean
public RmiProxyFactoryBean saleService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(SaleService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
示例16
@Bean
public RmiProxyFactoryBean purchaseService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(PurchaseService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
示例17
@Bean
public RmiProxyFactoryBean employeeService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(EmployeeService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
示例18
@Bean
public RmiProxyFactoryBean payableAccountService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(PayableAccountService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
示例19
@Bean
public RmiProxyFactoryBean receivableAccountService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(ReceivableAccountService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
示例20
@Bean
public RmiProxyFactoryBean paidTransactionService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(PaidTransactionService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
示例21
@Bean
public RmiProxyFactoryBean receivedTransactionService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(ReceivedTransactionService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
示例22
@Bean
public RmiProxyFactoryBean itemService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/ItemService");
	rmiProxy.setServiceInterface(ItemService.class);
	return rmiProxy;
}
 
示例23
@Bean
public RmiProxyFactoryBean productService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/ProductService");
	rmiProxy.setServiceInterface(ProductService.class);
	return rmiProxy;
}
 
示例24
@Bean
public RmiProxyFactoryBean brandService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/BrandService");
	rmiProxy.setServiceInterface(BrandService.class);
	return rmiProxy;
}
 
示例25
@Bean
public RmiProxyFactoryBean categoryService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/CategoryService");
	rmiProxy.setServiceInterface(CategoryService.class);
	return rmiProxy;
}
 
示例26
@Bean
public RmiProxyFactoryBean manufacturerService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/ManufacturerService");
	rmiProxy.setServiceInterface(ManufacturerService.class);
	return rmiProxy;
}
 
示例27
@Override
public void registerClient(String clientAddress) {
	System.out.println("Client from " + clientAddress);

	ApplicationContext context = ServerApp.getApplicationContext();
	AutowireCapableBeanFactory factory = context
			.getAutowireCapableBeanFactory();
	BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
	GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
	beanDefinition.setBeanClass(RmiProxyFactoryBean.class);
	beanDefinition.setAutowireCandidate(true);

	Class<EM> entityModelInterfaceClass = getEntityModelInterfaceClass();

	MutablePropertyValues propertyValues = new MutablePropertyValues();
	propertyValues.addPropertyValue("serviceInterface",
			entityModelInterfaceClass);
	propertyValues.addPropertyValue("serviceUrl", "rmi://" + clientAddress
			+ ":1099/" + entityModelInterfaceClass.getCanonicalName());
	beanDefinition.setPropertyValues(propertyValues);

	registry.registerBeanDefinition(
			entityModelInterfaceClass.getCanonicalName(), beanDefinition);
	EM entityModel = context.getBean(entityModelInterfaceClass);
	registerEntityModel(entityModel);
	System.out.println(entityModel);

}
 
示例28
@Bean RmiProxyFactoryBean service() {
    RmiProxyFactoryBean rmiProxyFactory = new RmiProxyFactoryBean();
    rmiProxyFactory.setServiceUrl("rmi://localhost:1099/CabBookingService");
    rmiProxyFactory.setServiceInterface(CabBookingService.class);
    return rmiProxyFactory;
}