KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > jaxws > EndpointRegistryImpl


1 package org.objectweb.celtix.bus.jaxws;
2
3 import java.util.List JavaDoc;
4 import java.util.Vector JavaDoc;
5 import java.util.logging.Logger JavaDoc;
6
7 import javax.xml.ws.Endpoint;
8
9 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 JavaDoc LOG = LogUtils.getL7dLogger(EndpointRegistryImpl.class);
18     private final Bus bus;
19     private final List JavaDoc<EndpointImpl> endpoints;
20
21     public EndpointRegistryImpl(Bus b) {
22         bus = b;
23         endpoints = new Vector JavaDoc<EndpointImpl>();
24     }
25
26     public void registerEndpoint(Endpoint ep) {
27         assert ep instanceof EndpointImpl;
28         EndpointImpl epl = (EndpointImpl)ep;
29         assert epl.getBus() == bus;
30         if (endpoints.contains(epl)) {
31             LOG.warning("ENDPOINT_ALREADY_REGISTERED_MSG");
32         } else {
33             endpoints.add(epl);
34             if (bus != null) {
35                 bus.sendEvent(new ComponentCreatedEvent(epl));
36             }
37         }
38     }
39
40     public void unregisterEndpoint(Endpoint ep) {
41         if (ep.isPublished()) {
42             LOG.warning("ENDPOINT_ACTIVE_MSG");
43         }
44         endpoints.remove(ep);
45     }
46     
47     public void shutdown() {
48         for (Endpoint ep : endpoints) {
49             if (ep.isPublished()) {
50                 ep.stop();
51                 bus.sendEvent(new ComponentRemovedEvent((EndpointImpl)ep));
52             }
53         }
54         endpoints.clear();
55     }
56
57     public List JavaDoc<EndpointImpl> getEndpoints() {
58         return endpoints;
59     }
60
61 }
62
Popular Tags