たとえば、MyClassクライアントをSpring Beanとして指定し、必要な場所に注入することができます。RestEasyプロキシクライアントはApacheCommonsHttp Clientの下で使用し、デフォルトではスレッドセーフではないSimpleHttpConnectionManagerを使用するため、スレッドセーフに注意してください。
マルチスレッド環境(サーブレットコンテナで実行)でこれを実現するには、次のようにします。
MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
HttpClient httpClient = new HttpClient(connectionManager);
// Only needed if you have a authentication
Credentials credentials = new UsernamePasswordCredentials(username, password);
httpClient.getState().setCredentials(AuthScope.ANY, credentials);
httpClient.getParams().setAuthenticationPreemptive(true);
clientExecutor = new ApacheHttpClientExecutor(httpClient);
MyClass client = ProxyFactory.create(MyClass.class, "http://localhost:8080", clientExecutor);