KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > uddi4j > transport > TransportBase


1 /*
2  * The source code contained herein is licensed under the IBM Public License
3  * Version 1.0, which has been approved by the Open Source Initiative.
4  * Copyright (C) 2001, International Business Machines Corporation
5  * All Rights Reserved.
6  *
7  */

8
9 package org.uddi4j.transport;
10
11 import java.net.URL JavaDoc;
12
13 import javax.xml.parsers.DocumentBuilder JavaDoc;
14 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
15
16 import org.uddi4j.UDDIElement;
17 import org.w3c.dom.Element JavaDoc;
18
19 /**
20  * Partial implementation of Transport interface.
21  * This class provides a default implementation of the
22  * send UDDIElement method. This converts the UDDIElement
23  * to a DOM element and invokes the send DOM Element
24  * method.
25  * In the future, if the data representation is not
26  * DOM based, transports will need to implement their
27  * own send UDDIElement methods.
28  *
29  * @author David Melgar (dmelgar@us.ibm.com)
30  */

31 abstract public class TransportBase implements Transport {
32
33     /**
34      * Sends a UDDIElement to URL.
35      *
36      * @param el UDDIElement to send
37      * @param url Destination URL
38      * @return An element representing a XML DOM tree containing the UDDI response.
39      * @exception TransportException
40      * Thrown if a problem occurs during transmission
41      */

42     public Element send(UDDIElement el, URL JavaDoc url) throws TransportException {
43         Element base = null;
44         try {
45             DocumentBuilder JavaDoc docBuilder =
46                 DocumentBuilderFactory.newInstance().newDocumentBuilder();
47             base = docBuilder.newDocument().createElement("tmp");
48         } catch (Exception JavaDoc e) {
49             e.printStackTrace();
50         }
51
52         el.saveToXML(base);
53         return send((Element) base.getFirstChild(), url);
54     }
55
56     public boolean logEnabled() {
57         boolean logEnabled = false;
58         String JavaDoc value = System.getProperty("org.uddi4j.logEnabled");
59         if (value != null && value.equalsIgnoreCase("true")) {
60             logEnabled = true;
61         }
62         return logEnabled;
63     }
64
65 }
66
Popular Tags