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: * CustomComponentWsdlGenerator
022: * LPS
023: * Sep 18, 2007
024: */package com.bostechcorp.cbesb.common.util.generators.wsdl.generators;
025:
026: import java.util.Iterator;
027: import java.util.Properties;
028:
029: import javax.wsdl.Binding;
030: import javax.wsdl.WSDLException;
031: import javax.xml.namespace.QName;
032:
033: import org.jdom.Namespace;
034:
035: import com.bostechcorp.cbesb.common.sa.service.EndPoint;
036: import com.bostechcorp.cbesb.common.sa.service.PropertiesKey;
037: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.AttributeFullElement;
038: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.BindingExtension;
039: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.ConfigConstants;
040: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.ConfigExtension;
041: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.ConfigExtensionRegistry;
042: import com.bostechcorp.cbesb.common.util.generators.wsdl.extensions.CustomTagExtension;
043: import com.bostechcorp.cbesb.common.util.macro.MacroUtil;
044:
045: /**
046: * @author LPS
047: *
048: */
049: public class CustomComponentWsdlGenerator extends
050: ScheduleableComponentWsdlGenerator {
051:
052: private String componentURI;
053:
054: /**
055: * @param path
056: * @param saNAme
057: * @param suName
058: * @param suType
059: * @param endpoint
060: * @throws WSDLException
061: */
062: public CustomComponentWsdlGenerator(String path, String saNAme,
063: String suName, String suType, EndPoint endpoint, boolean b,
064: String componentURI) throws WSDLException {
065: super (path, saNAme, suName, suType, endpoint, b);
066: this .componentURI = componentURI;
067: createDocumentStructure();
068: }
069:
070: @Override
071: protected String getPropertyRoot(String role) {
072:
073: return PropertiesKey.CUSTOM_COMPONENT;
074: }
075:
076: protected void handleRegistry(ConfigExtensionRegistry cer) {
077: cer.customTagRegister(getRegistrationTag());
078:
079: }
080:
081: /**
082: * overwrite this method to
083: * @param properiesRoot
084: */
085: @Override
086: protected AttributeFullElement setConfigElement(String properiesRoot) {
087: CustomTagExtension config = new CustomTagExtension(
088: getRegistrationTag());
089:
090: config
091: .addAttributes(endpointSettingsToAttributes(properiesRoot));
092:
093: handleMacro(config);
094:
095: config.addAttribute(ROLE, endpoint.getRole());
096:
097: port.addExtensibilityElement(config);
098:
099: //
100: Properties attributes = config.getAttributes();
101: String prefix = "epns";
102: int count = 0;
103: for (Iterator<Object> it = attributes.keySet().iterator(); it
104: .hasNext();) {
105: String key = (String) it.next();
106: if (key.endsWith("ServiceName")) {
107: String value = attributes.getProperty(key);
108: QName qvalue = QName.valueOf(value);
109: definition.addNamespace(prefix + count, qvalue
110: .getNamespaceURI());
111: attributes.setProperty(key, prefix + count + ":"
112: + qvalue.getLocalPart());
113: }
114: count++;
115: }
116:
117: return config;
118:
119: }
120:
121: /* (non-Javadoc)
122: * @see com.bostechcorp.cbesb.common.util.generators.wsdl.generators.AbstractWsdlGenaretor#addComponentNameSpace()
123: */
124: @Override
125: protected String getComponentURI() {
126: return this .componentURI;
127:
128: }
129:
130: public void handleMacro(CustomTagExtension config) {
131: for (Object key : config.getAttributes().keySet()) {
132: String property = config.getAttributes().getProperty(
133: (String) key);
134: if (property != null) {
135: String result = MacroUtil.resolveBuiltinMacro(property,
136: saName);
137: config.getAttributes()
138: .setProperty((String) key, result);
139: }
140: }
141: }
142:
143: }
|