KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > jbi > serviceengine > core > EndpointRegistry


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.jbi.serviceengine.core;
24 import java.util.Hashtable JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.Map JavaDoc;
27 import javax.xml.namespace.QName JavaDoc;
28
29 /**
30  * Registry of all ServiceEndpoints, provides mapping between EndPointName and
31  * ServiceEngineEndpoint.
32  * @author Manisha Umbarje
33  */

34 public class EndpointRegistry {
35     
36     /** Service QName to table of endpoints
37      * The key being the service name and value being table of ServiceEngineEndpoints
38      */

39     private Hashtable JavaDoc endpoints;
40     
41     private static EndpointRegistry store;
42     
43     /** Creates a new instance of ServiceEndPointRegistry */
44     private EndpointRegistry() {
45         endpoints = new Hashtable JavaDoc();
46     }
47     
48     public static EndpointRegistry getInstance() {
49         if(store == null)
50             store = new EndpointRegistry();
51         return store;
52     }
53     
54     
55     
56     /**
57      * Adds a ServiceEndpoint to the store
58      */

59     public void put(QName JavaDoc service, String JavaDoc endpointName, ServiceEngineEndpoint endpoint) {
60         Map JavaDoc map= (Map JavaDoc)endpoints.get(service);
61         if(map == null) {
62             map = new Hashtable JavaDoc();
63             endpoints.put(service, map);
64         }
65         map.put(endpointName, endpoint);
66         
67     }
68     
69     /**
70      *
71      */

72     public ServiceEngineEndpoint get(QName JavaDoc service, String JavaDoc endpointName) {
73         
74         Map JavaDoc map= (Map JavaDoc)endpoints.get(service);
75         if(map != null)
76         return (ServiceEngineEndpoint)map.get(endpointName);
77         else
78             return null;
79         
80     }
81     
82     /**
83      * Removes ServiceEndpoint from the store
84      */

85     public void delete(QName JavaDoc service, String JavaDoc endpointName) {
86         
87         Map JavaDoc map= (Map JavaDoc)endpoints.get(service);
88         map.remove(endpointName);
89         
90     }
91     
92     public Iterator JavaDoc<ServiceEngineEndpoint> list() {
93         return endpoints.values().iterator();
94     }
95 }
96
Popular Tags