01: package org.objectweb.celtix.bus.jaxws;
02:
03: import java.util.List;
04: import java.util.Vector;
05: import java.util.logging.Logger;
06:
07: import javax.xml.ws.Endpoint;
08:
09: import org.objectweb.celtix.Bus;
10: import org.objectweb.celtix.bus.busimpl.ComponentCreatedEvent;
11: import org.objectweb.celtix.bus.busimpl.ComponentRemovedEvent;
12: import org.objectweb.celtix.common.logging.LogUtils;
13: import org.objectweb.celtix.jaxws.EndpointRegistry;
14:
15: public class EndpointRegistryImpl implements EndpointRegistry {
16:
17: private static final Logger LOG = LogUtils
18: .getL7dLogger(EndpointRegistryImpl.class);
19: private final Bus bus;
20: private final List<EndpointImpl> endpoints;
21:
22: public EndpointRegistryImpl(Bus b) {
23: bus = b;
24: endpoints = new Vector<EndpointImpl>();
25: }
26:
27: public void registerEndpoint(Endpoint ep) {
28: assert ep instanceof EndpointImpl;
29: EndpointImpl epl = (EndpointImpl) ep;
30: assert epl.getBus() == bus;
31: if (endpoints.contains(epl)) {
32: LOG.warning("ENDPOINT_ALREADY_REGISTERED_MSG");
33: } else {
34: endpoints.add(epl);
35: if (bus != null) {
36: bus.sendEvent(new ComponentCreatedEvent(epl));
37: }
38: }
39: }
40:
41: public void unregisterEndpoint(Endpoint ep) {
42: if (ep.isPublished()) {
43: LOG.warning("ENDPOINT_ACTIVE_MSG");
44: }
45: endpoints.remove(ep);
46: }
47:
48: public void shutdown() {
49: for (Endpoint ep : endpoints) {
50: if (ep.isPublished()) {
51: ep.stop();
52: bus.sendEvent(new ComponentRemovedEvent(
53: (EndpointImpl) ep));
54: }
55: }
56: endpoints.clear();
57: }
58:
59: public List<EndpointImpl> getEndpoints() {
60: return endpoints;
61: }
62:
63: }
|