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 2006/01/18 16:18:52 UTC
svn commit: r370167 - in /incubator/woden/java/src/org/apache/woden:
internal/Messages.properties
internal/wsdl20/extensions/PopulatedExtensionRegistry.java
wsdl20/extensions/ExtensionRegistry.java xml/UnknownAttr.java
Author: jkaputin
Date: Wed Jan 18 07:18:39 2006
New Revision: 370167
URL: http://svn.apache.org/viewcvs?rev=370167&view=rev
Log:
Added support for unregistered extension attributes.
If an unregistered ext attr is encountered, the Java type
UnknownAttr will be used to map the attribute (it treats
the attribute value as a string). There is also the
option to register a different class to be used as the
default mapping type for unregistered ext attributes.
Also modifed to the text for msg WSDL010 to reflect this
new behaviour.
Added:
incubator/woden/java/src/org/apache/woden/xml/UnknownAttr.java
Modified:
incubator/woden/java/src/org/apache/woden/internal/Messages.properties
incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java
incubator/woden/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java
Modified: incubator/woden/java/src/org/apache/woden/internal/Messages.properties
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/Messages.properties?rev=370167&r1=370166&r2=370167&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/Messages.properties (original)
+++ incubator/woden/java/src/org/apache/woden/internal/Messages.properties Wed Jan 18 07:18:39 2006
@@ -43,7 +43,7 @@
WSDL007=The property name must not be null when attempting to get or set a named property.
WSDL008=The property name "{0}" is not recognized.
WSDL009=Could not instantiate the "{0}" class.
-WSDL010=No Java class was registered for the extension attribute "{0}" in the context of "{1}".
+WSDL010=The extension attribute "{0}" in the context of "{1}" does not have a Java class registered, so it will map to "{2}" by default.
WSDL011=The Java class "{0}" does not implement the "Attr" interface.
WSDL012=No Java type was registered for the extension element "{0}" in the context of "{1}".
WSDL013=The Java class "{0}" does not implement the "ExtensionElement" interface.
Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java?rev=370167&r1=370166&r2=370167&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/PopulatedExtensionRegistry.java Wed Jan 18 07:18:39 2006
@@ -39,14 +39,21 @@
* This class was copied from WSDL4J and modified for Woden.
*
* @author Matthew J. Duftler (duftler@us.ibm.com)
- * @author jkaputin@apache.org
+ * @author jkaputin@apache.org (Woden changes)
*/
public class PopulatedExtensionRegistry extends ExtensionRegistry
{
public PopulatedExtensionRegistry()
{
- //SOAP extension attributes
+ // Register a default Java type for unregistered extension attributes
+
+ /* Uncomment this code if a default other than UnknownAttr is required.
+ registerExtAttributeType(
+ WSDLElement.class, new QName("http://ws.apache.org/woden", "DefaultAttr"), StringAttrImpl.class);
+ */
+
+ //------------ SOAP extension attributes ------------
registerExtAttributeType(
BindingElement.class, SOAPConstants.Q_ATTR_SOAP_VERSION, StringAttrImpl.class);
@@ -70,7 +77,7 @@
registerExtAttributeType(
BindingOperationElement.class, SOAPConstants.Q_ATTR_SOAP_ACTION, URIAttrImpl.class);
- //SOAPModule extension elements
+ //------------ SOAPModule extension elements ------------
SOAPModuleDeserializer soapModuleDeser = new SOAPModuleDeserializer();
@@ -84,7 +91,7 @@
SOAPConstants.Q_ELEM_SOAP_MODULE,
SOAPModuleImpl.class);
- //SOAPHeaderBlock extension elements
+ //------------ SOAPHeaderBlock extension elements ------------
SOAPHeaderBlockDeserializer soapHeaderBlockDeser = new SOAPHeaderBlockDeserializer();
Modified: incubator/woden/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java?rev=370167&r1=370166&r2=370167&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java (original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java Wed Jan 18 07:18:39 2006
@@ -23,6 +23,8 @@
import org.apache.woden.ErrorReporter;
import org.apache.woden.WSDLException;
+import org.apache.woden.wsdl20.xml.WSDLElement;
+import org.apache.woden.xml.UnknownAttr;
import org.apache.woden.xml.XMLAttr;
/**
@@ -532,8 +534,18 @@
if (implClass == null)
{
- //TODO capture the attr in an 'UnknownAttr' object instead of just reporting the
- //error and returning null.
+ /*
+ * Implementations MAY register a default class to handle unknown extension attributes,
+ * which will be retrieved here from the Extension Registry. For example, the
+ * StringAttr implementation class may be registered as the default.
+ *
+ * TODO TBC, then add this info to javadoc and user docs. See sample code in PopulatedExtReg.
+ */
+ implClass = queryExtAttributeType(WSDLElement.class,
+ new QName("http://ws.apache.org/woden", "DefaultAttr"));
+
+ //If no default Java class is registered, use the UnknownAttr class.
+ if(implClass == null) implClass = UnknownAttr.class;
/* TODO the following line was replaced by null in the reportError call below
* to avoid an API build problem for Milestone 2. This must be fixed, post-M2.
@@ -541,14 +553,13 @@
*
* new ErrorLocatorImpl(), //TODO line/col nos.
*/
-
getErrorReporter().reportError(
null, //see comment above
"WSDL010",
- new Object[] {attrQName.toString(), ownerClass.getName()},
- ErrorReporter.SEVERITY_ERROR);
-
- return null;
+ new Object[] {attrQName.toString(),
+ ownerClass.getName(),
+ implClass.getName()},
+ ErrorReporter.SEVERITY_WARNING);
}
else if (!(XMLAttr.class.isAssignableFrom(implClass)))
{
Added: incubator/woden/java/src/org/apache/woden/xml/UnknownAttr.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/xml/UnknownAttr.java?rev=370167&view=auto
==============================================================================
--- incubator/woden/java/src/org/apache/woden/xml/UnknownAttr.java (added)
+++ incubator/woden/java/src/org/apache/woden/xml/UnknownAttr.java Wed Jan 18 07:18:39 2006
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2006 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.xml;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.w3c.dom.Element;
+
+/**
+ * This class represents extension attributes (those not in the WSDL namespace)
+ * that do not have a Java type registered in the Extension Registry.
+ * It treats the attribute's value as a string.
+ *
+ * @author jkaputin@apache.org
+ */
+public class UnknownAttr implements XMLAttr
+{
+ private Object fContent = null;
+ private String fExternalForm = null;
+ private boolean fValid = true;
+ private ErrorReporter fErrorReporter = null;
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.XMLAttr#setErrorReporter(org.apache.woden.ErrorReporter)
+ */
+ public void setErrorReporter(ErrorReporter errRpt) {
+ fErrorReporter = errRpt;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.XMLAttr#init(org.w3c.dom.Element, java.lang.String)
+ */
+ public void init(Element ownerEl, String attrValue) throws WSDLException {
+ fExternalForm = attrValue;
+ fContent = attrValue;
+ if(fContent == null) fValid = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.XMLAttr#getContent()
+ */
+ public Object getContent() {
+ return fContent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.XMLAttr#toExternalForm()
+ */
+ public String toExternalForm() {
+ return fExternalForm;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.woden.xml.XMLAttr#isValid()
+ */
+ public boolean isValid() {
+ return fValid;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org