1 package com.trendmicro.grid.acl.client;
2
3 import com.trendmicro.grid.acl.Service;
4
5 import javax.annotation.PostConstruct;
6 import javax.annotation.Resource;
7
8
9
10
11
12
13
14 public abstract class AbstractClient<T extends Service> {
15
16 @Resource
17 protected SharedClientServiceContext serviceContext;
18
19 protected final Class<? extends T> serviceImplementation;
20 private Class<T> endpointInterface;
21
22 protected AbstractClient(Class<? extends T> serviceImplementation) {
23 this.serviceImplementation = serviceImplementation;
24 }
25
26 @PostConstruct
27 private void init() {
28 endpointInterface = serviceContext.addDefinition(serviceImplementation);
29 }
30
31 public Class<T> getEndpointInterface() {
32 return endpointInterface;
33 }
34
35 public Class<? extends T> getServiceImplementation() {
36 return serviceImplementation;
37 }
38
39 public T getLocalPort() {
40 return serviceContext.getPort(endpointInterface, null);
41 }
42
43 public T getRemotePort(String host) {
44 return serviceContext.getPort(endpointInterface, host);
45 }
46
47 public T getRemotePort(String host, int portNumber, boolean secure) {
48 return serviceContext.getPort(endpointInterface, host, portNumber, secure);
49 }
50 }