You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/19 20:28:30 UTC
svn commit: r509308 - in
/incubator/tuscany/branches/sca-java-integration/sca:
kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/
services/databinding/databinding-jaxb/
services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/da...
Author: rfeng
Date: Mon Feb 19 11:28:29 2007
New Revision: 509308
URL: http://svn.apache.org/viewvc?view=rev&rev=509308
Log:
Add more parameters to ExceptionHandler.createException and implement the interface for JAXB
Added:
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java (with props)
Modified:
incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java
incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/pom.xml
Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java?view=diff&rev=509308&r1=509307&r2=509308
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java Mon Feb 19 11:28:29 2007
@@ -30,10 +30,13 @@
/**
* Create an exception to wrap the fault data
*
+ * @param exceptionType The DataType for the exception
+ * @param message The error message
* @param faultInfo The databinding-specific fault data
+ * @param cause The protocol-specific error
* @return An instance of java exception to represent the fault
*/
- Exception createException(Object faultInfo);
+ Exception createException(DataType<DataType<?>> exceptionType, String message, Object faultInfo, Throwable cause);
/**
* Retrieve the fault info from a java exception
Modified: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/pom.xml?view=diff&rev=509308&r1=509307&r2=509308
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/pom.xml (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/pom.xml Mon Feb 19 11:28:29 2007
@@ -65,6 +65,12 @@
<scope>compile</scope>
</dependency>
<dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ <version>2.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.0.4</version>
Added: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java?view=auto&rev=509308
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java Mon Feb 19 11:28:29 2007
@@ -0,0 +1,106 @@
+/*
+ * 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.tuscany.databinding.jaxb;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebFault;
+
+import org.apache.tuscany.spi.databinding.ExceptionHandler;
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * JAXB implementation of ExceptionHandler
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXBExceptionHandler implements ExceptionHandler {
+ private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
+
+ /**
+ * <ul>
+ * <li>WrapperException(String message, FaultBean faultInfo) <br>
+ * A constructor where WrapperException is replaced with the name of the
+ * generated wrapper exception and FaultBean is replaced by the name of the
+ * generated fault bean.
+ * <li> WrapperException(String message, FaultBean faultInfo, Throwable
+ * cause) <br>
+ * A constructor whereWrapperException is replaced with the name of the
+ * generated wrapper exception and FaultBean is replaced by the name of the
+ * generated fault bean. The last argument, cause, may be used to convey
+ * protocol specific fault information
+ * </ul>
+ */
+ public Exception createException(DataType<DataType<?>> exceptionType,
+ String message,
+ Object faultInfo,
+ Throwable cause) {
+ Class exceptionClass = (Class)exceptionType.getPhysical();
+ DataType<?> faultBeanType = exceptionType.getLogical();
+ Class faultBeanClass = (Class)faultBeanType.getPhysical();
+ try {
+ Constructor constructor =
+ exceptionClass.getConstructor(new Class[] {String.class, faultBeanClass, Throwable.class});
+ return (Exception)constructor.newInstance(new Object[] {message, faultInfo, cause});
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Object getFaultInfo(Exception exception) {
+ if (exception == null) {
+ return null;
+ }
+ try {
+ Method method = exception.getClass().getMethod("getFaultInfo", EMPTY_CLASS_ARRAY);
+ return method.invoke(exception, (Object[])null);
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public DataType<?> getFaultType(Class<? extends Exception> exceptionType) {
+ WebFault webFault = exceptionType.getAnnotation(WebFault.class);
+ if (webFault == null) {
+ return null;
+ } else {
+ QName element = new QName(webFault.targetNamespace(), webFault.name());
+ // TODO: Need to determine the fault bean class
+ // String faultBean = webFault.faultBean();
+ Class faultBeanClass = null;
+ try {
+ Method method = exceptionType.getMethod("getFaultInfo", EMPTY_CLASS_ARRAY);
+ faultBeanClass = method.getReturnType();
+ } catch (NoSuchMethodException e) {
+ faultBeanClass = null;
+ }
+ // The logical type of a fault is the QName of the element that the
+ // only part in
+ // the fault message references
+ DataType<QName> faultType = new DataType<QName>(faultBeanClass, element);
+ // The logical type of the exception type is the DataType of the
+ // fault bean
+ return new DataType<DataType<QName>>(exceptionType, faultType);
+ }
+ }
+
+}
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/branches/sca-java-integration/sca/services/databinding/databinding-jaxb/src/main/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org