You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2005/11/25 02:24:34 UTC

svn commit: r348848 - in /incubator/woden/java/src/org/apache/woden: internal/ internal/wsdl20/ wsdl20/ wsdl20/enum/ wsdl20/xml/

Author: jkaputin
Date: Thu Nov 24 17:24:18 2005
New Revision: 348848

URL: http://svn.apache.org/viewcvs?rev=348848&view=rev
Log:
Changes to represent the {message label} and {direction}
properties as typesafe enumerations, rather than Strings.
Created the MessageLabel and Direction classes in new
package org.apache.woden.wsdl20.enum. Removed related
constants from the Constants file as they are now 
redundant. Modified the Element and Component interfaces
and Reader impl to use the new enum classes instead of
Strings and the old Constants.

Added:
    incubator/woden/java/src/org/apache/woden/wsdl20/enum/Direction.java
    incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java
Modified:
    incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultReferenceImpl.java
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java
    incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceFaultReference.java
    incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceMessageReference.java
    incubator/woden/java/src/org/apache/woden/wsdl20/xml/FaultReferenceElement.java
    incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java

Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Thu Nov 24 17:24:18 2005
@@ -45,6 +45,8 @@
 import org.apache.woden.schema.ImportedSchema;
 import org.apache.woden.schema.InlinedSchema;
 import org.apache.woden.schema.Schema;
+import org.apache.woden.wsdl20.enum.Direction;
+import org.apache.woden.wsdl20.enum.MessageLabel;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
 import org.apache.woden.wsdl20.xml.DocumentationElement;
 import org.apache.woden.wsdl20.xml.FaultReferenceElement;
@@ -540,13 +542,24 @@
         ((InterfaceMessageReferenceImpl)message).setTypes(desc.getTypesElement());
         
         if(Constants.ELEM_INPUT.equals(messageEl.getLocalName())) {
-            message.setDirection(Constants.VALUE_IN);
+            message.setDirection(Direction.IN);
         } 
         else if(Constants.ELEM_OUTPUT.equals(messageEl.getLocalName())) {
-            message.setDirection(Constants.VALUE_OUT);
+            message.setDirection(Direction.OUT);
         }
         
-        message.setMessageLabel(DOMUtils.getAttribute(messageEl, Constants.ATTR_MESSAGE_LABEL));
+        String msgLabel = DOMUtils.getAttribute(messageEl, Constants.ATTR_MESSAGE_LABEL);
+        if(msgLabel != null) 
+        {
+            if(msgLabel.equals(MessageLabel.IN.toString())) {
+                message.setMessageLabel(MessageLabel.IN);
+            } else if(msgLabel.equals(MessageLabel.OUT.toString())) {
+                message.setMessageLabel(MessageLabel.OUT);
+            } else {
+                //invalid value, but capture it anyway.
+                message.setMessageLabel(MessageLabel.invalidValue(msgLabel));
+            }
+        }
         
         String element = DOMUtils.getAttribute(messageEl, Constants.ATTR_ELEMENT);
         if(element != null)
@@ -619,10 +632,10 @@
         faultRef.setParentElement(parent);
         
         if(Constants.ELEM_INFAULT.equals(faultRefEl.getLocalName())) {
-            faultRef.setDirection(Constants.VALUE_IN);
+            faultRef.setDirection(Direction.IN);
         } 
         else if(Constants.ELEM_OUTFAULT.equals(faultRefEl.getLocalName())){
-            faultRef.setDirection(Constants.VALUE_OUT);
+            faultRef.setDirection(Direction.OUT);
         }
         
         String ref = DOMUtils.getAttribute(faultRefEl, Constants.ATTR_REF);
@@ -640,7 +653,18 @@
             }
         }
 
-        faultRef.setMessageLabel(DOMUtils.getAttribute(faultRefEl, Constants.ATTR_MESSAGE_LABEL));
+        String msgLabel = DOMUtils.getAttribute(faultRefEl, Constants.ATTR_MESSAGE_LABEL);
+        if(msgLabel != null)
+        {
+            if(msgLabel.equals(MessageLabel.IN.toString())) {
+                faultRef.setMessageLabel(MessageLabel.IN);
+            } else if(msgLabel.equals(MessageLabel.OUT.toString())) {
+                faultRef.setMessageLabel(MessageLabel.OUT);
+            } else {
+                //invalid value, but capture it anyway.
+                faultRef.setMessageLabel(MessageLabel.invalidValue(msgLabel));
+            }
+        }
         
         //TODO extension attributes
 

Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java Thu Nov 24 17:24:18 2005
@@ -120,10 +120,6 @@
     public static final String VALUE_EMPTY_STRING = "";
     public static final String VALUE_TRUE = "true";
     public static final String VALUE_FALSE = "false";
-    public static final String VALUE_IN = "in";
-    public static final String VALUE_OUT = "out";
-    public static final String VALUE_IN_ROLE = "In";
-    public static final String VALUE_OUT_ROLE = "Out";
     public static final String NMTOKEN_VALUE = "#value";
     public static final String NMTOKEN_ANY = "#any";
     public static final String NMTOKEN_NONE = "#none";

Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultReferenceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultReferenceImpl.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultReferenceImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultReferenceImpl.java Thu Nov 24 17:24:18 2005
@@ -19,6 +19,8 @@
 
 import org.apache.woden.wsdl20.InterfaceFault;
 import org.apache.woden.wsdl20.InterfaceFaultReference;
+import org.apache.woden.wsdl20.enum.Direction;
+import org.apache.woden.wsdl20.enum.MessageLabel;
 import org.apache.woden.wsdl20.xml.FaultReferenceElement;
 
 /**
@@ -33,8 +35,8 @@
 {
     //WSDL Component model data
     private InterfaceFault fInterfaceFault = null;
-    private String fMessageLabel = null;
-    private String fDirection = null;
+    private MessageLabel fMessageLabel = null;
+    private Direction fDirection = null;
     
     //XML Element model data
     QName fRef = null;
@@ -54,7 +56,7 @@
      * @see org.apache.woden.wsdl20.InterfaceFaultReference#getMessageLabel()
      * @see org.apache.woden.wsdl20.xml.FaultReferenceElement#getMessageLabel()
      */
-    public String getMessageLabel() {
+    public MessageLabel getMessageLabel() {
         return fMessageLabel;
     }
 
@@ -62,7 +64,7 @@
      * @see org.apache.woden.wsdl20.InterfaceFaultReference#getDirection()
      * @see org.apache.woden.wsdl20.xml.InterfaceFaultReference#getDirection()
      */
-    public String getDirection() {
+    public Direction getDirection() {
         return fDirection;
     }
 
@@ -93,16 +95,16 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.FaultReferenceElement#setMessageLabel(java.lang.String)
+     * @see org.apache.woden.wsdl20.xml.FaultReferenceElement#setMessageLabel(org.apache.woden.wsdl20.enum.MessageLabel)
      */
-    public void setMessageLabel(String msgLabel) {
+    public void setMessageLabel(MessageLabel msgLabel) {
         fMessageLabel = msgLabel;
     }
 
     /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.FaultReferenceElement#setDirection(java.lang.String)
+     * @see org.apache.woden.wsdl20.xml.FaultReferenceElement#setDirection(org.apache.woden.wsdl20.enum.Direction)
      */
-    public void setDirection(String dir) {
+    public void setDirection(Direction dir) {
         fDirection = dir;
     }
 

Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java Thu Nov 24 17:24:18 2005
@@ -19,6 +19,8 @@
 
 import org.apache.woden.wsdl20.ElementDeclaration;
 import org.apache.woden.wsdl20.InterfaceMessageReference;
+import org.apache.woden.wsdl20.enum.Direction;
+import org.apache.woden.wsdl20.enum.MessageLabel;
 import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
 import org.apache.woden.wsdl20.xml.TypesElement;
 import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -34,8 +36,8 @@
                                              InterfaceMessageReferenceElement 
 {
     //WSDL Component model data
-    private String fMessageLabel = null; //TODO check String correct, not URI
-    private String fDirection = null;
+    private MessageLabel fMessageLabel = null;
+    private Direction fDirection = null;
     private String fMessageContentModel = null;
     private ElementDeclaration fElementDeclaration = null;
     
@@ -52,7 +54,7 @@
      * @see org.apache.woden.wsdl20.InterfaceMessageReference#getMessageLabel()
      * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#getMessageLabel()
      */
-    public String getMessageLabel() {
+    public MessageLabel getMessageLabel() {
         return fMessageLabel;
     }
 
@@ -60,7 +62,7 @@
      * @see org.apache.woden.wsdl20.InterfaceMessageReference#getDirection()
      * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#getDirection()
      */
-    public String getDirection() {
+    public Direction getDirection() {
         return fDirection;
     }
 
@@ -91,9 +93,9 @@
      * ************************************************************/
     
     /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#setMessageLabel(java.lang.String)
+     * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#setMessageLabel(org.apache.woden.wsdl20.enum.MessageLabel)
      */
-    public void setMessageLabel(String msgLabel) {
+    public void setMessageLabel(MessageLabel msgLabel) {
         fMessageLabel = msgLabel;
     }
 
@@ -131,9 +133,9 @@
     }
 
     /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#setDirection(java.lang.String)
+     * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#setDirection(org.apache.woden.wsdl20.enum.Direction)
      */
-    public void setDirection(String dir) {
+    public void setDirection(Direction dir) {
         fDirection = dir;
     }
 

Modified: incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceFaultReference.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceFaultReference.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceFaultReference.java (original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceFaultReference.java Thu Nov 24 17:24:18 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.woden.wsdl20;
 
+import org.apache.woden.wsdl20.enum.Direction;
+import org.apache.woden.wsdl20.enum.MessageLabel;
 import org.apache.woden.wsdl20.xml.FaultReferenceElement;
 
 /**
@@ -24,9 +26,9 @@
     
     public InterfaceFault getInterfaceFault();
     
-    public String getMessageLabel();
+    public MessageLabel getMessageLabel();
     
-    public String getDirection();
+    public Direction getDirection();
     
     public FaultReferenceElement toElement();
     

Modified: incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceMessageReference.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceMessageReference.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceMessageReference.java (original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/InterfaceMessageReference.java Thu Nov 24 17:24:18 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.woden.wsdl20;
 
+import org.apache.woden.wsdl20.enum.Direction;
+import org.apache.woden.wsdl20.enum.MessageLabel;
 import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
 
 
@@ -23,9 +25,9 @@
  */
 public interface InterfaceMessageReference extends NestedComponent, ConfigurableComponent {
     
-    public String getMessageLabel();
+    public MessageLabel getMessageLabel();
     
-    public String getDirection();
+    public Direction getDirection();
     
     /**
      * Indicates the type of message content.#any means any single element, 

Added: incubator/woden/java/src/org/apache/woden/wsdl20/enum/Direction.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/enum/Direction.java?rev=348848&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/enum/Direction.java (added)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/enum/Direction.java Thu Nov 24 17:24:18 2005
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2005 Apache Software Foundation 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.enum;
+
+/**
+ * This class defines the values of the {direction} property of
+ * InterfaceMessageReference and InterfaceFaultReference. This property 
+ * indicates whether a message is coming "in" to the service or going "out" 
+ * from the service.
+ * <p>
+ * The property is represented in XML by the message or fault 
+ * reference element's tag name:
+ * <ul>
+ * <li>&lt;input&gt; and &lt;infault&gt; have the direction "in" - 
+ *     represented by the constant IN
+ * <li>&lt;output&gt; and &lt;outfault&gt; have the direction "out" - 
+ *     represented by the constant OUT
+ * </ul>
+ * This class uses the typesafe enum pattern. Applications should use the
+ * public static final constants defined in this class to specify or to 
+ * evaluate direction.
+ * <p>
+ * Examples:
+ * <pre>
+ *     msgRef.setDirection(Direction.IN);
+ *     if(msgRef.getDirection() == Direction.IN) ...
+ *     if(msgRef.getDirection().equals(Direction.IN)) ...
+ * 
+ *     Note that == and .equals() are equivalent.
+ * </pre>
+ * TODO if extensibility is required, chg ctor to protected
+ * 
+ * @author jkaputin@apache.org
+ */
+public class Direction 
+{
+    private final String fValue;
+    private Direction(String value) { fValue = value; }
+    public String toString() {return fValue;}
+    
+    public static final Direction IN = new Direction("in");
+    public static final Direction OUT = new Direction("out");
+}

Added: incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java?rev=348848&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java (added)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/enum/MessageLabel.java Thu Nov 24 17:24:18 2005
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2005 Apache Software Foundation 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); 
+ * you may not use this file except in compliance with the License. 
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.enum;
+
+/**
+ * This class defines the values of the {message label} property of
+ * InterfaceMessageReference and InterfaceFaultReference. This property 
+ * identifies the role the message plays in the message exchange pattern
+ * associated with the parent InterfaceOperation.
+ * The property is represented in XML by the <code>messageLabel</code>
+ * attribute of the &lt;input&gt;, &lt;output&gt;, &lt;infault&gt; and
+ * &lt;outfault&gt; elements.
+ * <p>
+ * The message label values are:
+ * <ul>
+ * <li>"In" - represented by the constant IN
+ * <li>"Out" - represented by the constant OUT
+ * </ul>
+ * This class uses the typesafe enum pattern. Applications should use the
+ * public static final constants defined in this class to specify or to 
+ * evaluate a message label.
+ * <p>
+ * Examples:
+ * <pre>
+ *     msgRef.setMessageLabel(MessageLabel.IN);
+ *     if(msgRef.getMessageLabel() == MessageLabel.IN) ...
+ *     if(msgRef.getMessageLabel().equals(MessageLabel.IN)) ...
+ * 
+ *     Note that == and .equals() are equivalent.
+ * </pre>
+ * If a messageLabel attribute in the WSDL specifies an invalid value 
+ * (i.e. not "In" or "Out"), it may still be useful to capture this value 
+ * for reporting purposes. Implementations can capture this value in a 
+ * MessagaLabel object by using the public static method <tt>invalidValue(String)</tt> 
+ * and can retrieve it using the <tt>toString()</tt> method.
+ * <p>
+ * TODO if extensibility is required, chg ctor to protected
+ * 
+ * @author jkaputin@apache.org
+ */
+public class MessageLabel 
+{
+    private final String fValue;
+    private MessageLabel(String value) { fValue = value; }
+    public String toString() {return fValue;}
+    
+    public static final MessageLabel invalidValue(String value) {
+        return new MessageLabel(value);
+    }
+    
+    public static final MessageLabel IN = new MessageLabel("In");
+    public static final MessageLabel OUT = new MessageLabel("Out");
+}

Modified: incubator/woden/java/src/org/apache/woden/wsdl20/xml/FaultReferenceElement.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/xml/FaultReferenceElement.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/xml/FaultReferenceElement.java (original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/xml/FaultReferenceElement.java Thu Nov 24 17:24:18 2005
@@ -17,6 +17,9 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.woden.wsdl20.enum.Direction;
+import org.apache.woden.wsdl20.enum.MessageLabel;
+
 /**
  * This interface represents the &lt;infault&gt; or &lt;outfault&gt; 
  * child element of a WSDL interface &lt;operation&gt; or 
@@ -34,9 +37,9 @@
     public void setRef(QName faultQName);
     public QName getRef();
     
-    public void setMessageLabel(String msgLabel);
-    public String getMessageLabel();
+    public void setMessageLabel(MessageLabel msgLabel);
+    public MessageLabel getMessageLabel();
     
-    public void setDirection(String dir);
-    public String getDirection();
+    public void setDirection(Direction dir);
+    public Direction getDirection();
 }

Modified: incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java?rev=348848&r1=348847&r2=348848&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java (original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java Thu Nov 24 17:24:18 2005
@@ -17,6 +17,8 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.woden.wsdl20.enum.Direction;
+import org.apache.woden.wsdl20.enum.MessageLabel;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
 /**
@@ -29,8 +31,8 @@
                                                           ConfigurableElement,
                                                           NestedElement
 {
-    public void setMessageLabel(String msgLabel);
-    public String getMessageLabel();
+    public void setMessageLabel(MessageLabel msgLabel);
+    public MessageLabel getMessageLabel();
     
     public void setMessageContentModel(String nmToken);
     public String getMessageContentModel();
@@ -57,7 +59,7 @@
      */
     public XmlSchemaElement getElement();
     
-    public void setDirection(String dir);
-    public String getDirection();
+    public void setDirection(Direction dir);
+    public Direction getDirection();
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org