1
|
package eu.dnetlib.enabling.is.sn;
|
2
|
|
3
|
import javax.xml.ws.WebServiceFeature;
|
4
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
5
|
|
6
|
import org.apache.commons.logging.Log;
|
7
|
import org.apache.commons.logging.LogFactory;
|
8
|
import org.springframework.beans.factory.annotation.Required;
|
9
|
|
10
|
import eu.dnetlib.common.rmi.BaseService;
|
11
|
|
12
|
/**
|
13
|
* This is a basic notification invoker which calls dnet1.0 compatible notify() methods.
|
14
|
*
|
15
|
* @author marko
|
16
|
*
|
17
|
*/
|
18
|
public class NotificationInvokerImpl implements NotificationInvoker {
|
19
|
/**
|
20
|
* logger.
|
21
|
*/
|
22
|
private static final Log log = LogFactory.getLog(NotificationInvokerImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
|
23
|
|
24
|
/**
|
25
|
* invocation logger.
|
26
|
*/
|
27
|
private NotificationInvocationLogger invocationLogger;
|
28
|
|
29
|
/**
|
30
|
* {@inheritDoc}
|
31
|
*
|
32
|
* @see eu.dnetlib.enabling.is.sn.NotificationInvoker#send(javax.xml.ws.wsaddressing.W3CEndpointReference,
|
33
|
* eu.dnetlib.enabling.is.sn.NotificationMessage, int)
|
34
|
*/
|
35
|
@Override
|
36
|
public void send(final W3CEndpointReference destination, final NotificationMessage message, final int timeout) {
|
37
|
final BaseService service = destination.getPort(BaseService.class, new WebServiceFeature[] {});
|
38
|
log.info("phisically sending notification: " + message.getTopic());
|
39
|
|
40
|
final NotificationInvocationLogger.Entry logEntry = invocationLogger.startLogging(destination, message);
|
41
|
logEntry.ongoing();
|
42
|
|
43
|
try {
|
44
|
service.notify(message.getSubscriptionId(), message.getTopic(), message.getResourceId(), message.getBody());
|
45
|
logEntry.success();
|
46
|
} catch (final Throwable e) { // NOPMD
|
47
|
log.debug("notification error", e);
|
48
|
logEntry.failure(e);
|
49
|
}
|
50
|
}
|
51
|
|
52
|
public NotificationInvocationLogger getInvocationLogger() {
|
53
|
return invocationLogger;
|
54
|
}
|
55
|
|
56
|
@Required
|
57
|
public void setInvocationLogger(final NotificationInvocationLogger invocationLogger) {
|
58
|
this.invocationLogger = invocationLogger;
|
59
|
}
|
60
|
|
61
|
}
|