org.springframework.remoting.rmi.RmiProxyFactoryBean Java Examples

The following examples show how to use org.springframework.remoting.rmi.RmiProxyFactoryBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteClientSpringApplication.java    From spring-5-examples with MIT License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: RmiRemoteInputStreamServer.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #3
Source File: RmiProtocol.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #4
Source File: PartyRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean customerService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/CustomerService");
	rmiProxy.setServiceInterface(CustomerService.class);
	return rmiProxy;
}
 
Example #5
Source File: AbstractEntityService.java    From OpERP with MIT License 5 votes vote down vote up
@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);

}
 
Example #6
Source File: ItemRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean manufacturerService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/ManufacturerService");
	rmiProxy.setServiceInterface(ManufacturerService.class);
	return rmiProxy;
}
 
Example #7
Source File: ItemRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean categoryService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/CategoryService");
	rmiProxy.setServiceInterface(CategoryService.class);
	return rmiProxy;
}
 
Example #8
Source File: ItemRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean brandService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/BrandService");
	rmiProxy.setServiceInterface(BrandService.class);
	return rmiProxy;
}
 
Example #9
Source File: ItemRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean productService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/ProductService");
	rmiProxy.setServiceInterface(ProductService.class);
	return rmiProxy;
}
 
Example #10
Source File: ItemRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean itemService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/ItemService");
	rmiProxy.setServiceInterface(ItemService.class);
	return rmiProxy;
}
 
Example #11
Source File: AccountRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean receivedTransactionService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(ReceivedTransactionService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
Example #12
Source File: AccountRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean paidTransactionService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(PaidTransactionService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
Example #13
Source File: AccountRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean receivableAccountService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(ReceivableAccountService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
Example #14
Source File: AccountRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean payableAccountService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(PayableAccountService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
Example #15
Source File: EmployeeRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean employeeService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(EmployeeService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
Example #16
Source File: BusinessRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean purchaseService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(PurchaseService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
Example #17
Source File: BusinessRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean saleService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceInterface(SaleService.class);
	String serviceName = rmiProxy.getServiceInterface().getCanonicalName();
	rmiProxy.setServiceUrl(rmiUrl + "/" + serviceName);
	return rmiProxy;
}
 
Example #18
Source File: PartyRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean vendorService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/VendorService");
	rmiProxy.setServiceInterface(VendorService.class);
	return rmiProxy;
}
 
Example #19
Source File: StockRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean stockKeeperService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/StockKeeperService");
	rmiProxy.setServiceInterface(StockKeeperService.class);
	return rmiProxy;
}
 
Example #20
Source File: StockRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean warehouseService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/WarehouseService");
	rmiProxy.setServiceInterface(WarehouseService.class);
	return rmiProxy;
}
 
Example #21
Source File: StockRmiContext.java    From OpERP with MIT License 5 votes vote down vote up
@Bean
public RmiProxyFactoryBean stockService() {
	RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
	rmiProxy.setServiceUrl(rmiUrl + "/StockService");
	rmiProxy.setServiceInterface(StockService.class);
	return rmiProxy;
}
 
Example #22
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #23
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #24
Source File: RmiProtocol.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #25
Source File: RmiProtocol.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #26
Source File: RmiClientConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #27
Source File: RmiClientConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #28
Source File: RmiClient.java    From tutorials with MIT License 4 votes vote down vote up
@Bean RmiProxyFactoryBean service() {
    RmiProxyFactoryBean rmiProxyFactory = new RmiProxyFactoryBean();
    rmiProxyFactory.setServiceUrl("rmi://localhost:1099/CabBookingService");
    rmiProxyFactory.setServiceInterface(CabBookingService.class);
    return rmiProxyFactory;
}