1
|
package eu.dnetlib.enabling.tools;
|
2
|
|
3
|
import java.util.HashMap;
|
4
|
import java.util.Map;
|
5
|
import javax.jws.WebService;
|
6
|
|
7
|
import eu.dnetlib.rmi.common.BaseService;
|
8
|
import org.apache.commons.logging.Log;
|
9
|
import org.apache.commons.logging.LogFactory;
|
10
|
import org.springframework.context.Lifecycle;
|
11
|
|
12
|
/**
|
13
|
* This class contains default definition for BaseService contract and basic service lifecycle.
|
14
|
*
|
15
|
* TODO: split BaseService contract implementation from lifecycle and other helper method
|
16
|
*
|
17
|
* @author marko
|
18
|
*
|
19
|
*/
|
20
|
@WebService(targetNamespace = "http://services.dnetlib.eu/")
|
21
|
public abstract class AbstractBaseService implements BaseService, Lifecycle {
|
22
|
|
23
|
|
24
|
/**
|
25
|
* logger.
|
26
|
*/
|
27
|
private static final Log log = LogFactory // NOPMD by marko on 11/24/08 5:02 PM
|
28
|
.getLog(AbstractBaseService.class);
|
29
|
|
30
|
private boolean started = false;
|
31
|
|
32
|
private String profileId;
|
33
|
|
34
|
/**
|
35
|
* Key-value pairs with service specific parameters which will appear in service profile.
|
36
|
*/
|
37
|
private Map<String, String> serviceProperties = new HashMap<>();
|
38
|
|
39
|
/**
|
40
|
* Key-value pairs [name - endpoint] of extra protocols available in service profiles.
|
41
|
*/
|
42
|
private Map<String, String> extraProtocols = new HashMap<>();
|
43
|
|
44
|
protected String getServiceName() {
|
45
|
return BaseServiceUtils.getServiceName(getClass());
|
46
|
}
|
47
|
|
48
|
|
49
|
/**
|
50
|
* {@inheritDoc}
|
51
|
*
|
52
|
* @see eu.dnetlib.rmi.common.BaseService#identify()
|
53
|
*/
|
54
|
@Override
|
55
|
public String identify() {
|
56
|
return getClass().getName();
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* {@inheritDoc}
|
61
|
*
|
62
|
* @see eu.dnetlib.rmi.common.BaseService#notify(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
63
|
*/
|
64
|
@Override
|
65
|
public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
|
66
|
log.debug("got notification: " + topic + ", profile: " + isId + ", body: " + message);
|
67
|
}
|
68
|
|
69
|
public void start() {
|
70
|
log.info("Starting service " + identify());
|
71
|
if (this.started) {
|
72
|
log.warn("Service " + this + "already started, check bean initializations!");
|
73
|
}
|
74
|
this.started = true;
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* {@inheritDoc}
|
79
|
*
|
80
|
* @see org.springframework.context.Lifecycle#isRunning()
|
81
|
*/
|
82
|
@Override
|
83
|
public boolean isRunning() {
|
84
|
log.debug("called isRunning " + this);
|
85
|
return false;
|
86
|
}
|
87
|
|
88
|
/**
|
89
|
* {@inheritDoc}
|
90
|
*
|
91
|
* @see org.springframework.context.Lifecycle#stop()
|
92
|
*/
|
93
|
@Override
|
94
|
public void stop() {
|
95
|
log.info("Stopping service " + this);
|
96
|
}
|
97
|
|
98
|
@Override
|
99
|
public String getProfileId() {
|
100
|
return this.profileId;
|
101
|
}
|
102
|
|
103
|
public void setProfileId(final String profileId) {
|
104
|
this.profileId = profileId;
|
105
|
}
|
106
|
|
107
|
public Map<String, String> getServiceProperties() {
|
108
|
return serviceProperties;
|
109
|
}
|
110
|
|
111
|
public void setServiceProperties(final Map<String, String> serviceProperties) {
|
112
|
this.serviceProperties = serviceProperties;
|
113
|
}
|
114
|
|
115
|
public Map<String, String> getExtraProtocols() {
|
116
|
return extraProtocols;
|
117
|
}
|
118
|
|
119
|
public void setExtraProtocols(final Map<String, String> extraProtocols) {
|
120
|
this.extraProtocols = extraProtocols;
|
121
|
}
|
122
|
}
|