本文整理汇总了Java中org.springframework.remoting.rmi.RmiProxyFactoryBean.setServiceUrl方法的典型用法代码示例。如果您正苦于以下问题:Java RmiProxyFactoryBean.setServiceUrl方法的具体用法?Java RmiProxyFactoryBean.setServiceUrl怎么用?Java RmiProxyFactoryBean.setServiceUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.remoting.rmi.RmiProxyFactoryBean
的用法示例。
在下文中一共展示了RmiProxyFactoryBean.setServiceUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: obtain
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
/**
* 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();
}
示例2: doRefer
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
//RMI传输时使用自定义的远程执行对象,从而传递额外的参数
rmiProxyFactoryBean.setRemoteInvocationFactory(new RemoteInvocationFactory() {
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();
}
示例3: doRefer
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@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();
}
示例4: createConnection
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@Override
public CommunicationConnection createConnection(CommunicationParam params) {
if (params == null) {
throw new IllegalArgumentException("param is null!");
}
// 构造对应的url
String serviceUrl = MessageFormat.format(RMI_SERVICE_URL, params.getIp(), String.valueOf(params.getPort()));
// 自己实现的有连接池的Stub
RmiProxyFactoryBean proxy = new RmiProxyFactoryBean();
proxy.setServiceUrl(serviceUrl);
proxy.setServiceInterface(CommunicationEndpoint.class);
proxy.afterPropertiesSet();
return new RmiCommunicationConnection(params, (CommunicationEndpoint) proxy.getObject());// 创建链接
}
示例5: register
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
public String register(String workerId, String address) {
RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
factoryBean.setServiceInterface(WorkAPI.class);
factoryBean.setServiceUrl(String.format("rmi://%s:%s/worker", address, workerPort));
factoryBean.afterPropertiesSet();
WorkAPI worker = (WorkAPI) factoryBean.getObject();
String token = UUID.randomUUID().toString();
workers.put(token, worker);
System.out.println(String.format("A worker(%s) at %s registered, and assigned with token(%s)",
workerId, address, token));
return token;
}
示例6: main
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
/**
* java -Drouter.port=1097 -Drouter.address=localhost -jar path/to/com.myapp.caller-1.0.0.jar jobId
*
* @param args jobId(mandatory)
*/
public static void main(String[] args) {
if (args.length < 1)
throw new IllegalArgumentException("You must specify a job id");
String jobId = args[0];
RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
factoryBean.setServiceInterface(RouteAPI.class);
factoryBean.setServiceUrl(String.format("rmi://%s:%s/router",
System.getProperty("router.address", "localhost"),
System.getProperty("router.port", "1097")));
factoryBean.afterPropertiesSet();
RouteAPI router = (RouteAPI) factoryBean.getObject();
Object result = router.perform(jobId);
System.out.println("Got router response: " + result);
}
示例7: start
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@Override
public void start() {
this.running = true;
RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
factoryBean.setServiceInterface(RouteAPI.class);
factoryBean.setServiceUrl(String.format("rmi://localhost:%d/router", routerPort));
factoryBean.afterPropertiesSet();
RouteAPI routeAPI = (RouteAPI) factoryBean.getObject();
routeAPI.register(id, this.ip);
}
示例8: LauncherThroughPort
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
public LauncherThroughPort(String host, int port) {
this.host = host;
this.port = port;
RmiProxyFactoryBean factoryBean = new RmiProxyFactoryBean();
factoryBean.setServiceInterface(Executable.class);
String serviceUrl = String.format("rmi://%s:%d/%sLauncher",
this.host, this.port, System.getProperty("app.name"));
factoryBean.setServiceUrl(serviceUrl);
try {
factoryBean.afterPropertiesSet();
} catch (Exception e) {
throw new IllegalArgumentException("Can't lookup Executable Service at: " + serviceUrl);
}
remote = (Executable) factoryBean.getObject();
}
示例9: init
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
/**
*
*/
@PostConstruct
protected void init() {
try {
log.debug("Trying to reach server at URL : {}", PropertiesConstants.SERVER_URL);
final RmiProxyFactoryBean factory = new RmiProxyFactoryBean();
factory.setServiceInterface(IServer.class);
factory.setServiceUrl(PropertiesConstants.SERVER_URL);
factory.afterPropertiesSet();
server = (IServer) factory.getObject();
} catch (final Exception e) {
// do nothing, let server be null
}
}
示例10: importService
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
public static <T> T importService(Class<T> serviceInterface, int port, String serviceName, long timeout, TimeUnit timeunit) {
long timeoutMs = timeunit.toMillis(timeout);
String url = "rmi://localhost:" + port + "/" + serviceName;
log.debug("Creating RMI proxy for " + serviceInterface + " on " + url);
RmiProxyFactoryBean rmiFactory = new RmiProxyFactoryBean();
rmiFactory.setServiceInterface(serviceInterface);
rmiFactory.setServiceUrl(url);
rmiFactory.setRefreshStubOnConnectFailure(true);
rmiFactory.setLookupStubOnStartup(true);
boolean connected = false;
RuntimeException thrown = null;
long start = System.currentTimeMillis();
while (!connected && System.currentTimeMillis() - start < timeoutMs) {
try {
rmiFactory.afterPropertiesSet();
connected = true;
} catch (RuntimeException e) {
thrown = e;
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
throw new RuntimeException("Interrupted while waiting for service to be available", e1);
}
}
}
if (!connected) {
throw thrown;
}
T serviceProxy = (T) rmiFactory.getObject();
return serviceProxy;
}
示例11: stockService
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public RmiProxyFactoryBean stockService() {
RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
rmiProxy.setServiceUrl(rmiUrl + "/StockService");
rmiProxy.setServiceInterface(StockService.class);
return rmiProxy;
}
示例12: warehouseService
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public RmiProxyFactoryBean warehouseService() {
RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
rmiProxy.setServiceUrl(rmiUrl + "/WarehouseService");
rmiProxy.setServiceInterface(WarehouseService.class);
return rmiProxy;
}
示例13: stockKeeperService
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public RmiProxyFactoryBean stockKeeperService() {
RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
rmiProxy.setServiceUrl(rmiUrl + "/StockKeeperService");
rmiProxy.setServiceInterface(StockKeeperService.class);
return rmiProxy;
}
示例14: vendorService
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public RmiProxyFactoryBean vendorService() {
RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
rmiProxy.setServiceUrl(rmiUrl + "/VendorService");
rmiProxy.setServiceInterface(VendorService.class);
return rmiProxy;
}
示例15: customerService
import org.springframework.remoting.rmi.RmiProxyFactoryBean; //导入方法依赖的package包/类
@Bean
public RmiProxyFactoryBean customerService() {
RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
rmiProxy.setServiceUrl(rmiUrl + "/CustomerService");
rmiProxy.setServiceInterface(CustomerService.class);
return rmiProxy;
}