示例#1
0
 @Bean
 public RmiProxyFactoryBean stockKeeperService() {
   RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
   rmiProxy.setServiceUrl(rmiUrl + "/StockKeeperService");
   rmiProxy.setServiceInterface(StockKeeperService.class);
   return rmiProxy;
 }
示例#2
0
 @Bean
 public RmiProxyFactoryBean warehouseService() {
   RmiProxyFactoryBean rmiProxy = new RmiProxyFactoryBean();
   rmiProxy.setServiceUrl(rmiUrl + "/WarehouseService");
   rmiProxy.setServiceInterface(WarehouseService.class);
   return rmiProxy;
 }
  /** {@inheritDoc} */
  public LocalSave createProxy(String user) {

    RmiProxyFactoryBean proxyFactory = new RmiProxyFactoryBean();
    proxyFactory.setServiceUrl("rmi://" + user + ":8989/LocalSave");
    proxyFactory.setServiceInterface(LocalSave.class);
    proxyFactory.afterPropertiesSet();
    return (LocalSave) proxyFactory.getObject();
  }
 @Bean
 public QuoteService quoteServiceBean() {
   RmiProxyFactoryBean factory = new RmiProxyFactoryBean();
   factory.setServiceUrl("rmi://localhost:1099/QuoteService");
   factory.setServiceInterface(QuoteService.class);
   factory.afterPropertiesSet();
   return (QuoteService) factory.getObject();
 }
  public RemoteNodeRegistration startProxy() {

    RmiProxyFactoryBean proxyFactory = new RmiProxyFactoryBean();
    proxyFactory.setServiceUrl(
        "rmi://" + props.getProperty("server.ip") + ":8989/RemoteNodeRegistration");
    proxyFactory.setServiceInterface(RemoteNodeRegistration.class);
    proxyFactory.afterPropertiesSet();

    return (RemoteNodeRegistration) proxyFactory.getObject();
  }
示例#6
0
 /** @return */
 private Object buildStub() {
   RmiProxyFactoryBean remoteStub = new RmiProxyFactoryBean();
   remoteStub.setLookupStubOnStartup(true);
   remoteStub.setRefreshStubOnConnectFailure(true);
   remoteStub.setCacheStub(true);
   remoteStub.setServiceUrl(serviceUrl);
   remoteStub.setServiceInterface(serviceInterface);
   remoteStub.afterPropertiesSet();
   return remoteStub.getObject();
 }
示例#7
0
  /** Connect to the remote servers. */
  private static List<LoaderServerProxy> connect(
      Set<String> rmiUrls, String username, String password) throws Exception {
    List<LoaderServerProxy> remoteServers = new ArrayList<LoaderServerProxy>(rmiUrls.size());
    for (String rmiUrl : rmiUrls) {
      try {
        // Ensure the RMI URL is consistent
        if (!rmiUrl.endsWith("/")) {
          rmiUrl += "/";
        }
        // Get the FileFolderServiceTransport
        FileFolderRemoteClient fileFolderRemote = new FileFolderRemoteClient(rmiUrl);
        // Get the LoaderServiceTransport
        RmiProxyFactoryBean loaderFactory = new RmiProxyFactoryBean();
        loaderFactory.setRefreshStubOnConnectFailure(true);
        loaderFactory.setServiceInterface(LoaderRemote.class);
        loaderFactory.setServiceUrl(rmiUrl + LoaderRemote.SERVICE_NAME);
        loaderFactory.afterPropertiesSet();
        LoaderRemote loaderRemote = (LoaderRemote) loaderFactory.getObject();

        // Authenticate
        String ticket = loaderRemote.authenticate(username, password);

        // Store the service references
        LoaderServerProxy remoteServer =
            new LoaderServerProxy(rmiUrl, ticket, fileFolderRemote, loaderRemote);
        remoteServers.add(remoteServer);
      } catch (Throwable e) {
        // Failed to connect.
        System.err.println(
            "\n"
                + "ERROR: Failed to establish connection to server: \n"
                + "   Server: "
                + rmiUrl
                + "\n"
                + "   Error:  "
                + e.getMessage());
        e.printStackTrace();
      }
    }
    // Check that there is at least one server
    if (remoteServers.size() == 0) {
      throw new LoaderClientException("No remote servers are available");
    }
    return remoteServers;
  }
示例#8
0
 // @Bean
 public RmiProxyFactoryBean rmiProxyFactoryBean() {
   RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
   rmiProxyFactoryBean.setServiceUrl("rmi://localhost/personService");
   rmiProxyFactoryBean.setServiceInterface(PersonService.class);
   return rmiProxyFactoryBean;
 }