1
|
package eu.dnetlib.enabling.hcm.sn;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import javax.annotation.PostConstruct;
|
6
|
import javax.annotation.Resource;
|
7
|
import javax.xml.ws.Endpoint;
|
8
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
9
|
|
10
|
import org.apache.commons.logging.Log;
|
11
|
import org.apache.commons.logging.LogFactory;
|
12
|
import org.springframework.beans.factory.annotation.Required;
|
13
|
|
14
|
import eu.dnetlib.enabling.actions.SubscriptionAction;
|
15
|
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
|
16
|
import eu.dnetlib.enabling.is.sn.rmi.ISSNService;
|
17
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
18
|
import eu.dnetlib.soap.EndpointReferenceBuilder;
|
19
|
|
20
|
/**
|
21
|
* This component takes care of subscribing the SubscriptionAction(s) to interesting events.
|
22
|
*
|
23
|
* @author claudio
|
24
|
*
|
25
|
*/
|
26
|
public class HCMSubscriberImpl implements HCMSubscriber {
|
27
|
|
28
|
/**
|
29
|
* logger.
|
30
|
*/
|
31
|
private static final Log log = LogFactory.getLog(HCMSubscriberImpl.class);
|
32
|
|
33
|
/**
|
34
|
* notification endpoint (normally the msro service).
|
35
|
*/
|
36
|
private Endpoint endpoint;
|
37
|
|
38
|
/**
|
39
|
* service locator.
|
40
|
*/
|
41
|
private UniqueServiceLocator serviceLocator;
|
42
|
|
43
|
/**
|
44
|
* injected EPR builder.
|
45
|
*/
|
46
|
@Resource(name = "jaxwsEndpointReferenceBuilder")
|
47
|
private EndpointReferenceBuilder<Endpoint> eprBuilder;
|
48
|
|
49
|
/**
|
50
|
* subscription actions.
|
51
|
*/
|
52
|
private List<SubscriptionAction> actions;
|
53
|
|
54
|
@PostConstruct
|
55
|
public void printList() {
|
56
|
log.info(getActions());
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* {@inheritDoc}
|
61
|
*
|
62
|
* @throws ISSNException
|
63
|
* could happen
|
64
|
* @see eu.dnetlib.enabling.hcm.sn.HCMSubscriber#subscribeAll()
|
65
|
*/
|
66
|
@Override
|
67
|
public void subscribeAll() throws ISSNException {
|
68
|
|
69
|
final W3CEndpointReference endpointReference = eprBuilder
|
70
|
.getEndpointReference(getEndpoint());
|
71
|
|
72
|
if (getActions() != null) {
|
73
|
for (final SubscriptionAction action : getActions()) {
|
74
|
log.info("dynamically subscribing to "
|
75
|
+ action.getTopicExpression());
|
76
|
serviceLocator.getService(ISSNService.class, true).subscribe(endpointReference,
|
77
|
action.getTopicExpression(), 0);
|
78
|
}
|
79
|
}
|
80
|
}
|
81
|
|
82
|
public void setEndpoint(final Endpoint endpoint) {
|
83
|
this.endpoint = endpoint;
|
84
|
}
|
85
|
|
86
|
public Endpoint getEndpoint() {
|
87
|
return endpoint;
|
88
|
}
|
89
|
|
90
|
public void setEprBuilder(
|
91
|
final EndpointReferenceBuilder<Endpoint> eprBuilder) {
|
92
|
this.eprBuilder = eprBuilder;
|
93
|
}
|
94
|
|
95
|
public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
|
96
|
return eprBuilder;
|
97
|
}
|
98
|
|
99
|
public List<SubscriptionAction> getActions() {
|
100
|
return actions;
|
101
|
}
|
102
|
|
103
|
@Required
|
104
|
public void setActions(final List<SubscriptionAction> actions) {
|
105
|
this.actions = actions;
|
106
|
}
|
107
|
|
108
|
public UniqueServiceLocator getServiceLocator() {
|
109
|
return serviceLocator;
|
110
|
}
|
111
|
|
112
|
@Required
|
113
|
public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
|
114
|
this.serviceLocator = serviceLocator;
|
115
|
}
|
116
|
|
117
|
}
|