public static class WSNServiceUnit extends ServiceUnit {
public void start() throws Exception {
List<Endpoint> activated = new ArrayList<Endpoint>();
try {
for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
Endpoint endpoint = (Endpoint) iter.next();
if (endpoint instanceof WSNPullPointEndpoint) {
endpoint.activate();
activated.add(endpoint);
}
}
for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
Endpoint endpoint = (Endpoint) iter.next();
if (endpoint instanceof WSNSubscriptionEndpoint) {
endpoint.activate();
activated.add(endpoint);
}
}
this.status = LifeCycleMBean.STARTED;
} catch (Exception e) {
// Deactivate activated endpoints
for (Endpoint endpoint : activated) {
try {
endpoint.deactivate();
} catch (Exception e2) {
// do nothing
}
}
throw e;