Revision 41977
Added by Sandro La Bruzzo almost 8 years ago
ServiceRegistrator.java | ||
---|---|---|
9 | 9 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
10 | 10 |
|
11 | 11 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
12 |
import eu.dnetlib.enabling.tools.AbstractBaseService; |
|
12 | 13 |
import eu.dnetlib.enabling.tools.BaseServiceUtils; |
13 | 14 |
import eu.dnetlib.enabling.tools.HNMLocator; |
14 | 15 |
import eu.dnetlib.enabling.tools.NullHNMLocator; |
... | ... | |
54 | 55 |
*/ |
55 | 56 |
private HNMLocator hnmLocator = new NullHNMLocator(); |
56 | 57 |
|
57 |
/** |
|
58 |
* Key-value pairs with service specific parameters which will appear in service profile. |
|
59 |
*/ |
|
60 |
private Map<String, String> serviceProperties = new HashMap<>(); |
|
61 | 58 |
|
62 |
/** |
|
63 |
* Key-value pairs [name - endpoint] of extra protocols available in service profiles. |
|
64 |
*/ |
|
65 |
private Map<String, String> extraProtocols = new HashMap<>(); |
|
66 | 59 |
|
67 | 60 |
public String registerService(final BaseService service, final Endpoint endpoint) throws Exception { |
68 |
return registerService(BaseServiceUtils.getServiceName(service.getClass()), this.eprBuilder.getEndpointReference(endpoint)); |
|
61 |
if (service instanceof AbstractBaseService) { |
|
62 |
AbstractBaseService abs = (AbstractBaseService) service; |
|
63 |
return registerService(BaseServiceUtils.getServiceName(service.getClass()), this.eprBuilder.getEndpointReference(endpoint), |
|
64 |
abs.getServiceProperties(), abs.getExtraProtocols()); |
|
65 |
} |
|
66 |
return registerService(BaseServiceUtils.getServiceName(service.getClass()), this.eprBuilder.getEndpointReference(endpoint), new HashMap<>(), |
|
67 |
new HashMap<>()); |
|
69 | 68 |
} |
70 | 69 |
|
71 |
private String registerService(final String serviceName, final W3CEndpointReference epr) throws Exception { |
|
70 |
private String registerService(final String serviceName, final W3CEndpointReference epr, final Map<String, String> serviceProperties, |
|
71 |
final Map<String, String> extraProtocols) throws Exception { |
|
72 | 72 |
|
73 | 73 |
ensureSchemaExists(serviceName); |
74 | 74 |
|
... | ... | |
94 | 94 |
templ.setAttribute("resourceType", resourceType); |
95 | 95 |
templ.setAttribute("serviceName", serviceName); |
96 | 96 |
templ.setAttribute("address", address); |
97 |
templ.setAttribute("protocols", getExtraProtocols());
|
|
97 |
templ.setAttribute("protocols", extraProtocols);
|
|
98 | 98 |
templ.setAttribute("parentId", hnmId); |
99 |
templ.setAttribute("properties", this.serviceProperties);
|
|
99 |
templ.setAttribute("properties", serviceProperties); |
|
100 | 100 |
|
101 | 101 |
log.debug("template: " + templ.toString()); |
102 | 102 |
|
... | ... | |
171 | 171 |
this.hnmLocator = hnmLocator; |
172 | 172 |
} |
173 | 173 |
|
174 |
public Map<String, String> getServiceProperties() { |
|
175 |
return this.serviceProperties; |
|
176 |
} |
|
177 |
|
|
178 |
public void setServiceProperties(final Map<String, String> serviceProperties) { |
|
179 |
this.serviceProperties = serviceProperties; |
|
180 |
} |
|
181 |
|
|
182 |
public Map<String, String> getExtraProtocols() { |
|
183 |
return this.extraProtocols; |
|
184 |
} |
|
185 |
|
|
186 |
public void setExtraProtocols(final Map<String, String> extraProtocols) { |
|
187 |
this.extraProtocols = extraProtocols; |
|
188 |
} |
|
189 |
|
|
190 | 174 |
public UniqueServiceLocator getServiceLocator() { |
191 | 175 |
return this.serviceLocator; |
192 | 176 |
} |
Also available in: Unified diff
Added dnet-data-provision