ws-woden-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sag...@apache.org
Subject svn commit: r809831 [3/10] - in /webservices/woden/trunk/java/woden-commons: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/woden/ src/main/java/org/apache/woden/internal/ src/main/java/org/apache...
Date Tue, 01 Sep 2009 05:49:07 GMT
Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/ObjectRegistry.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/ObjectRegistry.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/ObjectRegistry.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/ObjectRegistry.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.util;
+
+import java.util.Hashtable;
+
+/**
+ * This class copied from WSDL4J.
+ * 
+ * The <em>ObjectRegistry</em> is used to do name-to-object reference lookups.
+ * If an <em>ObjectRegistry</em> is passed as a constructor argument, then this
+ * <em>ObjectRegistry</em> will be a cascading registry: when a lookup is
+ * invoked, it will first look in its own table for a name, and if it's not
+ * there, it will cascade to the parent <em>ObjectRegistry</em>.
+ * All registration is always local. [??]
+ * 
+ * @author   Sanjiva Weerawarana
+ * @author   Matthew J. Duftler
+ */
+public class ObjectRegistry {
+  Hashtable      reg    = new Hashtable ();
+  ObjectRegistry parent = null;
+
+  public ObjectRegistry () {
+  }
+
+  public ObjectRegistry (ObjectRegistry parent) {
+    this.parent = parent;
+  }
+
+  // register an object
+  public void register (String name, Object obj) {
+    reg.put (name, obj);
+  }
+
+  // unregister an object (silent if unknown name)
+  public void unregister (String name) {
+    reg.remove (name);
+  }
+
+  // lookup an object: cascade up if needed
+  public Object lookup (String name) throws IllegalArgumentException {
+    Object obj = reg.get (name);
+
+    if (obj == null && parent != null) {
+      obj = parent.lookup (name);
+    }
+
+    if (obj == null) {
+      throw new IllegalArgumentException ("object '" + name + "' not in registry");
+    }
+
+    return obj;
+  }
+}
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/PropertyUtils.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/PropertyUtils.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/PropertyUtils.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/PropertyUtils.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,126 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * This class defines the property lookup mechanism for the three supported 
+ * alternatives for specifying configuration properties. 
+ * 
+ * These alternatives, listed in search order, are:
+ * 1. JVM system properties (e.g. java -D arguments)
+ * 2. application properties defined in /META-INF/services (e.g. in a jar file)
+ * 3. properties defined in a wsdl properties file located in JAVAHOME/lib directory
+ * 
+ * @author jkaputin@apache.org
+ */
+public class PropertyUtils {
+    
+    private static final String PROPERTY_FILE_NAME = "wsdl.properties";
+    
+    private static String fFullPropertyFileName = null;
+    
+    private static Properties fProperties;
+    
+    public static String findProperty(String propertyName) {
+        
+        String propertyValue = null;
+
+        //First, check for a JVM-wide system property.
+        
+        try
+        {
+          propertyValue = System.getProperty(propertyName);
+
+          if (propertyValue != null)
+          {
+            return propertyValue;
+          }
+        }
+        catch (SecurityException e)
+        {
+            //TODO empty catch block copied from wsdl4j. Is this necessary?
+            //Was possibly used here to ignore exc for applet invocation?
+        }
+
+        // Second, check for an application-specific /META-INF/services property
+        
+        //TODO put code here to check for factory impl name property in /META...
+        
+        // Third, check the system properties file.
+        
+        if (fProperties == null) {
+            
+            fProperties = new Properties();
+            
+            String propFileName = getFullPropertyFileName();
+
+            if (propFileName != null)
+            {
+                try
+                {
+                    File propFile = new File(propFileName);
+                    FileInputStream fis = new FileInputStream(propFile);
+
+                    fProperties.load(fis);
+                    fis.close();
+                }
+                catch (IOException e)
+                {
+                    //TODO empty catch block copied from wsdl4j. Necessary?
+                }
+            }
+        }
+        
+        propertyValue = fProperties.getProperty(propertyName);
+
+        if (propertyValue != null)
+        {
+            return propertyValue;
+        }
+
+        //Return null if we can't find the property
+        return null;
+    }
+
+    private static String getFullPropertyFileName()
+    {
+        if (fFullPropertyFileName == null)
+        {
+            try
+            {
+                String javaHome = System.getProperty("java.home");
+                
+                fFullPropertyFileName = javaHome + File.separator + "lib" +
+                File.separator + PROPERTY_FILE_NAME;
+            }
+            catch (SecurityException e)
+            {
+                //TODO empty catch block copied from wsdl4j. Is this necessary?
+                //Was possibly used here to ignore exc for applet invocation?
+            }
+        }
+        
+        return fFullPropertyFileName;
+    }
+    
+
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/StringUtils.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/StringUtils.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/StringUtils.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/util/StringUtils.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,238 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+ * This class originated from WSDL4J.
+ * 
+ * @author   Matthew J. Duftler
+ * @author jkaputin@apache.org (Woden changes)
+ */
+public class StringUtils {
+
+    public static final String lineSeparator =
+        System.getProperty("line.separator", "\n");
+      public static final String lineSeparatorStr = cleanString(lineSeparator);
+
+      // Ensure that escape sequences are passed through properly.
+      public static String cleanString(String str)
+      {
+        if (str == null)
+          return null;
+        else
+        {
+          char[]       charArray = str.toCharArray();
+          StringBuffer sBuf      = new StringBuffer();
+          
+          for (int i = 0; i < charArray.length; i++)
+            switch (charArray[i])
+            {
+              case '\"' : sBuf.append("\\\"");
+                          break;
+              case '\\' : sBuf.append("\\\\");
+                          break;
+              case '\n' : sBuf.append("\\n");
+                          break;
+              case '\r' : sBuf.append("\\r");
+                          break;
+              default   : sBuf.append(charArray[i]);
+                          break;
+            }
+          
+          return sBuf.toString();
+        }
+      }
+
+      /*
+        This method will return the correct name for a class object representing
+        a primitive, a single instance of a class, as well as n-dimensional arrays
+        of primitives or instances. This logic is needed to handle the string returned
+        from Class.getName(). If the class object represents a single instance (or
+        a primitive), Class.getName() returns the fully-qualified name of the class
+        and no further work is needed. However, if the class object represents an
+        array (of n dimensions), Class.getName() returns a Descriptor (the Descriptor
+        grammar is defined in section 4.3 of the Java VM Spec). This method will
+        parse the Descriptor if necessary.
+      */
+      public static String getClassName(Class targetClass)
+      {
+        String className = targetClass.getName();
+
+        return targetClass.isArray() ? parseDescriptor(className) : className;
+      }
+
+      /*
+        See the comment above for getClassName(targetClass)...
+      */
+      private static String parseDescriptor(String className)
+      {
+        char[] classNameChars = className.toCharArray();
+        int    arrayDim       = 0;
+        int    i              = 0;
+
+        while (classNameChars[i] == '[')
+        {
+          arrayDim++;
+          i++;
+        }
+
+        StringBuffer classNameBuf = new StringBuffer();
+
+        switch (classNameChars[i++])
+        {
+          case 'B' : classNameBuf.append("byte");
+                     break;
+          case 'C' : classNameBuf.append("char");
+                     break;
+          case 'D' : classNameBuf.append("double");
+                     break;
+          case 'F' : classNameBuf.append("float");
+                     break;
+          case 'I' : classNameBuf.append("int");
+                     break;
+          case 'J' : classNameBuf.append("long");
+                     break;
+          case 'S' : classNameBuf.append("short");
+                     break;
+          case 'Z' : classNameBuf.append("boolean");
+                     break;
+          case 'L' : classNameBuf.append(classNameChars,
+                                         i, classNameChars.length - i - 1);
+                     break;
+        }
+
+        for (i = 0; i < arrayDim; i++)
+          classNameBuf.append("[]");
+
+        return classNameBuf.toString();
+      }
+
+    /*
+     * Return a URL created from a context URL and a relative URI.
+     * If a valid URL cannot be created the only other possibility
+     * this method will consider is that an absolute file path has 
+     * been passed in as the relative URI argument, and it will try
+     * to create a 'file' URL from it.
+     *
+     * @param contextURL the document base URL
+     * @param fileSpec a file URI relative to the contextURL or an
+     * absolute file path
+     * @return the URL created from contextURL and fileSpec
+     */
+    public static URL getURL(URL contextURL, String fileSpec)
+      throws MalformedURLException {
+
+        URL url = null;
+        
+        try {
+            url = new URL(contextURL, fileSpec);
+        }
+        catch (MalformedURLException e) {
+            
+            File file = new File(fileSpec);
+            if (file.isAbsolute()) {
+                url = file.toURL();
+            }
+            else {
+                throw e;
+            }
+        }
+        
+        return url;
+    }
+    
+    public static InputStream getContentAsInputStream(URL url)
+      throws IllegalArgumentException, IOException {
+        
+        if (url == null)
+        {
+            //TODO externalize the message
+            throw new IllegalArgumentException("URL cannot be null.");
+        }
+        
+        //TODO consider exception handling used in wsdl4j
+        Object content = url.getContent();
+        
+        if (content == null)
+        {
+            //TODO externalize the message
+            throw new IllegalArgumentException("No content.");
+        }
+        
+        if (content instanceof InputStream)
+        {
+            return (InputStream)content;
+        }
+        else
+        {
+            //TODO externalize the message
+            throw new IllegalArgumentException((content instanceof String)
+                    ? (String)content
+                            : "This URL points to a: " +
+                            StringUtils.getClassName(content.getClass()));
+        }
+    }
+    
+    public static List parseNMTokens(String nmTokens)
+    {
+      return parseNMTokens(nmTokens, " ");
+    }
+
+    public static List parseNMTokens(String nmTokens, String delimiter)
+    {
+      StringTokenizer strTok = new StringTokenizer(nmTokens, delimiter);
+      List tokens = new Vector();
+
+      while (strTok.hasMoreTokens())
+      {
+        tokens.add(strTok.nextToken());
+      }
+
+      return tokens;
+    }
+
+    public static String getNMTokens(List list)
+    {
+      if (list != null)
+      {
+        StringBuffer strBuf = new StringBuffer();
+        int size = list.size();
+
+        for (int i = 0; i < size; i++)
+        {
+          String token = (String)list.get(i);
+
+          strBuf.append((i > 0 ? " " : "") + token);
+        }
+
+        return strBuf.toString();
+      }
+      else
+      {
+        return null;
+      }
+    }
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,123 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.wsdl20;
+
+import javax.xml.namespace.QName;
+import org.apache.woden.types.NCName;
+
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFault;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.InterfaceFault;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+
+import org.apache.woden.wsdl20.fragids.FragmentIdentifier;
+import org.apache.woden.wsdl20.fragids.BindingFaultPart;
+
+/**
+ * This class represents the BindingFault component from the WSDL 2.0 Component Model 
+ * and the &lt;fault&gt; child element of the WSDL &lt;binding&gt; element.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class BindingFaultImpl extends NestedImpl 
+                              implements BindingFault, BindingFaultElement 
+{
+    private QName fRef = null;
+    
+    /* ************************************************************
+     *  BindingFault interface methods (i.e. WSDL Component model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingFault#getInterfaceFault()
+     */
+    public InterfaceFault getInterfaceFault() 
+    {
+        InterfaceFault fault = null;
+        Binding binding = (Binding)getParent();
+        Interface interfac = binding.getInterface();
+        if(interfac != null) {
+            fault = interfac.getFromAllInterfaceFaults(fRef);
+        }
+        return fault;
+    }
+
+    /*
+     * @see org.apache.woden.wsdl20.BindingFault#toElement()
+     */
+    public BindingFaultElement toElement() {
+        return this;
+    }
+    
+    /* ************************************************************
+     *  BindingFaultElement interface methods (the XML Element model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultElement#setRef(javax.xml.namespace.QName)
+     */
+    public void setRef(QName qname) {
+        fRef = qname;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultElement#getRef()
+     */
+    public QName getRef() {
+        return fRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultElement#getInterfaceFaultElement()
+     */
+    public InterfaceFaultElement getInterfaceFaultElement() 
+    {
+        InterfaceFaultElement fault = null;
+        BindingElement binding = (BindingElement)getParentElement();
+        InterfaceElement interfac = binding.getInterfaceElement();
+        if(interfac != null) {
+            InterfaceFault faultComp = ((Interface)interfac).getFromAllInterfaceFaults(fRef);
+            if (faultComp != null) {
+                fault = faultComp.toElement();
+            }
+        }
+        return fault;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.wsdl20.WSDLComponent#getFragmentIdentifier()
+     */
+    public FragmentIdentifier getFragmentIdentifier() {
+        //Find properties needed.
+        Binding bindingComp = (Binding)getParent();
+        NCName binding = new NCName(bindingComp.getName().getLocalPart());
+        
+        //Return a new FragmentIdentifier.
+        return new FragmentIdentifier(new BindingFaultPart(binding,  fRef));
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods
+     * ************************************************************/
+    
+
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultReferenceImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultReferenceImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultReferenceImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingFaultReferenceImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,212 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.wsdl20;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFaultReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.InterfaceFault;
+import org.apache.woden.wsdl20.InterfaceFaultReference;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.enumeration.Direction;
+import org.apache.woden.wsdl20.xml.BindingFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+
+import org.apache.woden.wsdl20.fragids.FragmentIdentifier;
+import org.apache.woden.wsdl20.fragids.BindingFaultReferencePart;
+
+/**
+ * This class represents the BindingFaultReference component of the
+ * WSDL 2.0 Component model and the &lt;infault&gt; or &lt;outfault&gt; 
+ * child element of a WSDL binding &lt;operation&gt;.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class BindingFaultReferenceImpl extends NestedImpl 
+                                       implements BindingFaultReference, BindingFaultReferenceElement 
+{
+    private QName fRef = null;
+    private Direction fDirection = null;
+    private NCName fMessageLabel = null;
+
+    /* ************************************************************
+     *  BindingFaultReference interface methods (i.e. WSDL Component model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingFaultReference#getInterfaceFaultReference()
+     * 
+     * The "effective" message label of the binding fault reference must be equal to the message label 
+     * of an interface fault reference and the interface fault reference must refer to an interface 
+     * fault with its {name} equal to the 'ref' qname of the binding fault reference.
+     * 
+     * The WSDL 2.0 Part 1 spec says "Define the effective message label of a binding fault reference element 
+     * information item  to be either the actual value of the messageLabel attribute information item if it 
+     * is present, or the {message label} of the unique placeholder message with {direction} equal to the 
+     * message direction if the attribute information item is absent."
+     * 
+     * The code in this method currently just supports the first type of "effective" message label,
+     * where the message label property IS present in the binding fault reference.
+     * 
+     * TODO effective message label based on message exchange pattern placeholder message, 
+     * where the message label property IS NOT present in the binding fault reference.
+     * 
+     */
+    public InterfaceFaultReference getInterfaceFaultReference() 
+    {
+        InterfaceFaultReference intFaultRef = null;
+        
+        if(fRef != null) //if 'ref' is null, we cannot match against an interface fault qname.
+        {
+            BindingOperation bindOp = (BindingOperation)getParent();
+            InterfaceOperation intOp = bindOp.getInterfaceOperation();
+            if(intOp != null)
+            {
+                //Determine the "effective" msg label for this binding fault ref.
+                NCName effectiveMsgLabel = null;
+                if(fMessageLabel != null) 
+                {
+                    effectiveMsgLabel = fMessageLabel;
+                } 
+                else 
+                {
+                    //implement placeholder effective msg label, as per the todo comment above
+                }
+                
+                //Now match the effective msg label against the msg label of an interface fault reference
+                //that refers to an interface fault whose qname matches the 'ref' attribute.
+                if(effectiveMsgLabel != null)
+                {
+                    InterfaceFaultReference[] intFaultRefs = intOp.getInterfaceFaultReferences();
+                    for(int i=0; i<intFaultRefs.length; i++)
+                    {
+                        InterfaceFaultReference tempIntFaultRef = intFaultRefs[i];
+                        InterfaceFault tempIntFault = tempIntFaultRef.getInterfaceFault();
+                        QName intFaultName = (tempIntFault != null ? tempIntFault.getName() : null); 
+                        if(fRef.equals(intFaultName) &&
+                           effectiveMsgLabel.equals(tempIntFaultRef.getMessageLabel()))
+                        {
+                            intFaultRef = tempIntFaultRef;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        
+        return intFaultRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingFaultReference#toElement()
+     */
+    public BindingFaultReferenceElement toElement() {
+        return this;
+    }
+
+    /* ************************************************************
+     *  BindingFaultReferenceElement interface methods (the XML Element model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultReferenceElement#setRef(javax.xml.namespace.QName)
+     */
+    public void setRef(QName qname) {
+        fRef = qname;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultReferenceElement#getRef()
+     */
+    public QName getRef() {
+        return fRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultReferenceElement#getInterfaceFaultReferenceElement()
+     * 
+     * TODO added 'effective msg label' matching, as per the component model method getInterfFaultRef.
+     */
+    public InterfaceFaultReferenceElement getInterfaceFaultReferenceElement() 
+    {
+        InterfaceFaultReferenceElement intFaultRef = null;
+        
+        if(fRef != null && fMessageLabel != null)
+        {
+            BindingOperationElement bindOp = (BindingOperationElement)getParentElement();
+            InterfaceOperationElement intOp = bindOp.getInterfaceOperationElement();
+            if(intOp != null)
+            {
+                InterfaceFaultReferenceElement[] intFaultRefs = intOp.getInterfaceFaultReferenceElements();
+                for(int i=0; i<intFaultRefs.length; i++)
+                {
+                    InterfaceFaultReferenceElement temp = intFaultRefs[i];
+                    if(fRef.equals(temp.getRef()) &&
+                       fMessageLabel.equals(temp.getMessageLabel()))
+                    {
+                        intFaultRef = temp;
+                        break;
+                    }
+                }
+            }
+        }
+        
+        return intFaultRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultReferenceElement#setMessageLabel(org.apache.woden.wsdl20.enumeration.MessageLabel)
+     */
+    public void setMessageLabel(NCName msgLabel) {
+        fMessageLabel = msgLabel;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingFaultReferenceElement#getMessageLabel()
+     */
+    public NCName getMessageLabel() {
+        return fMessageLabel;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.wsdl20.WSDLComponent#getFragmentIdentifier()
+     */
+    public FragmentIdentifier getFragmentIdentifier() {
+        //Find parent components.
+        BindingOperation bindingOperationComp = (BindingOperation)getParent();
+        Binding bindingComp = (Binding)bindingOperationComp.getParent();
+        InterfaceOperation interfaceOperationComp = bindingOperationComp.getInterfaceOperation();
+        
+        //Get needed properties.
+        NCName binding = new NCName(bindingComp.getName().getLocalPart());
+        QName interfaceOperation = interfaceOperationComp.getName();
+       
+        //Return a new Fragment Identifier.
+        return new FragmentIdentifier(new BindingFaultReferencePart(binding, interfaceOperation, fMessageLabel, fRef));
+    }
+
+    /* ************************************************************
+     *  Non-API implementation methods
+     * ************************************************************/
+    
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,318 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.wsdl20;
+
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFault;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.WSDLElement;
+
+import org.apache.woden.wsdl20.fragids.FragmentIdentifier;
+import org.apache.woden.wsdl20.fragids.BindingPart;
+
+/**
+ * This class represents the Binding component from the WSDL 2.0 Component Model 
+ * and the WSDL &lt;binding&gt; element.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class BindingImpl extends WSDLComponentImpl 
+                         implements Binding, BindingElement 
+{
+    private WSDLElement fParentElem = null;
+    
+    /* This field refers to the Description component which contains this Binding
+     * component in its {bindings} property. It is set whenever this Binding is 
+     * returned by that Description's getBindings() or getBinding(QName) methods. 
+     * Note that with modularization via a wsdl import or include, this 
+     * reference may be different to fDescriptionElement because it refers to the 
+     * importing or including description at the top of the wsdl tree (whereas the 
+     * latter refers to the description in which this binding is directly declared).
+     * This field is used to retrieve components that are available (i.e. in-scope) 
+     * to the top-level Description component.
+     */ 
+    private Description fDescriptionComponent = null;
+    
+    private NCName fName = null;
+    private QName fInterfaceName = null;
+    private URI fType = null;
+    private List fFaults = new Vector();
+    private List fOperations = new Vector();
+    
+    /* ************************************************************
+     *  Binding interface methods (i.e. WSDL Component model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.Binding#getName()
+     * @see org.apache.woden.wsdl20.xml.BindingElement#getName()
+     */
+    public QName getName() {
+        QName name = null;
+        if (fName != null) {
+            String[] tns = DescriptionImpl.getTargetNamespaceAndPrefix(this);
+            name = new QName(tns[0], fName.toString(), tns[1]);
+        }
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.Binding#getInterface()
+     */
+    public Interface getInterface() 
+    {
+        Interface interfac = fDescriptionComponent.getInterface(fInterfaceName); 
+        return interfac;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.Binding#getType()
+     * @see org.apache.woden.wsdl20.xml.BindingElement#getType()
+     */
+    public URI getType() {
+        return fType;
+    }
+
+    /*
+     * @see org.apache.woden.wsdl20.Binding#getBindingFaults()
+     */
+    public BindingFault[] getBindingFaults() 
+    {
+        BindingFault[] array = new BindingFault[fFaults.size()];
+        fFaults.toArray(array);
+        return array;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.Binding#getBindingOperations()
+     */
+    public BindingOperation[] getBindingOperations() 
+    {
+        BindingOperation[] array = new BindingOperation[fOperations.size()];
+        fOperations.toArray(array);
+        return array;
+    }
+
+    /*
+     * @see org.apache.woden.wsdl20.Binding#toElement()
+     */
+    public BindingElement toElement() {
+        return this;
+    }
+    
+    /* ************************************************************
+     *  BindingElement interface methods (the XML Element model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingElement#setName(javax.xml.namespace.QName)
+     */
+    public void setName(NCName name) {
+        fName = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingElement#setInterfaceName(javax.xml.namespace.QName)
+     */
+    public void setInterfaceName(QName qname) {
+        fInterfaceName = qname;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingElement#getInterfaceName()
+     */
+    public QName getInterfaceName() {
+        return fInterfaceName;
+    }
+
+    /* 
+     * @see org.apache.woden.wsdl20.xml.BindingElement#getInterfaceElement()
+     */
+    public InterfaceElement getInterfaceElement() 
+    {
+        //Cast the containing description element to a description component to re-use its
+        //logic for navigating a composite wsdl to retrieve the in-scope top-level components.
+        Description desc = (Description)fParentElem;
+        InterfaceElement interfac = (InterfaceElement)desc.getInterface(fInterfaceName); 
+        return interfac;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingElement#setType(java.net.URI)
+     */
+    public void setType(URI type) {
+        fType = type;
+    }
+
+    /* 
+     * @see org.apache.woden.wsdl20.xml.BindingElement#addBindingFaultElement()
+     */
+    public BindingFaultElement addBindingFaultElement() 
+    {
+        BindingFaultImpl fault = new BindingFaultImpl();
+        fFaults.add(fault);
+        fault.setParentElement(this);
+        return fault;
+    }
+
+    /* 
+     * @see org.apache.woden.wsdl20.xml.BindingElement#getBindingFaultElements()
+     */
+    public BindingFaultElement[] getBindingFaultElements() 
+    {
+        BindingFaultElement[] array = new BindingFaultElement[fFaults.size()];
+        fFaults.toArray(array);
+        return array;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingElement#addBindingOperationElement()
+     */
+    public BindingOperationElement addBindingOperationElement() 
+    {
+        BindingOperationImpl operation = new BindingOperationImpl();
+        fOperations.add(operation);
+        operation.setParentElement(this);
+        return operation;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingElement#getBindingOperationElements()
+     */
+    public BindingOperationElement[] getBindingOperationElements() 
+    {
+        BindingOperationElement[] array = new BindingOperationElement[fOperations.size()];
+        fOperations.toArray(array);
+        return array;
+    }
+    
+    /* 
+     * package private, used only by factory methods in this package
+     */
+    void setParentElement(WSDLElement parent) {
+        fParentElem = parent;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.NestedElement#getParentElement()
+     */
+    public WSDLElement getParentElement() {
+        return fParentElem;
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods
+     * ************************************************************/
+    
+    /* 
+     * Get the binding fault with the specified 'ref' attribute qname.
+     * 
+     * TODO decide if this type of qname-based accessor is needed, either internally or on API.
+     * TODO also consider if getBindingFaultWithRef is needed (i.e. component model)
+     */
+    public BindingFaultElement getBindingFaultElementWithRef(QName qname) 
+    {
+        BindingFaultElement fault = null;
+        if(qname != null)
+        {
+            BindingFaultElement bindFault = null;
+            Iterator i = fFaults.iterator();
+            while(i.hasNext())
+            {
+                bindFault = (BindingFaultElement)i.next();
+                if(qname.equals(bindFault.getRef())) 
+                {
+                    fault = bindFault;
+                    break;
+                }
+            }
+        }
+        return fault;
+    }
+
+    /*
+     * Get the binding operation with the specified 'ref' attribute qname.
+     * 
+     * TODO decide if this type of qname-based accessor is needed, either internally or on API.
+     * TODO also consider if getBindingOperationWithRef is needed (i.e. component model)
+     */
+    public BindingOperationElement getBindingOperationElementWithRef(QName qname) 
+    {
+        BindingOperationElement operation = null;
+        if(qname != null)
+        {
+            BindingOperationElement bindOp = null;
+            Iterator i = fOperations.iterator();
+            while(i.hasNext())
+            {
+                bindOp = (BindingOperationElement)i.next();
+                if(qname.equals(bindOp.getRef())) 
+                {
+                    operation = bindOp;
+                    break;
+                }
+            }
+        }
+        return operation;
+    }
+    
+    /*
+     * This method sets specifies the Description component in which this Binding is contained 
+     * (i.e. this Binding is contained in the Description's {bindings} property). 
+     * It should only be invoked by DescriptionImpl when the getBindings() method is called,
+     * so it is declared package private to restrict access to it.
+     */
+    void setDescriptionComponent(Description desc) {
+        fDescriptionComponent = desc;
+    }
+
+    /*
+     * This is method returns the Description component in which this Binding is contained.
+     * (i.e. the Description specified on the setDescriptionComponent method above).
+     * Ideally it would be package private too, but it is needed by component extensions for
+     * resolving qnames to ElementDeclarations and TypeDefinitions contained within the same
+     * Description, so it has been defined as a non-API public method.
+     * 
+     * TODO see if there is a way to make this method non-public. 
+     */
+    public Description getDescriptionComponent() {
+        return fDescriptionComponent;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.wsdl20.WSDLComponent#getFragmentIdentifier()
+     */
+    public FragmentIdentifier getFragmentIdentifier() {
+        return new FragmentIdentifier(new BindingPart(this));
+    }
+
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingMessageReferenceImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingMessageReferenceImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingMessageReferenceImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingMessageReferenceImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,200 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.wsdl20;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.InterfaceMessageReference;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.enumeration.Direction;
+import org.apache.woden.wsdl20.fragids.BindingMessageReferencePart;
+import org.apache.woden.wsdl20.fragids.FragmentIdentifier;
+import org.apache.woden.wsdl20.xml.BindingMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+/**
+ * This class represents the BindingMessageReference component of the 
+ * WSDL 2.0 Component model and the &lt;input&gt; and &lt;output&gt; 
+ * child elements of a WSDL binding &lt;operation&gt;. 
+ * 
+ * @author jkaputin@apache.org
+ */
+public class BindingMessageReferenceImpl extends NestedImpl
+                                         implements BindingMessageReference, 
+                                                    BindingMessageReferenceElement 
+{
+    private Direction fDirection = null;
+    private NCName fMessageLabel = null;
+
+    /* ************************************************************
+     *  BindingMessageReference interface methods (i.e. WSDL Component model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingMessageReference#getInterfaceMessageReference()
+     * 
+     * The "effective" message label of the binding message reference message must be equal to the 
+     * message label of an interface message reference.
+     * 
+     * The WSDL 2.0 Part 1 spec says " Define the effective message label of a binding message reference 
+     * element information item  to be either the actual value of the messageLabel attribute information 
+     * item if it is present, or the {message label} of the unique placeholder message with {direction} equal 
+     * to the message direction if the attribute information item is absent."
+     * 
+     * The code in this method currently just supports the first type of "effective" message label,
+     * where the message label property IS present in the binding msg reference.
+     * 
+     */
+    public InterfaceMessageReference getInterfaceMessageReference() 
+    {
+        InterfaceMessageReference intMsgRef = null;
+        BindingOperation bindOp = (BindingOperation)getParent();
+        InterfaceOperation intOp = bindOp.getInterfaceOperation();
+        if(intOp != null)
+        {
+            //Determine the "effective" msg label for this binding msg ref.
+            NCName effectiveMsgLabel = null;
+            if(fMessageLabel != null) 
+            {
+                effectiveMsgLabel = fMessageLabel;
+            } 
+            else 
+            {
+                //TODO implement placeholder effective msg label, as per Part 1 of spec section 2.10.3
+            }
+            
+            //Now match the effective msg label against the msg label of an interface msg reference.
+            if(effectiveMsgLabel != null)
+            {
+                InterfaceMessageReference[] intMsgRefs = intOp.getInterfaceMessageReferences();
+                for(int i=0; i<intMsgRefs.length; i++)
+                {
+                    if( effectiveMsgLabel.equals(intMsgRefs[i].getMessageLabel()) )
+                    {
+                        intMsgRef = intMsgRefs[i];
+                        break;
+                    }
+                }
+            }
+        }
+        return intMsgRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingMessageReference#toElement()
+     */
+    public BindingMessageReferenceElement toElement() {
+        return this;
+    }
+
+    /* ************************************************************
+     *  BindingMessageReferenceElement interface methods (the XML Element model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingMessageReferenceElement#setDirection(org.apache.woden.wsdl20.enumeration.Direction)
+     */
+    public void setDirection(Direction dir) {
+        fDirection = dir;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingMessageReferenceElement#getDirection()
+     */
+    public Direction getDirection() {
+        return fDirection;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingMessageReferenceElement#setMessageLabel(org.apache.woden.wsdl20.enumeration.MessageLabel)
+     */
+    public void setMessageLabel(NCName msgLabel) {
+        fMessageLabel = msgLabel;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingMessageReferenceElement#getMessageLabel()
+     */
+    public NCName getMessageLabel() {
+        return fMessageLabel;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingMessageReferenceElement#getInterfaceMessageReferenceElement()
+     */
+    public InterfaceMessageReferenceElement getInterfaceMessageReferenceElement() {
+        InterfaceMessageReferenceElement intMsgRef = null;
+        BindingOperationElement bindOp = (BindingOperationElement)getParentElement();
+        InterfaceOperationElement intOp = bindOp.getInterfaceOperationElement();
+        if(intOp != null)
+        {
+            //Determine the "effective" msg label for this binding msg ref.
+            NCName effectiveMsgLabel = null;
+            if(fMessageLabel != null) 
+            {
+                effectiveMsgLabel = fMessageLabel;
+            } 
+            else 
+            {
+                //TODO: implement placeholder effective msg label, as per Part 1 of spec section 2.10.3
+            }
+            
+            //Now match the effective msg label against the msg label of an interface msg reference.
+            if(effectiveMsgLabel != null)
+            {
+                InterfaceMessageReferenceElement[] intMsgRefs = intOp.getInterfaceMessageReferenceElements();
+                for(int i=0; i<intMsgRefs.length; i++)
+                {
+                    if( effectiveMsgLabel.equals(intMsgRefs[i].getMessageLabel()) )
+                    {
+                        intMsgRef = intMsgRefs[i];
+                        break;
+                    }
+                }
+            }
+        }
+        return intMsgRef;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.wsdl20.WSDLComponent#getFragmentIdentifier()
+     */
+    public FragmentIdentifier getFragmentIdentifier() {
+        //Find parent components.
+        BindingOperation bindingOperationComp = (BindingOperation)getParent();
+        Binding bindingComp = (Binding)bindingOperationComp.getParent();
+        InterfaceOperation interfaceOperationComp = bindingOperationComp.getInterfaceOperation();
+        
+        //Get needed properties.
+        NCName binding = new NCName(bindingComp.getName().getLocalPart());
+        QName interfaceOperation = interfaceOperationComp.getName();
+        
+        //Return a new FragmentIdentifier.
+        return new FragmentIdentifier(new BindingMessageReferencePart(binding, interfaceOperation, fMessageLabel));
+    }
+
+    /* ************************************************************
+     *  Non-API implementation methods
+     * ************************************************************/
+    
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingOperationImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingOperationImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingOperationImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/BindingOperationImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,205 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.wsdl20;
+
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFaultReference;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.Service;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+
+import org.apache.woden.wsdl20.fragids.FragmentIdentifier;
+import org.apache.woden.wsdl20.fragids.BindingOperationPart;
+
+/**
+ * This class represents the BindingOperation component from the WSDL 2.0 Component Model 
+ * and the &lt;operation&gt; child element of the WSDL &lt;binding&gt; element.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class BindingOperationImpl extends NestedImpl 
+                                  implements BindingOperation, BindingOperationElement 
+{
+    private QName fRef = null;
+    private List fMessageRefs = new Vector();
+    private List fFaultRefs = new Vector();
+
+    /* ************************************************************
+     *  BindingOperation interface methods (i.e. WSDL Component model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingOperation#getInterfaceOperation()
+     */
+    public InterfaceOperation getInterfaceOperation() 
+    {
+        InterfaceOperation oper = null;
+        Binding binding = (Binding)getParent();
+        Interface interfac = binding.getInterface();
+        if(interfac != null) {
+            oper = interfac.getFromAllInterfaceOperations(fRef);
+        }
+        return oper;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingOperation#getBindingMessageReferences()
+     */
+    public BindingMessageReference[] getBindingMessageReferences() {
+        BindingMessageReference[] array = new BindingMessageReference[fMessageRefs.size()];
+        fMessageRefs.toArray(array);
+        return array;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.BindingOperation#getBindingFaultReferences()
+     */
+    public BindingFaultReference[] getBindingFaultReferences() {
+        BindingFaultReference[] array = new BindingFaultReference[fFaultRefs.size()];
+        fFaultRefs.toArray(array);
+        return array;
+    }
+
+    /*
+     * @see org.apache.woden.wsdl20.BindingOperation#toElement()
+     */
+    public BindingOperationElement toElement() {
+        return this;
+    }
+    
+    /* ************************************************************
+     *  BindingOperationElement interface methods (the XML Element model)
+     * ************************************************************/
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#setRef(javax.xml.namespace.QName)
+     */
+    public void setRef(QName qname) {
+        fRef = qname;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#getRef()
+     */
+    public QName getRef() {
+        return fRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#getInterfaceOperationElement()
+     */
+    public InterfaceOperationElement getInterfaceOperationElement() 
+    {
+        InterfaceOperationElement oper = null;
+        BindingElement binding = (BindingElement)getParentElement();
+        InterfaceElement interfac = binding.getInterfaceElement();
+        if(interfac != null) {
+            InterfaceOperation operComp = ((Interface)interfac).getFromAllInterfaceOperations(fRef);
+            if(operComp != null) {
+                oper = operComp.toElement();
+            }
+        }
+        return oper;
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#addBindingMessageReferenceElement()
+     */
+    public BindingMessageReferenceElement addBindingMessageReferenceElement() 
+    {
+        BindingMessageReferenceImpl msgRef = new BindingMessageReferenceImpl();
+        fMessageRefs.add(msgRef);
+        msgRef.setParentElement(this);
+        return msgRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#removeBindingMessageReferenceElement(org.apache.woden.wsdl20.xml.BindingMessageReferenceElement)
+     */
+    public void removeBindingMessageReferenceElement(BindingMessageReferenceElement msgRef) {
+        fMessageRefs.remove(msgRef);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#getBindingMessageReferenceElements()
+     */
+    public BindingMessageReferenceElement[] getBindingMessageReferenceElements() {
+        BindingMessageReferenceElement[] array = new BindingMessageReferenceElement[fMessageRefs.size()];
+        fMessageRefs.toArray(array);
+        return array;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#addBindingFaultReferenceElement()
+     */
+    public BindingFaultReferenceElement addBindingFaultReferenceElement() 
+    {
+        BindingFaultReferenceImpl faultRef = new BindingFaultReferenceImpl();
+        fFaultRefs.add(faultRef);
+        faultRef.setParentElement(this);
+        return faultRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#removeBindingFaultReferenceElement(org.apache.woden.wsdl20.xml.BindingFaultReferenceElement)
+     */
+    public void removeBindingFaultReferenceElement(BindingFaultReferenceElement faultRef) {
+        fFaultRefs.remove(faultRef);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.xml.BindingOperationElement#getBindingFaultReferenceElements()
+     */
+    public BindingFaultReferenceElement[] getBindingFaultReferenceElements() {
+        BindingFaultReferenceElement[] array = new BindingFaultReferenceElement[fFaultRefs.size()];
+        fFaultRefs.toArray(array);
+        return array;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.wsdl20.WSDLComponent#getFragmentIdentifier()
+     */
+    public FragmentIdentifier getFragmentIdentifier() {
+        //Find parent component and get needed properties.
+        Binding bindingComp = (Binding)getParent();
+        NCName binding = new NCName(bindingComp.getName().getLocalPart());
+        
+        //Return a new FragmentIdentifier.
+        return new FragmentIdentifier(new BindingOperationPart (binding , fRef));
+    }
+
+    /* ************************************************************
+     *  Non-API implementation methods
+     * ************************************************************/
+    
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/ComponentModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/ComponentModelBuilder.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/ComponentModelBuilder.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/ComponentModelBuilder.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,612 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.internal.wsdl20;
+
+import java.net.URI;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.schema.SchemaConstants;
+import org.apache.woden.schema.Schema;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFault;
+import org.apache.woden.wsdl20.BindingFaultReference;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.WSDLComponent;
+import org.apache.woden.wsdl20.extensions.ComponentExtensionContext;
+import org.apache.woden.wsdl20.extensions.WSDLExtensionConstants;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+import org.apache.woden.wsdl20.extensions.rpc.RPCConstants;
+import org.apache.woden.wsdl20.xml.BindingElement;
+import org.apache.woden.wsdl20.xml.BindingFaultElement;
+import org.apache.woden.wsdl20.xml.BindingFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.BindingOperationElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.EndpointElement;
+import org.apache.woden.wsdl20.xml.ImportElement;
+import org.apache.woden.wsdl20.xml.IncludeElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+import org.apache.woden.wsdl20.xml.ServiceElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+import org.apache.ws.commons.schema.utils.NamespacePrefixList;
+
+/**
+ * Converts the xml representation of a WSDL document to the WSDL component
+ * model representation defined by the W3C WSDL 2.0 spec. The xml model is
+ * contained within a DescriptionElement object. The component model is
+ * contained within a Description object.
+ * 
+ * TODO consider moving this logic inside DescriptionImpl, maybe as an inner
+ * class.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ * @author Arthur Ryman (ryman@ca.ibm.com, arthur.ryman@gmail.com) - added
+ *         Interface Operation extensions, - added Endpoint extensions
+ */
+public class ComponentModelBuilder {
+    
+    private static final String emptyString = "".intern();
+
+	// TODO support for other (non-Schema) type systems
+
+	private DescriptionImpl fDesc;
+
+	// TODO private ErrorReporter fErrorRpt; see todo in
+	// buildElementDeclarations()
+    private List fDescTypesDone = new Vector();
+    
+	private List fSchemasDone = new Vector();
+
+	private List fInterfacesDone = new Vector();
+
+	private List fBindingsDone = new Vector();
+
+	private List fServicesDone = new Vector();
+    
+    private URI fBindingType = null;
+    
+	public ComponentModelBuilder(DescriptionImpl desc) {
+		fDesc = desc;
+		// TODO fErrorRpt = errorRpt; see todo in buildElementDeclarations()
+		initComponents(fDesc);
+	}
+
+	private void initComponents(DescriptionImpl desc) {
+
+		buildElementsAndTypes(desc);
+		buildInterfaces(desc);
+		buildBindings(desc);
+		buildServices(desc);
+
+		IncludeElement[] includes = desc.getIncludeElements();
+		for (int i = 0; i < includes.length; i++) {
+			DescriptionElement inclDesc = includes[i].getDescriptionElement();
+			if (inclDesc != null) {
+				initComponents((DescriptionImpl) inclDesc);
+			}
+		}
+
+		ImportElement[] imports = desc.getImportElements();
+		for (int i = 0; i < imports.length; i++) {
+			DescriptionElement impDesc = imports[i].getDescriptionElement();
+			if (impDesc != null) {
+				initComponents((DescriptionImpl) impDesc);
+			}
+		}
+	}
+
+	/***************************************************************************
+	 * TYPES
+	 **************************************************************************/
+
+	/*
+	 * Extract from the collections of in-scope schemas the element declarations
+	 * and type definitions.
+	 */
+	private void buildElementsAndTypes(DescriptionImpl desc) {
+        
+        if(fDescTypesDone.contains(desc)) {
+            return;
+        } else {
+            fDescTypesDone.add(desc);
+        }
+        
+        //process the schema components declared within this description's types element
+		URI typeSystemURI = URI.create(Constants.TYPE_XSD_2001); //TODO support other type systems?
+        TypesElement types = desc.getTypesElement();
+		if (types != null) {
+            //first, get the list of imported schema namespaces
+            Schema[] importedSchemas = types.getImportedSchemas();
+            List importedNSpaces = new Vector();
+            for(int j=0; j<importedSchemas.length; j++) {
+                URI nsURI = importedSchemas[j].getNamespace();
+                if(nsURI != null) {
+                    String ns = nsURI.toString();
+                    if(!importedNSpaces.contains(ns)) {
+                        importedNSpaces.add(ns);
+                    }
+                }
+            }
+            //second, process all schemas inlined or imported directly by <types>
+            Schema[] schemas = types.getSchemas();
+            XmlSchema xmlSchema;
+            for(int i=0; i<schemas.length; i++) {
+                xmlSchema = schemas[i].getSchemaDefinition();
+                if(xmlSchema != null && !fSchemasDone.contains(xmlSchema)) {
+                    buildElementsAndTypes(
+                            xmlSchema, xmlSchema.getTargetNamespace(), typeSystemURI, importedNSpaces);
+                }
+            }
+        }
+        
+        //process the schema components declared within any included descriptions
+        IncludeElement[] includes = desc.getIncludeElements();
+        DescriptionElement includedDesc;
+        for(int i = 0; i < includes.length; i++)
+        {
+            includedDesc = includes[i].getDescriptionElement();
+            if(includedDesc != null) 
+            {
+                buildElementsAndTypes((DescriptionImpl)includedDesc);
+            }
+        }
+        
+        //process the schema components declared within any imported descriptions
+        ImportElement[] imports = desc.getImportElements();
+        DescriptionElement importedDesc;
+        for(int i = 0; i < imports.length; i++)
+        {
+            importedDesc = imports[i].getDescriptionElement();
+            if(importedDesc != null) 
+            {
+                buildElementsAndTypes((DescriptionImpl)importedDesc);
+            }
+        }
+            
+            
+			//List referenceableSchemaDefs = ((TypesImpl) types)
+			//		.getReferenceableSchemaDefs();
+			//Iterator i = referenceableSchemaDefs.iterator();
+			//while (i.hasNext()) {
+			//	XmlSchema schemaDef = (XmlSchema) i.next();
+            //    buildElementsAndTypes(schemaDef, schemaDef.getTargetNamespace(), typeSystemURI);
+			//}
+	}
+    
+    private void buildElementsAndTypes(XmlSchema schemaDef, String schemaTns, URI typeSystemURI, List importedNSpaces) {
+        
+        if(fSchemasDone.contains(schemaDef)) {
+            return;
+        } else {
+            fSchemasDone.add(schemaDef);
+        }
+        
+        //process elements and types declared directly in this schema
+        
+        if(!SchemaConstants.NS_STRING_SCHEMA.equals(schemaDef.getTargetNamespace())) {
+            //XML Schema namespace is implicitly imported to get built-in types...we don't want the elements.
+            //TODO detect if the XML Schema NS has been explicitly imported (if so, we do want the elements) 
+            buildElementDeclarations(schemaDef, schemaTns, typeSystemURI);
+        }
+        buildTypeDefinitions(schemaDef, schemaTns, typeSystemURI);
+            
+        //process elements and types declared in any included or imported schemas.
+        //note that XmlSchema keeps included and imported schemas together, via getIncludes().
+        
+        XmlSchemaObjectCollection includeColl = schemaDef.getIncludes();
+        Iterator includes = includeColl.getIterator();
+        while(includes.hasNext()) {
+            Object o = includes.next();
+            XmlSchemaExternal externalSchema = (XmlSchemaExternal)o;
+            XmlSchema schema = externalSchema.getSchema();
+            if(schema != null )
+            {
+                String schemaTNS = schema.getTargetNamespace();
+                if( externalSchema instanceof XmlSchemaInclude ||
+                   (externalSchema instanceof XmlSchemaImport && importedNSpaces.contains(schemaTNS)) ) {
+                    buildElementsAndTypes(schema, schemaTNS, typeSystemURI, importedNSpaces);
+                }
+            }
+        }
+    }
+
+	/*
+	 * Extract the element declarations from the given schema.
+	 */
+	private void buildElementDeclarations(XmlSchema schemaDef, String schemaTns, URI typeSystemURI) {
+        
+	    XmlSchemaObjectTable elementTable = schemaDef.getElements();
+        NamespacePrefixList prefixes = schemaDef.getNamespaceContext();
+	    Iterator qnames = elementTable.getNames();
+	    while (qnames.hasNext()) {
+	        QName xseQN = (QName) qnames.next();
+            if(fDesc.getElementDeclaration(xseQN) != null) {
+                //The Description already contains this Element Declaration.
+                continue;
+                //This check is necessary because the XmlSchema.equals method, which gets used
+                //to evaluate fSchemas.contains(..), cannot detect the equivalence of a schema 
+                //that is xs:imported within <wsdl:types> and also xs:imported within by 
+                //an inlined schema within the same <wsdl:types> element.
+                //Error case is result.xsd in the W3C WSDL 2.0 test case SparqlQuerySimplified-1G.
+                //This check may be necessary anyway, because if the document assertion Schema-1073
+                //is violated, we don't want the duplicate schema components in the component model.
+                //TODO check that this behaviour is correct (eliminating duplicates)
+            }
+            QName edQN = xseQN;
+            if(xseQN.getNamespaceURI() == null && schemaTns != null) {
+                //this is how XmlSchema represents tns for chameleon xs:includes,
+                //so replace it with the including schema's tns.
+                edQN = new QName(schemaTns, xseQN.getLocalPart(), xseQN.getPrefix());
+            }
+            if(edQN.getPrefix() == "" || edQN.getPrefix() == null) {
+                //if a prefix has been declared for this NS uri, include it in the qname
+                String pfx = prefixes.getPrefix(edQN.getNamespaceURI());
+                if(pfx != null) {
+                    edQN = new QName(edQN.getNamespaceURI(), edQN.getLocalPart(), pfx);
+                }
+            }
+	        if(schemaTns == null || schemaTns.equals(edQN.getNamespaceURI())) //TODO test with schema imports, may be incorrect.
+            {
+	            ElementDeclarationImpl ed = new ElementDeclarationImpl();
+	            ed.setName(edQN);
+	            ed.setSystem(typeSystemURI);
+	            ed.setContentModel(Constants.API_APACHE_WS_XS);
+	            ed.setContent(elementTable.getItem(xseQN));
+	            fDesc.addElementDeclaration(ed);
+	        }
+	    }
+	}
+
+	/*
+	 * Extract the type definitions from the given schema.
+	 */
+	private void buildTypeDefinitions(XmlSchema schemaDef, String schemaTns, URI typeSystemURI) {
+        
+	    XmlSchemaObjectTable typeTable = schemaDef.getSchemaTypes();
+        NamespacePrefixList prefixes = schemaDef.getNamespaceContext();
+	    Iterator qnames = typeTable.getNames();
+	    while (qnames.hasNext()) {
+	        QName xstQN = (QName) qnames.next();
+            
+            if(SchemaConstants.NS_STRING_SCHEMA.equals(schemaTns) && 
+               !SchemaConstants.LIST_Q_BUILT_IN_TYPES.contains(xstQN)) {
+                //XML Schema namespace is implicitly imported to get built-in types...we don't want non-built-in types.
+                //TODO detect if the XML Schema NS has been explicitly imported (if so, we want ALL type defs) 
+                continue;
+            }
+            
+            if(fDesc.getTypeDefinition(xstQN) != null) {
+                //The Description already contains this Type Definition.
+                continue;
+                //The same comments apply here as stated in the buildElementDeclarations method.
+                //TODO check that this behaviour is correct (per assertion Schema-1073).
+            }
+            QName tdQN = xstQN;
+            if(xstQN.getNamespaceURI() == null && schemaTns != null) {
+                //this is how XmlSchema represents tns for chameleon xs:includes,
+                //so replace it with the including schema's tns.
+                tdQN = new QName(schemaTns, xstQN.getLocalPart(), xstQN.getPrefix());
+            }
+            if(tdQN.getPrefix() == emptyString || tdQN.getPrefix() == null) {
+                //if a prefix has been declared for this NS uri, include it in the qname
+                String pfx = prefixes.getPrefix(tdQN.getNamespaceURI());
+                if(pfx != null) {
+                    tdQN = new QName(tdQN.getNamespaceURI(), tdQN.getLocalPart(), pfx);
+                }
+            }
+	        if (schemaTns == null || schemaTns.equals(tdQN.getNamespaceURI())) 
+            {
+	            TypeDefinitionImpl td = new TypeDefinitionImpl();
+	            td.setName(tdQN);
+	            td.setSystem(typeSystemURI);
+	            td.setContentModel(Constants.API_APACHE_WS_XS);
+	            td.setContent(typeTable.getItem(xstQN));
+	            fDesc.addTypeDefinition(td);
+	        }
+	    }
+	}
+
+	/***************************************************************************
+	 * INTERFACE
+	 **************************************************************************/
+
+	/*
+	 * Initialize the Interface component and its child components from the
+	 * InterfaceElement and its child elements.
+	 */
+	private void buildInterfaces(DescriptionImpl desc) {
+		InterfaceElement[] interfaceEls = desc.getInterfaceElements();
+		for (int i = 0; i < interfaceEls.length; i++) {
+			InterfaceImpl interfaceImpl = (InterfaceImpl) interfaceEls[i];
+			if (!fInterfacesDone.contains(interfaceImpl)) {
+				buildInterfaceOperations(interfaceImpl);
+				fInterfacesDone.add(interfaceImpl);
+			}
+		}
+	}
+
+	private void buildInterfaceOperations(InterfaceImpl interfaceImpl) {
+		InterfaceOperationElement[] operations = interfaceImpl
+				.getInterfaceOperationElements();
+		for (int i = 0; i < operations.length; i++) {
+			InterfaceOperationImpl oper = (InterfaceOperationImpl) operations[i];
+			buildInterfaceOperationExtensions(oper);
+		}
+	}
+
+	private void buildInterfaceOperationExtensions(InterfaceOperationImpl oper) {
+        
+        /*
+         * Create a ComponentExtensions object for each registered extension
+         * namespace used within this operation by extension elements or attributes.
+         */
+		ExtensionRegistry er = fDesc.getWsdlContext().extensionRegistry;
+		URI[] extNamespaces = er
+				.queryComponentExtensionNamespaces(InterfaceOperation.class);
+
+		for (int i = 0; i < extNamespaces.length; i++) {
+			URI extNS = extNamespaces[i];
+			if (oper.hasExtensionAttributesForNamespace(extNS)) {
+				ComponentExtensionContext compExt = createComponentExtensions(
+						InterfaceOperation.class, oper, extNS);
+				oper.setComponentExtensionContext(extNS, compExt);
+			}
+		}
+        
+        /*
+         * {safety} is a REQUIRED extension property on interface operation
+         * so if an InterfaceOperationExtensions object has not already been
+         * created, create one now.
+         */
+        if (oper.getComponentExtensionContext(
+                WSDLExtensionConstants.NS_URI_WSDL_EXTENSIONS) == null) {
+            ComponentExtensionContext compExt = createComponentExtensions(
+                    InterfaceOperation.class, oper,
+                    WSDLExtensionConstants.NS_URI_WSDL_EXTENSIONS);
+            oper.setComponentExtensionContext(
+                    WSDLExtensionConstants.NS_URI_WSDL_EXTENSIONS, compExt);
+        }
+        
+        /*
+         * If interface operation style includes RPC then if an
+         * RPCInterfaceOperationExtensions object has not already been
+         * created, create one now.
+         */
+        boolean isRPCStyle = false;
+        URI[] style = oper.getStyle();
+        for(int i=0; i<style.length; i++)
+        {
+            URI temp = style[i];
+            if(RPCConstants.STYLE_URI_RPC.equals(temp)) {
+                isRPCStyle = true;
+                break;
+            }
+        }
+        
+        if(isRPCStyle) {
+            if (oper.getComponentExtensionContext(
+                    RPCConstants.NS_URI_RPC) == null) {
+                ComponentExtensionContext compExt = createComponentExtensions(
+                        InterfaceOperation.class, oper,
+                        RPCConstants.NS_URI_RPC);
+                oper.setComponentExtensionContext(
+                        RPCConstants.NS_URI_RPC, compExt);
+            }
+        }
+	}
+
+	/***************************************************************************
+	 * BINDING
+	 **************************************************************************/
+
+	/*
+	 * Initialize the Binding component and its child components from the
+	 * BindingElement and its child elements.
+	 */
+	private void buildBindings(DescriptionImpl desc) {
+		BindingElement[] bindingEls = desc.getBindingElements();
+		for (int i = 0; i < bindingEls.length; i++) {
+			BindingImpl bindImpl = (BindingImpl) bindingEls[i];
+			if (!fBindingsDone.contains(bindImpl)) {
+                buildBindingExtensions(bindImpl);
+				buildBindingFaults(bindImpl);
+				buildBindingOperations(bindImpl);
+				fBindingsDone.add(bindImpl);
+			}
+		}
+	}
+
+	private void buildBindingFaults(BindingImpl binding) {
+		BindingFaultElement[] bindFaults = binding.getBindingFaultElements();
+		for (int i = 0; i < bindFaults.length; i++) {
+			BindingFaultImpl bindFault = (BindingFaultImpl) bindFaults[i];
+			buildBindingFaultExtensions(bindFault);
+		}
+	}
+
+	private void buildBindingOperations(BindingImpl binding) {
+		BindingOperationElement[] operations = binding
+				.getBindingOperationElements();
+		for (int i = 0; i < operations.length; i++) {
+			BindingOperationImpl oper = (BindingOperationImpl) operations[i];
+			buildBindingFaultReferences(oper);
+			buildBindingMessageReferences(oper);
+			buildBindingOperationExtensions(oper);
+		}
+	}
+
+	private void buildBindingFaultReferences(BindingOperationImpl oper) {
+		BindingFaultReferenceElement[] faultRefs = oper
+				.getBindingFaultReferenceElements();
+		for (int i = 0; i < faultRefs.length; i++) {
+			BindingFaultReferenceImpl faultRef = (BindingFaultReferenceImpl) faultRefs[i];
+
+			buildBindingFaultReferenceExtensions(faultRef);
+
+		}
+	}
+
+	private void buildBindingMessageReferences(BindingOperationImpl oper) {
+		BindingMessageReferenceElement[] messages = oper
+				.getBindingMessageReferenceElements();
+		for (int i = 0; i < messages.length; i++) {
+			BindingMessageReferenceImpl message = (BindingMessageReferenceImpl) messages[i];
+
+			buildBindingMessageReferenceExtensions(message);
+		}
+	}
+
+	private void buildBindingExtensions(BindingImpl binding) {
+        
+        /*
+         * Create a ComponentExtensions subtype specific to the binding type.
+         */
+        
+        fBindingType = binding.getType();
+        if(fBindingType != null) {
+            ComponentExtensionContext compExt = createComponentExtensions(
+                    Binding.class, binding, fBindingType);
+            binding.setComponentExtensionContext(fBindingType, compExt);
+        }
+	}
+
+	private void buildBindingFaultExtensions(BindingFaultImpl bindFault) {
+        
+        /*
+         * Create a ComponentExtensions subtype specific to the binding type.
+         */
+        
+        if(fBindingType != null) {
+            ComponentExtensionContext compExt = createComponentExtensions(
+                    BindingFault.class, bindFault, fBindingType);
+            bindFault.setComponentExtensionContext(fBindingType, compExt);
+        }
+	}
+
+	private void buildBindingOperationExtensions(BindingOperationImpl bindOper) {
+        
+        /*
+         * Create a ComponentExtensions subtype specific to the binding type.
+         */
+        
+        if(fBindingType != null) {
+            ComponentExtensionContext compExt = createComponentExtensions(
+                    BindingOperation.class, bindOper, fBindingType);
+            bindOper.setComponentExtensionContext(fBindingType, compExt);
+        }
+	}
+
+	private void buildBindingMessageReferenceExtensions(
+			BindingMessageReferenceImpl bindMsgRef) {
+        
+        /*
+         * Create a ComponentExtensions subtype specific to the binding type.
+         */
+        
+        if(fBindingType != null) {
+            ComponentExtensionContext compExt = createComponentExtensions(
+                    BindingMessageReference.class, bindMsgRef, fBindingType);
+            bindMsgRef.setComponentExtensionContext(fBindingType, compExt);
+        }
+	}
+
+	private void buildBindingFaultReferenceExtensions(
+			BindingFaultReferenceImpl bindFaultRef) {
+        
+        /*
+         * Create a ComponentExtensions subtype specific to the binding type.
+         */
+        
+        if(fBindingType != null) {
+            ComponentExtensionContext compExt = createComponentExtensions(
+                    BindingFaultReference.class, bindFaultRef, fBindingType);
+            bindFaultRef.setComponentExtensionContext(fBindingType, compExt);
+        }
+	}
+
+	private void buildServices(DescriptionImpl desc) {
+
+		ServiceElement[] serviceEls = desc.getServiceElements();
+		for (int i = 0; i < serviceEls.length; i++) {
+			ServiceImpl serviceImpl = (ServiceImpl) serviceEls[i];
+			if (!fServicesDone.contains(serviceImpl)) {
+				buildEndpoints(serviceImpl);
+				fServicesDone.add(serviceImpl);
+			}
+		}
+	}
+
+	private void buildEndpoints(ServiceImpl serviceImpl) {
+
+		EndpointElement[] endpoints = serviceImpl.getEndpointElements();
+		for (int i = 0; i < endpoints.length; i++) {
+			EndpointImpl endpoint = (EndpointImpl) endpoints[i];
+			buildEndpointExtensions(endpoint);
+		}
+	}
+
+	private void buildEndpointExtensions(EndpointImpl endpoint) {
+		
+        /*
+         * Create a ComponentExtensions subtype specific to the binding type.
+         */
+        
+        if(fBindingType != null) {
+            ComponentExtensionContext compExt = createComponentExtensions(
+                    Endpoint.class, endpoint, fBindingType);
+            endpoint.setComponentExtensionContext(fBindingType, compExt);
+        }
+	}
+
+	/*
+	 * This helper method factors out common code for creating
+	 * ComponentExtensionContexts registered in the ExtensionRegistry.
+	 */
+	private ComponentExtensionContext createComponentExtensions(Class parentClass,
+			WSDLComponent parentComp, URI extNS) {
+		ExtensionRegistry er = fDesc.getWsdlContext().extensionRegistry;
+		ComponentExtensionContext compExt = null;
+		try {
+			compExt = er.createComponentExtension(parentClass, parentComp, extNS);
+			//TODO remove with woden-47 ((ComponentExtensionsImpl) compExt).init(parentElem, extNS);
+		} catch (WSDLException e) {
+			// This exception occurs if there is no Java class registered for
+			// the namespace, but
+			// this namespace was obtained from the extension registry so we
+			// know that a Java class is
+			// registered and that this exception cannot occur. Ignore the catch
+			// block.
+		}
+		return compExt;
+	}
+
+}



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


Mime
View raw message