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 java.util.Enumeration;
028: import java.util.Properties;
029:
030: import org.jdom.Element;
031: import org.jdom.Namespace;
032:
033: import com.bostechcorp.cbesb.common.sa.service.PropertiesKey;
034:
035: /**
036: * @author LPS
037: *
038: */
039: public class CbrComponentDOMWsdlXMLGenerator extends
040: AbstractComponentDOMWsdlXMLGenerator {
041:
042: /**
043: * @param s
044: */
045: protected static final String ROLE_A = "role";
046:
047: protected static final String PROVIDER = "provider";
048:
049: protected static final String DEFAULT_MEP_A = "defaultMep";
050:
051: protected static final String IN_OUT = "in-out";
052:
053: protected static final String TRIDROOT = "cbr.wsdl.";
054:
055: protected Element config;
056:
057: protected Element trxId;
058:
059: public CbrComponentDOMWsdlXMLGenerator(String s) {
060: super (s);
061:
062: }
063:
064: /*
065: * (non-Javadoc)
066: *
067: * @see com.bostechcorp.cbesb.common.sa.service.AbstractComponentDOMWsdlXMLGenerator#getFileOut()
068: */
069: @Override
070: protected String getFileOut() {
071: if (filePath.endsWith("/")) {
072: return filePath + fileName;
073: } else {
074: return filePath + "/" + fileName;
075: }
076: }
077:
078: protected void writeTrxId(Element tag, Properties settings) {
079: String root = "cbr.wsdl.";
080: String rootMatch = root
081: + settings
082: .getProperty(PropertiesKey.CBR_WSDL_TRXID_TYPE)
083: + ".";
084: Enumeration e = settings.propertyNames();
085: tag.setAttribute(jdomFactory.attribute("type", settings
086: .getProperty(PropertiesKey.CBR_WSDL_TRXID_TYPE)));
087: while (e.hasMoreElements()) {
088: String key = (String) e.nextElement();
089: if (key.indexOf(rootMatch) == 0) {
090: String subKey = key.substring(rootMatch.length());
091: String value = settings.getProperty(key);
092: tag.setAttribute(subKey, value);
093: }
094: }
095: }
096:
097: /*
098: public void setDefinitionNamespace(String namespace, String tnsPrefix,
099: String filePrefix) {
100:
101: rootElement.setNamespace(Namespace.getNamespace(namespace));
102: rootElement.addNamespaceDeclaration(Namespace.getNamespace(
103: definitions_Tns_NS, tnsPrefix));
104: rootElement.addNamespaceDeclaration(Namespace.getNamespace(
105: definitions_CBR_NS, filePrefix));
106: }
107: */
108: @Override
109: public void setComponentProperty(Properties componentProperties,
110: String role, String componentType, String endPointName,
111: String saName, String componentName) {
112: String routingRulesfileName = saName + "_" + endPointName
113: + ".xml";
114: fileName = "cbr" + "provider" + ".wsdl";
115: config = jdomFactory.element("config");
116: trxId = jdomFactory.element("trxId");
117: config.setNamespace(Namespace.getNamespace("cbr", "cbr"));
118: config.setAttribute(jdomFactory.attribute(ROLE_A, PROVIDER));
119: config.setAttribute(jdomFactory
120: .attribute(DEFAULT_MEP_A, IN_OUT));
121: config.setAttribute(jdomFactory.attribute("routingRules",
122: routingRulesfileName));
123: setTagAttributes(config, componentType + "."
124: + PropertiesKey.ROLE_PROVIDER, componentProperties);
125: //setting the operation in PortType
126: if (componentProperties.get(PropertiesKey.CBR_WSDL_DEFAULTMEP) != null) {
127: if (componentProperties.get(
128: PropertiesKey.CBR_WSDL_DEFAULTMEP)
129: .equals("in-only")) {
130: setOperation(saName + "_" + componentName, false);
131: } else if (componentProperties.get(
132: PropertiesKey.CBR_WSDL_DEFAULTMEP).equals("in-out")) {
133: setOperation(saName + "_" + componentName, true);
134: }
135: } else { // set operation even if the mep is not set
136: setOperation(saName + "_" + componentName, false);
137: }
138: //
139:
140: writeTrxId(trxId, componentProperties);
141: config.addContent(trxId);
142: portElement.addContent(config);
143: }
144: }
|