KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > jbi > serviceengine > bridge > RuntimeEndpointInfoRegistryImpl


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.bridge;
24 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException;
25 import com.sun.enterprise.jbi.serviceengine.core.EndpointRegistry;
26 import com.sun.enterprise.jbi.serviceengine.core.ServiceEngineEndpoint;
27 import java.util.Hashtable JavaDoc;
28 import java.util.Map JavaDoc;
29 import javax.xml.namespace.QName JavaDoc;
30
31
32
33 /**
34  * Endpoint Name to JAXWS RuntimeEndpointInfo mapping
35  * @author Manisha Umbarje
36  */

37 public class RuntimeEndpointInfoRegistryImpl implements
38         RuntimeEndpointInfoRegistry {
39     
40     private Hashtable JavaDoc store;
41     private static RuntimeEndpointInfoRegistry registry = new RuntimeEndpointInfoRegistryImpl();
42     private EndpointRegistry endpointRegistry = null;
43
44     /** Creates a new instance of RuntimeEndpointInfoRegistry */
45     private RuntimeEndpointInfoRegistryImpl() {
46         store = new Hashtable JavaDoc(5);
47         endpointRegistry = EndpointRegistry.getInstance();
48     }
49     
50     public static RuntimeEndpointInfoRegistry getInstance() {
51         return registry;
52     }
53     
54     public Object JavaDoc getRuntimeEndpointInfo(QName JavaDoc service, String JavaDoc endpoint)
55     throws ServiceEngineException {
56         Object JavaDoc runtimeInfo = null;
57         ServiceEngineEndpoint endpt = null;
58         Map JavaDoc runtimeEndpointInfoTable = null;
59         endpt = endpointRegistry.get(service, endpoint);
60       
61         if(endpt != null) {
62             runtimeEndpointInfoTable = (Map JavaDoc)store.get(service);
63             if(runtimeEndpointInfoTable == null) {
64                 runtimeEndpointInfoTable = new Hashtable JavaDoc();
65                 store.put(service, runtimeEndpointInfoTable);
66             }
67             
68             runtimeInfo = runtimeEndpointInfoTable.get(endpoint);
69       
70             if(runtimeInfo == null) {
71       
72                 if(endpt.isJAXWSEndpoint())
73                     runtimeInfo = JAXWSRuntimeEndpointHelper.populateRuntimeInfo(endpt);
74                 else
75                     runtimeInfo = JAXRPCRuntimeEndpointHelper.populateRuntimeInfo(endpt);
76                 
77       
78                 runtimeEndpointInfoTable.put(endpoint, runtimeInfo);
79             } else {
80                 if(endpt.isJAXWSEndpoint()) {
81             if (endpt.isImplementedByEJB())
82                         runtimeInfo = JAXWSRuntimeEndpointHelper.populateRuntimeInfo(endpt);
83                     else
84                 JAXWSRuntimeEndpointHelper.setMessageContext((com.sun.xml.ws.spi.runtime.RuntimeEndpointInfo)runtimeInfo);
85                 }
86             }
87             return runtimeInfo;
88         }
89         throw new ServiceEngineException("Endpoint " + endpoint + "not deployed in JBI");
90     }
91     
92     public void deleteRuntimeEndpointInfo(QName JavaDoc service, String JavaDoc endpoint) {
93         
94         if(endpoint != null) {
95             Map JavaDoc runtimeInfoTable = (Map JavaDoc)store.get(service);
96             
97             if((runtimeInfoTable != null) &&
98                     (runtimeInfoTable.get(endpoint) != null))
99                 runtimeInfoTable.remove(endpoint);
100         }
101     }
102
103     public void releaseEndpoint(QName JavaDoc service, String JavaDoc endpointName) {
104         ServiceEngineEndpoint endpt = endpointRegistry.get(service, endpointName);
105         if(endpt!=null && endpt.isImplementedByEJB())
106             JAXWSRuntimeEndpointHelper.releaseEjbEndpoint(endpt);
107         
108     }
109 }
110
Popular Tags