title: Passing RMI Bean to custom class variable
body: <p>I am trying to mess up with RMI and I've got some problems. I want to use remote method in my custom class but I don't know how to pass bean to class variable. The RMI connection itself seems to work fine. My code is:</p>
  
  <pre><code>//Application start class
  
  @Configuration
  @ComponentScan
  @EnableAutoConfiguration
  public class Application {
  
      @Bean
      RmiProxyFactoryBean searchService() {
          RmiProxyFactoryBean rmiSearchServiceBean = new RmiProxyFactoryBean();
          rmiSearchServiceBean.setServiceUrl("rmi://127.0.0.1:1199/searchService");
          rmiSearchServiceBean.setServiceInterface(SearchService.class);
          return rmiSearchServiceBean;
      }
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
  }
  
  
  @Component
  public class RmiSearchContext {
  
      @Bean
      RmiProxyFactoryBean searchService() {
          RmiProxyFactoryBean rmiSearchServiceBean = new RmiProxyFactoryBean();
          rmiSearchServiceBean.setServiceUrl("rmi://127.0.0.1:1199/searchService");
          rmiSearchServiceBean.setServiceInterface(SearchService.class);
          return rmiSearchServiceBean;
      }
  
  }
  
  
  //My custom class where I want to make remote method call
  @Component
  public class BasicSearchQuery {
  
      private long id;
      private String content;
      //This is a variable for the Bean
      @Autowared
      private SearchService searchService; 
  
      public long getId() {
          return this.id;
      }
  
      public void setId(long id) {
          this.id = id;
      }
  
      public String getContent() {
          return this.content;
      }
  
      public void setContent(String content) {
          this.content = content;
      }
  
      public SearchService getSearchService() {
          return this.searchService;
      }
  
      public void  setSearchService(SearchService searchService) {
          this.searchService = searchService;
      }
  
      public List&lt;BasicSearchResults&gt; execute() {
          // Here i want to do a remote method call
          return this.searchService.getSearchResults(this.id, this.content));
      }
  
  }
  </code></pre>
  
  <p>Is there any way to do that without using context.xml files? </p>