001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)JMSBindingResolver.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.jms;
030:
031: import java.util.Hashtable;
032:
033: import javax.jbi.servicedesc.ServiceEndpoint;
034:
035: import org.w3c.dom.Document;
036:
037: import javax.xml.parsers.DocumentBuilderFactory;
038:
039: /**
040: * Resolver implementation for the JMS binding.
041: *
042: * @author Sun Microsystems Inc.
043: */
044: public class JMSBindingResolver {
045: /**
046: * Description cache.
047: */
048: private Hashtable mDescriptorCache;
049:
050: /**
051: * Creates a new JMSBindingResolver object.
052: */
053: public JMSBindingResolver() {
054: mDescriptorCache = new Hashtable();
055: }
056:
057: /**
058: * Returns the service description.
059: *
060: * @param ef enpoint reference.
061: *
062: * @return document object.
063: */
064: public Document getServiceDescription(ServiceEndpoint ef) {
065: try {
066: Document df = (Document) mDescriptorCache.get(ef
067: .getServiceName().toString()
068: + ef.getEndpointName());
069:
070: /*org.w3c.dom.Document d =
071: DocumentBuilderFactory.newInstance().newDocumentBuilder()
072: .newDocument();
073: Node n = d.importNode(df, true);
074: d.appendChild(n);
075: */
076: return df;
077: } catch (Exception e) {
078: return null;
079: }
080: }
081:
082: /**
083: * Adds an endpoint document.
084: *
085: * @param epname endpoint name.
086: * @param filename wsdl file.
087: */
088: public void addEndpointDoc(String epname, String filename) {
089: if ((epname != null) && (filename != null)) {
090: try {
091: org.w3c.dom.Document d = DocumentBuilderFactory
092: .newInstance().newDocumentBuilder().parse(
093: filename);
094: mDescriptorCache.put(epname, d);
095: } catch (Exception e) {
096: e.printStackTrace();
097: }
098: }
099: }
100:
101: /**
102: * Adds an endpoint document.
103: *
104: * @param epname endpoint name.
105: * @param df document fragment.
106: */
107: public void addEndpointDoc(String epname, Document df) {
108: if ((epname != null) && (df != null)) {
109: try {
110: mDescriptorCache.put(epname, df);
111: } catch (Exception e) {
112: e.printStackTrace();
113: }
114: }
115: }
116:
117: /**
118: * Clears the cache.
119: */
120: public void clearCache() {
121: mDescriptorCache = new Hashtable();
122: }
123: }
|