[jboss-svn-commits] JBL Code SVN: r17811 - in labs/jbosstm/workspace/adinn: wsbrew and 15 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jan 14 08:18:13 EST 2008
Author: adinn
Date: 2008-01-14 08:18:13 -0500 (Mon, 14 Jan 2008)
New Revision: 17811
Added:
labs/jbosstm/workspace/adinn/wsbrew/
labs/jbosstm/workspace/adinn/wsbrew/build.xml
labs/jbosstm/workspace/adinn/wsbrew/src/
labs/jbosstm/workspace/adinn/wsbrew/src/javax/
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Action.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ActionNotSupportedException.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingBuilder.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingConstants.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingException.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingProperties.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingType.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributeExtensible.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedQName.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedURI.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/DestinationUnreachableException.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ElementExtensible.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointReference.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointUnavailableException.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/FaultAction.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/InvalidMapException.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/JAXWSAConstants.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/MapRequiredException.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Metadata.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ReferenceParameters.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Relationship.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingBuilder.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingElement.java
labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingProperties.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingBuilderImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingClientUtil.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingConstantsImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingPropertiesImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingTypeImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeElementExtensibleImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeExtensibleImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedQNameImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedURIImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ElementExtensibleImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/EndpointReferenceImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/MetadataImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ReferenceParametersImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/RelationshipImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/metadata/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/metadata/AddressingOpMetaExt.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingBuilderImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMUtils.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMWriter.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/MetaDataExtension.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/NotImplementedException.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/UUIDGenerator.java
labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/WSException.java
Log:
stub implementation of WS Addressing functionality currently missing from Glassfish V2.0 -- for use by workspace code in XTSGF
Added: labs/jbosstm/workspace/adinn/wsbrew/build.xml
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/build.xml (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/build.xml 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,68 @@
+<!--
+ 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-2007,
+ @author JBoss Inc.
+-->
+<project name="wsbrew" default="build" basedir=".">
+
+ <property environment="env"/>
+
+ <property name="wsbrew.properties" value="wsbrew.properties"/>
+
+ <property name="current.dir" value="${basedir}"/>
+
+ <!-- Load Build Properties File -->
+ <property file="${wsbrew.properties}"/>
+
+ <!-- Configure dependencies -->
+ <property name="wsbrew.src.dir" location="${current.dir}/src"/>
+ <property name="wsbrew.build.dir" location="${current.dir}/build"/>
+ <property name="gf.dir" location="${env.GF_HOME}"/>
+ <property name="gf.lib.dir" location="${gf.dir}/lib"/>
+ <property name="gf.jars" value="javaee.jar"/>
+
+ <path id="build.classpath">
+ <fileset dir="${gf.lib.dir}" includes="${gf.jars}"/>
+ </path>
+
+ <property name="build.classpath" refid="build.classpath"/>
+
+ <target name="init">
+ <mkdir dir="${wsbrew.build.dir}"/>
+ <mkdir dir="${wsbrew.build.dir}/classes"/>
+ </target>
+
+ <target name="build" depends="init">
+ <javac destdir="${wsbrew.build.dir}/classes" debug="on">
+ <classpath path="${build.classpath}"/>
+ <src path="${wsbrew.src.dir}"/>
+ </javac>
+ <jar jarfile="${wsbrew.build.dir}/wsbrew.jar">
+ <fileset dir="${wsbrew.build.dir}/classes"/>
+ </jar>
+ </target>
+
+ <target name="install" depends="build">
+ <copy file="${wsbrew.build.dir}/wsbrew.jar" tofile="../XTSGF/ext/wsbrew.jar"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="${wsbrew.build.dir}}/classes" includes="**/*"/>
+ </target>
+
+</project>
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Action.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Action.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Action.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: Action.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+ at Documented
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+public @interface Action
+{
+
+ String input() default "##default";
+
+ String output() default "##default";
+
+ String[] fault() default "##default";
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ActionNotSupportedException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ActionNotSupportedException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ActionNotSupportedException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: ActionNotSupportedException.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+
+public class ActionNotSupportedException extends AddressingException
+{
+
+ static
+ {
+ fMessage = ac.getActionNotSupportedText();
+ }
+
+ private String action;
+
+ protected ActionNotSupportedException()
+ {
+ super();
+ }
+
+ public ActionNotSupportedException(String action)
+ {
+ super(fMessage + ": " + action);
+ this.action = action;
+ }
+
+ public String getAction()
+ {
+ return action;
+ }
+
+ public QName getSubcode()
+ {
+ return ac.getActioNotSupportedQName();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingBuilder.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingBuilder.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingBuilder.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AddressingBuilder.java 3576 2007-06-14 09:23:52Z thomas.diesler at jboss.com $
+
+import static javax.xml.ws.addressing.JAXWSAConstants.ADDRESSING_BUILDER_PROPERTY;
+import static javax.xml.ws.addressing.JAXWSAConstants.DEFAULT_ADDRESSING_BUILDER;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+public abstract class AddressingBuilder implements AddressingType
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(AddressingBuilder.class.getName());
+
+ protected AddressingBuilder()
+ {
+ }
+
+ public static AddressingBuilder getAddressingBuilder()
+ {
+ ClassLoader classLoader;
+ try
+ {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ catch (Exception x)
+ {
+ throw new AddressingException(x.toString(), x);
+ }
+
+ String name = null;
+
+ // Use the system property first
+ try
+ {
+ name = System.getProperty(ADDRESSING_BUILDER_PROPERTY);
+ if (name != null)
+ {
+ return newInstance(name, classLoader);
+ }
+ }
+ catch (Exception e)
+ {
+ log.warning("Could not create and instance of " + name + " trying " + DEFAULT_ADDRESSING_BUILDER);
+ }
+
+ // default builder
+ return newInstance(DEFAULT_ADDRESSING_BUILDER, classLoader);
+ }
+
+ private static AddressingBuilder newInstance(String className, ClassLoader classLoader)
+ {
+ try
+ {
+ Class cls;
+ if (classLoader == null)
+ {
+ cls = Class.forName(className);
+ }
+ else
+ {
+ cls = classLoader.loadClass(className);
+ }
+ return (AddressingBuilder)cls.newInstance();
+ }
+ catch (ClassNotFoundException x)
+ {
+ throw new AddressingException("Provider " + className + " not found", x);
+ }
+ catch (Exception x)
+ {
+ throw new AddressingException("Provider " + className + " could not be instantiated: " + x, x);
+ }
+ }
+
+ public abstract AttributedURI newURI(URI uri);
+
+ public abstract AttributedURI newURI(String uri) throws URISyntaxException;
+
+ public abstract AttributedQName newQName(QName name);
+
+ public abstract Relationship newRelationship(URI uri);
+
+ public abstract EndpointReference newEndpointReference(URI uri);
+
+ public abstract AddressingProperties newAddressingProperties();
+
+ public abstract AddressingConstants newAddressingConstants();
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingConstants.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingConstants.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingConstants.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AddressingConstants.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+
+public interface AddressingConstants
+{
+ String getNamespaceURI();
+
+ String getNamespacePrefix();
+
+ String getWSDLNamespaceURI();
+
+ String getWSDLNamespacePrefix();
+
+ QName getWSDLExtensibilityQName();
+
+ QName getWSDLActionQName();
+
+ String getAnonymousURI();
+
+ String getNoneURI();
+
+ QName getFromQName();
+
+ QName getToQName();
+
+ QName getReplyToQName();
+
+ QName getFaultToQName();
+
+ QName getActionQName();
+
+ QName getMessageIDQName();
+
+ QName getRelationshipReplyQName();
+
+ QName getRelatesToQName();
+
+ String getRelationshipTypeName();
+
+ // [TODO] Add this method
+ QName getReferenceParametersQName();
+
+ QName getMetadataQName();
+
+ QName getAddressQName();
+
+ String getPackageName();
+
+ String getIsReferenceParameterName() throws Exception;
+
+ QName getInvalidMapQName();
+
+ QName getMapRequiredQName();
+
+ QName getDestinationUnreachableQName();
+
+ QName getActioNotSupportedQName();
+
+ QName getEndpointUnavailableQName();
+
+ String getDefaultFaultAction();
+
+ String getActionNotSupportedText();
+
+ String getDestinationUnreachableText();
+
+ String getEndpointUnavailableText();
+
+ String getInvalidMapText();
+
+ String getMapRequiredText();
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AddressingException.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceException;
+
+public class AddressingException extends WebServiceException
+{
+
+ protected QName code;
+
+ protected String reason;
+
+ protected Object detail;
+
+ protected static AddressingConstants ac = null;
+ protected static String fMessage = null;
+ static
+ {
+ ac = AddressingBuilder.getAddressingBuilder().newAddressingConstants();
+ }
+
+ public AddressingException()
+ {
+ }
+
+ public AddressingException(String message)
+ {
+ super(message);
+ }
+
+ public AddressingException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public AddressingException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * Returns the fault code.
+ *
+ * @return the fault code
+ */
+ public QName getCode()
+ {
+ return code;
+ }
+
+ public QName getSubcode()
+ {
+ return null;
+ }
+
+ public String getReason()
+ {
+ return reason;
+ }
+
+ public Object getDetail()
+ {
+ return detail;
+ }
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingProperties.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingProperties.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingProperties.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AddressingProperties.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+public interface AddressingProperties extends AddressingType, Map<QName, AddressingType>
+{
+
+ public AttributedURI getTo();
+
+ public void setTo(AttributedURI iri);
+
+ public AttributedURI getAction();
+
+ public void setAction(AttributedURI iri);
+
+ public AttributedURI getMessageID();
+
+ public void setMessageID(AttributedURI iri);
+
+ public Relationship[] getRelatesTo();
+
+ public void setRelatesTo(Relationship[] relationship);
+
+ public EndpointReference getReplyTo();
+
+ public void setReplyTo(EndpointReference ref);
+
+ public EndpointReference getFaultTo();
+
+ public void setFaultTo(EndpointReference ref);
+
+ public EndpointReference getFrom();
+
+ public void setFrom(EndpointReference ref);
+
+ public ReferenceParameters getReferenceParameters();
+
+ public void initializeAsDestination(EndpointReference ref);
+
+ public void initializeAsReply(AddressingProperties props, boolean isFault);
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingType.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingType.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AddressingType.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AddressingType.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+public interface AddressingType
+{
+ public String getNamespaceURI();
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributeExtensible.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributeExtensible.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributeExtensible.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AttributeExtensible.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+public interface AttributeExtensible extends AddressingType
+{
+ public Map<QName, String> getAttributes();
+
+ public void addAttribute(QName name, String value) throws AddressingException;
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedQName.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedQName.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedQName.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AttributedQName.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+
+public interface AttributedQName extends AddressingType, AttributeExtensible
+{
+
+ public QName getQName();
+
+ public void addAttribute(QName name, String value);
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedURI.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedURI.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/AttributedURI.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: AttributedURI.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+public interface AttributedURI extends AddressingType, AttributeExtensible
+{
+ public URI getURI();
+
+ public void addAttribute(QName name, String value);
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/DestinationUnreachableException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/DestinationUnreachableException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/DestinationUnreachableException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: DestinationUnreachableException.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+
+public class DestinationUnreachableException extends AddressingException
+{
+
+ static
+ {
+ fMessage = ac.getDestinationUnreachableText();
+ }
+
+ public DestinationUnreachableException()
+ {
+ }
+
+ public DestinationUnreachableException(String problemIRI)
+ {
+ super(fMessage + ": " + problemIRI);
+ }
+
+ public QName getSubcode()
+ {
+ return ac.getDestinationUnreachableQName();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ElementExtensible.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ElementExtensible.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ElementExtensible.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: ElementExtensible.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import java.util.List;
+
+public interface ElementExtensible extends AddressingType
+{
+ public List<Object> getElements();
+
+ public void addElement(Object element);
+
+ public boolean removeElement(Object element);
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointReference.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointReference.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointReference.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: EndpointReference.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+public interface EndpointReference extends AddressingType, AttributeExtensible, ElementExtensible
+{
+ public AttributedURI getAddress();
+
+ public ReferenceParameters getReferenceParameters();
+
+ public Metadata getMetadata();
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointUnavailableException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointUnavailableException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/EndpointUnavailableException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: EndpointUnavailableException.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+
+public class EndpointUnavailableException extends AddressingException
+{
+
+ static
+ {
+ fMessage = ac.getEndpointUnavailableText();
+ }
+
+ public EndpointUnavailableException()
+ {
+ }
+
+ public EndpointUnavailableException(int retryAfter, String problemIRI)
+ {
+ super(fMessage + ": [retry=" + retryAfter + ",iri=" + problemIRI + "]");
+ }
+
+ public QName getSubcode()
+ {
+ return ac.getEndpointUnavailableQName();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/FaultAction.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/FaultAction.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/FaultAction.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: FaultAction.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+ at Documented
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target(ElementType.METHOD)
+public @interface FaultAction
+{
+
+ Class className();
+
+ String value() default "##default";
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/InvalidMapException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/InvalidMapException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/InvalidMapException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: InvalidMapException.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+
+public class InvalidMapException extends AddressingException
+{
+
+ static
+ {
+ fMessage = ac.getInvalidMapText();
+ }
+
+ protected InvalidMapException()
+ {
+ }
+
+ public InvalidMapException(QName name)
+ {
+ super(fMessage + ": " + name);
+ }
+
+ public QName getSubcode()
+ {
+ return ac.getInvalidMapQName();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/JAXWSAConstants.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/JAXWSAConstants.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/JAXWSAConstants.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: JAXWSAConstants.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+
+public class JAXWSAConstants
+{
+
+ private JAXWSAConstants()
+ {
+ }
+
+ public static final String ADDRESSING_BUILDER_PROPERTY = "javax.xml.ws.addressing.AddressingBuilder";
+
+ public static final String DEFAULT_ADDRESSING_BUILDER = "org.jboss.ws.extensions.addressing.soap.SOAPAddressingBuilderImpl";
+
+ public static final String SOAP11_NAMESPACE_NAME = "http://schemas.xmlsoap.org/soap/envelope/";
+
+ public static final String SOAP12_NAMESPACE_NAME = "http://www.w3.org/2003/05/soap-envelope";
+
+ public static final QName SOAP11_SENDER_QNAME = new QName(SOAP11_NAMESPACE_NAME, "Client");
+
+ public static final QName SOAP11_RECEIVER_QNAME = new QName(SOAP11_NAMESPACE_NAME, "Server");
+
+ public static final QName SOAP12_SENDER_QNAME = new QName(SOAP12_NAMESPACE_NAME, "Sender");
+
+ public static final QName SOAP12_RECEIVER_QNAME = new QName(SOAP12_NAMESPACE_NAME, "Receiver");
+
+ public static final String SOAP11HTTP_ADDRESSING_BINDING = "http://schemas.xmlsoap.org/wsdl/soap/http?addressing=1.0";
+
+ public static final String SOAP12HTTP_ADDRESSING_BINDING = "http://www.w3.org/2003/05/soap/bindings/HTTP/?addressing=1.0";
+
+ public static final String CLIENT_ADDRESSING_PROPERTIES = "javax.xml.ws.addressing.context";
+
+ public static final String CLIENT_ADDRESSING_PROPERTIES_INBOUND = "javax.xml.ws.addressing.context.inbound";
+
+ public static final String CLIENT_ADDRESSING_PROPERTIES_OUTBOUND = "javax.xml.ws.addressing.context.outbound";
+
+ public static final String SERVER_ADDRESSING_PROPERTIES_INBOUND = "javax.xml.ws.addressing.context.inbound";
+
+ public static final String SERVER_ADDRESSING_PROPERTIES_OUTBOUND = "javax.xml.ws.addressing.context.outbound";
+
+ public static SOAPFactory SOAP_FACTORY = null;
+
+ static
+ {
+ try
+ {
+ SOAP_FACTORY = SOAPFactory.newInstance();
+ }
+ catch (SOAPException e)
+ {
+ }
+ }
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/MapRequiredException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/MapRequiredException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/MapRequiredException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: MapRequiredException.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+
+public class MapRequiredException extends AddressingException
+{
+
+ static
+ {
+ fMessage = ac.getMapRequiredText();
+ }
+
+ public MapRequiredException()
+ {
+ }
+
+ public MapRequiredException(QName name)
+ {
+ super(fMessage + ": " + name);
+ }
+
+ public QName getSubcode()
+ {
+ return ac.getMapRequiredQName();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Metadata.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Metadata.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Metadata.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: Metadata.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+public interface Metadata extends AttributeExtensible, ElementExtensible
+{
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ReferenceParameters.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ReferenceParameters.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/ReferenceParameters.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: ReferenceParameters.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+public interface ReferenceParameters extends AttributeExtensible, ElementExtensible
+{
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Relationship.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Relationship.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/Relationship.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing;
+
+//$Id: Relationship.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+public interface Relationship extends AttributeExtensible
+{
+
+ public URI getID();
+
+ public QName getType();
+
+ public void setType(QName type);
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingBuilder.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingBuilder.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingBuilder.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing.soap;
+
+//$Id: SOAPAddressingBuilder.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.ws.addressing.AddressingBuilder;
+
+public abstract class SOAPAddressingBuilder extends AddressingBuilder
+{
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingElement.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingElement.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingElement.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing.soap;
+
+//$Id: SOAPAddressingElement.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPElement;
+import javax.xml.ws.addressing.AddressingException;
+import javax.xml.ws.addressing.AddressingType;
+
+public interface SOAPAddressingElement extends AddressingType
+{
+
+ public void read(SOAPElement element) throws AddressingException;
+
+ public SOAPElement write(SOAPElement parent, QName name) throws AddressingException;
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingProperties.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingProperties.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/javax/xml/ws/addressing/soap/SOAPAddressingProperties.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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 javax.xml.ws.addressing.soap;
+
+//$Id: SOAPAddressingProperties.java 2897 2007-04-23 06:12:12Z thomas.diesler at jboss.com $
+
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.addressing.AddressingException;
+import javax.xml.ws.addressing.AddressingProperties;
+
+public interface SOAPAddressingProperties extends AddressingProperties
+{
+ public void readHeaders(SOAPMessage message) throws AddressingException;
+
+ public void writeHeaders(SOAPMessage message) throws AddressingException;
+
+ public void setMu(boolean mu);
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingBuilderImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingBuilderImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingBuilderImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: AddressingBuilderImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AddressingBuilder;
+import javax.xml.ws.addressing.AddressingConstants;
+import javax.xml.ws.addressing.AddressingProperties;
+import javax.xml.ws.addressing.AttributedQName;
+import javax.xml.ws.addressing.AttributedURI;
+import javax.xml.ws.addressing.EndpointReference;
+import javax.xml.ws.addressing.Relationship;
+
+/**
+ * Factory for <code>AddressingElements</code>.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AddressingBuilderImpl extends AddressingBuilder
+{
+ public AttributedURI newURI(URI uri)
+ {
+ return new AttributedURIImpl(uri);
+ }
+
+ public AttributedURI newURI(String uri) throws URISyntaxException
+ {
+ return newURI(new URI(uri));
+ }
+
+ public AttributedQName newQName(QName name)
+ {
+ return new AttributedQNameImpl(name);
+ }
+
+ public Relationship newRelationship(URI uri)
+ {
+ return new RelationshipImpl(uri);
+ }
+
+ public EndpointReference newEndpointReference(URI uri)
+ {
+ return new EndpointReferenceImpl(uri);
+ }
+
+ public AddressingProperties newAddressingProperties()
+ {
+ return new AddressingPropertiesImpl();
+ }
+
+ public AddressingConstants newAddressingConstants()
+ {
+ return new AddressingConstantsImpl();
+ }
+
+ public String getNamespaceURI()
+ {
+ return new AddressingTypeImpl().getNamespaceURI();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingClientUtil.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingClientUtil.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingClientUtil.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,120 @@
+package org.jboss.ws.extensions.addressing;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.rpc.Stub;
+import javax.xml.ws.addressing.AddressingBuilder;
+import javax.xml.ws.addressing.AddressingConstants;
+import javax.xml.ws.addressing.AddressingProperties;
+import javax.xml.ws.addressing.AttributedURI;
+
+import org.jboss.ws.core.utils.UUIDGenerator;
+
+/**
+ * @author Heiko Braun, <heiko at openj.net>
+ * @since 04-Mar-2006
+ */
+public class AddressingClientUtil
+{
+ private static AddressingBuilder BUILDER;
+ private static AddressingConstants CONSTANTS;
+ static
+ {
+ BUILDER = AddressingBuilder.getAddressingBuilder();
+ CONSTANTS = BUILDER.newAddressingConstants();
+ }
+
+ /* creates outbound addressing properties */
+ public static AddressingProperties createRequestProperties()
+ {
+ AddressingProperties addrProps = BUILDER.newAddressingProperties();
+ addrProps.setMessageID(BUILDER.newURI(generateMessageID()));
+ return addrProps;
+ }
+
+ /**
+ * create default outbound addressing properties.
+ */
+ public static AddressingProperties createDefaultProps(String wsaAction, String wsaTo)
+ {
+ try
+ {
+ AddressingProperties addrProps = createRequestProperties();
+ addrProps.setMessageID(BUILDER.newURI(generateMessageID()));
+ addrProps.setAction(BUILDER.newURI(wsaAction));
+ addrProps.setTo(BUILDER.newURI(wsaTo));
+ return addrProps;
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ /**
+ * create anonymous request properties.
+ * wsa:ReplyTo is set to anonymous and a messageID is supplied.
+ */
+ public static AddressingProperties createAnonymousProps(String wsaAction, String wsaTo)
+ {
+ try
+ {
+ AddressingProperties addrProps = createDefaultProps(wsaAction, wsaTo);
+ addrProps.setReplyTo(BUILDER.newEndpointReference(new URI(CONSTANTS.getAnonymousURI())));
+ return addrProps;
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ /**
+ * one-way properties cary a wsa:ReplyTo of none
+ * upon which no response is expected.
+ */
+ public static AddressingProperties createOneWayProps(String wsaAction, String wsaTo)
+ {
+ try
+ {
+ AddressingProperties addrProps = createDefaultProps(wsaAction, wsaTo);
+ addrProps.setReplyTo(BUILDER.newEndpointReference(new URI(CONSTANTS.getNoneURI())));
+ return addrProps;
+ }
+ catch (URISyntaxException e)
+ {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ /**
+ * customize a stubs endpooint url
+ */
+ public static void setTargetAddress(Stub stub, String url)
+ {
+ stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, url);
+ }
+
+ /**
+ * generate a UUID based message id.
+ */
+ public static URI generateMessageID()
+ {
+ URI messageId = null;
+ try
+ {
+ messageId = new URI("urn:uuid:" + UUIDGenerator.generateRandomUUIDString());
+ }
+ catch (URISyntaxException e)
+ {
+ // Doesnt happen
+ }
+ return messageId;
+ }
+
+ public static AttributedURI createMessageID()
+ {
+ return BUILDER.newURI(generateMessageID());
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingConstantsImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingConstantsImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingConstantsImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,208 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: AddressingConstantsImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AddressingConstants;
+
+import org.jboss.ws.extensions.addressing.util.NotImplementedException;
+
+/**
+ * Encapsulation for version-specific WS-Addressing constants.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AddressingConstantsImpl implements AddressingConstants
+{
+ static final String URI_ADDRESSING = "http://www.w3.org/2005/08/addressing";
+ static final String PREFIX_ADDRESSING = "wsa";
+ static final String NS_WSDL11 = "http://schemas.xmlsoap.org/wsdl/";
+ static final String PREFIX_WSDL = "wsdl";
+
+ public String getNamespaceURI()
+ {
+ return URI_ADDRESSING;
+ }
+
+ public String getNamespacePrefix()
+ {
+ return PREFIX_ADDRESSING;
+ }
+
+ public String getWSDLNamespaceURI()
+ {
+ return NS_WSDL11;
+ }
+
+ public String getWSDLNamespacePrefix()
+ {
+ return PREFIX_WSDL;
+ }
+
+ public QName getWSDLExtensibilityQName()
+ {
+ return null;
+ }
+
+ public QName getWSDLActionQName()
+ {
+ return new QName(URI_ADDRESSING, "Action", "wsa");
+ }
+
+ public String getAnonymousURI()
+ {
+ return "http://www.w3.org/2005/08/addressing/anonymous";
+ }
+
+ public String getNoneURI()
+ {
+ return "http://www.w3.org/2005/08/addressing/none";
+ }
+
+ public QName getFromQName()
+ {
+ return new QName(URI_ADDRESSING, "From", PREFIX_ADDRESSING);
+ }
+
+ public QName getToQName()
+ {
+ return new QName(URI_ADDRESSING, "To", PREFIX_ADDRESSING);
+ }
+
+ public QName getReplyToQName()
+ {
+ return new QName(URI_ADDRESSING, "ReplyTo", PREFIX_ADDRESSING);
+ }
+
+ public QName getFaultToQName()
+ {
+ return new QName(URI_ADDRESSING, "FaultTo", PREFIX_ADDRESSING);
+ }
+
+ public QName getActionQName()
+ {
+ return new QName(URI_ADDRESSING, "Action", PREFIX_ADDRESSING);
+ }
+
+ public QName getMessageIDQName()
+ {
+ return new QName(URI_ADDRESSING, "MessageID", PREFIX_ADDRESSING);
+ }
+
+ public QName getRelationshipReplyQName()
+ {
+ return new QName(URI_ADDRESSING, "Reply", PREFIX_ADDRESSING);
+ }
+
+ public QName getRelatesToQName()
+ {
+ return new QName(URI_ADDRESSING, "RelatesTo", PREFIX_ADDRESSING);
+ }
+
+ public String getRelationshipTypeName()
+ {
+ return "RelationshipType";
+ }
+
+ public QName getMetadataQName()
+ {
+ return new QName(URI_ADDRESSING, "Metadata", PREFIX_ADDRESSING);
+ }
+
+ public QName getAddressQName()
+ {
+ return new QName(URI_ADDRESSING, "Address", PREFIX_ADDRESSING);
+ }
+
+ public QName getReferenceParametersQName()
+ {
+ return new QName(URI_ADDRESSING, "ReferenceParameters", PREFIX_ADDRESSING);
+ }
+
+ public String getPackageName()
+ {
+ return getClass().getPackage().getName();
+ }
+
+ public String getIsReferenceParameterName() throws Exception
+ {
+ throw new NotImplementedException();
+ }
+
+ public QName getInvalidMapQName()
+ {
+ return new QName(URI_ADDRESSING, "InvalidMessageInformationHeader", PREFIX_ADDRESSING);
+ }
+
+ public QName getMapRequiredQName()
+ {
+ return new QName(URI_ADDRESSING, "MessageInformationHeaderRequired", PREFIX_ADDRESSING);
+ }
+
+ public QName getDestinationUnreachableQName()
+ {
+ return new QName(URI_ADDRESSING, "DestinationUnreachable", PREFIX_ADDRESSING);
+ }
+
+ public QName getActioNotSupportedQName()
+ {
+ return new QName(URI_ADDRESSING, "ActionNotSupported", PREFIX_ADDRESSING);
+ }
+
+ public QName getEndpointUnavailableQName()
+ {
+ return new QName(URI_ADDRESSING, "EndpointUnavailable", PREFIX_ADDRESSING);
+ }
+
+ public String getDefaultFaultAction()
+ {
+ return "http://www.w3.org/2005/08/addressing/fault";
+ }
+
+ public String getActionNotSupportedText()
+ {
+ return "Action not supported";
+ }
+
+ public String getDestinationUnreachableText()
+ {
+ return "Destination unreachable";
+ }
+
+ public String getEndpointUnavailableText()
+ {
+ return "Endpoint unavailable";
+ }
+
+ public String getInvalidMapText()
+ {
+ return "Invalid Map";
+ }
+
+ public String getMapRequiredText()
+ {
+ return "Map Required";
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingPropertiesImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingPropertiesImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingPropertiesImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,292 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPElement;
+import javax.xml.ws.addressing.AddressingBuilder;
+import javax.xml.ws.addressing.AddressingConstants;
+import javax.xml.ws.addressing.AddressingProperties;
+import javax.xml.ws.addressing.AddressingType;
+import javax.xml.ws.addressing.AttributedURI;
+import javax.xml.ws.addressing.EndpointReference;
+import javax.xml.ws.addressing.ReferenceParameters;
+import javax.xml.ws.addressing.Relationship;
+
+// $Id: AddressingPropertiesImpl.java 3534 2007-06-11 16:10:05Z heiko.braun at jboss.com $
+
+/**
+ * Each instance is associated with a particular WS-Addressing schema whose
+ * namespace URI is returned by its <code>getAddressingVersion</code> method.
+ *
+ * The namespace of each key in the underlying map must match this URI and the
+ * local names of all the keys must be exactly the names of the Message Addressing Properties
+ * defined in that version of the WS-Addressing specification.
+ *
+ * Each value in the underlying type must be an instance of <code>AddressingType</code> whose
+ * WS-Addressing version (determined by its <code>getAddressingVersion</code>) method must
+ * match the WS-Addressing version associated with the <code>AddressingProperties</code>.
+ *
+ * TODO: verify that AddressingPropertiesImpl can extend ElementExtensibleImpl.
+ * See http://jira.jboss.com/jira/browse/JBWS-728
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AddressingPropertiesImpl extends ElementExtensibleImpl implements AddressingProperties
+{
+ private static AddressingConstants ADDR = new AddressingConstantsImpl();
+
+ // A REQUIRED absolute URI representing the address of the intended receiver of this message.
+ private AttributedURI to;
+ // A REQUIRED absolute URI that uniquely identifies the semantics implied by this message.
+ private AttributedURI action;
+ // An OPTIONAL absolute URI that uniquely identifies the message.
+ private AttributedURI messageId;
+ // An OPTIONAL pair of values that indicate how this message relates to another message.
+ private Relationship[] relatesTo;
+ // An OPTIONAL endpoint reference for the intended receiver for replies to this message.
+ private EndpointReference replyTo;
+ // An OPTIONAL endpoint reference for the intended receiver for faults related to this message.
+ private EndpointReference faultTo;
+ // An OPTIONAL reference to the endpoint from which the message originated.
+ private EndpointReference from;
+ // Corresponds to the value of the [reference parameters] property of the endpoint reference to which the message is addressed.
+ private ReferenceParameters refParams = new ReferenceParametersImpl();
+
+ private Map<QName, AddressingType> addrTypes = new HashMap<QName, AddressingType>();
+
+ private boolean initialized = false;
+
+ public AttributedURI getTo()
+ {
+ return to;
+ }
+
+ public void setTo(AttributedURI to)
+ {
+ this.to = to;
+ }
+
+ public AttributedURI getAction()
+ {
+ return action;
+ }
+
+ public void setAction(AttributedURI action)
+ {
+ this.action = action;
+ }
+
+ public AttributedURI getMessageID()
+ {
+ return messageId;
+ }
+
+ public void setMessageID(AttributedURI iri)
+ {
+ this.messageId = iri;
+ }
+
+ public Relationship[] getRelatesTo()
+ {
+ return relatesTo;
+ }
+
+ public void setRelatesTo(Relationship[] relatesTo)
+ {
+ this.relatesTo = relatesTo;
+ }
+
+ public EndpointReference getReplyTo()
+ {
+ return replyTo;
+ }
+
+ public void setReplyTo(EndpointReference replyTo)
+ {
+ this.replyTo = replyTo;
+ }
+
+ public EndpointReference getFaultTo()
+ {
+ return faultTo;
+ }
+
+ public void setFaultTo(EndpointReference faultTo)
+ {
+ this.faultTo = faultTo;
+ }
+
+ public EndpointReference getFrom()
+ {
+ return from;
+ }
+
+ public void setFrom(EndpointReference from)
+ {
+ this.from = from;
+ }
+
+ public ReferenceParameters getReferenceParameters()
+ {
+ return refParams;
+ }
+
+ /**
+ * Initializes the properties as a destination using the given
+ * <code>EndpointReference</code>. The <bold>To</bold> property is initialized
+ * using the <bold>Address</bold> property of the <code>EndpointReference</code>
+ * and the <bold>ReferenceParameters</bold> property is initialized using the
+ * <bold>ReferenceParameters</bold> property of the <code>EndpointReference</code>.
+ *
+ * @param epr The <code>EndpointReference</code> representing the destination.
+ */
+ public void initializeAsDestination(EndpointReference epr)
+ {
+ if(initialized) return;
+
+ if (epr == null)
+ throw new IllegalArgumentException("Invalid null endpoint reference");
+
+ this.to = epr.getAddress();
+
+ ReferenceParameters srcParams = epr.getReferenceParameters();
+ for (Object obj : srcParams.getElements())
+ {
+ SOAPElement soapElement = (SOAPElement)obj;
+ soapElement.setAttributeNS(getNamespaceURI(), "wsa:IsReferenceParameter", "true");
+ addElement(soapElement);
+ }
+
+ this.initialized = true;
+ }
+
+ /**
+ * Initialize this <code>AddressingProperties</code> as a reply to the
+ * given message. As described in the WS-Addressing Core specification.
+ * The <bold>ReplyTo</bold> property is using the <bold>Address</bold>
+ * property of the source <code>AddressingProperties</code> and the
+ * <bold>ReferenceParameters</bold> property is initialized using the
+ * <bold>ReferenceParameters</bold> property of the source message.
+ *
+ * @param props The source <code>AddressingProperties</code>
+ * @param isFault <code>true</code> if the reply is a Fault message.
+ */
+ public void initializeAsReply(AddressingProperties props, boolean isFault)
+ {
+ if(initialized) return;
+
+ EndpointReference epr = (isFault ? props.getFaultTo() : null);
+ if (epr == null)
+ {
+ epr = props.getReplyTo();
+ }
+ this.to = (epr != null ? epr.getAddress() : new AttributedURIImpl(ADDR.getAnonymousURI()));
+
+ if (epr != null)
+ {
+ ReferenceParameters srcParams = epr.getReferenceParameters();
+ for (Object obj : srcParams.getElements())
+ {
+ SOAPElement soapElement = (SOAPElement)obj;
+ soapElement.setAttributeNS(getNamespaceURI(), "wsa:IsReferenceParameter", "true");
+ addElement(soapElement);
+ }
+ }
+ if (props.getMessageID() != null)
+ {
+ AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
+ Relationship rel = builder.newRelationship(props.getMessageID().getURI());
+ this.relatesTo = new Relationship[] { rel };
+ }
+
+ this.initialized = true;
+ }
+
+ // Map interface ****************************************************************
+
+ public int size()
+ {
+ return addrTypes.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return addrTypes.isEmpty();
+ }
+
+ public boolean containsKey(Object arg0)
+ {
+ return addrTypes.containsKey(arg0);
+ }
+
+ public boolean containsValue(Object arg0)
+ {
+ return addrTypes.containsValue(arg0);
+ }
+
+ public AddressingType get(Object arg0)
+ {
+ return addrTypes.get(arg0);
+ }
+
+ public AddressingType put(QName arg0, AddressingType arg1)
+ {
+ return addrTypes.put(arg0, arg1);
+ }
+
+ public AddressingType remove(Object arg0)
+ {
+ return addrTypes.remove(arg0);
+ }
+
+ public void putAll(Map<? extends QName, ? extends AddressingType> arg0)
+ {
+ addrTypes.putAll(arg0);
+ }
+
+ public void clear()
+ {
+ addrTypes.clear();
+ }
+
+ public Set<QName> keySet()
+ {
+ return addrTypes.keySet();
+ }
+
+ public Collection<AddressingType> values()
+ {
+ return addrTypes.values();
+ }
+
+ public Set<Entry<QName, AddressingType>> entrySet()
+ {
+ return addrTypes.entrySet();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingTypeImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingTypeImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AddressingTypeImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: AddressingTypeImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import javax.xml.ws.addressing.AddressingType;
+
+/**
+ * Implemented by wrappers for types defined by <b>WS-Addressing</b>.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AddressingTypeImpl implements AddressingType
+{
+ public String getNamespaceURI()
+ {
+ return AddressingConstantsImpl.URI_ADDRESSING;
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeElementExtensibleImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeElementExtensibleImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeElementExtensibleImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,76 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: AttributeElementExtensibleImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AddressingException;
+import javax.xml.ws.addressing.AddressingType;
+import javax.xml.ws.addressing.AttributeExtensible;
+import javax.xml.ws.addressing.ElementExtensible;
+
+/**
+ * Used to represent Addressing classes that support collections of arbitrary XML Elements.
+ * Used to represent Addressing classes that support extensibility attributes.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AttributeElementExtensibleImpl implements AttributeExtensible, ElementExtensible, AddressingType
+{
+ private AttributeExtensible attrExt = new AttributeExtensibleImpl();
+ private ElementExtensible elmtExt = new ElementExtensibleImpl();
+
+ public Map<QName, String> getAttributes()
+ {
+ return attrExt.getAttributes();
+ }
+
+ public void addAttribute(QName name, String value) throws AddressingException
+ {
+ attrExt.addAttribute(name, value);
+ }
+
+ public List<Object> getElements()
+ {
+ return elmtExt.getElements();
+ }
+
+ public void addElement(Object element)
+ {
+ elmtExt.addElement(element);
+ }
+
+ public boolean removeElement(Object element)
+ {
+ return elmtExt.removeElement(element);
+ }
+
+ public String getNamespaceURI()
+ {
+ return new AddressingTypeImpl().getNamespaceURI();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeExtensibleImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeExtensibleImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributeExtensibleImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: AttributeExtensibleImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AddressingException;
+import javax.xml.ws.addressing.AttributeExtensible;
+
+/**
+ * Used to represent Addressing classes that support extensibility attributes.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AttributeExtensibleImpl extends AddressingTypeImpl implements AttributeExtensible
+{
+ private Map<QName, String> extMap = new HashMap<QName, String>();
+
+ public Map<QName, String> getAttributes()
+ {
+ return extMap;
+ }
+
+ public void addAttribute(QName name, String value) throws AddressingException
+ {
+ extMap.put(name, value);
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedQNameImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedQNameImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedQNameImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: AttributedQNameImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AttributedQName;
+
+/**
+ * Abstraction of <code>AttributedQNameType</code> defined in the normative
+ * WS-Addressing core schema.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AttributedQNameImpl extends AttributeExtensibleImpl implements AttributedQName
+{
+ private QName qname;
+
+ public AttributedQNameImpl(QName qname)
+ {
+ this.qname = qname;
+ }
+
+ public QName getQName()
+ {
+ return qname;
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedURIImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedURIImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/AttributedURIImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: AttributedURIImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.ws.addressing.AttributedURI;
+
+/**
+ * Abstraction <code>AttributedURIType</code> defined in the normative WS-Addressing core schema.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class AttributedURIImpl extends AttributeExtensibleImpl implements AttributedURI
+{
+ private URI uri;
+
+ public AttributedURIImpl(URI uri)
+ {
+ this.uri = uri;
+ }
+
+ public AttributedURIImpl(String uri)
+ {
+ try
+ {
+ this.uri = new URI(uri);
+ }
+ catch (URISyntaxException ex)
+ {
+ throw new IllegalArgumentException(ex.toString());
+ }
+ }
+
+ public URI getURI()
+ {
+ return uri;
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ElementExtensibleImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ElementExtensibleImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ElementExtensibleImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: ElementExtensibleImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.ws.addressing.ElementExtensible;
+
+/**
+ * Implemented by classes exposing a <code>List</code> of
+ * <code>SOAPElements</code>. Used to represent addressing classes that
+ * support collections of arbitrary XML Elements.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class ElementExtensibleImpl extends AddressingTypeImpl implements ElementExtensible
+{
+ private List<Object> elements = new ArrayList<Object>();
+
+ public List<Object> getElements()
+ {
+ return elements;
+ }
+
+ public void addElement(Object element)
+ {
+ elements.add(element);
+ }
+
+ public boolean removeElement(Object element)
+ {
+ return elements.remove(element);
+ }
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/EndpointReferenceImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/EndpointReferenceImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/EndpointReferenceImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,300 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: EndpointReferenceImpl.java 3959 2007-07-20 14:44:19Z heiko.braun at jboss.com $
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AddressingConstants;
+import javax.xml.ws.addressing.AddressingException;
+import javax.xml.ws.addressing.AttributedURI;
+import javax.xml.ws.addressing.EndpointReference;
+import javax.xml.ws.addressing.Metadata;
+import javax.xml.ws.addressing.ReferenceParameters;
+import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
+
+import org.jboss.ws.extensions.addressing.util.WSException;
+import org.jboss.ws.extensions.addressing.soap.SOAPAddressingBuilderImpl;
+import org.jboss.ws.extensions.addressing.util.DOMUtils;
+import org.jboss.ws.extensions.addressing.util.DOMWriter;
+import org.w3c.dom.Element;
+
+/**
+ * Abstraction of EndpointReference.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class EndpointReferenceImpl extends AttributeElementExtensibleImpl implements EndpointReference
+{
+ private static AddressingConstants ADDR = new AddressingConstantsImpl();
+
+ // The REQUIRED root element name
+ private QName rootQName = new QName(ADDR.getNamespaceURI(), "EndpointReference", ADDR.getNamespacePrefix());
+ // This REQUIRED element (whose content is of type xs:anyURI) specifies the [address] property of the endpoint reference.
+ private AttributedURIImpl address = new AttributedURIImpl(ADDR.getAnonymousURI());
+ // This OPTIONAL element may contain elements from any namespace. Such elements form the [reference parameters] of the reference.
+ private ReferenceParametersImpl refParams = new ReferenceParametersImpl();
+ // This OPTIONAL element may contain elements from any namespace.
+ private MetadataImpl metadata = new MetadataImpl();
+
+ public EndpointReferenceImpl(URI uri)
+ {
+ this.address = new AttributedURIImpl(uri);
+ }
+
+ public EndpointReferenceImpl(Element elRoot)
+ {
+ initFromElement(elRoot);
+ }
+
+ public QName getRootQName()
+ {
+ return rootQName;
+ }
+
+ public void setRootQName(QName rootElementName)
+ {
+ this.rootQName = rootElementName;
+ }
+
+ public AttributedURI getAddress()
+ {
+ return address;
+ }
+
+ public ReferenceParameters getReferenceParameters()
+ {
+ return refParams;
+ }
+
+ public Metadata getMetadata()
+ {
+ return metadata;
+ }
+
+ private void initFromElement(Element elRoot)
+ {
+ if (elRoot == null)
+ throw new IllegalArgumentException("Cannot initialize from null element");
+
+ try
+ {
+ Map<QName, String> attributes = DOMUtils.getAttributes(elRoot);
+ for (QName attqname : attributes.keySet())
+ {
+ String value = attributes.get(attqname);
+ addAttribute(attqname, value);
+ }
+
+ Iterator it = DOMUtils.getChildElements(elRoot);
+ while (it.hasNext())
+ {
+ Element el = (Element)it.next();
+ QName qname = DOMUtils.getElementQName(el);
+
+ // Parse Address
+ if (qname.equals(ADDR.getAddressQName()))
+ {
+ address = new AttributedURIImpl(DOMUtils.getTextContent(el));
+
+ attributes = DOMUtils.getAttributes(el);
+ for (QName attqname : attributes.keySet())
+ {
+ String value = attributes.get(attqname);
+ address.addAttribute(attqname, value);
+ }
+ }
+ // Parse ReferenceParameters
+ else if (qname.equals(ADDR.getReferenceParametersQName()))
+ {
+ attributes = DOMUtils.getAttributes(el);
+ for (QName attqname : attributes.keySet())
+ {
+ String value = attributes.get(attqname);
+ refParams.addAttribute(attqname, value);
+ }
+ Iterator itel = DOMUtils.getChildElements(el);
+ while (itel.hasNext())
+ {
+ Element child = (Element)itel.next();
+ refParams.addElement(child);
+ }
+ }
+ // Parse Metadata
+ else if (qname.equals(ADDR.getMetadataQName()))
+ {
+ attributes = DOMUtils.getAttributes(el);
+ for (QName attqname : attributes.keySet())
+ {
+ String value = attributes.get(attqname);
+ metadata.addAttribute(attqname, value);
+ }
+ Iterator itel = DOMUtils.getChildElements(el);
+ while (itel.hasNext())
+ {
+ Element child = (Element)itel.next();
+ metadata.addElement(child);
+ }
+ }
+ else
+ {
+ addElement(el);
+ }
+ }
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new AddressingException("Cannot init EPR from element", ex);
+ }
+ }
+
+ public Element toElement()
+ {
+ String xmlString = toXMLString(false);
+ try
+ {
+ return DOMUtils.parse(xmlString);
+ }
+ catch (IOException ex)
+ {
+ throw new WSException("Cannot parse: " + xmlString, ex);
+ }
+ }
+
+ public String toXMLString(boolean pretty)
+ {
+ if (pretty)
+ {
+ Element epRef = toElement();
+ return DOMWriter.printNode(epRef, true);
+ }
+
+ SOAPAddressingBuilder builder = new SOAPAddressingBuilderImpl();
+ AddressingConstants ADDR = builder.newAddressingConstants();
+
+ String rootname = getPrefixedName(rootQName);
+ StringBuilder xmlBuffer = new StringBuilder("<" + rootname);
+ appendAttributes(xmlBuffer, getAttributes());
+ xmlBuffer.append(">");
+
+ // insert xmlns:wsa
+ String wsaURI = ADDR.getNamespaceURI();
+ String wsaPrefix = ADDR.getNamespacePrefix();
+ String wsaDeclaration = " xmlns:" + wsaPrefix + "='" + wsaURI + "'";
+ if (xmlBuffer.indexOf(wsaDeclaration) < 0)
+ {
+ xmlBuffer.insert(rootname.length() + 1, wsaDeclaration);
+ }
+
+ // append address
+ xmlBuffer.append("<" + getPrefixedName(ADDR.getAddressQName()));
+ appendAttributes(xmlBuffer, address.getAttributes());
+ xmlBuffer.append(">");
+ xmlBuffer.append(address.getURI() + "</" + getPrefixedName(ADDR.getAddressQName()) + ">");
+
+ // append parameters
+ if (refParams.getElements().size() > 0 || refParams.getAttributes().size() > 0)
+ {
+ xmlBuffer.append("<" + getPrefixedName(ADDR.getReferenceParametersQName()));
+ appendAttributes(xmlBuffer, refParams.getAttributes());
+ xmlBuffer.append(">");
+ appendElements(xmlBuffer, refParams.getElements());
+ xmlBuffer.append("</" + getPrefixedName(ADDR.getReferenceParametersQName()) + ">");
+ }
+
+ // append metadata
+ if (metadata.getElements().size() > 0 || metadata.getAttributes().size() > 0)
+ {
+ xmlBuffer.append("<" + getPrefixedName(ADDR.getMetadataQName()));
+ appendAttributes(xmlBuffer, metadata.getAttributes());
+ xmlBuffer.append(">");
+ appendElements(xmlBuffer, metadata.getElements());
+ xmlBuffer.append("</" + getPrefixedName(ADDR.getMetadataQName()) + ">");
+ }
+
+ // append custom elements
+ appendElements(xmlBuffer, getElements());
+
+ xmlBuffer.append("</" + rootname + ">");
+
+ String xmlString = xmlBuffer.toString();
+ return xmlString;
+ }
+
+ private void appendAttributes(StringBuilder xmlBuffer, Map<QName, String> attributes)
+ {
+ for (QName qname : attributes.keySet())
+ {
+ String qualname = getPrefixedName(qname);
+ String value = attributes.get(qname);
+ xmlBuffer.append(" " + qualname + "='" + value + "'");
+ }
+ }
+
+ private void appendElements(StringBuilder xmlBuffer, List<Object> elements)
+ {
+ for (Object obj : elements)
+ {
+ if (obj instanceof Element)
+ {
+ StringWriter strwr = new StringWriter();
+ DOMWriter domWriter = new DOMWriter(strwr).setCompleteNamespaces(false);
+ domWriter.print((Element)obj);
+ String xmlFragment = strwr.toString();
+ xmlBuffer.append(xmlFragment);
+ }
+ else if (obj instanceof String)
+ {
+ xmlBuffer.append(obj);
+ }
+ else
+ {
+ throw new AddressingException("Unsupported element: " + obj.getClass().getName());
+ }
+ }
+ }
+
+ private String getPrefixedName(QName qname)
+ {
+ String prefix = qname.getPrefix();
+ String localPart = qname.getLocalPart();
+ String qualname = (prefix != null && prefix.length() > 0 ? prefix + ":" + localPart : localPart);
+ return qualname;
+ }
+
+ public String toString()
+ {
+ return toXMLString(true);
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/MetadataImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/MetadataImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/MetadataImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.extensions.addressing;
+
+//$Id: MetadataImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import javax.xml.ws.addressing.Metadata;
+
+/**
+ * Abstraction of Metadata bucket in an <code>EndpointReference</code>.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class MetadataImpl extends AttributeElementExtensibleImpl implements Metadata
+{
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ReferenceParametersImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ReferenceParametersImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/ReferenceParametersImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing;
+
+import javax.xml.ws.addressing.ReferenceParameters;
+
+// $Id: ReferenceParametersImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+/**
+ * Abstraction of ReferenceParameters bucket in an
+ * <code>EndpointReference</code>.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class ReferenceParametersImpl extends AttributeElementExtensibleImpl implements ReferenceParameters
+{
+ public ReferenceParametersImpl()
+ {
+ super();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/RelationshipImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/RelationshipImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/RelationshipImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.Relationship;
+
+// $Id: RelationshipImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+/**
+ * Abstraction of the RelatesToType defined by WS-Addressing. Includes an ID
+ * property that references the MessageID of the related message and a Type
+ * property corresponding to the RelationshipType attribute of the
+ * RelatesToType. Implementing classes must supply a single argument constructor
+ * with parameter type <code>java.net.URI</code>, which is used to initialize
+ * the <b>ID</b> property.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class RelationshipImpl extends AttributeExtensibleImpl implements Relationship
+{
+ private URI uri;
+ private QName type;
+
+ public RelationshipImpl(URI uri)
+ {
+ this.uri = uri;
+ }
+
+ public URI getID()
+ {
+ return uri;
+ }
+
+ public QName getType()
+ {
+ return type;
+ }
+
+ public void setType(QName type)
+ {
+ this.type = type;
+ }
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingClientHandler.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.jaxws;
+
+import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
+import org.jboss.ws.extensions.addressing.soap.SOAPAddressingPropertiesImpl;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.addressing.AddressingBuilder;
+import javax.xml.ws.addressing.AddressingException;
+import javax.xml.ws.addressing.AttributedURI;
+import javax.xml.ws.addressing.JAXWSAConstants;
+import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
+import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.MessageContext.Scope;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A client side handler that reads/writes the addressing properties
+ * and puts then into the message context.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author Heiko.Braun at jboss.com
+ * @since 24-Nov-2005
+ */
+public class WSAddressingClientHandler implements SOAPHandler<SOAPMessageContext>
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(WSAddressingClientHandler.class.getCanonicalName());
+
+ private static AddressingBuilder ADDR_BUILDER;
+ private static AddressingConstantsImpl ADDR_CONSTANTS;
+ private static Set<QName> HEADERS = new HashSet<QName>();
+
+ static
+ {
+ ADDR_CONSTANTS = new AddressingConstantsImpl();
+ ADDR_BUILDER = AddressingBuilder.getAddressingBuilder();
+
+ HEADERS.add( ADDR_CONSTANTS.getActionQName());
+ HEADERS.add( ADDR_CONSTANTS.getToQName());
+ }
+
+ public Set getHeaders()
+ {
+ return Collections.unmodifiableSet(HEADERS);
+ }
+
+ public boolean handleMessage(SOAPMessageContext msgContext)
+ {
+ Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (outbound == null)
+ throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+ return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
+ }
+
+ public boolean handleFault(SOAPMessageContext msgContext)
+ {
+ return true;
+ }
+
+ public void close(MessageContext context)
+ {
+ }
+
+ protected boolean handleOutbound(SOAPMessageContext msgContext)
+ {
+ log.log(Level.INFO, "handleOutbound");
+
+ SOAPAddressingProperties addrProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
+ if (addrProps != null)
+ {
+ SOAPMessage soapMessage = msgContext.getMessage();
+ addrProps.writeHeaders(soapMessage);
+ }
+ else
+ {
+ // supply default addressing properties
+ addrProps = (SOAPAddressingPropertiesImpl)ADDR_BUILDER.newAddressingProperties();
+ msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, addrProps);
+ msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, Scope.APPLICATION);
+ }
+
+ return true;
+ }
+
+ protected boolean handleInbound(SOAPMessageContext msgContext)
+ {
+ log.log(Level.INFO, "handleInbound");
+
+ try
+ {
+ SOAPMessage soapMessage = msgContext.getMessage();
+ if (soapMessage.getSOAPPart().getEnvelope() != null)
+ {
+ SOAPAddressingBuilder builder = (SOAPAddressingBuilder)SOAPAddressingBuilder.getAddressingBuilder();
+ SOAPAddressingProperties addrProps = (SOAPAddressingProperties)builder.newAddressingProperties();
+ addrProps.readHeaders(soapMessage);
+ msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND, addrProps);
+ msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND, Scope.APPLICATION);
+ }
+ }
+ catch (SOAPException ex)
+ {
+ throw new AddressingException("Cannot handle response", ex);
+ }
+
+ return true;
+ }
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/jaxws/WSAddressingServerHandler.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.jaxws;
+
+import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.addressing.AddressingBuilder;
+import javax.xml.ws.addressing.AttributedURI;
+import javax.xml.ws.addressing.JAXWSAConstants;
+import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
+import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.MessageContext.Scope;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A server side handler that reads/writes the addressing properties
+ * and puts then into the message context.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author Heiko.Braun at jboss.com
+ * @since 24-Nov-2005
+ */
+public class WSAddressingServerHandler implements SOAPHandler<SOAPMessageContext>
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(WSAddressingServerHandler.class.getCanonicalName());
+
+ private static AddressingBuilder ADDR_BUILDER;
+ private static AddressingConstantsImpl ADDR_CONSTANTS;
+ private static Set<QName> HEADERS = new HashSet<QName>();
+
+ static
+ {
+ ADDR_CONSTANTS = new AddressingConstantsImpl();
+ ADDR_BUILDER = AddressingBuilder.getAddressingBuilder();
+
+ HEADERS.add( ADDR_CONSTANTS.getActionQName());
+ HEADERS.add( ADDR_CONSTANTS.getToQName());
+ }
+
+ public Set getHeaders()
+ {
+ return Collections.unmodifiableSet(HEADERS);
+ }
+
+ public boolean handleMessage(SOAPMessageContext msgContext)
+ {
+ Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (outbound == null)
+ throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+
+ return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
+ }
+
+ public void close(MessageContext context)
+ {
+ }
+
+ protected boolean handleInbound(SOAPMessageContext msgContext)
+ {
+ log.log(Level.INFO, "handleInbound");
+
+ SOAPAddressingProperties addrProps = (SOAPAddressingProperties)ADDR_BUILDER.newAddressingProperties();
+ SOAPMessage soapMessage = msgContext.getMessage();
+ addrProps.readHeaders(soapMessage);
+ msgContext.put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND, addrProps);
+ msgContext.setScope(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND, Scope.APPLICATION);
+ // use any supplied action as the value for the context's soap action property
+ // TODO do we realy need to do this?
+ AttributedURI action = addrProps.getAction();
+ if (action != null) {
+ msgContext.put(BindingProvider.SOAPACTION_USE_PROPERTY, new Boolean("true"));
+ msgContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, action.getURI().toString());
+ }
+ return true;
+ }
+
+ protected boolean handleOutbound(SOAPMessageContext msgContext)
+ {
+ log.log(Level.INFO, "handleOutbound");
+ handleResponseOrFault(msgContext, false);
+ return true;
+ }
+
+ /**
+ * Get a SOAPAddressingProperties object from the message context
+ * and write the adressing headers
+ */
+ public boolean handleFault(SOAPMessageContext msgContext)
+ {
+ log.log(Level.INFO, "handleFault");
+ handleResponseOrFault(msgContext, true);
+ return true;
+ }
+
+ private void handleResponseOrFault(SOAPMessageContext msgContext, boolean isFault)
+ {
+ SOAPAddressingBuilder builder = (SOAPAddressingBuilder)SOAPAddressingBuilder.getAddressingBuilder();
+ SOAPMessage soapMessage = msgContext.getMessage();
+
+ SOAPAddressingProperties inProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
+ SOAPAddressingProperties outProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND);
+
+ if (outProps == null)
+ {
+ // create new response properties
+ outProps = (SOAPAddressingProperties)builder.newAddressingProperties();
+ msgContext.put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, outProps);
+ msgContext.setScope(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, Scope.APPLICATION);
+ }
+
+ outProps.initializeAsReply(inProps, isFault);
+ /*
+ * cannot do this bit but we don't care
+ try
+ {
+ // supply the response action
+
+ OperationMetaData opMetaData = ((CommonMessageContext)msgContext).getOperationMetaData();
+ msgContext.
+
+ if (!isFault && !opMetaData.isOneWay())
+ {
+
+ AddressingOpMetaExt addrExt = (AddressingOpMetaExt)opMetaData.getExtension(ADDR_CONSTANTS.getNamespaceURI());
+ if (addrExt != null)
+ {
+ outProps.setAction(ADDR_BUILDER.newURI(addrExt.getOutboundAction()));
+ }
+ else
+ {
+ log.warn("Unable to resolve replyAction for " + opMetaData.getQName());
+ }
+
+ }
+ else if (isFault)
+ {
+ outProps.setAction(ADDR_BUILDER.newURI(ADDR_CONSTANTS.getDefaultFaultAction()));
+ }
+
+ }
+ catch (URISyntaxException e)
+ {
+ log.error("Error setting response action", e);
+ }
+ */
+
+ // don't need to do this for glassfish
+ // outProps.writeHeaders(soapMessage);
+ }
+
+ /* check wsa formal constraints */
+ private void validateRequest(SOAPAddressingProperties addrProps)
+ {
+ // If wsa:ReplyTo is supplied and the message lacks a [message id] property, the processor MUST fault.
+ if (addrProps.getReplyTo() != null && addrProps.getMessageID() == null)
+ throw new IllegalArgumentException("wsa:MessageId is required when wsa:ReplyTo is supplied");
+
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/metadata/AddressingOpMetaExt.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/metadata/AddressingOpMetaExt.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/metadata/AddressingOpMetaExt.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.metadata;
+
+// $Id: AddressingOpMetaExt.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import org.jboss.ws.extensions.addressing.util.MetaDataExtension;
+
+/**
+ * Addressing meta data extensions:
+ * <ul>
+ * <li>wsa:Action attribute
+ * </ul>
+ * @author Heiko Braun, <heiko at openj.net>
+ * @since 17-Mar-2006
+ */
+public class AddressingOpMetaExt extends MetaDataExtension
+{
+ private String inboundAction;
+ private String outboundAction;
+
+ public AddressingOpMetaExt(String extensionNameSpace)
+ {
+ super(extensionNameSpace);
+ }
+
+ public String getInboundAction()
+ {
+ return inboundAction;
+ }
+
+ public void setInboundAction(String inboundAction)
+ {
+ this.inboundAction = inboundAction;
+ }
+
+ public String getOutboundAction()
+ {
+ return outboundAction;
+ }
+
+ public void setOutboundAction(String outboundAction)
+ {
+ this.outboundAction = outboundAction;
+ }
+
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingBuilderImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingBuilderImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingBuilderImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.soap;
+
+//$Id: SOAPAddressingBuilderImpl.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.AddressingConstants;
+import javax.xml.ws.addressing.AddressingProperties;
+import javax.xml.ws.addressing.AttributedQName;
+import javax.xml.ws.addressing.AttributedURI;
+import javax.xml.ws.addressing.EndpointReference;
+import javax.xml.ws.addressing.Relationship;
+import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
+
+import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
+import org.jboss.ws.extensions.addressing.AddressingTypeImpl;
+import org.jboss.ws.extensions.addressing.AttributedQNameImpl;
+import org.jboss.ws.extensions.addressing.AttributedURIImpl;
+import org.jboss.ws.extensions.addressing.EndpointReferenceImpl;
+import org.jboss.ws.extensions.addressing.RelationshipImpl;
+
+/**
+ * Factory for <code>AddressingElements</code>.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 14-Nov-2005
+ */
+public class SOAPAddressingBuilderImpl extends SOAPAddressingBuilder
+{
+ public AttributedURI newURI(URI uri)
+ {
+ return new AttributedURIImpl(uri);
+ }
+
+ public AttributedURI newURI(String uri) throws URISyntaxException
+ {
+ return newURI(new URI(uri));
+ }
+
+ public AttributedQName newQName(QName name)
+ {
+ return new AttributedQNameImpl(name);
+ }
+
+ public Relationship newRelationship(URI uri)
+ {
+ return new RelationshipImpl(uri);
+ }
+
+ public EndpointReference newEndpointReference(URI uri)
+ {
+ return new EndpointReferenceImpl(uri);
+ }
+
+ public AddressingProperties newAddressingProperties()
+ {
+ return new SOAPAddressingPropertiesImpl();
+ }
+
+ public AddressingConstants newAddressingConstants()
+ {
+ return new AddressingConstantsImpl();
+ }
+
+ public String getNamespaceURI()
+ {
+ return new AddressingTypeImpl().getNamespaceURI();
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,353 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.soap;
+
+//$Id: SOAPAddressingPropertiesImpl.java 3959 2007-07-20 14:44:19Z heiko.braun at jboss.com $
+
+import javax.xml.soap.*;
+import org.jboss.ws.extensions.addressing.AddressingConstantsImpl;
+import org.jboss.ws.extensions.addressing.AddressingPropertiesImpl;
+import org.jboss.ws.extensions.addressing.EndpointReferenceImpl;
+import org.jboss.ws.extensions.addressing.util.DOMUtils;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.addressing.*;
+import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
+import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
+import java.lang.reflect.Array;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Subimplementation of <code>AddressingProperties</code> includes methods that
+ * read and write the Message Addressing Properties to a <code>SOAPMessage</code>.
+ * All individual properties must implement <code>SOAPAddressingElement</code>.
+ *
+ * @See http://www.w3.org/TR/ws-addr-core/
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 15-Nov-2005
+ */
+public class SOAPAddressingPropertiesImpl extends AddressingPropertiesImpl implements SOAPAddressingProperties
+{
+ private static AddressingConstants ADDR = new AddressingConstantsImpl();
+
+
+ private boolean mustunderstand;
+
+ private String getRequiredHeaderContent(SOAPHeader soapHeader, QName qname)
+ {
+ Element element = DOMUtils.getFirstChildElement(soapHeader, qname);
+ if(null == element) throw new AddressingException("Required element "+qname+" is missing");
+
+ String value = DOMUtils.getTextContent(element);
+ if(null == value || value.equals("")) throw new AddressingException("Required element "+qname+" is missing");
+
+ return value;
+ }
+
+ private String getOptionalHeaderContent(SOAPHeader soapHeader, QName qname)
+ {
+ Element element = DOMUtils.getFirstChildElement(soapHeader, qname);
+ if (element != null)
+ {
+ return DOMUtils.getTextContent(element);
+ }
+
+ return null;
+ }
+
+ public void readHeaders(SOAPMessage message) throws AddressingException
+ {
+ try
+ {
+ SOAPHeader soapHeader = message.getSOAPHeader();
+
+ SOAPAddressingBuilder builder = new SOAPAddressingBuilderImpl();
+ AddressingConstants ADDR = builder.newAddressingConstants();
+
+ // wsa:To
+ // This OPTIONAL element provides the value for the [destination] property.
+ // If this element is NOT present then the value of the [destination]
+ // property is "http://www.w3.org/2005/08/addressing/anonymous".
+ String to = getOptionalHeaderContent(soapHeader, ADDR.getToQName());
+ if(to!=null)
+ setTo(builder.newURI(to));
+
+ // Read wsa:From
+ // This OPTIONAL element (of type wsa:EndpointReferenceType) provides the value for the [source endpoint] property.
+ Element wsaFrom = DOMUtils.getFirstChildElement(soapHeader, ADDR.getFromQName());
+ if (wsaFrom != null)
+ {
+ EndpointReferenceImpl ref = new EndpointReferenceImpl(wsaFrom);
+ setReplyTo(ref);
+ }
+
+ // Read wsa:ReplyTo
+ // This OPTIONAL element provides the value for the [reply endpoint] property.
+ // If this element is NOT present then the value of the [address] property of the [reply endpoint]
+ // EPR is "http://www.w3.org/2005/08/addressing/anonymous".
+ Element wsaReplyTo = DOMUtils.getFirstChildElement(soapHeader, ADDR.getReplyToQName());
+ if (wsaReplyTo != null)
+ {
+ EndpointReferenceImpl ref = new EndpointReferenceImpl(wsaReplyTo);
+ setReplyTo(ref);
+ }
+
+ // Read wsa:FaultTo
+ // This OPTIONAL element (of type wsa:EndpointReferenceType) provides the value for the [fault endpoint] property.
+ // If this element is present, wsa:MessageID MUST be present.
+ Element wsaFaultTo = DOMUtils.getFirstChildElement(soapHeader, ADDR.getFaultToQName());
+ if (wsaFaultTo != null)
+ {
+ EndpointReferenceImpl ref = new EndpointReferenceImpl(wsaFaultTo);
+ setFaultTo(ref);
+ }
+
+ // wsa:Action
+ // This REQUIRED element of type xs:anyURI conveys the [action] property.
+ // The [children] of this element convey the value of this property.
+ String action = getRequiredHeaderContent(soapHeader, ADDR.getActionQName());
+ setAction(builder.newURI(action));
+
+ // Read wsa:MessageID
+ // This OPTIONAL element (whose content is of type xs:anyURI) conveys the [message id] property.
+ String messageID = getOptionalHeaderContent(soapHeader, ADDR.getMessageIDQName());
+ if(messageID!=null) setMessageID(builder.newURI(messageID));
+
+ // Read wsa:RelatesTo
+ // This OPTIONAL attribute conveys the relationship type as an IRI.
+ // When absent, the implied value of this attribute is "http://www.w3.org/2005/08/addressing/reply".
+ Iterator itRelatesTo = DOMUtils.getChildElements(soapHeader, ADDR.getRelatesToQName());
+ List<Relationship> relList = new ArrayList<Relationship>();
+ while (itRelatesTo.hasNext())
+ {
+ Element wsaRelatesTo = (Element)itRelatesTo.next();
+ QName type = DOMUtils.getAttributeValueAsQName(wsaRelatesTo, ADDR.getRelationshipTypeName());
+ String uri = DOMUtils.getTextContent(wsaRelatesTo);
+ Relationship rel = builder.newRelationship(new URI(uri));
+ rel.setType(type);
+ relList.add(rel);
+ }
+ Relationship[] relArr = (Relationship[])Array.newInstance(Relationship.class, relList.size());
+ relList.toArray(relArr);
+ setRelatesTo(relArr);
+
+ // Read wsa:ReferenceParameters
+ QName refQName = new QName(getNamespaceURI(), "IsReferenceParameter");
+ ReferenceParameters refParams = getReferenceParameters();
+ Iterator it = soapHeader.examineAllHeaderElements();
+ while (it.hasNext())
+ {
+ SOAPHeaderElement headerElement = (SOAPHeaderElement)it.next();
+ if ("true".equals(DOMUtils.getAttributeValue(headerElement, refQName)))
+ {
+ refParams.addElement(headerElement);
+ }
+ }
+ }
+ catch (SOAPException ex)
+ {
+ throw new AddressingException("Cannot read headers", ex);
+ }
+ catch (URISyntaxException ex)
+ {
+ throw new AddressingException("Cannot read headers", ex);
+ }
+ }
+
+ public void writeHeaders(SOAPMessage message) throws AddressingException
+ {
+ try
+ {
+ SOAPFactory factory = (SOAPFactory)SOAPFactory.newInstance();
+ SOAPHeader soapHeader = message.getSOAPHeader();
+
+ if (soapHeader == null) {
+ soapHeader = message.getSOAPPart().getEnvelope().addHeader();
+ }
+
+ // Add the xmlns:wsa declaration
+ soapHeader.addNamespaceDeclaration(ADDR.getNamespacePrefix(), ADDR.getNamespaceURI());
+
+ // Write wsa:To
+ if (getTo() != null)
+ {
+ SOAPElement element = soapHeader.addChildElement(ADDR.getToQName());
+ element.addTextNode(getTo().getURI().toString());
+ }
+
+ // Write wsa:From
+ if (getFrom() != null)
+ {
+ EndpointReferenceImpl epr = (EndpointReferenceImpl)getFrom();
+ epr.setRootQName(ADDR.getFromQName());
+ SOAPElement soapElement = factory.createElement(epr.toElement());
+ soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
+ soapHeader.addChildElement(soapElement);
+ }
+
+ // Write wsa:ReplyTo
+ if (getReplyTo() != null)
+ {
+ EndpointReferenceImpl epr = (EndpointReferenceImpl)getReplyTo();
+ epr.setRootQName(ADDR.getReplyToQName());
+ SOAPElement soapElement = factory.createElement(epr.toElement());
+ soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
+ soapHeader.addChildElement(soapElement);
+ }
+
+ // Write wsa:FaultTo
+ if (getFaultTo() != null)
+ {
+ EndpointReferenceImpl epr = (EndpointReferenceImpl)getFaultTo();
+ epr.setRootQName(ADDR.getFaultToQName());
+ SOAPElement soapElement = factory.createElement(epr.toElement());
+ soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
+ soapHeader.addChildElement(soapElement);
+ }
+
+ appendRequiredHeader(soapHeader, ADDR.getActionQName(), getAction());
+
+ // Write wsa:MessageID
+ if( (getReplyTo()!=null || getFaultTo()!=null) && null==getMessageID())
+ {
+ throw new AddressingException("Required addressing header missing:" + ADDR.getMessageIDQName());
+ }
+ else if (getMessageID() != null)
+ {
+ SOAPElement wsaMessageId = soapHeader.addChildElement(ADDR.getMessageIDQName());
+ wsaMessageId.addTextNode(getMessageID().getURI().toString());
+ }
+
+ // Write wsa:RelatesTo
+ if (getRelatesTo() != null)
+ {
+ for (Relationship rel : getRelatesTo())
+ {
+ SOAPElement wsaRelatesTo = soapHeader.addChildElement(ADDR.getRelatesToQName());
+ if (rel.getType() != null)
+ {
+ wsaRelatesTo.setAttribute(ADDR.getRelationshipTypeName(), getPrefixedName(rel.getType()));
+ }
+ wsaRelatesTo.addTextNode(rel.getID().toString());
+ }
+ }
+
+ // Write wsa:ReferenceParameters
+ ReferenceParameters refParams = getReferenceParameters();
+ if (refParams.getElements().size() > 0 || refParams.getAttributes().size() > 0)
+ {
+ SOAPElement wsaRefParams = soapHeader.addChildElement(ADDR.getReferenceParametersQName());
+ appendAttributes(wsaRefParams, refParams.getAttributes());
+ appendElements(wsaRefParams, refParams.getElements());
+ }
+
+ appendElements(soapHeader, getElements());
+ }
+ catch (SOAPException ex)
+ {
+ throw new AddressingException("Cannot read ws-addressing headers", ex);
+ }
+ }
+
+ private void appendRequiredHeader(SOAPHeader soapHeader, QName name, AttributedURI value) throws SOAPException
+ {
+ if(null == value)
+ throw new AddressingException("Required addressing property missing: " + name);
+
+ SOAPElement element = soapHeader.addChildElement(name);
+ element.addTextNode(value.getURI().toString());
+
+ if(mustunderstand)
+ {
+ // add soap:mustUnderstand=1
+ String envNS = soapHeader.getParentElement().getNamespaceURI();
+ element.addNamespaceDeclaration("soap", envNS);
+ element.addAttribute(new QName(envNS, "mustUnderstand", "soap"), "1");
+ }
+ }
+
+ public void setMu(boolean mu)
+ {
+ this.mustunderstand = mu;
+ }
+
+ private void appendAttributes(SOAPElement soapElement, Map<QName, String> attributes)
+ {
+ for (QName qname : attributes.keySet())
+ {
+ String qualname = getPrefixedName(qname);
+ String value = attributes.get(qname);
+ soapElement.setAttribute(qualname, value);
+ }
+ }
+
+ private void appendElements(SOAPElement soapElement, List<Object> elements)
+ {
+ try
+ {
+ SOAPFactory factory = (SOAPFactory)SOAPFactory.newInstance();
+ for (Object obj : elements)
+ {
+ if (obj instanceof Element)
+ {
+ SOAPElement child = factory.createElement((Element)obj);
+ soapElement.addChildElement(child);
+ }
+ else if (obj instanceof String)
+ {
+ Element el = DOMUtils.parse((String)obj);
+ SOAPElement child = factory.createElement(el);
+ soapElement.addChildElement(child);
+ }
+ else
+ {
+ throw new AddressingException("Unsupported element: " + obj.getClass().getName());
+ }
+ }
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new AddressingException("Cannot append elements", ex);
+ }
+ }
+
+ private String getPrefixedName(QName qname)
+ {
+ String prefix = qname.getPrefix();
+ String localPart = qname.getLocalPart();
+ String qualname = (prefix != null && prefix.length() > 0 ? prefix + ":" + localPart : localPart);
+ return qualname;
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMUtils.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMUtils.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMUtils.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,636 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.util;
+
+// $Id$
+
+import org.w3c.dom.*;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.*;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.*;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * DOM2 utilites
+ *
+ * @author Thomas.Diesler at jboss.org
+ */
+public final class DOMUtils
+{
+ private static Logger log = Logger.getLogger(DOMUtils.class.getCanonicalName());
+
+ // All elements created by the same thread are created by the same builder and belong to the same doc
+ private static ThreadLocal<Document> documentThreadLocal = new ThreadLocal<Document>();
+ private static ThreadLocal<DocumentBuilder> builderThreadLocal = new ThreadLocal<DocumentBuilder>()
+ {
+ protected DocumentBuilder initialValue()
+ {
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ setEntityResolver(builder);
+ return builder;
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new RuntimeException("Failed to create DocumentBuilder", e);
+ }
+ }
+
+ private void setEntityResolver(DocumentBuilder builder)
+ {
+ String[] resolvers = new String[] { "org.jboss.ws.core.utils.JBossWSEntityResolver", "org.jboss.util.xml.JBossEntityResolver" };
+
+ EntityResolver entityResolver = null;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ for (String resolver : resolvers)
+ {
+ try
+ {
+ Class<?> resolverClass = loader.loadClass(resolver);
+ entityResolver = (EntityResolver)resolverClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ log.log(Level.FINE, "Cannot load: " + resolver);
+ }
+ }
+
+ if (entityResolver != null)
+ builder.setEntityResolver(entityResolver);
+ }
+ };
+
+ public static void clearThreadLocals()
+ {
+ documentThreadLocal.remove();
+ builderThreadLocal.remove();
+ }
+
+ // Hide the constructor
+ private DOMUtils()
+ {
+ }
+
+ /** Initialize the DocumentBuilder
+ */
+ public static DocumentBuilder getDocumentBuilder()
+ {
+ return builderThreadLocal.get();
+ }
+
+ /** Parse the given XML string and return the root Element
+ */
+ public static Element parse(String xmlString) throws IOException
+ {
+ try
+ {
+ return parse(new ByteArrayInputStream(xmlString.getBytes("UTF-8")));
+ }
+ catch (IOException e)
+ {
+ log.log(Level.SEVERE, "Cannot parse: " + xmlString);
+ throw e;
+ }
+ }
+
+ /** Parse the given XML stream and return the root Element
+ */
+ public static Element parse(InputStream xmlStream) throws IOException
+ {
+ try
+ {
+ return getDocumentBuilder().parse(xmlStream).getDocumentElement();
+ }
+ catch (SAXException se)
+ {
+ throw new IOException(se.toString());
+ }
+ }
+
+ /** Parse the given input source and return the root Element
+ */
+ public static Element parse(InputSource source) throws IOException
+ {
+ try
+ {
+ return getDocumentBuilder().parse(source).getDocumentElement();
+ }
+ catch (SAXException se)
+ {
+ throw new IOException(se.toString());
+ }
+ }
+
+ /** Create an Element for a given name
+ */
+ public static Element createElement(String localPart)
+ {
+ Document doc = getOwnerDocument();
+ log.log(Level.FINER, "createElement {}" + localPart);
+ return doc.createElement(localPart);
+ }
+
+ /** Create an Element for a given name and prefix
+ */
+ public static Element createElement(String localPart, String prefix)
+ {
+ Document doc = getOwnerDocument();
+ log.log(Level.FINER, "createElement {}" + prefix + ":" + localPart);
+ return doc.createElement(prefix + ":" + localPart);
+ }
+
+ /** Create an Element for a given name, prefix and uri
+ */
+ public static Element createElement(String localPart, String prefix, String uri)
+ {
+ Document doc = getOwnerDocument();
+ if (prefix == null || prefix.length() == 0)
+ {
+ log.log(Level.FINER, "createElement {" + uri + "}" + localPart);
+ return doc.createElementNS(uri, localPart);
+ }
+ else
+ {
+ log.log(Level.FINER, "createElement {" + uri + "}" + prefix + ":" + localPart);
+ return doc.createElementNS(uri, prefix + ":" + localPart);
+ }
+ }
+
+ /** Create an Element for a given QName
+ */
+ public static Element createElement(QName qname)
+ {
+ return createElement(qname.getLocalPart(), qname.getPrefix(), qname.getNamespaceURI());
+ }
+
+ /** Create a org.w3c.dom.Text node
+ */
+ public static Text createTextNode(String value)
+ {
+ Document doc = getOwnerDocument();
+ return doc.createTextNode(value);
+ }
+
+ /** Get the qname of the given node.
+ */
+ public static QName getElementQName(Element el)
+ {
+ String qualifiedName = el.getNodeName();
+ return resolveQName(el, qualifiedName);
+ }
+
+ /** Transform the given qualified name into a QName
+ */
+ public static QName resolveQName(Element el, String qualifiedName)
+ {
+ QName qname;
+ String prefix = "";
+ String namespaceURI = "";
+ String localPart = qualifiedName;
+
+ int colIndex = qualifiedName.indexOf(":");
+ if (colIndex > 0)
+ {
+ prefix = qualifiedName.substring(0, colIndex);
+ localPart = qualifiedName.substring(colIndex + 1);
+
+ if ("xmlns".equals(prefix))
+ {
+ namespaceURI = "URI:XML_PREDEFINED_NAMESPACE";
+ }
+ else
+ {
+ Element nsElement = el;
+ while (namespaceURI.equals("") && nsElement != null)
+ {
+ namespaceURI = nsElement.getAttribute("xmlns:" + prefix);
+ if (namespaceURI.equals(""))
+ nsElement = getParentElement(nsElement);
+ }
+ }
+
+ if (namespaceURI.equals(""))
+ throw new IllegalArgumentException("Cannot find namespace uri for: " + qualifiedName);
+ }
+ else
+ {
+ Element nsElement = el;
+ while (namespaceURI.equals("") && nsElement != null)
+ {
+ namespaceURI = nsElement.getAttribute("xmlns");
+ if (namespaceURI.equals(""))
+ nsElement = getParentElement(nsElement);
+ }
+ }
+
+ qname = new QName(namespaceURI, localPart, prefix);
+ return qname;
+ }
+
+ /** Get the value from the given attribute
+ *
+ * @return null if the attribute value is empty or the attribute is not present
+ */
+ public static String getAttributeValue(Element el, String attrName)
+ {
+ return getAttributeValue(el, new QName(attrName));
+ }
+
+ /** Get the value from the given attribute
+ *
+ * @return null if the attribute value is empty or the attribute is not present
+ */
+ public static String getAttributeValue(Element el, QName attrName)
+ {
+ String attr = null;
+ if ("".equals(attrName.getNamespaceURI()))
+ attr = el.getAttribute(attrName.getLocalPart());
+ else attr = el.getAttributeNS(attrName.getNamespaceURI(), attrName.getLocalPart());
+
+ if ("".equals(attr))
+ attr = null;
+
+ return attr;
+ }
+
+ /** Get the qname value from the given attribute
+ */
+ public static QName getAttributeValueAsQName(Element el, String attrName)
+ {
+ return getAttributeValueAsQName(el, new QName(attrName));
+
+ }
+
+ /** Get the qname value from the given attribute
+ */
+ public static QName getAttributeValueAsQName(Element el, QName attrName)
+ {
+ QName qname = null;
+
+ String qualifiedName = getAttributeValue(el, attrName);
+ if (qualifiedName != null)
+ {
+ qname = resolveQName(el, qualifiedName);
+ }
+
+ return qname;
+ }
+
+ /** Get the boolean value from the given attribute
+ */
+ public static boolean getAttributeValueAsBoolean(Element el, String attrName)
+ {
+ return getAttributeValueAsBoolean(el, new QName(attrName));
+ }
+
+ /** Get the boolean value from the given attribute
+ */
+ public static boolean getAttributeValueAsBoolean(Element el, QName attrName)
+ {
+ String attrVal = getAttributeValue(el, attrName);
+ boolean ret = "true".equalsIgnoreCase(attrVal) || "1".equalsIgnoreCase(attrVal);
+ return ret;
+ }
+
+ /** Get the integer value from the given attribute
+ */
+ public static Integer getAttributeValueAsInteger(Element el, String attrName)
+ {
+ return getAttributeValueAsInteger(el, new QName(attrName));
+ }
+
+ /** Get the integer value from the given attribute
+ */
+ public static Integer getAttributeValueAsInteger(Element el, QName attrName)
+ {
+ String attrVal = getAttributeValue(el, attrName);
+ return (attrVal != null ? new Integer(attrVal) : null);
+ }
+
+ /** Get the attributes as Map<QName, String>
+ */
+ public static Map getAttributes(Element el)
+ {
+ Map attmap = new HashMap();
+ NamedNodeMap attribs = el.getAttributes();
+ for (int i = 0; i < attribs.getLength(); i++)
+ {
+ Attr attr = (Attr)attribs.item(i);
+ String name = attr.getName();
+ QName qname = resolveQName(el, name);
+ String value = attr.getNodeValue();
+ attmap.put(qname, value);
+ }
+ return attmap;
+ }
+
+ /** Copy attributes between elements
+ */
+ public static void copyAttributes(Element destElement, Element srcElement)
+ {
+ NamedNodeMap attribs = srcElement.getAttributes();
+ for (int i = 0; i < attribs.getLength(); i++)
+ {
+ Attr attr = (Attr)attribs.item(i);
+ String uri = attr.getNamespaceURI();
+ String qname = attr.getName();
+ String value = attr.getNodeValue();
+
+ // Prevent DOMException: NAMESPACE_ERR: An attempt is made to create or
+ // change an object in a way which is incorrect with regard to namespaces.
+ if (uri == null && qname.startsWith("xmlns"))
+ {
+ log.log(Level.FINER, "Ignore attribute: [uri=" + uri + ",qname=" + qname + ",value=" + value + "]");
+ }
+ else
+ {
+ destElement.setAttributeNS(uri, qname, value);
+ }
+ }
+ }
+
+ /** True if the node has text child elements only
+ */
+ public static boolean hasTextChildNodesOnly(Node node)
+ {
+ NodeList nodeList = node.getChildNodes();
+ if (nodeList.getLength() == 0)
+ return false;
+
+ for (int i = 0; i < nodeList.getLength(); i++)
+ {
+ Node acksToChildNode = nodeList.item(i);
+ if (acksToChildNode.getNodeType() != Node.TEXT_NODE)
+ return false;
+ }
+
+ return true;
+ }
+
+ /** True if the node has child elements
+ */
+ public static boolean hasChildElements(Node node)
+ {
+ NodeList nlist = node.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++)
+ {
+ Node child = nlist.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ return true;
+ }
+ return false;
+ }
+
+ /** Gets child elements
+ */
+ public static Iterator<Element> getChildElements(Node node)
+ {
+ List<Element> list = new LinkedList<Element>();
+ NodeList nlist = node.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++)
+ {
+ Node child = nlist.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ list.add((Element)child);
+ }
+ return list.iterator();
+ }
+
+ /** Get the concatenated text content, or null.
+ */
+ public static String getTextContent(Node node)
+ {
+ boolean hasTextContent = false;
+ StringBuffer buffer = new StringBuffer();
+ NodeList nlist = node.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++)
+ {
+ Node child = nlist.item(i);
+ if (child.getNodeType() == Node.TEXT_NODE)
+ {
+ buffer.append(child.getNodeValue());
+ hasTextContent = true;
+ }
+ }
+ return (hasTextContent ? buffer.toString() : null);
+ }
+
+ /** Gets the first child element
+ */
+ public static Element getFirstChildElement(Node node)
+ {
+ return getFirstChildElementIntern(node, null);
+ }
+
+ /** Gets the first child element for a given local name without namespace
+ */
+ public static Element getFirstChildElement(Node node, String nodeName)
+ {
+ return getFirstChildElementIntern(node, new QName(nodeName));
+ }
+
+ /** Gets the first child element for a given qname
+ */
+ public static Element getFirstChildElement(Node node, QName nodeName)
+ {
+ return getFirstChildElementIntern(node, nodeName);
+ }
+
+ private static Element getFirstChildElementIntern(Node node, QName nodeName)
+ {
+ Element childElement = null;
+ Iterator it = getChildElementsIntern(node, nodeName);
+ if (it.hasNext())
+ {
+ childElement = (Element)it.next();
+ }
+ return childElement;
+ }
+
+ /** Gets the child elements for a given local name without namespace
+ */
+ public static Iterator getChildElements(Node node, String nodeName)
+ {
+ return getChildElementsIntern(node, new QName(nodeName));
+ }
+
+ /** Gets the child element for a given qname
+ */
+ public static Iterator getChildElements(Node node, QName nodeName)
+ {
+ return getChildElementsIntern(node, nodeName);
+ }
+
+ public static List<Element> getChildElementsAsList(Node node, String nodeName)
+ {
+ return getChildElementsAsListIntern(node, new QName(nodeName));
+ }
+
+ public static List<Element> getChildElementsAsList(Node node, QName nodeName)
+ {
+ return getChildElementsAsListIntern(node, nodeName);
+ }
+
+ private static List<Element> getChildElementsAsListIntern(Node node, QName nodeName)
+ {
+ List<Element> list = new LinkedList<Element>();
+ NodeList nlist = node.getChildNodes();
+ for (int i = 0; i < nlist.getLength(); i++)
+ {
+ Node child = nlist.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ {
+ if (nodeName == null)
+ {
+ list.add((Element)child);
+ }
+ else
+ {
+ QName qname;
+ if (nodeName.getNamespaceURI().length() > 0)
+ {
+ qname = new QName(child.getNamespaceURI(), child.getLocalName());
+ }
+ else
+ {
+ qname = new QName(child.getLocalName());
+ }
+ if (qname.equals(nodeName))
+ {
+ list.add((Element)child);
+ }
+ }
+ }
+ }
+ return list;
+ }
+
+ private static Iterator getChildElementsIntern(Node node, QName nodeName)
+ {
+ return getChildElementsAsListIntern(node, nodeName).iterator();
+ }
+
+ /** Gets parent element or null if there is none
+ */
+ public static Element getParentElement(Node node)
+ {
+ Node parent = node.getParentNode();
+ return (parent instanceof Element ? (Element)parent : null);
+ }
+
+ /** Get the owner document that is associated with the current thread */
+ public static Document getOwnerDocument()
+ {
+ Document doc = documentThreadLocal.get();
+ if (doc == null)
+ {
+ doc = getDocumentBuilder().newDocument();
+ documentThreadLocal.set(doc);
+ }
+ return doc;
+ }
+
+ public static Element sourceToElement(Source source) throws IOException
+ {
+ Element retElement = null;
+
+ try
+ {
+ if (source instanceof StreamSource)
+ {
+ StreamSource streamSource = (StreamSource)source;
+
+ InputStream ins = streamSource.getInputStream();
+ if (ins != null)
+ {
+ retElement = DOMUtils.parse(ins);
+ }
+ else
+ {
+ Reader reader = streamSource.getReader();
+ retElement = DOMUtils.parse(new InputSource(reader));
+ }
+ }
+ else if (source instanceof DOMSource)
+ {
+ DOMSource domSource = (DOMSource)source;
+ Node node = domSource.getNode();
+ if (node instanceof Element)
+ {
+ retElement = (Element)node;
+ }
+ else if (node instanceof Document)
+ {
+ retElement = ((Document)node).getDocumentElement();
+ }
+ else
+ {
+ throw new RuntimeException("Unsupported Node type: " + node.getClass().getName());
+ }
+ }
+ else if (source instanceof SAXSource)
+ {
+ // The fact that JAXBSource derives from SAXSource is an implementation detail.
+ // Thus in general applications are strongly discouraged from accessing methods defined on SAXSource.
+ // The XMLReader object obtained by the getXMLReader method shall be used only for parsing the InputSource object returned by the getInputSource method.
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ Transformer transformer = tf.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.transform(source, new StreamResult(baos));
+ retElement = DOMUtils.parse(new ByteArrayInputStream(baos.toByteArray()));
+ }
+ else
+ {
+ throw new RuntimeException("Source type not implemented: " + source.getClass().getName());
+ }
+
+ }
+ catch (TransformerException ex)
+ {
+ IOException ioex = new IOException();
+ ioex.initCause(ex);
+ throw ioex;
+ }
+
+ return retElement;
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMWriter.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMWriter.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/DOMWriter.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,609 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache at apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+package org.jboss.ws.extensions.addressing.util;
+
+// $Id$
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Traverse a DOM tree in order to print a document that is parsed.
+ *
+ * @author Andy Clark, IBM
+ * @author Thomas.Diesler at jboss.org
+ * @version $Revision$
+ */
+public class DOMWriter
+{
+ // Print writer
+ private PrintWriter out;
+ // True, if canonical output
+ private boolean canonical;
+ // True, if pretty printing should be used
+ private boolean prettyprint;
+ // True, if the XML declaration should be written
+ private boolean writeXMLDeclaration;
+ // Explicit character set encoding
+ private String charsetName;
+ // indent for the pretty printer
+ private int prettyIndent;
+ // True, if the XML declaration has been written
+ private boolean wroteXMLDeclaration;
+ // The node that started the write
+ private Node rootNode;
+ // True if we want namespace completion
+ private boolean completeNamespaces = true;
+ // The current default namespace
+ private String currentDefaultNamespace;
+
+ public DOMWriter(Writer w)
+ {
+ this.out = new PrintWriter(w);
+ }
+
+ public DOMWriter(Writer w, String charsetName)
+ {
+ this.out = new PrintWriter(w);
+ this.charsetName = charsetName;
+ this.writeXMLDeclaration = true;
+ }
+
+ public DOMWriter(OutputStream stream)
+ {
+ try
+ {
+ this.out = new PrintWriter(new OutputStreamWriter(stream, "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // ignore, UTF-8 should be available
+ }
+ }
+
+ public DOMWriter(OutputStream stream, String charsetName)
+ {
+ try
+ {
+ this.out = new PrintWriter(new OutputStreamWriter(stream, charsetName));
+ this.charsetName = charsetName;
+ this.writeXMLDeclaration = true;
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new IllegalArgumentException("Unsupported encoding: " + charsetName);
+ }
+ }
+
+ /**
+ * Print a node with explicit prettyprinting.
+ * The defaults for all other DOMWriter properties apply.
+ *
+ */
+ public static String printNode(Node node, boolean prettyprint)
+ {
+ StringWriter strw = new StringWriter();
+ new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
+ return strw.toString();
+ }
+
+ public boolean isCanonical()
+ {
+ return canonical;
+ }
+
+ /**
+ * Set wheter entities should appear in their canonical form.
+ * The default is false.
+ */
+ public DOMWriter setCanonical(boolean canonical)
+ {
+ this.canonical = canonical;
+ return this;
+ }
+
+ /**
+ * Set wheter subelements should have their namespaces completed.
+ * Setting this to false may lead to invalid XML fragments.
+ * The default is true.
+ */
+ public DOMWriter setCompleteNamespaces(boolean complete)
+ {
+ this.completeNamespaces = complete;
+ return this;
+ }
+
+ public boolean isPrettyprint()
+ {
+ return prettyprint;
+ }
+
+ /**
+ * Set wheter element should be indented.
+ * The default is false.
+ */
+ public DOMWriter setPrettyprint(boolean prettyprint)
+ {
+ this.prettyprint = prettyprint;
+ return this;
+ }
+
+ public boolean isWriteXMLDeclaration()
+ {
+ return writeXMLDeclaration;
+ }
+
+ /**
+ * Set wheter the XML declaration should be written.
+ * The default is false.
+ */
+ public DOMWriter setWriteXMLDeclaration(boolean flag)
+ {
+ this.writeXMLDeclaration = flag;
+ return this;
+ }
+
+ public void print(Node node)
+ {
+ rootNode = node;
+ printInternal(node, false);
+ }
+
+ private void printInternal(Node node, boolean indentEndMarker)
+ {
+ // is there anything to do?
+ if (node == null)
+ {
+ return;
+ }
+
+ // JBAS-2117 - Don't skip the DOCUMENT_NODE
+ // if (node instanceof Document) node = ((Document)node).getDocumentElement();
+
+ if (wroteXMLDeclaration == false && writeXMLDeclaration == true && canonical == false)
+ {
+ out.print("<?xml version='1.0'");
+ if (charsetName != null)
+ out.print(" encoding='" + charsetName + "'");
+
+ out.print("?>");
+ if (prettyprint)
+ out.println();
+
+ wroteXMLDeclaration = true;
+ }
+
+ int type = node.getNodeType();
+ boolean hasChildNodes = node.getChildNodes().getLength() > 0;
+
+ String nodeName = node.getNodeName();
+ switch (type)
+ {
+ // print document
+ case Node.DOCUMENT_NODE:
+ {
+ NodeList children = node.getChildNodes();
+ for (int iChild = 0; iChild < children.getLength(); iChild++)
+ {
+ printInternal(children.item(iChild), false);
+ }
+ out.flush();
+ break;
+ }
+
+ // print element with attributes
+ case Node.ELEMENT_NODE:
+ {
+ Element element = (Element)node;
+ if (prettyprint)
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+ prettyIndent++;
+ }
+
+ out.print('<');
+ out.print(nodeName);
+
+ Map nsMap = new HashMap();
+ String elPrefix = node.getPrefix();
+ String elNamespaceURI = node.getNamespaceURI();
+ if (elPrefix != null)
+ {
+ String nsURI = getNamespaceURI(elPrefix, element, rootNode);
+ nsMap.put(elPrefix, nsURI);
+ }
+
+ Attr attrs[] = sortAttributes(node.getAttributes());
+ for (int i = 0; i < attrs.length; i++)
+ {
+ Attr attr = attrs[i];
+ String atPrefix = attr.getPrefix();
+ String atName = attr.getNodeName();
+ String atValue = normalize(attr.getNodeValue(), canonical);
+
+ if (atName.equals("xmlns"))
+ currentDefaultNamespace = atValue;
+
+ if (atPrefix != null && !atPrefix.equals("xmlns") && !atPrefix.equals("xml"))
+ {
+ String nsURI = getNamespaceURI(atPrefix, element, rootNode);
+ nsMap.put(atPrefix, nsURI);
+ // xsi:type='ns1:SubType', xsi:type='xsd:string'
+ if (atName.equals(atPrefix + ":type") && atValue.indexOf(":") > 0)
+ {
+ // xsi defined on the envelope
+ if (nsURI == null)
+ nsURI = getNamespaceURI(atPrefix, element, null);
+
+ if ("http://www.w3.org/2001/XMLSchema-instance".equals(nsURI))
+ {
+ String typePrefix = atValue.substring(0, atValue.indexOf(":"));
+ String typeURI = getNamespaceURI(typePrefix, element, rootNode);
+ nsMap.put(typePrefix, typeURI);
+ }
+ }
+ }
+
+ out.print(" " + atName + "='" + atValue + "'");
+ }
+
+ // Add namespace declaration for prefixes
+ // that are defined further up the tree
+ if (completeNamespaces)
+ {
+ Iterator itPrefix = nsMap.keySet().iterator();
+ while (itPrefix.hasNext())
+ {
+ String prefix = (String)itPrefix.next();
+ String nsURI = (String)nsMap.get(prefix);
+ if (nsURI == null)
+ {
+ nsURI = getNamespaceURI(prefix, element, null);
+ out.print(" xmlns:" + prefix + "='" + nsURI + "'");
+ }
+ }
+ }
+
+ // The SAX ContentHandler will by default not add the namespace declaration
+ // <Hello xmlns='http://somens'>World</Hello>
+ if (elPrefix == null && elNamespaceURI != null)
+ {
+ String defaultNamespace = element.getAttribute("xmlns");
+ if (defaultNamespace.length() == 0 && !elNamespaceURI.equals(currentDefaultNamespace))
+ {
+ out.print(" xmlns='" + elNamespaceURI + "'");
+ currentDefaultNamespace = elNamespaceURI;
+ }
+ }
+
+ if (hasChildNodes)
+ {
+ out.print('>');
+ }
+
+ // Find out if the end marker is indented
+ indentEndMarker = isEndMarkerIndented(node);
+
+ if (indentEndMarker)
+ {
+ out.print('\n');
+ }
+
+ NodeList childNodes = node.getChildNodes();
+ int len = childNodes.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node childNode = childNodes.item(i);
+ printInternal(childNode, false);
+ }
+ break;
+ }
+
+ // handle entity reference nodes
+ case Node.ENTITY_REFERENCE_NODE:
+ {
+ if (canonical)
+ {
+ NodeList children = node.getChildNodes();
+ if (children != null)
+ {
+ int len = children.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ printInternal(children.item(i), false);
+ }
+ }
+ }
+ else
+ {
+ out.print('&');
+ out.print(nodeName);
+ out.print(';');
+ }
+ break;
+ }
+
+ // print cdata sections
+ case Node.CDATA_SECTION_NODE:
+ {
+ if (canonical)
+ {
+ out.print(normalize(node.getNodeValue(), canonical));
+ }
+ else
+ {
+ out.print("<![CDATA[");
+ out.print(node.getNodeValue());
+ out.print("]]>");
+ }
+ break;
+ }
+
+ // print text
+ case Node.TEXT_NODE:
+ {
+ String text = normalize(node.getNodeValue(), canonical);
+ if (prettyprint == false || text.trim().length() > 0)
+ out.print(text);
+ break;
+ }
+
+ // print processing instruction
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ {
+ out.print("<?");
+ out.print(nodeName);
+ String data = node.getNodeValue();
+ if (data != null && data.length() > 0)
+ {
+ out.print(' ');
+ out.print(data);
+ }
+ out.print("?>");
+ break;
+ }
+
+ // print comment
+ case Node.COMMENT_NODE:
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+
+ out.print("<!--");
+ String data = node.getNodeValue();
+ if (data != null)
+ {
+ out.print(data);
+ }
+ out.print("-->");
+
+ if (prettyprint)
+ {
+ out.print('\n');
+ }
+
+ break;
+ }
+ }
+
+ if (type == Node.ELEMENT_NODE)
+ {
+ if (prettyprint)
+ prettyIndent--;
+
+ if (hasChildNodes == false)
+ {
+ out.print("/>");
+ }
+ else
+ {
+ if (indentEndMarker)
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+ }
+
+ out.print("</");
+ out.print(nodeName);
+ out.print('>');
+ }
+
+ if (prettyIndent > 0)
+ {
+ out.print('\n');
+ }
+ }
+ out.flush();
+ }
+
+ private String getNamespaceURI(String prefix, Element element, Node stopNode)
+ {
+ Node parent = element.getParentNode();
+ String nsURI = element.getAttribute("xmlns:" + prefix);
+ if (nsURI.length() == 0 && element != stopNode && parent instanceof Element)
+ return getNamespaceURI(prefix, (Element)parent, stopNode);
+
+ return (nsURI.length() > 0 ? nsURI : null);
+ }
+
+ private boolean isEndMarkerIndented(Node node)
+ {
+ if (prettyprint)
+ {
+ NodeList childNodes = node.getChildNodes();
+ int len = childNodes.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node children = childNodes.item(i);
+ if (children.getNodeType() == Node.ELEMENT_NODE)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /** Returns a sorted list of attributes. */
+ private Attr[] sortAttributes(NamedNodeMap attrs)
+ {
+
+ int len = (attrs != null) ? attrs.getLength() : 0;
+ Attr array[] = new Attr[len];
+ for (int i = 0; i < len; i++)
+ {
+ array[i] = (Attr)attrs.item(i);
+ }
+ for (int i = 0; i < len - 1; i++)
+ {
+ String name = array[i].getNodeName();
+ int index = i;
+ for (int j = i + 1; j < len; j++)
+ {
+ String curName = array[j].getNodeName();
+ if (curName.compareTo(name) < 0)
+ {
+ name = curName;
+ index = j;
+ }
+ }
+ if (index != i)
+ {
+ Attr temp = array[i];
+ array[i] = array[index];
+ array[index] = temp;
+ }
+ }
+ return (array);
+ }
+
+ /** Normalizes the given string. */
+ public static String normalize(String s, boolean canonical)
+ {
+ StringBuffer str = new StringBuffer();
+
+ int len = (s != null) ? s.length() : 0;
+ for (int i = 0; i < len; i++)
+ {
+ char ch = s.charAt(i);
+ switch (ch)
+ {
+ case '<':
+ {
+ str.append("<");
+ break;
+ }
+ case '>':
+ {
+ str.append(">");
+ break;
+ }
+ case '&':
+ {
+ str.append("&");
+ break;
+ }
+ case '"':
+ {
+ str.append(""");
+ break;
+ }
+ case '\'':
+ {
+ str.append("'");
+ break;
+ }
+ case '\r':
+ case '\n':
+ {
+ if (canonical)
+ {
+ str.append("&#");
+ str.append(Integer.toString(ch));
+ str.append(';');
+ break;
+ }
+ // else, default append char
+ }
+ default:
+ {
+ str.append(ch);
+ }
+ }
+ }
+ return (str.toString());
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/MetaDataExtension.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/MetaDataExtension.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/MetaDataExtension.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.util;
+
+// $Id: MetaDataExtension.java 1757 2006-12-22 15:40:24Z thomas.diesler at jboss.com $
+
+/**
+ * Operation metaData extension.
+ *
+ * @author Heiko Braun, <heiko at openj.net>
+ * @since 17-Mar-2006
+ */
+public abstract class MetaDataExtension
+{
+ private String extensionNameSpace;
+
+ public MetaDataExtension(String extensionNameSpace)
+ {
+ this.extensionNameSpace = extensionNameSpace;
+ }
+
+ public String getExtensionNameSpace()
+ {
+ return extensionNameSpace;
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/NotImplementedException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/NotImplementedException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/NotImplementedException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,31 @@
+package org.jboss.ws.extensions.addressing.util;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: adinn
+ * Date: Dec 5, 2007
+ * Time: 3:51:44 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class NotImplementedException extends Exception
+{
+ public NotImplementedException()
+ {
+ super();
+ }
+
+ public NotImplementedException(String s)
+ {
+ super(s);
+ }
+
+ public NotImplementedException(String s, Throwable t)
+ {
+ super(s, t);
+ }
+
+ public NotImplementedException(Throwable t)
+ {
+ super(t);
+ }
+}
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/UUIDGenerator.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/UUIDGenerator.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/UUIDGenerator.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,121 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, 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.ws.core.utils;
+
+import java.security.SecureRandom;
+
+/**
+ * Generates the string form of IETF variant UUIDs.
+ *
+ * See <a href="http://www.ietf.org/internet-drafts/draft-mealling-uuid-urn-05.txt">
+ * the latest IETF draft</a> for more information about UUID generation.
+ *
+ * Currently only pseudo random (type 4) UUIDs are supported.
+ *
+ * @author <a href="mailto:jason at stacksmash.com">Jason T. Greene</a>
+ */
+public class UUIDGenerator
+{
+ private static SecureRandom rand;
+
+ private static String bytesToHex(byte[] buffer, int offset, int length)
+ {
+ long value = 0;
+ for (int i = 0, countDown = 8 * length; i < length; i++)
+ {
+ value |= (buffer[offset + i] & 0xffL) << (countDown -= 8);
+ }
+
+ return Long.toHexString(value);
+ }
+
+ /**
+ * Generates a pseudo random UUID and returns it in byte array form.
+ *
+ * @return a UUID byte array in network order
+ */
+ public static byte[] generateRandomUUIDBytes()
+ {
+ if (rand == null)
+ rand = new SecureRandom();
+
+ byte[] buffer = new byte[16];
+ rand.nextBytes(buffer);
+
+ // Set version to 3 (Random)
+ buffer[6] = (byte) ((buffer[6] & 0x0f) | 0x40);
+ // Set variant to 2 (IETF)
+ buffer[8] = (byte) ((buffer[8] & 0x3f) | 0x80);
+
+ return buffer;
+ }
+
+ /**
+ * Generates a pseudo random UUID and returns it the IETF specified
+ * String form. See {@link #convertToString(byte[])} for a description
+ * of the format.
+ *
+ * @return a UUID in IETF string form.
+ */
+ public static String generateRandomUUIDString()
+ {
+ return convertToString(generateRandomUUIDBytes());
+ }
+
+ /**
+ * Converts a UUID in byte array form to the IETF string format.
+ *
+ * <p>The BNF follows:
+ * <pre>
+ * UUID = <time_low> "-" <time_mid> "-"
+ * <time_high_and_version> "-"
+ * <variant_and_sequence> "-"
+ * <node>
+ * time_low = 4*<hexOctet>
+ * time_mid = 2*<hexOctet>
+ * time_high_and_version = 2*<hexOctet>
+ * variant_and_sequence = 2*<hexOctet>
+ * node = 6*<hexOctet>
+ * hexOctet = <hexDigit><hexDigit>
+ * hexDigit =
+ * "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
+ * | "a" | "b" | "c" | "d" | "e" | "f"
+ * | "A" | "B" | "C" | "D" | "E" | "F"
+ * </pre>
+ *
+ * @param uuid a 16 byte
+ * @return the IETF string form of the passed UUID
+ */
+ public static String convertToString(byte[] uuid)
+ {
+ if (uuid.length != 16)
+ throw new IllegalArgumentException("A UUID must be 16 bytes!");
+
+ String string = bytesToHex(uuid, 0, 4) + "-"
+ + bytesToHex(uuid, 4, 2) + "-"
+ + bytesToHex(uuid, 6, 2) + "-"
+ + bytesToHex(uuid, 8, 2) + "-"
+ + bytesToHex(uuid, 10, 6);
+
+ return string;
+ }
+}
\ No newline at end of file
Added: labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/WSException.java
===================================================================
--- labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/WSException.java (rev 0)
+++ labs/jbosstm/workspace/adinn/wsbrew/src/org/jboss/ws/extensions/addressing/util/WSException.java 2008-01-14 13:18:13 UTC (rev 17811)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.ws.extensions.addressing.util;
+
+/**
+ * A RuntimeException that should be thrown when a cause is needed
+ *
+ * The retrotranslator-0.9.5 cannot handle
+ *
+ * new IllegalStateException(String, Throwable)
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 06-Jan-2006
+ */
+public class WSException extends RuntimeException
+{
+ public WSException()
+ {
+ }
+
+ public WSException(String message)
+ {
+ super(message);
+ }
+
+ public WSException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public WSException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public static void rethrow(String string, Throwable th)
+ {
+ if (th instanceof WSException)
+ throw (WSException)th;
+
+ throw new WSException(string, th);
+ }
+
+ public static void rethrow(Throwable th)
+ {
+ if (th instanceof WSException)
+ throw (WSException)th;
+
+ throw new WSException(th);
+ }
+}
More information about the jboss-svn-commits
mailing list