001: /**
002: * JOnAS : Java(TM) OpenSource Application Server
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
017: * USA
018: *
019: * Initial Developer : Guillaume Sauthier
020: * --------------------------------------------------------------------------
021: * $Id: WsClientDDModifier.java 7513 2005-10-17 15:45:34Z sauthieg $
022: * --------------------------------------------------------------------------
023: */package org.objectweb.jonas_ws.wsgen.ddmodifier;
024:
025: import org.w3c.dom.Document;
026: import org.w3c.dom.Element;
027:
028: import org.objectweb.jonas_lib.genbase.utils.XMLUtils;
029:
030: /**
031: * Modify a Web Services Client Deployment Desc Element. Wrapper around a
032: * <code>jonas-service-ref</code> element
033: * @author Guillaume Sauthier
034: */
035: public class WsClientDDModifier extends DeploymentDescModifier {
036:
037: /**
038: * jonas-init-param Element name
039: */
040: private static final String JONAS_INIT_PARAM = "jonas-init-param";
041:
042: /**
043: * param-name Element name
044: */
045: private static final String PARAM_NAME = "param-name";
046:
047: /**
048: * param-value Element name
049: */
050: private static final String PARAM_VALUE = "param-value";
051:
052: /**
053: * Creates a new WsClientDDModifier where element is a
054: * <code>jonas-service-ref</code> XML Node.
055: * @param name service-ref-name value
056: * @param doc document base for Element creation
057: * @param base base element for searching jonas-service-ref
058: */
059: public WsClientDDModifier(String name, Document doc, Element base) {
060: super (XMLUtils.getJonasServiceRef(base, name), doc, base);
061: }
062:
063: /**
064: * Add a jonas-init-param in jonas-service-ref.
065: * @param name param name
066: * @param value param value
067: */
068: public void addJonasInitParam(String name, String value) {
069: Element jip = newJOnASElement(JONAS_INIT_PARAM);
070: Element pn = newJOnASElement(PARAM_NAME, name);
071: Element pv = newJOnASElement(PARAM_VALUE, value);
072:
073: jip.appendChild(pn);
074: jip.appendChild(pv);
075:
076: getElement().appendChild(jip);
077: }
078:
079: /**
080: * @return Returns true if this web service client has a JOnAS specific
081: * descriptor (jonas-service-ref).
082: */
083: public boolean hasJonasServiceRef() {
084: return (getElement() != null);
085: }
086:
087: /**
088: * @param serviceRefName the value of service-ref-name Element
089: * @return Returns a default jonas-service-ref Element (initialized with the given service-ref-name).
090: */
091: public Element createJonasServiceRef(String serviceRefName) {
092: Element jsr = newJOnASElement("jonas-service-ref");
093: Element srn = newJOnASElement("service-ref-name",
094: serviceRefName);
095:
096: jsr.appendChild(srn);
097: return jsr;
098: }
099:
100: }
|