KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_ws > wsgen > ddmodifier > WsClientDDModifier


1 /**
2  * JOnAS : Java(TM) OpenSource Application Server
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA
18  *
19  * Initial Developer : Guillaume Sauthier
20  * --------------------------------------------------------------------------
21  * $Id: WsClientDDModifier.java,v 1.4 2004/10/11 13:16:15 benoitf Exp $
22  * --------------------------------------------------------------------------
23  */

24
25 package org.objectweb.jonas_ws.wsgen.ddmodifier;
26
27 import org.w3c.dom.Document JavaDoc;
28 import org.w3c.dom.Element JavaDoc;
29
30 import org.objectweb.jonas_lib.genbase.utils.XMLUtils;
31
32
33 /**
34  * Modify a Web Services Client Deployment Desc Element. Wrapper around a
35  * <code>jonas-service-ref</code> element
36  * @author Guillaume Sauthier
37  */

38 public class WsClientDDModifier extends DeploymentDescModifier {
39
40     /**
41      * jonas-init-param Element name
42      */

43     private static final String JavaDoc JONAS_INIT_PARAM = "jonas-init-param";
44
45     /**
46      * param-name Element name
47      */

48     private static final String JavaDoc PARAM_NAME = "param-name";
49
50     /**
51      * param-value Element name
52      */

53     private static final String JavaDoc PARAM_VALUE = "param-value";
54
55     /**
56      * Creates a new WsClientDDModifier where element is a
57      * <code>jonas-service-ref</code> XML Node.
58      * @param name service-ref-name value
59      * @param doc document base for Element creation
60      * @param base base element for searching jonas-service-ref
61      */

62     public WsClientDDModifier(String JavaDoc name, Document JavaDoc doc, Element JavaDoc base) {
63         super(XMLUtils.getJonasServiceRef(base, name), doc, base);
64     }
65
66     /**
67      * Add a jonas-init-param in jonas-service-ref.
68      * @param name param name
69      * @param value param value
70      */

71     public void addJonasInitParam(String JavaDoc name, String JavaDoc value) {
72         Element JavaDoc jip = newJOnASElement(JONAS_INIT_PARAM);
73         Element JavaDoc pn = newJOnASElement(PARAM_NAME, name);
74         Element JavaDoc pv = newJOnASElement(PARAM_VALUE, value);
75
76         jip.appendChild(pn);
77         jip.appendChild(pv);
78
79         getElement().appendChild(jip);
80     }
81
82     /**
83      * @return Returns true if this web service client has a JOnAS specific
84      * descriptor (jonas-service-ref).
85      */

86     public boolean hasJonasServiceRef() {
87         return (getElement() != null);
88     }
89
90     /**
91      * @param serviceRefName the value of service-ref-name Element
92      * @return Returns a default jonas-service-ref Element (initialized with the given service-ref-name).
93      */

94     public Element JavaDoc createJonasServiceRef(String JavaDoc serviceRefName) {
95         Element JavaDoc jsr = newJOnASElement("jonas-service-ref");
96         Element JavaDoc srn = newJ2EEElement("service-ref-name", serviceRefName);
97
98         jsr.appendChild(srn);
99         return jsr;
100     }
101
102 }
Popular Tags