1
|
package eu.dnetlib.common.services.locators;
|
2
|
|
3
|
import java.util.HashMap;
|
4
|
import java.util.Map;
|
5
|
|
6
|
import javax.xml.ws.WebServiceFeature;
|
7
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
8
|
import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
|
9
|
|
10
|
import eu.dnetlib.rmi.soap.BaseService;
|
11
|
|
12
|
/**
|
13
|
* This bean packages the minimum information for describing a service running instance.
|
14
|
*/
|
15
|
public class ServiceRunningInstance {
|
16
|
|
17
|
private String serviceId;
|
18
|
private String url;
|
19
|
private BaseService localService;
|
20
|
private int usedDiskSpace = 0;
|
21
|
private int handledDatastructures = 0;
|
22
|
private Map<String, String> serviceProperties = new HashMap<String, String>();
|
23
|
|
24
|
public ServiceRunningInstance() {}
|
25
|
|
26
|
public ServiceRunningInstance(final String serviceId, final String url) {
|
27
|
this.serviceId = serviceId;
|
28
|
this.url = url;
|
29
|
}
|
30
|
|
31
|
public ServiceRunningInstance(final String serviceId, final String url, final BaseService localService, final int usedDiskSpace,
|
32
|
final int handledDatastructures, final Map<String, String> serviceProperties) {
|
33
|
this.serviceId = serviceId;
|
34
|
this.url = url;
|
35
|
this.localService = localService;
|
36
|
this.usedDiskSpace = usedDiskSpace;
|
37
|
this.handledDatastructures = handledDatastructures;
|
38
|
this.serviceProperties = serviceProperties;
|
39
|
}
|
40
|
|
41
|
public boolean isLocal() {
|
42
|
return localService != null;
|
43
|
}
|
44
|
|
45
|
synchronized public <T extends BaseService> T obtainClient(final Class<T> clazz) {
|
46
|
if (isLocal() && clazz.isInstance(localService)) {
|
47
|
return clazz.cast(localService);
|
48
|
} else {
|
49
|
final W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
|
50
|
builder.address(url);
|
51
|
builder.wsdlDocumentLocation(url + "?wsdl");
|
52
|
final W3CEndpointReference epr = builder.build();
|
53
|
return epr.getPort(clazz, new WebServiceFeature[] {});
|
54
|
}
|
55
|
}
|
56
|
|
57
|
public String getServiceId() {
|
58
|
return serviceId;
|
59
|
}
|
60
|
|
61
|
public void setServiceId(final String serviceId) {
|
62
|
this.serviceId = serviceId;
|
63
|
}
|
64
|
|
65
|
public String getUrl() {
|
66
|
return url;
|
67
|
}
|
68
|
|
69
|
public void setUrl(final String url) {
|
70
|
this.url = url;
|
71
|
}
|
72
|
|
73
|
public BaseService getLocalService() {
|
74
|
return localService;
|
75
|
}
|
76
|
|
77
|
public void setLocalService(final BaseService localService) {
|
78
|
this.localService = localService;
|
79
|
}
|
80
|
|
81
|
public Map<String, String> getServiceProperties() {
|
82
|
return serviceProperties;
|
83
|
}
|
84
|
|
85
|
public void setServiceProperties(final Map<String, String> serviceProperties) {
|
86
|
this.serviceProperties = serviceProperties;
|
87
|
}
|
88
|
|
89
|
public int getUsedDiskSpace() {
|
90
|
return usedDiskSpace;
|
91
|
}
|
92
|
|
93
|
public void setUsedDiskSpace(final int usedDiskSpace) {
|
94
|
this.usedDiskSpace = usedDiskSpace;
|
95
|
}
|
96
|
|
97
|
public int getHandledDatastructures() {
|
98
|
return handledDatastructures;
|
99
|
}
|
100
|
|
101
|
public void setHandledDatastructures(final int handledDatastructures) {
|
102
|
this.handledDatastructures = handledDatastructures;
|
103
|
}
|
104
|
|
105
|
}
|