[jboss-svn-commits] JBL Code SVN: r17016 - in labs/jbossesb/trunk: product/rosetta/src/org/jboss/internal/soa/esb/dependencies and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 4 10:21:18 EST 2007
Author: kevin.conner at jboss.com
Date: 2007-12-04 10:21:18 -0500 (Tue, 04 Dec 2007)
New Revision: 17016
Added:
labs/jbossesb/trunk/product/lib/ext/wstx-lgpl-3.2.1.jar
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_expected.xml
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_source.xml
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java
Removed:
labs/jbossesb/trunk/product/services/soap/lib/ext/ognl-2.6.9.jar
labs/jbossesb/trunk/product/services/soap/lib/ext/stax-api-1.0.1.jar
labs/jbossesb/trunk/product/services/soap/lib/ext/wstx-lgpl-3.2.1.jar
labs/jbossesb/trunk/product/services/soap/lib/ext/xbean.jar
labs/jbossesb/trunk/product/services/soap/lib/ext/xstream-1.1.3.jar
labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Element.java
labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/IdentitySAXHandler.java
labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Node.java
labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Text.java
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ElementContent.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/QNameHelper.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/JBossESBPropertyService.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java
labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksService.java
labs/jbossesb/trunk/product/services/soap/build.xml
labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java
Log:
Incorporate property replacement: JBESB-1273
Copied: labs/jbossesb/trunk/product/lib/ext/wstx-lgpl-3.2.1.jar (from rev 17011, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/lib/ext/wstx-lgpl-3.2.1.jar)
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/JuddiRMIService.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -22,13 +22,13 @@
package org.jboss.internal.soa.esb.dependencies;
-import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.net.URI;
+import java.io.InputStream;
import java.net.URL;
-import java.util.Enumeration;
-import java.util.Hashtable;
import java.util.Properties;
import javax.naming.InitialContext;
@@ -36,6 +36,7 @@
import org.apache.juddi.registry.rmi.JNDIRegistration;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.util.PropertiesHelper;
+import org.jboss.internal.soa.esb.util.XMLHelper;
import org.jboss.system.ServiceMBeanSupport;
import org.jboss.system.server.ServerConfig;
import org.jboss.system.server.ServerConfigLocator;
@@ -43,8 +44,6 @@
public class JuddiRMIService extends ServiceMBeanSupport implements JuddiRMIServiceMBean
{
private Logger logger = Logger.getLogger(this.getClass());
- public static final String JBOSS_BIND_ADDRESS_TOKEN = "jboss.bind.address";
-
public static final String PROPNAME_JAVA_NAMING_FACTORY_INITIAL = "java.naming.factory.initial";
public static final String PROPNAME_JAVA_NAMING_PROVIDER_URL = "java.naming.provider.url";
public static final String PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS = "java.naming.factory.url.pkgs";
@@ -53,8 +52,6 @@
private static final String JUDDI_PROPERTIES_RESOURCE_FILE = "esb.juddi.properties";
private static final String JUDDI_PROPERTY_FILE_COMMENTS = "Auto generated property file, do not edit" ;
- private Hashtable<String, String> tokenHash;
-
private String propertiesResourceFile ;
public String getPropertiesResourceFile()
@@ -66,12 +63,6 @@
{
this.propertiesResourceFile = propertiesResourceFile;
}
-
- public void initializeTokenHash() {
- tokenHash = new Hashtable<String,String>();
- String bindAddress = System.getProperty("jboss.bind.address");
- tokenHash.put("${" + JBOSS_BIND_ADDRESS_TOKEN + "}", bindAddress);
- }
protected void startService() throws Exception
{
@@ -87,53 +78,42 @@
}
final File baseFile = new File(propertiesResourceFileVal) ;
- final File xmlPropertyFile ;
+ final InputStream xmlPropertyIS ;
if (baseFile.isAbsolute())
{
- xmlPropertyFile = baseFile;
+ xmlPropertyIS = new FileInputStream(baseFile);
}
else
{
- URL url = Thread.currentThread().getContextClassLoader().getResource(propertiesResourceFileVal);
- URI uri = new URI(url.toString());
- xmlPropertyFile = new File(uri) ;
+ final URL url = Thread.currentThread().getContextClassLoader().getResource(propertiesResourceFileVal);
+ xmlPropertyIS = url.openStream() ;
}
+ final byte[] propertyFileContents ;
+ try {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream() ;
+ XMLHelper.replaceSystemProperties(XMLHelper.getXMLStreamReader(xmlPropertyIS),
+ XMLHelper.getXMLStreamWriter(baos)) ;
+ propertyFileContents = baos.toByteArray() ;
+ } finally {
+ xmlPropertyIS.close() ;
+ }
+
final ServerConfig serverConfig = ServerConfigLocator.locate() ;
final File dataDir = serverConfig.getServerDataDir() ;
final File juddiPropertyFile = new File(dataDir, JUDDI_PROPERTIES_RESOURCE_FILE) ;
- final Properties xmlProperties = PropertiesHelper.translateXMLToText(xmlPropertyFile, juddiPropertyFile, JUDDI_PROPERTY_FILE_COMMENTS) ;
- System.setProperty("juddi.propertiesFile", juddiPropertyFile.getAbsolutePath());
- System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
-
- // Support token replacement
- initializeTokenHash();
- for (Enumeration e = xmlProperties.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- String value = xmlProperties.getProperty(key);
- for (String tokenKey : tokenHash.keySet()) {
- String tokenValue = tokenHash.get(tokenKey);
- if (value.contains(tokenKey)) {
- value = value.replace(tokenKey, tokenValue);
- System.setProperty(key, value);
- xmlProperties.setProperty(key, value);
- }
- }
- }
-
- // Rewrite for token replacement
- FileOutputStream rewritePropertyOS = new FileOutputStream(juddiPropertyFile) ;
+ final ByteArrayInputStream bais = new ByteArrayInputStream(propertyFileContents) ;
+ final FileOutputStream juddiPropertyOS = new FileOutputStream(juddiPropertyFile) ;
+ final Properties xmlProperties ;
try {
- rewritePropertyOS = new FileOutputStream(juddiPropertyFile);
- final BufferedOutputStream bos = new BufferedOutputStream(rewritePropertyOS) ;
- xmlProperties.store(bos, JUDDI_PROPERTY_FILE_COMMENTS) ;
- bos.flush() ;
+ xmlProperties = PropertiesHelper.translateXMLToText(bais, juddiPropertyOS, JUDDI_PROPERTY_FILE_COMMENTS) ;
} finally {
- rewritePropertyOS.close();
+ juddiPropertyOS.close() ;
}
+ System.setProperty("juddi.propertiesFile", juddiPropertyFile.getAbsolutePath());
+ System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
// Read properties from file and if they exist - pass them on to juddi as system properties
- // Do not pass back the properties back if
String factoryInitial = xmlProperties.getProperty(PROPNAME_JAVA_NAMING_FACTORY_INITIAL, null);
String providerURL = xmlProperties.getProperty(PROPNAME_JAVA_NAMING_PROVIDER_URL, null);
String factoryURLPkgs = xmlProperties.getProperty(PROPNAME_JAVA_NAMING_FACTORY_URL_PKGS, null);
Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java (from rev 17011, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/XMLHelper.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.jboss.internal.soa.esb.util.stax.ParsingSupport;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.util.StringPropertyReplacer;
+
+/**
+ * Helper class for manipulating XML documents.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class XMLHelper
+{
+ /**
+ * The XML input factory.
+ */
+ private static final XMLInputFactory XML_INPUT_FACTORY = getXMLInputFactory() ;
+ /**
+ * The XML output factory.
+ */
+ private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance() ;
+
+ /**
+ * Get the XML stream reader.
+ * @param reader The input reader.
+ * @return The XML stream reader.
+ * @throws XMLStreamException For errors obtaining an XML stream reader.
+ */
+ public static XMLStreamReader getXMLStreamReader(final Reader reader)
+ throws XMLStreamException
+ {
+ return XML_INPUT_FACTORY.createXMLStreamReader(reader) ;
+ }
+
+ /**
+ * Get the XML stream reader.
+ * @param is The input stream.
+ * @return The XML stream reader.
+ * @throws XMLStreamException For errors obtaining an XML stream reader.
+ */
+ public static XMLStreamReader getXMLStreamReader(final InputStream is)
+ throws XMLStreamException
+ {
+ return XML_INPUT_FACTORY.createXMLStreamReader(is) ;
+ }
+
+ /**
+ * Get the XML stream reader.
+ * @param is The input stream.
+ * @param encoding The input stream encoding.
+ * @return The XML stream reader.
+ * @throws XMLStreamException For errors obtaining an XML stream reader.
+ */
+ public static XMLStreamReader getXMLStreamReader(final InputStream is, final String encoding)
+ throws XMLStreamException
+ {
+ return XML_INPUT_FACTORY.createXMLStreamReader(is, encoding) ;
+ }
+
+ /**
+ * Get the XML stream writer.
+ * @param writer The output writer.
+ * @return The XML stream writer.
+ * @throws XMLStreamException For errors obtaining an XML stream writer.
+ */
+ public static XMLStreamWriter getXMLStreamWriter(final Writer writer)
+ throws XMLStreamException
+ {
+ return XML_OUTPUT_FACTORY.createXMLStreamWriter(writer) ;
+ }
+
+ /**
+ * Get the XML stream writer.
+ * @param os The output stream.
+ * @return The XML stream writer.
+ * @throws XMLStreamException For errors obtaining an XML stream writer.
+ */
+ public static XMLStreamWriter getXMLStreamWriter(final OutputStream os)
+ throws XMLStreamException
+ {
+ return XML_OUTPUT_FACTORY.createXMLStreamWriter(os) ;
+ }
+
+ /**
+ * Get the XML stream writer.
+ * @param os The output stream.
+ * @param encoding The output stream encoding.
+ * @return The XML stream writer.
+ * @throws XMLStreamException For errors obtaining an XML stream writer.
+ */
+ public static XMLStreamWriter getXMLStreamWriter(final OutputStream os, final String encoding)
+ throws XMLStreamException
+ {
+ return XML_OUTPUT_FACTORY.createXMLStreamWriter(os, encoding) ;
+ }
+
+ /**
+ * Replace system property values within the attribute values/text elements.
+ * @param streamReader The XML stream reader.
+ * @param streamWriter The XMl stream writer.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public static void replaceSystemProperties(final XMLStreamReader streamReader,
+ final XMLStreamWriter streamWriter)
+ throws XMLStreamException
+ {
+ streamWriter.writeStartDocument() ;
+
+ StreamHelper.skipToStartElement(streamReader) ;
+ final QName elementName = streamReader.getName() ;
+ final String uri = StreamHelper.writeStartElement(streamWriter, elementName) ;
+
+ new SystemPropertyReplacementParser(streamReader, streamWriter) ;
+
+ StreamHelper.writeEndElement(streamWriter, elementName.getPrefix(), uri) ;
+
+ streamWriter.writeEndDocument() ;
+ streamWriter.flush() ;
+ }
+
+ /**
+ * Create the XML input factory.
+ * @return The XML input factory.
+ */
+ private static XMLInputFactory getXMLInputFactory()
+ {
+ final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance() ;
+ xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE) ;
+ return xmlInputFactory ;
+ }
+
+ /**
+ * The parser class used to perform system property replacement.
+ * @author kevin
+ */
+ private static final class SystemPropertyReplacementParser extends ParsingSupport
+ {
+ /**
+ * The output writer.
+ */
+ private final XMLStreamWriter out ;
+
+ /**
+ * Construct the parser.
+ * @param in The XML input stream.
+ * @param out The XML output stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ SystemPropertyReplacementParser(final XMLStreamReader in, final XMLStreamWriter out)
+ throws XMLStreamException
+ {
+ this.out = out ;
+ parse(in) ;
+ }
+
+ /**
+ * Set the text value of this element.
+ * @param in The current input stream.
+ * @param value The text value of this element.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ protected void putValue(final XMLStreamReader in, final String value)
+ throws XMLStreamException
+ {
+ out.writeCharacters(StringPropertyReplacer.replaceProperties(value)) ;
+ }
+
+ /**
+ * Add the attribute value.
+ * @param in The current input stream.
+ * @param attributeName The qualified attribute name.
+ * @param attributeValue The qualified attribute value.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ protected void putAttribute(final XMLStreamReader in,
+ final QName attributeName, final String attributeValue)
+ throws XMLStreamException
+ {
+ StreamHelper.writeAttribute(out, attributeName, StringPropertyReplacer.replaceProperties(attributeValue)) ;
+ }
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ protected void putElement(final XMLStreamReader in,
+ final QName elementName)
+ throws XMLStreamException
+ {
+ final String uri = StreamHelper.writeStartElement(out, elementName) ;
+ new SystemPropertyReplacementParser(in, out) ;
+ StreamHelper.writeEndElement(out, elementName.getPrefix(), uri) ;
+ }
+ }
+}
Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax (from rev 17011, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax)
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ElementContent.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ElementContent.java 2007-12-04 13:15:19 UTC (rev 17011)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ElementContent.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -44,7 +44,6 @@
/**
* Write the attributes of the element.
* @param out The output stream.
- * @throws XMLStreamException For errors during output.
*/
protected void writeAttributes(final XMLStreamWriter out)
throws XMLStreamException
@@ -54,7 +53,6 @@
/**
* Write the child content of the element.
* @param out The output stream.
- * @throws XMLStreamException For errors during output.
*/
protected void writeChildContent(final XMLStreamWriter out)
throws XMLStreamException
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java 2007-12-04 13:15:19 UTC (rev 17011)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -43,6 +43,7 @@
/**
* Parse the contents of this element from the input stream.
* @param in The input stream.
+ * @message com.arjuna.webservices.stax.ParsingSupport_1 [com.arjuna.webservices.stax.ParsingSupport_1] -
*/
protected final void parse(final XMLStreamReader in)
throws XMLStreamException
@@ -100,7 +101,6 @@
* Set the text value of this element.
* @param in The current input stream.
* @param value The text value of this element.
- * @throws XMLStreamException For errors during parsing.
*/
protected void putValue(final XMLStreamReader in, final String value)
throws XMLStreamException
@@ -112,7 +112,6 @@
* @param in The current input stream.
* @param attributeName The qualified attribute name.
* @param attributeValue The qualified attribute value.
- * @throws XMLStreamException For errors during parsing.
*/
protected void putAttribute(final XMLStreamReader in,
final QName attributeName, final String attributeValue)
@@ -124,7 +123,6 @@
* Add the element.
* @param in The current input stream.
* @param elementName The qualified element name.
- * @throws XMLStreamException For errors during parsing.
*/
protected abstract void putElement(final XMLStreamReader in,
final QName elementName)
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/QNameHelper.java
===================================================================
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java 2007-12-04 13:15:19 UTC (rev 17011)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -196,6 +196,7 @@
}
else
{
+ // KEV must handle clashes with default namespace
writeAttribute(out, attributeName, QNameHelper.toQualifiedName(origPrefix, attributeValue.getLocalPart())) ;
}
}
@@ -221,6 +222,7 @@
}
else
{
+ // KEV must handle clashes with default namespace
final String prefix = QNameHelper.getNormalisedValue(attributeName.getPrefix()) ;
writeNamespace(out, prefix, namespaceURI) ;
out.writeAttribute(namespaceURI, localName, attributeValue) ;
@@ -255,6 +257,7 @@
}
else
{
+ // KEV must handle clashes with default namespace
out.writeCharacters(QNameHelper.toQualifiedName(origPrefix, qName.getLocalPart())) ;
}
}
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util.stax;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Utility class representing a text element.
+ * @author kevin
+ */
+public class TextElement extends ElementContent
+{
+ /**
+ * The value of the text element.
+ */
+ private String text ;
+
+ /**
+ * Construct the text element.
+ * @param text The text element.
+ */
+ public TextElement(final String text)
+ {
+ this.text = text ;
+ }
+
+ /**
+ * Construct the text element.
+ * @param in The current input stream.
+ * @throws XMLStreamException For errors during reading.
+ */
+ public TextElement(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
+
+ /**
+ * Get the text value of this element.
+ * @return The text value of this element.
+ */
+ public String getText()
+ {
+ return text ;
+ }
+
+ /**
+ * Set the text value of this element.
+ * @param in The current input stream.
+ * @param value The text value of this element.
+ */
+ protected void putValue(final XMLStreamReader in, final String value)
+ throws XMLStreamException
+ {
+ text = value ;
+ }
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ */
+ protected void putElement(final XMLStreamReader in,
+ final QName elementName)
+ throws XMLStreamException
+ {
+ throw new XMLStreamException("Text elements cannot have embedded elements.") ;
+ }
+
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ */
+ protected void writeChildContent(final XMLStreamWriter out)
+ throws XMLStreamException
+ {
+ out.writeCharacters(text) ;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/JBossESBPropertyService.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/JBossESBPropertyService.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/JBossESBPropertyService.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -21,12 +21,19 @@
package org.jboss.soa.esb.common;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.net.URL;
import javax.transaction.Status;
import javax.transaction.TransactionManager;
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.util.XMLHelper;
import org.jboss.system.ServiceMBeanSupport;
+import org.jboss.system.server.ServerConfig;
+import org.jboss.system.server.ServerConfigLocator;
import org.jboss.tm.TransactionManagerLocator;
/**
@@ -36,6 +43,11 @@
public class JBossESBPropertyService extends ServiceMBeanSupport implements JBossESBPropertyServiceMBean
{
/**
+ * The name of the ESB property file.
+ */
+ private static final String ESB_PROPERTY_FILE = "jbossesb-properties.xml";
+
+ /**
* The current property file name.
*/
private String propertyFile ;
@@ -67,14 +79,31 @@
{
if (propertyFile != null)
{
- final File propertyFile = new File(this.propertyFile) ;
- if (propertyFile.isAbsolute())
- {
- System.setProperty(Environment.PROPERTIES_FILE, "abs://" + propertyFile.getAbsolutePath());
+ final File baseFile = new File(this.propertyFile) ;
+ final InputStream xmlPropertyIS ;
+ if (!baseFile.isAbsolute()) {
+ final URL resourceURL = Thread.currentThread().getContextClassLoader().getResource(propertyFile) ;
+ xmlPropertyIS = resourceURL.openStream() ;
+ } else {
+ xmlPropertyIS = new FileInputStream(baseFile) ;
}
- else
- {
- System.setProperty(Environment.PROPERTIES_FILE, this.propertyFile);
+
+ try {
+ final ServerConfig serverConfig = ServerConfigLocator.locate() ;
+ final File dataDir = serverConfig.getServerDataDir() ;
+ final File esbPropertyFile = new File(dataDir, ESB_PROPERTY_FILE) ;
+
+ final FileOutputStream esbPropertyOS = new FileOutputStream(esbPropertyFile) ;
+ try {
+ XMLHelper.replaceSystemProperties(XMLHelper.getXMLStreamReader(xmlPropertyIS),
+ XMLHelper.getXMLStreamWriter(esbPropertyOS)) ;
+ } finally {
+ esbPropertyOS.close() ;
+ }
+
+ System.setProperty(Environment.PROPERTIES_FILE, "abs://" + esbPropertyFile.getAbsolutePath());
+ } finally {
+ xmlPropertyIS.close() ;
}
}
// We also setup the transaction strategy here
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -24,6 +24,7 @@
import java.io.File;
import java.io.InputStream;
import java.io.StringReader;
+import java.io.StringWriter;
import java.net.URL;
import java.util.HashSet;
import java.util.Iterator;
@@ -41,6 +42,7 @@
import org.jboss.deployment.DeploymentInfo;
import org.jboss.deployment.SubDeployer;
import org.jboss.deployment.SubDeployerSupport;
+import org.jboss.internal.soa.esb.util.XMLHelper;
import org.jboss.logging.Logger;
import org.jboss.metadata.MetaData;
import org.jboss.metadata.XmlFileLoader;
@@ -270,9 +272,19 @@
}
}
- InputStream inputStream = document.openStream();
- String jbossEsbXml = Configuration.getStringFromStream(inputStream);
- inputStream.close();
+ final InputStream inputStream = document.openStream();
+ final String jbossEsbXml ;
+ try
+ {
+ final StringWriter sw = new StringWriter() ;
+ XMLHelper.replaceSystemProperties(XMLHelper.getXMLStreamReader(inputStream),
+ XMLHelper.getXMLStreamWriter(sw)) ;
+ jbossEsbXml = sw.toString();
+ }
+ finally
+ {
+ inputStream.close();
+ }
addActionDependencies(di.shortName, jbossEsbXml, deps) ;
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java (from rev 17011, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/XMLHelperUnitTest.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.Properties;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.jboss.soa.esb.testutils.StringUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests associated with the XML helper class.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class XMLHelperUnitTest extends TestCase
+{
+ public void testReplaceSystemProperties()
+ throws Exception
+ {
+ final Properties props = System.getProperties() ;
+ props.setProperty("test.property.attributeValue1", " testAttributeValue1 ") ;
+ props.setProperty("test.property.attributeValue2", "testAttributeValue2") ;
+ props.setProperty("test.property.attributeValue3", "${test.property.attributeValue1}") ;
+ props.setProperty("test.property.attributeValue4", "<testAttr/>") ;
+ props.setProperty("test.property.textValue1", "testTextValue1") ;
+ props.setProperty("test.property.textValue2", "${test.property.textValue2}") ;
+ props.setProperty("test.property.textValue3", "<testText/>") ;
+
+ final InputStream is = getClass().getResourceAsStream("replaceSystemProperties_source.xml") ;
+ final XMLStreamReader streamReader = XMLHelper.getXMLStreamReader(is) ;
+ final String encoding = streamReader.getEncoding() ;
+
+ final StringWriter sw = new StringWriter() ;
+
+ XMLHelper.replaceSystemProperties(streamReader,
+ XMLHelper.getXMLStreamWriter(sw)) ;
+ final String contents = sw.toString() ;
+
+ final String expectedContents = StreamUtils.getResourceAsString("replaceSystemProperties_expected.xml", encoding) ;
+
+ final boolean match = StringUtils.compareXMLContent(expectedContents, contents) ;
+ assertTrue("System property replacement", match) ;
+ }
+}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_expected.xml (from rev 17011, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_expected.xml)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_expected.xml (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_expected.xml 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,9 @@
+<?xml version='1.0' encoding='UTF-8'?><test attr=" testAttributeValue1 ">
+ testTextValue1
+ <inner xmlns="http://www.jboss.org/jbossesb/test/property-namespace" attr=" testAttributeValue2 ">
+ <inner:inner xmlns:inner="http://www.jboss.org/jbossesb/test/property-namespace2" inner:attr="${test.property.attributeValue1}" inner:attr2="<testAttr/>">
+ ${test.property.textValue2}
+ <testText/>
+ </inner:inner>
+ </inner>
+</test>
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_source.xml (from rev 17011, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_source.xml)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_source.xml (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/util/replaceSystemProperties_source.xml 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<test attr="${test.property.attributeValue1}">
+ ${test.property.textValue1}
+ <inner xmlns="http://www.jboss.org/jbossesb/test/property-namespace" attr=" ${test.property.attributeValue2} ">
+ <inner:inner xmlns:inner="http://www.jboss.org/jbossesb/test/property-namespace2"
+ inner:attr="${test.property.attributeValue3}"
+ inner:attr2="${test.property.attributeValue4}">
+ ${test.property.textValue2}
+ ${test.property.textValue3}
+ </inner:inner>
+ </inner>
+</test>
\ No newline at end of file
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java (from rev 16630, labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Element.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Element.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.xml.namespace.QName;
+
+import org.xml.sax.Attributes;
+
+/**
+ * Simple class representing an element.
+ * This is used to compare XML documents.
+ *
+ * @author Kevin Conner
+ */
+public class Element implements Node
+{
+ /**
+ * The QName comparator.
+ */
+ private static final Comparator<QName> QNAME_COMPARATOR = new QNameComparator() ;
+
+ /**
+ * The name of the element.
+ */
+ private final QName name ;
+ /**
+ * Associated attributes.
+ */
+ private final Map<QName, String> attributes = new TreeMap<QName, String>(QNAME_COMPARATOR) ;
+ /**
+ * Children.
+ */
+ private final List<Node> children = new ArrayList<Node>() ;
+
+ /**
+ * Construct the element.
+ * @param namespaceURI The namespace for the element.
+ * @param localName The local name of the element.
+ * @param attributes The associated attributes.
+ */
+ Element(final String namespaceURI, final String localName, final Attributes attributes)
+ {
+ name = new QName(namespaceURI, localName) ;
+ final int numAttributes = attributes.getLength() ;
+ for(int count = 0 ; count < numAttributes ; count++)
+ {
+ final String attrNamespaceURI = attributes.getURI(count) ;
+ final String attrLocalName = attributes.getLocalName(count) ;
+ final String attrValue = attributes.getValue(count) ;
+
+ this.attributes.put(new QName(attrNamespaceURI, attrLocalName), attrValue) ;
+ }
+ }
+
+ /**
+ * Add a child node.
+ * @param child The child node.
+ */
+ void addChild(final Node child)
+ {
+ children.add(child) ;
+ }
+
+ /**
+ * Check for equality.
+ * @param obj the object to test against.
+ */
+ @Override
+ public boolean equals(final Object obj)
+ {
+ if (obj == null)
+ {
+ return false ;
+ }
+
+ if (obj == this)
+ {
+ return true ;
+ }
+
+ if (obj instanceof Element)
+ {
+ final Element rhs = (Element)obj ;
+ return (name.equals(rhs.name) && attributes.equals(rhs.attributes) &&
+ children.equals(rhs.children)) ;
+ }
+
+ return false ;
+ }
+
+ /**
+ * The QName comparator class.
+ * @author kevin
+ */
+ private static final class QNameComparator implements Comparator<QName>
+ {
+ /**
+ * Compare the QNames.
+ * @param name1 The first QName.
+ * @param name2 The second QName.
+ * @return
+ */
+ public int compare(final QName name1, final QName name2)
+ {
+ final int uriComparator = name1.getNamespaceURI().compareTo(name2.getNamespaceURI()) ;
+ if (uriComparator != 0)
+ {
+ return uriComparator ;
+ }
+ return name1.getLocalPart().compareTo(name2.getLocalPart());
+ }
+ }
+}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java (from rev 16630, labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/IdentitySAXHandler.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/IdentitySAXHandler.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Simple SAX parser creating an identity document for the incoming XML.
+ * Any leading and trailing whitespace is ignored in the document as are
+ * namespace prefixes.
+ *
+ * @author Kevin Conner
+ */
+public class IdentitySAXHandler extends DefaultHandler
+{
+ /**
+ * The root element.
+ */
+ private Element rootElement ;
+ /**
+ * The current element.
+ */
+ private Element currentElement ;
+ /**
+ * The stack of working elements.
+ */
+ private List<Element> stack = new ArrayList<Element>() ;
+ /**
+ * The current text value.
+ */
+ private StringBuilder currentText = new StringBuilder() ;
+
+ @Override
+ public void startElement(final String uri, final String localName,
+ final String name, final Attributes attributes)
+ throws SAXException
+ {
+ checkText() ;
+
+ final Element element = new Element(uri, localName, attributes) ;
+ if (rootElement == null)
+ {
+ rootElement = element ;
+ }
+
+ if (currentElement != null)
+ {
+ currentElement.addChild(element) ;
+ stack.add(currentElement) ;
+ }
+ currentElement = element ;
+ }
+
+ @Override
+ public void endElement(final String uri, final String localName,
+ final String name)
+ throws SAXException
+ {
+ checkText() ;
+
+ final int lastIndex = (stack.size() - 1) ;
+ if (lastIndex < 0)
+ {
+ currentElement = null ;
+ }
+ else
+ {
+ currentElement = stack.remove(lastIndex) ;
+ }
+ }
+
+ @Override
+ public void characters(final char[] ch, final int start, final int length)
+ throws SAXException
+ {
+ currentText.append(ch, start, length) ;
+ }
+
+ private void checkText()
+ {
+ final int textLength = currentText.length() ;
+ if (textLength > 0)
+ {
+ int start = 0 ;
+ while((start < textLength) && isXMLWhitespace(currentText.charAt(start)))
+ {
+ start++ ;
+ }
+
+ int end = textLength-1 ;
+ while((end >= start) && isXMLWhitespace(currentText.charAt(end)))
+ {
+ end-- ;
+ }
+
+ if (start <= end)
+ {
+ currentElement.addChild(new Text(currentText.substring(start, end+1))) ;
+ }
+ currentText.setLength(0) ;
+ currentText.trimToSize() ;
+ }
+ }
+
+ private boolean isXMLWhitespace(final char ch)
+ {
+ return ((ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n')) ;
+ }
+
+ public Element getRootElement()
+ {
+ return rootElement ;
+ }
+}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java (from rev 16630, labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Node.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Node.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+/**
+ * Simple Node tagging XML nodes.
+ *
+ * @author Kevin Conner
+ */
+public interface Node
+{
+}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/StringUtils.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -21,6 +21,16 @@
*/
package org.jboss.soa.esb.testutils;
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
/**
* Utility methods for string manipulation and testing.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
@@ -67,4 +77,47 @@
return stringBuf.toString();
}
+
+ /**
+ * Compare the specified contents as XML.
+ * @param content1 The first content.
+ * @param content2 The second content.
+ * @return true if equals, false otherwise.
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ * @throws IOException
+ */
+ public static boolean compareXMLContent(final String content1, final String content2)
+ throws ParserConfigurationException, SAXException, IOException
+ {
+ try {
+ final SAXParserFactory parserFactory = SAXParserFactory.newInstance() ;
+ parserFactory.setNamespaceAware(true) ;
+
+ final SAXParser parser = parserFactory.newSAXParser() ;
+ final IdentitySAXHandler handler1;
+ final IdentitySAXHandler handler2;
+
+ try {
+ handler1 = new IdentitySAXHandler() ;
+ parser.parse(new InputSource(new StringReader(content1)), handler1) ;
+ } catch(SAXException e) {
+ System.out.println("Failed to parse content1 [" + content1 + "].");
+ throw e;
+ }
+
+ try {
+ handler2 = new IdentitySAXHandler() ;
+ parser.parse(new InputSource(new StringReader(content2)), handler2) ;
+ } catch(SAXException e) {
+ System.out.println("Failed to parse content2 [" + content2 + "].");
+ throw e;
+ }
+
+ return (handler1.getRootElement().equals(handler2.getRootElement())) ;
+ } catch(IOException e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
}
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java (from rev 16630, labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Text.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/Text.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.testutils;
+
+
+/**
+ * Simple class representing a text element.
+ * This is used to compare XML documents.
+ *
+ * @author Kevin Conner
+ */
+public class Text implements Node
+{
+ /**
+ * The text content.
+ */
+ private final String text ;
+
+ /**
+ * Construct the text element.
+ * @param text The text value.
+ */
+ Text(final String text)
+ {
+ this.text = text ;
+ }
+
+ /**
+ * Check for equality.
+ * @param obj the object to test against.
+ */
+ @Override
+ public boolean equals(final Object obj)
+ {
+ if (obj == null)
+ {
+ return false ;
+ }
+
+ if (obj == this)
+ {
+ return true ;
+ }
+
+ if (obj instanceof Text)
+ {
+ final Text rhs = (Text)obj ;
+ return (text.equals(rhs.text)) ;
+ }
+
+ return false ;
+ }
+}
Modified: labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksService.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksService.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksService.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -20,19 +20,19 @@
package org.jboss.soa.esb.actions.converters;
import org.jboss.internal.soa.esb.util.PropertiesHelper;
+import org.jboss.internal.soa.esb.util.XMLHelper;
import org.jboss.system.ServiceMBeanSupport;
import org.jboss.system.server.ServerConfig;
import org.jboss.system.server.ServerConfigLocator;
import org.apache.log4j.Logger;
-import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
-import java.util.Enumeration;
-import java.util.Hashtable;
import java.util.Properties;
/**
@@ -51,20 +51,11 @@
private static final String SMOOKS_PROPERTY_FILE = "smooks.esb.properties";
private static final String SMOOKS_PROPERTY_FILE_COMMENTS = "Auto generated property file, do not edit" ;
- private Hashtable<String, String> tokenHash;
-
/**
* The smooks default property file.
*/
private String propertyFile ;
-
- public void initializeTokenHash() {
- tokenHash = new Hashtable<String,String>();
- String bindAddress = System.getProperty("jboss.bind.address");
- tokenHash.put("${jboss.bind.address}", bindAddress);
- }
-
protected void startService() throws Exception {
super.startService();
@@ -77,49 +68,28 @@
} else {
xmlPropertyIS = new FileInputStream(baseFile) ;
}
-
+ final byte[] propertyFileContents ;
try {
- final ServerConfig serverConfig = ServerConfigLocator.locate() ;
- final File dataDir = serverConfig.getServerDataDir() ;
- final File smooksPropertyFile = new File(dataDir, SMOOKS_PROPERTY_FILE) ;
-
- final FileOutputStream smooksPropertyOS = new FileOutputStream(smooksPropertyFile) ;
- Properties xmlProperties = null;
- try {
- xmlProperties = PropertiesHelper.translateXMLToText(xmlPropertyIS, smooksPropertyOS, SMOOKS_PROPERTY_FILE_COMMENTS) ;
- SmooksConfiguration.setDefaultConfiguration(smooksPropertyFile.getAbsolutePath()) ;
-
- } finally {
- smooksPropertyOS.close() ;
- }
-
- // Support ${jboss.bind.address} replacement
- initializeTokenHash();
- for (Enumeration e = xmlProperties.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- String value = xmlProperties.getProperty(key);
- for (String tokenKey : tokenHash.keySet()) {
- String tokenValue = tokenHash.get(tokenKey);
- if (value.contains(tokenKey)) {
- value = value.replace(tokenKey, tokenValue);
- xmlProperties.setProperty(key, value);
- }
- }
- }
-
- // Rewrite for token replacement
- FileOutputStream rewritePropertyOS = new FileOutputStream(smooksPropertyFile) ;
- try {
- rewritePropertyOS = new FileOutputStream(smooksPropertyFile);
- final BufferedOutputStream bos = new BufferedOutputStream(rewritePropertyOS) ;
- xmlProperties.store(bos, SMOOKS_PROPERTY_FILE_COMMENTS) ;
- bos.flush() ;
- } finally {
- rewritePropertyOS.close();
- }
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream() ;
+ XMLHelper.replaceSystemProperties(XMLHelper.getXMLStreamReader(xmlPropertyIS),
+ XMLHelper.getXMLStreamWriter(baos)) ;
+ propertyFileContents = baos.toByteArray() ;
} finally {
xmlPropertyIS.close() ;
}
+
+ final ServerConfig serverConfig = ServerConfigLocator.locate() ;
+ final File dataDir = serverConfig.getServerDataDir() ;
+ final File smooksPropertyFile = new File(dataDir, SMOOKS_PROPERTY_FILE) ;
+
+ final ByteArrayInputStream bais = new ByteArrayInputStream(propertyFileContents) ;
+ final FileOutputStream smooksPropertyOS = new FileOutputStream(smooksPropertyFile) ;
+ try {
+ PropertiesHelper.translateXMLToText(bais, smooksPropertyOS, SMOOKS_PROPERTY_FILE_COMMENTS) ;
+ } finally {
+ smooksPropertyOS.close() ;
+ }
+ SmooksConfiguration.setDefaultConfiguration(smooksPropertyFile.getAbsolutePath()) ;
}
Properties smooksEsbConfig = new SmooksConfiguration();
Modified: labs/jbossesb/trunk/product/services/soap/build.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/build.xml 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/product/services/soap/build.xml 2007-12-04 15:21:18 UTC (rev 17016)
@@ -11,6 +11,9 @@
<!-- JAXB Intros... -->
<fileset dir="../../lib/ext" includes="jboss-jaxb-intros.jar"/>
+ <!-- StAX jars ... -->
+ <fileset dir="../../lib/ext" includes="xbean.jar stax-api-1.0.1.jar xstream-1.2.2.jar wstx-lgpl-3.2.1.jar ognl-2.6.9.jar"/>
+
<!-- Adding the Smooks jars... -->
<fileset dir="../smooks/lib/ext" includes="*.jar"/>
</path>
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/ognl-2.6.9.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/stax-api-1.0.1.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/wstx-lgpl-3.2.1.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/xbean.jar
===================================================================
(Binary files differ)
Deleted: labs/jbossesb/trunk/product/services/soap/lib/ext/xstream-1.1.3.jar
===================================================================
(Binary files differ)
Modified: labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java
===================================================================
--- labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/Helpers.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -35,7 +35,7 @@
import javax.xml.parsers.SAXParserFactory;
import org.jboss.soa.esb.actions.StoreMessageToFile;
-import org.jboss.soa.esb.quickstart.test.util.IdentitySAXHandler;
+import org.jboss.soa.esb.testutils.IdentitySAXHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Deleted: labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Element.java
===================================================================
--- labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Element.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Element.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.quickstart.test.util;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.xml.namespace.QName;
-
-import org.xml.sax.Attributes;
-
-/**
- * Simple class representing an element.
- * This is used to compare XML documents.
- *
- * @author Kevin Conner
- */
-public class Element implements Node
-{
- /**
- * The QName comparator.
- */
- private static final Comparator<QName> QNAME_COMPARATOR = new QNameComparator() ;
-
- /**
- * The name of the element.
- */
- private final QName name ;
- /**
- * Associated attributes.
- */
- private final Map<QName, String> attributes = new TreeMap<QName, String>(QNAME_COMPARATOR) ;
- /**
- * Children.
- */
- private final List<Node> children = new ArrayList<Node>() ;
-
- /**
- * Construct the element.
- * @param namespaceURI The namespace for the element.
- * @param localName The local name of the element.
- * @param attributes The associated attributes.
- */
- Element(final String namespaceURI, final String localName, final Attributes attributes)
- {
- name = new QName(namespaceURI, localName) ;
- final int numAttributes = attributes.getLength() ;
- for(int count = 0 ; count < numAttributes ; count++)
- {
- final String attrNamespaceURI = attributes.getURI(count) ;
- final String attrLocalName = attributes.getLocalName(count) ;
- final String attrValue = attributes.getValue(count) ;
-
- this.attributes.put(new QName(attrNamespaceURI, attrLocalName), attrValue) ;
- }
- }
-
- /**
- * Add a child node.
- * @param child The child node.
- */
- void addChild(final Node child)
- {
- children.add(child) ;
- }
-
- /**
- * Check for equality.
- * @param obj the object to test against.
- */
- @Override
- public boolean equals(final Object obj)
- {
- if (obj == null)
- {
- return false ;
- }
-
- if (obj == this)
- {
- return true ;
- }
-
- if (obj instanceof Element)
- {
- final Element rhs = (Element)obj ;
- return (name.equals(rhs.name) && attributes.equals(rhs.attributes) &&
- children.equals(rhs.children)) ;
- }
-
- return false ;
- }
-
- /**
- * The QName comparator class.
- * @author kevin
- */
- private static final class QNameComparator implements Comparator<QName>
- {
- /**
- * Compare the QNames.
- * @param name1 The first QName.
- * @param name2 The second QName.
- * @return
- */
- public int compare(final QName name1, final QName name2)
- {
- final int uriComparator = name1.getNamespaceURI().compareTo(name2.getNamespaceURI()) ;
- if (uriComparator != 0)
- {
- return uriComparator ;
- }
- return name1.getLocalPart().compareTo(name2.getLocalPart());
- }
- }
-}
Deleted: labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/IdentitySAXHandler.java
===================================================================
--- labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/IdentitySAXHandler.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/IdentitySAXHandler.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.quickstart.test.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Simple SAX parser creating an identity document for the incoming XML.
- * Any leading and trailing whitespace is ignored in the document as are
- * namespace prefixes.
- *
- * @author Kevin Conner
- */
-public class IdentitySAXHandler extends DefaultHandler
-{
- /**
- * The root element.
- */
- private Element rootElement ;
- /**
- * The current element.
- */
- private Element currentElement ;
- /**
- * The stack of working elements.
- */
- private List<Element> stack = new ArrayList<Element>() ;
- /**
- * The current text value.
- */
- private StringBuilder currentText = new StringBuilder() ;
-
- @Override
- public void startElement(final String uri, final String localName,
- final String name, final Attributes attributes)
- throws SAXException
- {
- checkText() ;
-
- final Element element = new Element(uri, localName, attributes) ;
- if (rootElement == null)
- {
- rootElement = element ;
- }
-
- if (currentElement != null)
- {
- currentElement.addChild(element) ;
- stack.add(currentElement) ;
- }
- currentElement = element ;
- }
-
- @Override
- public void endElement(final String uri, final String localName,
- final String name)
- throws SAXException
- {
- checkText() ;
-
- final int lastIndex = (stack.size() - 1) ;
- if (lastIndex < 0)
- {
- currentElement = null ;
- }
- else
- {
- currentElement = stack.remove(lastIndex) ;
- }
- }
-
- @Override
- public void characters(final char[] ch, final int start, final int length)
- throws SAXException
- {
- currentText.append(ch, start, length) ;
- }
-
- private void checkText()
- {
- final int textLength = currentText.length() ;
- if (textLength > 0)
- {
- int start = 0 ;
- while((start < textLength) && isXMLWhitespace(currentText.charAt(start)))
- {
- start++ ;
- }
-
- int end = textLength-1 ;
- while((end >= start) && isXMLWhitespace(currentText.charAt(end)))
- {
- end-- ;
- }
-
- if (start <= end)
- {
- currentElement.addChild(new Text(currentText.substring(start, end+1))) ;
- }
- currentText.setLength(0) ;
- currentText.trimToSize() ;
- }
- }
-
- private boolean isXMLWhitespace(final char ch)
- {
- return ((ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n')) ;
- }
-
- public Element getRootElement()
- {
- return rootElement ;
- }
-}
Deleted: labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Node.java
===================================================================
--- labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Node.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Node.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.quickstart.test.util;
-
-/**
- * Simple Node tagging XML nodes.
- *
- * @author Kevin Conner
- */
-public interface Node
-{
-}
Deleted: labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Text.java
===================================================================
--- labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Text.java 2007-12-04 14:52:58 UTC (rev 17015)
+++ labs/jbossesb/trunk/qa/quickstarts/src/org/jboss/soa/esb/quickstart/test/util/Text.java 2007-12-04 15:21:18 UTC (rev 17016)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.quickstart.test.util;
-
-
-/**
- * Simple class representing a text element.
- * This is used to compare XML documents.
- *
- * @author Kevin Conner
- */
-public class Text implements Node
-{
- /**
- * The text content.
- */
- private final String text ;
-
- /**
- * Construct the text element.
- * @param text The text value.
- */
- Text(final String text)
- {
- this.text = text ;
- }
-
- /**
- * Check for equality.
- * @param obj the object to test against.
- */
- @Override
- public boolean equals(final Object obj)
- {
- if (obj == null)
- {
- return false ;
- }
-
- if (obj == this)
- {
- return true ;
- }
-
- if (obj instanceof Text)
- {
- final Text rhs = (Text)obj ;
- return (text.equals(rhs.text)) ;
- }
-
- return false ;
- }
-}
More information about the jboss-svn-commits
mailing list