001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id:$
023: *
024: */
025: package com.bostechcorp.cbesb.common.util.generators;
026:
027: import org.jdom.DefaultJDOMFactory;
028: import org.jdom.Element;
029: import org.jdom.JDOMFactory;
030:
031: import com.bostechcorp.cbesb.common.util.macro.MacroUtil;
032:
033: /**
034: * @author LPS
035: * @deprecated
036: *
037: */
038: public class AbstractComponentDOMCcslXMLGenerator extends
039: AbstractDOMGenerator {
040:
041: /**
042: * constants holding tag names for the ccsl.xml
043: */
044: protected static final String CCSL_SU_CONFIG_T = "ccslSuConfig";
045: protected static final String ENDPOINTS_T = "endpoints";
046: protected static final String ENDPOINT_T = "endpoint";
047: protected static final String UPOC_T = "upoc";
048: protected static final String ENDPOINT_SERVICE_NS_A = "serviceNS";
049: protected static final String ENDPOINT_SERVICE_LOCAL_A = "serviceLocal";
050: protected static final String ENDPOINT_NAME_A = "name";
051: protected static final String ENPOINTt_ADDR_RECORD_A = "addRecord";
052: protected static final String ENDPOINT_STRIP_RECORD_A = "stripRecord";
053: protected static final String ENDPOINT_SAVE_ERRORS_A = "saveErrors";
054: protected static final String ENDPOINT_USE_SEND_MESSAGE_A = "useSendMessage";
055: protected static final String ENDPOINT_UPOC_CONTEXT_A = "context";
056: protected static final String ENDPOINT_UPOC_TYPE_A = "type";
057: protected static final String ENDPOINT_UPOC_CLASS_A = "class";
058: protected static final String ENDPOINT_UPOC_METHOD_A = "method";
059: // context="presend"
060: // type="Groovy"
061: // class="httpUPOCs.groovy"
062: // method="aaaaaa"
063: /**
064: * path managers
065: */
066:
067: protected String fileName = "/META-INF/ccsl.xml";
068:
069: private String saName = "";
070:
071: /**
072: * XML structure holders
073: */
074:
075: protected Element endpoint;
076: protected Element endpointsElement;
077:
078: public AbstractComponentDOMCcslXMLGenerator() {
079: super ();
080: }
081:
082: public AbstractComponentDOMCcslXMLGenerator(String string,
083: String saName) {
084: super (string);
085: this .saName = saName;
086: }
087:
088: public void addEndpoint(String serviceNS, String serviceLocal,
089: String name, String addRecord, String stripRecord,
090: String saveErr, String useSendMessage) {
091: JDOMFactory jdomFactory = new DefaultJDOMFactory();
092: endpoint = jdomFactory.element(ENDPOINT_T, rootElement
093: .getNamespace());
094: endpoint.setAttribute(jdomFactory.attribute(
095: ENDPOINT_SERVICE_NS_A, serviceNS));
096: endpoint.setAttribute(jdomFactory.attribute(
097: ENDPOINT_SERVICE_LOCAL_A, serviceLocal));
098: endpoint.setAttribute(jdomFactory.attribute(ENDPOINT_NAME_A,
099: name));
100: endpoint.setAttribute(jdomFactory.attribute(
101: ENPOINTt_ADDR_RECORD_A, addRecord));
102: endpoint.setAttribute(jdomFactory.attribute(
103: ENDPOINT_STRIP_RECORD_A, stripRecord));
104: endpoint.setAttribute(jdomFactory.attribute(
105: ENDPOINT_SAVE_ERRORS_A, saveErr));
106: endpoint.setAttribute(jdomFactory.attribute(
107: ENDPOINT_USE_SEND_MESSAGE_A, useSendMessage));
108: //endpoint.addContent("\n");
109: endpointsElement.addContent(endpoint);
110: }
111:
112: public void addContentedEndpoint(String serviceNS,
113: String serviceLocal, String name, String addRecord,
114: String stripRecord, String saveErr, String useSendMessage,
115: String tagContent) {
116: JDOMFactory jdomFactory = new DefaultJDOMFactory();
117: endpoint = jdomFactory.element(ENDPOINT_T, rootElement
118: .getNamespace());
119: endpoint.setAttribute(jdomFactory.attribute(
120: ENDPOINT_SERVICE_NS_A, serviceNS));
121: endpoint.setAttribute(jdomFactory.attribute(
122: ENDPOINT_SERVICE_LOCAL_A, serviceLocal));
123: endpoint.setAttribute(jdomFactory.attribute(ENDPOINT_NAME_A,
124: name));
125: endpoint.setAttribute(jdomFactory.attribute(
126: ENPOINTt_ADDR_RECORD_A, addRecord));
127: endpoint.setAttribute(jdomFactory.attribute(
128: ENDPOINT_STRIP_RECORD_A, stripRecord));
129: endpoint.setAttribute(jdomFactory.attribute(
130: ENDPOINT_SAVE_ERRORS_A, saveErr));
131: endpoint.setAttribute(jdomFactory.attribute(
132: ENDPOINT_USE_SEND_MESSAGE_A, useSendMessage));
133:
134: endpoint.addContent(tagContent);
135: endpointsElement.addContent(endpoint);
136: }
137:
138: public void addUpocAttribute(String context, String type,
139: String className, String method) {
140: JDOMFactory jdomFactory = new DefaultJDOMFactory();
141: Element upocElement = jdomFactory.element(UPOC_T, rootElement
142: .getNamespace());
143: upocElement.setAttribute(jdomFactory.attribute(
144: ENDPOINT_UPOC_CONTEXT_A, context));
145: upocElement.setAttribute(jdomFactory.attribute(
146: ENDPOINT_UPOC_TYPE_A, type));
147: upocElement.setAttribute(jdomFactory.attribute(
148: ENDPOINT_UPOC_CLASS_A, MacroUtil.resolveBuiltinMacro(
149: className, saName)));
150: upocElement.setAttribute(jdomFactory.attribute(
151: ENDPOINT_UPOC_METHOD_A, method));
152: endpoint.addContent(upocElement);
153: }
154:
155: // public void addUpooc(Element element,Element element2){
156: //
157: // }
158: protected void buildDocumentStructure() {
159: JDOMFactory jdomFactory = new DefaultJDOMFactory();
160: rootElement = jdomFactory.element(CCSL_SU_CONFIG_T);
161: endpointsElement = jdomFactory.element(ENDPOINTS_T, rootElement
162: .getNamespace());
163: rootElement.addContent(endpointsElement);
164: }
165:
166: protected String getFileOut() {
167: return filePath + fileName;
168: }
169:
170: /*
171: public static void main(String[] args)
172: {
173: AbstractComponentDOMCcslXMLGenerator dom = new AbstractComponentDOMCcslXMLGenerator("c:/");
174: dom.addEndpoint("df", "df", "fg", "uuy", "yu", "yu", "yu");
175: dom.addEndpoint("df", "df", "fg", "uuy", "yu", "yu", "yu");
176: dom.addEndpoint("df", "df", "fg", "uuy", "yu", "yu", "yu");
177: dom.addEndpoint("df", "df", "fg", "uuy", "yu", "yu", "yu");
178: dom.addEndpoint("df", "df", "fg", "uuy", "yu", "yu", "yu");
179: dom.addEndpoint("df", "df", "fg", "uuy", "yu", "yu", "yu");
180: dom.addEndpoint("df", "df", "fg", "uuy", "yu", "yu", "yu");
181: dom.write();
182: }*/
183: }
|