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 2008/02/04 08:08:26 UTC

svn commit: r618181 - in /webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions: BaseComponentExtensionContext.java ComponentExtensionContext.java ExtensionProperty.java GenericExtensionProperty.java PropertyExtensible.java

Author: jkaputin
Date: Sun Feb  3 23:08:24 2008
New Revision: 618181

URL: http://svn.apache.org/viewvc?rev=618181&view=rev
Log:
WODEN-47
Initial commit of new extension API interfaces and base classes, which add PropertyExtensible, generic ExtensionProperty type and the type
ComponentExtensionContext to replace
ComponentExtensions.

Added:
    webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/BaseComponentExtensionContext.java   (with props)
    webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ComponentExtensionContext.java   (with props)
    webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ExtensionProperty.java   (with props)
    webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/GenericExtensionProperty.java   (with props)
    webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/PropertyExtensible.java   (with props)

Added: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/BaseComponentExtensionContext.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/BaseComponentExtensionContext.java?rev=618181&view=auto
==============================================================================
--- webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/BaseComponentExtensionContext.java (added)
+++ webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/BaseComponentExtensionContext.java Sun Feb  3 23:08:24 2008
@@ -0,0 +1,124 @@
+/**
+ * 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.wsdl20.extensions;
+
+import java.net.URI;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.wsdl20.WSDLComponent;
+
+/**
+ * This abstract class partially implements the ComponentExtensionContext interface.
+ * It implements common behaviour, leaving the extension-specific methods abstract. 
+ * That is, it leaves the <code>getProperties</code> and <code>getProperty</code> methods 
+ * abstract, for subclasses to implement.
+ * <p>
+ * Implementors of WSDL 2.0 extensions may extend this class to reuse common behaviour 
+ * for accessing the parent component and the extension namespace. 
+ * It provides a constructor which subclasses should call that stores the parent component 
+ * and extension namespace.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public abstract class BaseComponentExtensionContext implements ComponentExtensionContext {
+    
+    private WSDLComponent parent;
+    private URI extNamespace;
+    protected ErrorReporter errorReporter;
+
+    /**
+     * Constructor accepts the parent component, the extension namespace and an error reporter.
+     * These parameters cannot be null. 
+     * <p>
+     * Normal behaviour is for these 3 parameters to be provided by the ExtensionRegistry when 
+     * it calls this constructor. 
+     * Woden client code should not need to call this constructor directly. 
+     * However, this assumes that extension properties from the required namespace have been 
+     * registered in the ExtensionRegistry. 
+     * This is done automatically by Woden for the extensions defined by the 
+     * WSDL 2.0 Recommendation (SOAP, HTTP, RPC, WSDLX), but implementors of other WSDL 2.0 
+     * extensions must ensure they register their extension properties so that this constructor 
+     * gets called by the ExtensionRegistry.
+     * 
+     * @param parent WSDLComponent containing these extension properties
+     * @param extNamespace extension namespace URI
+     * @param errorReporter ErrorReporter available to subclasses for reporting errors
+     * 
+     * @throws NullPointerException if any of the parameters are null
+     */
+    protected BaseComponentExtensionContext(WSDLComponent parent, 
+            URI extNamespace, ErrorReporter errorReporter) {
+        
+        if(errorReporter == null) {
+            throw new NullPointerException("ErrorReporter=null");
+        }
+        if(parent == null) {
+            throw new NullPointerException(errorReporter.getFormattedMessage("WSDL025", null));
+        }
+        if(extNamespace == null) {
+            throw new NullPointerException(errorReporter.getFormattedMessage("WSDL023", null));
+        }
+        
+        this.parent = parent;
+        this.extNamespace = extNamespace;
+        this.errorReporter = errorReporter;
+    }
+    
+    /* ************************************************************
+     *  Methods declared by ComponentExtensionContext
+     * ************************************************************/
+
+    /**
+     * @see org.apache.woden.wsdl20.extensions.ComponentExtensionContext#getParent()
+     */
+    public WSDLComponent getParent() {
+        return this.parent;
+    }
+    
+    /**
+     * @see org.apache.woden.wsdl20.extensions.ComponentExtensionContext#getNamespace()
+     */
+    public URI getNamespace() {
+        return this.extNamespace;
+    }
+
+    /**
+     * @see org.apache.woden.wsdl20.extensions.ComponentExtensionContext#getProperties()
+     */
+    abstract public ExtensionProperty[] getProperties();
+    
+    /**
+     * @see org.apache.woden.wsdl20.extensions.ComponentExtensionContext#getProperty(java.lang.String)
+     */
+    abstract public ExtensionProperty getProperty(String propertyName);
+
+    /* ************************************************************
+     *  Helper methods
+     * ************************************************************/
+
+    /**
+     * A factory-type method for instantiating and initialising ExtensionProperty objects. 
+     * This is a helper method for subclasses, as it automatically provides the extension namespace. 
+     * The only additional information the caller must provide is the property name and its content.
+     * The property name parameter must not be null.
+     * 
+     * @throws NullPointerException if the <code>name</code> parameter is null.
+     */
+    protected ExtensionProperty newExtensionProperty(String name, Object content) {
+            return new GenericExtensionProperty(name, getNamespace(), content);
+    }
+}

Propchange: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/BaseComponentExtensionContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ComponentExtensionContext.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ComponentExtensionContext.java?rev=618181&view=auto
==============================================================================
--- webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ComponentExtensionContext.java (added)
+++ webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ComponentExtensionContext.java Sun Feb  3 23:08:24 2008
@@ -0,0 +1,81 @@
+/**
+ * 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.wsdl20.extensions;
+
+import java.net.URI;
+
+import org.apache.woden.wsdl20.WSDLComponent;
+
+/**
+ * This interface defines a generic API for accessing the extension properties
+ * from a particular extension namespace that are attached to a particular 
+ * WSDL 2.0 component. That is, for accessing extension properties by namespace
+ * per component.
+ * <p>
+ * It provides accessor methods that return <code>ExtensionProperty</code> objects, 
+ * which callers can use to access the content of an extension property.
+ * <p>
+ * Implementors of WSDL 2.0 extensions must, as a minimum, implement this interface
+ * for each WSDL 2.0 component they extend. They must also <i>register</i> their
+ * extension implementations using the <code>ExtensionRegistry</code>. 
+ * Implementors may <i>optionally</i> extend this interface to add their own extension-specific 
+ * property accessor methods to the generic accessor methods declared by this interface.
+ * For examples of this, see the SOAP and HTTP binding extensions provided by Woden.
+ * <p>
+ * To document extensions consistently, implementors should copy the following Javadoc 
+ * fragment to use for their implementation classes or for their sub-interfaces of this
+ * interface, replacing the square bracket parts [...] accordingly.
+ * <p>
+ * <i>start of fragment:</i>
+ * <p>
+ * Provides access to the extension properties of the [parent component name] component 
+ * that are in the <code>[extension namespace]</code> namespace.
+ * These extension properties can be accessed as <code>ExtensionProperty</code> objects 
+ * via the <code>getProperties</code> and <code>getProperty</code> methods  
+ * using the property names and Java types shown in the following table.
+ * <p>
+ * <table border="1">
+ * <tr>
+ * <th>Property name</th>
+ * <th>Java type</th>
+ * </tr>
+ * <tr>
+ * <td>[property name]</td>
+ * <td>[java type]</td>
+ * </tr>
+ * <tr>
+ * <td>...</td>
+ * <td>...</td>
+ * </tr>
+ * </table>
+ * <p>
+ * <i>end of fragment:</i>
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ * 
+ * @see org.apache.woden.wsdl20.extensions.ExtensionProperty
+ */
+public interface ComponentExtensionContext {
+
+    public WSDLComponent getParent();
+    
+    public URI getNamespace();
+
+    public ExtensionProperty[] getProperties();
+    
+    public ExtensionProperty getProperty(String propertyName);
+}

Propchange: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ComponentExtensionContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ExtensionProperty.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ExtensionProperty.java?rev=618181&view=auto
==============================================================================
--- webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ExtensionProperty.java (added)
+++ webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ExtensionProperty.java Sun Feb  3 23:08:24 2008
@@ -0,0 +1,59 @@
+/**
+ * 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.wsdl20.extensions;
+
+import java.net.URI;
+
+/**
+ * Represents a WSDL 2.0 component extension property. That is, a property derived from WSDL 2.0 
+ * extension elements or attributes. This is a generic representation of an extension property 
+ * that simply provides the property's name and namespace and its content as a 
+ * <code>java.lang.Object</code>.
+ * The caller must know what to do with this <i>content</i> Object. 
+ * For example, what Java type to cast it to or whether it provides a useful 
+ * <code>toString()</code> implementation.
+ * <p>
+ * WSDL 2.0 extensions should be defined by their own specification, which may include this type 
+ * of information.
+ * Implementors of WSDL 2.0 extensions in Woden should also specify the names and Java types of 
+ * their extension properties using Javadoc comments in their implementations of the 
+ * <code>ComponentExtensionContext</code> interface. 
+ * For examples, see the SOAP and HTTP binding extensions provided by Woden.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ *
+ * @see org.apache.woden.wsdl20.extensions.ComponentExtensionContext
+ * 
+ */
+public interface ExtensionProperty {
+    
+    /**
+     * Returns a String representing the name of the extension property.
+     */
+    public String getName();
+    
+    /**
+     * Returns a URI representing the namespace the extension property belongs to.
+     */
+    public URI getNamespace();
+    
+    /**
+     * Returns the content of the extension property as a <code>java.lang.Object</code>.
+     */
+    public Object getContent();
+
+}

Propchange: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/ExtensionProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/GenericExtensionProperty.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/GenericExtensionProperty.java?rev=618181&view=auto
==============================================================================
--- webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/GenericExtensionProperty.java (added)
+++ webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/GenericExtensionProperty.java Sun Feb  3 23:08:24 2008
@@ -0,0 +1,87 @@
+/**
+ * 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.wsdl20.extensions;
+
+import java.net.URI;
+
+/**
+ * This class implements the ExtensionProperty interface to provide a 
+ * generic representation of a component extension property. 
+ * <p>
+ * This class may be used by implementors of WSDL 2.0 extensions when implementing the
+ * ExtensionProperty accessor methods of the ComponentExtensionContext interface.
+ * For example, when they extend the abstract class BaseComponentExtensionContext,
+ * which partially implements the ComponentExtensionContext interface.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ * 
+ * @see org.apache.woden.wsdl20.extensions.ComponentExtensionContext
+ * @see org.apache.woden.wsdl20.extensions.BaseComponentExtensionContext
+ *
+ */
+public class GenericExtensionProperty implements ExtensionProperty {
+    private String fName;
+    private URI fNamespace;
+    private Object fContent;
+    
+    /**
+     * This public constructor stores the extension property's name, namespace and
+     * content. The name and namespace parameters must not be null.
+     * 
+     * @param name the String name of the extension property
+     * @param namespace the namespace URI of the extension property
+     * @param content an Object representing the content of the extension property
+     * 
+     * @throws NullPointerException if the name or namespace parameter is null
+     */
+    public GenericExtensionProperty(String name, 
+            URI namespace, 
+            Object content) {
+        
+        if(name == null) {
+            throw new NullPointerException("name=null");
+        } 
+        if(namespace == null) {
+            throw new NullPointerException("namespace=null");
+        }
+        fName = name;
+        fNamespace = namespace;
+        fContent = content;
+    }
+    
+    /**
+     * @see org.apache.woden.wsdl20.extensions.ExtensionProperty#getName()
+     */
+    public String getName() {
+        return fName;
+    }
+
+    /**
+     * @see org.apache.woden.wsdl20.extensions.ExtensionProperty#getNamespace()
+     */
+    public URI getNamespace() {
+        return fNamespace;
+    }
+
+    /**
+     * @see org.apache.woden.wsdl20.extensions.ExtensionProperty#getContent()
+     */
+    public Object getContent() {
+        return fContent;
+    }
+
+}

Propchange: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/GenericExtensionProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/PropertyExtensible.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/PropertyExtensible.java?rev=618181&view=auto
==============================================================================
--- webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/PropertyExtensible.java (added)
+++ webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/PropertyExtensible.java Sun Feb  3 23:08:24 2008
@@ -0,0 +1,56 @@
+/**
+ * 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.wsdl20.extensions;
+
+import java.net.URI;
+
+/**
+ * Defines behaviour for accessing the extension properties 
+ * attached to WSDL 2.0 components.
+ * To be extended by each WSDL 2.0 component interface.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public interface PropertyExtensible {
+    
+    /**
+     * Returns all of the component's extension properties. These may span multiple namespaces.
+     */
+    public ExtensionProperty[] getExtensionProperties();
+
+    /**
+     * Returns the component's extension properties from a particular namespace.
+     * 
+     * @param namespace URI representing the namespace of the required extension properties
+     * @return extension properties from the specified namespace 
+     */
+    public ExtensionProperty[] getExtensionProperties(URI namespace);
+    
+    /**
+     * Returns the component's named extension property from the specified namespace.
+     * Within the WSDL 2.0-defined extensions, the extension property name itself
+     * is unique, but it is possible that property name collisions could occur across
+     * different user-defined extensions, so the extension namespace is used with
+     * property name to ensure uniqueness.
+     * 
+     * @param namespace the namespace of the named extension property
+     * @param name the name of the required extension property
+     * @return the named extension property
+     */
+    public ExtensionProperty getExtensionProperty(URI namespace, String name);
+    
+}

Propchange: webservices/woden/branches/woden47/src/org/apache/woden/wsdl20/extensions/PropertyExtensible.java
------------------------------------------------------------------------------
    svn:eol-style = native



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