axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r424001 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/ src/org/apache/axis2/jaxws/client/ src/org/apache/axis2/jaxws/core/controller/ src/org/apache/axis2/jaxws/description/ src/org/apache/axis2/jaxws/handler/...
Date Thu, 20 Jul 2006 17:43:49 GMT
Author: scheu
Date: Thu Jul 20 10:43:48 2006
New Revision: 424001

URL: http://svn.apache.org/viewvc?rev=424001&view=rev
Log:
AXIS2-905
ExceptionFactory for single point of exception construction and root cause processing.
Contributors: Samuel Isokpunwu & Rich Scheuerle

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Dispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/MessageException.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/AxisController.java Thu Jul 20 10:43:48 2006
@@ -170,7 +170,7 @@
         }catch(AxisFault e){
         	//TODO
         	String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
-            throw new WebServiceException(e.getMessage() + " " + todo);
+            throw ExceptionFactory.makeWebServiceException(e.getMessage() + " " + todo);
             
         }       
     }
@@ -198,7 +198,7 @@
         } catch(AxisFault e) {
         	
         	String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
-            throw new WebServiceException(e.getMessage() + " " + todo);
+            throw ExceptionFactory.makeWebServiceException(e.getMessage() + " " + todo);
         }
     }
     
@@ -258,10 +258,10 @@
                 getExecutor().submit(response).get();
             } catch (InterruptedException e) {
                 e.printStackTrace();
-                throw new WebServiceException(e.getMessage());
+                throw ExceptionFactory.makeWebServiceException(e.getMessage());
             } catch (ExecutionException e) {
                 e.printStackTrace();
-                throw new WebServiceException(e.getMessage());
+                throw ExceptionFactory.makeWebServiceException(e.getMessage());
             }
             
             //TODO: Need to figure out who/when the Listener should be shutdown
@@ -271,7 +271,7 @@
         }catch(AxisFault e){
         	
         	String todo = "Fault processing not supported for Alpha, we are only printing the fault node from soap fault.";
-            throw new WebServiceException(e.getMessage() + " " + todo);
+            throw ExceptionFactory.makeWebServiceException(e.getMessage() + " " + todo);
         }
     }
     
@@ -382,4 +382,4 @@
             serviceClient.getOptions().setProperty(key, value);
         }
     }
-}
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ClientMediator.java Thu Jul 20 10:43:48 2006
@@ -51,7 +51,7 @@
     public <T> JAXBDispatch<T> createJAXBDispatch(JAXWSClientContext<T> clientContext){
 
         if (clientContext == null) {
-            throw new WebServiceException(
+            throw ExceptionFactory.makeWebServiceException(
                     "Internal Error ... JAXWSClientContext not found");
         }
         this.clientContext = clientContext;
@@ -69,14 +69,14 @@
             dispatch.setJAXBContext(clientContext.getJAXBContext());
             return dispatch;
         }catch(AxisFault e){
-            throw new WebServiceException(e.getMessage());
+            throw ExceptionFactory.makeWebServiceException(e.getMessage());
         }
     }
     
     public <T> XMLDispatch<T> createXMLDispatch(JAXWSClientContext<T> clientContext){
 
 		if (clientContext == null) {
-			throw new WebServiceException(
+			throw ExceptionFactory.makeWebServiceException(
 					"Internal Error ... JAXWSClientContext not found");
 		}
 		this.clientContext = clientContext;
@@ -92,7 +92,7 @@
             dispatch.setMode(clientContext.getServiceMode());
 			return dispatch;
 		}catch(AxisFault e){
-			throw new WebServiceException(e.getMessage());
+			throw ExceptionFactory.makeWebServiceException(e);
 		}
 	}
 
@@ -115,7 +115,7 @@
 	    	
 	    	return sei.cast(proxyClass);
 		}catch(AxisFault e){
-    		throw new WebServiceException(e.getMessage());
+    		throw ExceptionFactory.makeWebServiceException(e);
     	}
 		
 	}
@@ -126,7 +126,7 @@
             ConfigurationContext configCtx = factory.getClientConfigurationContext();
             return configCtx;
 		} catch (Exception e) {
-			throw new WebServiceException(e);
+			throw ExceptionFactory.makeWebServiceException(e);
 		}
 	}
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Dispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Dispatch.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Dispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Dispatch.java Thu Jul 20 10:43:48 2006
@@ -151,7 +151,7 @@
                 p.setJAXBContext(jaxbContext);
             }
         } catch (Exception e) {
-            throw new WebServiceException(e);
+            throw ExceptionFactory.makeWebServiceException(e);
         }
         
         rspParam = fromOM(rspEnvelope, rspParam, axisController.getServiceClient().getOptions().getSoapVersionURI());
@@ -161,37 +161,39 @@
     
    public void invokeOneWay(Object obj) throws WebServiceException{
        if(obj == null){
-            throw new WebServiceException("Dispatch Cannot Invoke SEI with null object");
+    	   // TODO NLS
+           throw ExceptionFactory.makeWebServiceException("Dispatch Cannot Invoke SEI with null object");
         }
         try{
             Parameter param = ParameterFactory.createParameter(obj);
             axisController.invokeOneWay(param, requestContext);
         }catch(Exception e){
-            throw new WebServiceException(e);
+            throw ExceptionFactory.makeWebServiceException(e);
         }
     }
    
     public Future<?> invokeAsync(Object obj, AsyncHandler asynchandler) throws WebServiceException {
        if(obj == null){
-           throw new WebServiceException("Dispatch Cannot Invoke SEI with null object");
+           throw ExceptionFactory.makeWebServiceException("Dispatch Cannot Invoke SEI with null object");
        }
        try{
            Parameter param = ParameterFactory.createParameter(obj);
            return axisController.invokeAsync(param, asynchandler, requestContext);
        } catch(Exception e) {
-           throw new WebServiceException(e);
+           throw ExceptionFactory.makeWebServiceException(e);
        }
     }
   
     public Response invokeAsync(Object obj)throws WebServiceException{
         if(obj == null){
-            throw new WebServiceException("Dispatch Cannot Invoke SEI with null object");
+        	// TODO NLS
+            throw ExceptionFactory.makeWebServiceException("Dispatch Cannot Invoke SEI with null object");
         }
         try{
             Parameter param = ParameterFactory.createParameter(obj);
             return axisController.invokeAsync(param, requestContext);
         }catch(Exception e){
-            throw new WebServiceException(e);
+            throw ExceptionFactory.makeWebServiceException(e);
         }
     }    
 

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java?rev=424001&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/ExceptionFactory.java Thu Jul 20 10:43:48 2006
@@ -0,0 +1,344 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.axis2.jaxws;
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.xml.ws.ProtocolException;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.http.HTTPException;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.MessageInternalException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+  * ExceptionFactory is used to create exceptions within the JAX-WS implementation.
+  * There are several reasons for using a factory to create exceptions.
+  *    1. We can intercept all exception creation and add the appropriate logging/serviceability.
+  *    2. Exceptions are chained.  ExceptionFactory can lengthen or reduce the cause chains as
+  *       necessary to support the JAX-WS programming model.
+  *    3. Prevents construction of the same exception.  Uses similar principles as AxisFault.makeException.
+  *   
+  * Example Usage:
+  *          // Example usage
+  *          
+  *          public fooMethod() throws WebServiceException {
+  *             try{
+  *                ...
+  *             }
+  *             catch(Exception e){
+  *                throw ExceptionFactory.makeWebServiceException(e);
+  *             }
+  *          }
+  *     
+  *    
+  */
+public class ExceptionFactory {
+	
+	 protected static Log log =
+	        LogFactory.getLog(ExceptionFactory.class.getName());
+	
+	/**
+	 * Private Constructor
+	 * All methods are static.  The private constructor prevents instantiation.
+	 */
+	private ExceptionFactory() {
+	}
+	
+	/**
+	 * Create a WebServiceException using the information from a given Throwable instance
+	 * and message
+	 * @param message
+	 * @param throwable
+	 * @return WebServiceException
+	 */
+	public static WebServiceException makeWebServiceException(String message, Throwable throwable) {
+		try {
+			// See if there is already a WebServiceException (Note that the returned exception could be a ProtocolException or
+			// other kind of exception)
+			WebServiceException e = (WebServiceException) findException(throwable, WebServiceException.class);
+			if (e == null) {
+				e = createWebServiceException(message, throwable);
+			}
+			return e;
+		} catch (RuntimeException re) {
+			// TODO 
+			// This is not a good situation, an exception occurred while building the exception.
+			// This should never occur!  For now log the problem and rethrow...we may revisit this later
+			if (log.isDebugEnabled()) {
+				log.debug("Exception occurred while creating exception", re);
+			}
+			throw re;
+		}
+	}
+	
+	/**
+	 * Create a ProtocolException using the information from a Throwable and message
+	 * @param message
+	 * @param throwable
+	 * @return ProtocolException
+	 */
+	public static ProtocolException makeProtocolException(String message, Throwable throwable) {
+		try {
+			// See if there is already a ProtocolException 
+			ProtocolException e = (ProtocolException) findException(throwable, ProtocolException.class);
+			if (e == null) {
+				e = createProtocolException(message, throwable);
+			}
+			return e;
+		} catch (RuntimeException re) {
+			// TODO 
+			// This is not a good situation, an exception occurred while building the exception.
+			// This should never occur!  For now log the problem and rethrow...we may revisit this later
+			if (log.isDebugEnabled()) {
+				log.debug("Exception occurred while creating exception", re);
+			}
+			throw re;
+		}
+	}
+	
+	/**
+	 * Create a MessageException using the information from a Throwable and message
+	 * @param message
+	 * @param throwable
+	 * @return MessageException
+	 */
+	public static MessageException makeMessageException(String message, Throwable throwable) {
+		try {
+			// See if there is already a MessgeException 
+			MessageException e = (MessageException) findException(throwable, MessageException.class);
+			if (e == null) {
+				e = createMessageException(message, throwable);
+			}
+			return e;
+		} catch (RuntimeException re) {
+			// TODO 
+			// This is not a good situation, an exception occurred while building the exception.
+			// This should never occur!  For now log the problem and rethrow...we may revisit this later
+			if (log.isDebugEnabled()) {
+				log.debug("Exception occurred while creating exception", re);
+			}
+			throw re;
+		}
+	}
+	
+	/**
+	 * Create a MessageInternalException using the information from a Throwable and message
+	 * @param message
+	 * @param throwable
+	 * @return MessageInternalException
+	 */
+	public static MessageInternalException makeMessageInternalException(String message, Throwable throwable) {
+		try {
+			// See if there is already a HTTPException 
+			MessageInternalException e = (MessageInternalException) findException(throwable, MessageInternalException.class);
+			if (e == null) {
+				e = createMessageInternalException(message, throwable);
+			}
+			return e;
+		} catch (RuntimeException re) {
+			// TODO 
+			// This is not a good situation, an exception occurred while building the exception.
+			// This should never occur!  For now log the problem and rethrow...we may revisit this later
+			if (log.isDebugEnabled()) {
+				log.debug("Exception occurred while creating exception", re);
+			}
+			throw re;
+		}
+	}
+	
+	/**
+	 * Make a WebServiceException with a given message
+	 * @param message
+	 * @return WebServiceException
+	 */
+	public static WebServiceException makeWebServiceException(String message) {
+		return makeWebServiceException(message, null);  
+	}
+	
+	/**
+	 * Create a WebServiceException using the information from a given Throwable instance
+	 * @param throwable
+	 * @return WebServiceException
+	 */
+	public static WebServiceException makeWebServiceException(Throwable throwable){
+		return makeWebServiceException(null, throwable);
+	}
+	
+	/**
+	 * Create a MessageException using the information from a given Throwable instance
+	 * @param throwable
+	 * @return MessageException
+	 */
+	public static MessageException makeMessageException(Throwable throwable){
+		return makeMessageException(null, throwable);
+	}
+	
+	/**
+	 * Make a MessageException with a given message
+	 * @param message
+	 * @return MessageException
+	 */
+	public static MessageException makeMessageException(String message) {
+		return makeMessageException(message, null);  
+	}
+	
+	/**
+	 * Create a WebServiceException
+	 * @param message
+	 * @param t Throwable
+	 * @return WebServiceException
+	 */
+	private static WebServiceException createWebServiceException(String message, Throwable t) {
+		Throwable rootCause = null;
+		if (t != null) {
+			rootCause = getRootCause(t);
+		}
+		WebServiceException e = new WebServiceException(message, t);
+		if (log.isDebugEnabled()) {
+			log.debug("Create Exception:", e);
+		}
+		return e;
+	}
+	
+	/**
+	 * Create a ProtocolException
+	 * @param message
+	 * @param t Throwable
+	 * @return ProtocolException
+	 */
+	private static ProtocolException createProtocolException(String message, Throwable t) {
+		Throwable rootCause = null;
+		if (t != null) {
+			rootCause = getRootCause(t);
+		}
+		ProtocolException e = new ProtocolException(message, t);
+		if (log.isDebugEnabled()) {
+			log.debug("create Exception:", t);
+		}
+		return e;
+	}
+	
+	/**
+	 * Create a MessageException
+	 * @param message
+	 * @param t Throwable
+	 * @return MessageException
+	 */
+	private static MessageException createMessageException(String message, Throwable t) {
+		Throwable rootCause = null;
+		if (t != null) {
+			rootCause = getRootCause(t);
+		}
+		MessageException e = new MessageException(message, t);
+		if (log.isDebugEnabled()) {
+			log.debug("create Exception:", t);
+		}
+		return e;
+	}
+	
+	/**
+	 * Create a MessageInternalException
+	 * @param message
+	 * @param t Throwable
+	 * @return MessageException
+	 */
+	private static MessageInternalException createMessageInternalException(String message, Throwable t) {
+		Throwable rootCause = null;
+		if (t != null) {
+			rootCause = getRootCause(t);
+		}
+		MessageInternalException e = new MessageInternalException(message, t);
+		if (log.isDebugEnabled()) {
+			log.debug("create Exception:", t);
+		}
+		return e;
+	}
+	
+    /**
+     * Return the exception or nested cause that is assignable from the specified class
+     * @param t Throwable
+     * @param cls
+     * @return Exception or null
+     */
+    private static Exception findException(Throwable t, Class cls) {
+    	while(t != null) {
+    		if (cls.isAssignableFrom(t.getClass())) {
+                return (Exception) t;
+    		}
+    		t = getCause(t);
+    	}
+    	return null;
+    }
+    
+    /**
+     * Gets the Throwable cause of the Exception.  Some exceptions
+     * store the cause in a different field, which is why this method
+     * should be used when walking the causes.
+     * @param t Throwable
+     * @return Throwable or null
+     */
+    private static Throwable getCause(Throwable t) {
+    	Throwable cause = null;
+    	
+    	// Look for a specific cause for this kind of exception
+    	if (t instanceof InvocationTargetException) {
+    		cause = ((InvocationTargetException) t).getTargetException();
+    	}
+    	
+    	// If no specific cause, fall back to the general cause.
+    	if (cause == null) {
+    		cause = t.getCause();
+    	}
+    	return null;
+    }
+    
+    /**
+     * This method searches the causes of the specified throwable
+     * until it finds one that is acceptable as a "root" cause. 
+     * 
+     * Example: If t is an AxisFault, the code traverses to the next cause.
+     * 
+     * @param t Throwable
+     * @return Throwable root cause
+     */
+    private static Throwable getRootCause(Throwable t) {
+    	while (t != null) {
+    		Throwable nextCause = null;
+    		if (t instanceof InvocationTargetException ||
+    		    t instanceof AxisFault) {
+    			// Skip over this cause
+    			nextCause = getCause(t);
+    			if (nextCause == null) {
+    				return t;
+    			}
+    			t = nextCause;
+    		} else {
+    			// This is the root cause
+    			return t;
+    		}
+    	}
+    	return t;
+    }
+
+}
+

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java Thu Jul 20 10:43:48 2006
@@ -30,6 +30,7 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.jaxws.AxisController;
 import org.apache.axis2.jaxws.BindingProvider;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.InvocationContextFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
@@ -212,7 +213,7 @@
             Parameter param = ParameterFactory.createParameter(obj);
             return axisController.invokeAsync(param, requestContext);
         }catch(Exception e){
-            throw new WebServiceException(e);
+            throw ExceptionFactory.makeWebServiceException(e);
         }
     }
     
@@ -281,4 +282,4 @@
         response.fromEnvelope(mode, env);
         return response;
     }
-}
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Thu Jul 20 10:43:48 2006
@@ -32,6 +32,7 @@
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.jaxws.AxisCallback;
 import org.apache.axis2.jaxws.BindingProvider;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.impl.AsyncListenerWrapper;
@@ -86,10 +87,10 @@
         // Check to make sure we at least have a valid InvocationContext
         // and request MessageContext
         if (ic == null) {
-            throw new WebServiceException("Cannot invoke; InvocationContext was null");
+            throw ExceptionFactory.makeWebServiceException("Cannot invoke; InvocationContext was null");
         }
         if (ic.getRequestMessageContext() == null) {
-            throw new WebServiceException("Cannot invoke; request MessageContext was null");
+            throw ExceptionFactory.makeWebServiceException("Cannot invoke; request MessageContext was null");
         }
         
         // Setup the MessageContext for the response
@@ -115,7 +116,7 @@
                 OMElement reqEnvelope = requestMsgCtx.getMessageAsOM();
                 rspEnvelope = client.sendReceive(ServiceClient.ANON_OUT_IN_OP, reqEnvelope);
             } catch (AxisFault e) {
-                throw new WebServiceException(e);
+                throw ExceptionFactory.makeWebServiceException(e);
             }
             
             // Set the response message on the response MessageContext
@@ -141,10 +142,10 @@
         // Check to make sure we at least have a valid InvocationContext
         // and request MessageContext
         if (ic == null) {
-            throw new WebServiceException("Cannot invoke; InvocationContext was null");
+            throw ExceptionFactory.makeWebServiceException("Cannot invoke; InvocationContext was null");
         }
         if (ic.getRequestMessageContext() == null) {
-            throw new WebServiceException("Cannot invoke; request MessageContext was null");
+            throw ExceptionFactory.makeWebServiceException("Cannot invoke; request MessageContext was null");
         }
         
         // Setup the MessageContext for the response
@@ -173,7 +174,7 @@
                 OMElement reqEnvelope = requestMsgCtx.getMessageAsOM();
                 client.fireAndForget(ServiceClient.ANON_OUT_ONLY_OP, reqEnvelope);
             } catch (AxisFault e) {
-                throw new WebServiceException(e);
+                throw ExceptionFactory.makeWebServiceException(e);
             }
         }
         
@@ -198,10 +199,10 @@
         // Check to make sure we at least have a valid InvocationContext
         // and request MessageContext
         if (ic == null) {
-            throw new WebServiceException("Cannot invoke; InvocationContext was null");
+            throw ExceptionFactory.makeWebServiceException("Cannot invoke; InvocationContext was null");
         }
         if (ic.getRequestMessageContext() == null) {
-            throw new WebServiceException("Cannot invoke; request MessageContext was null");
+            throw ExceptionFactory.makeWebServiceException("Cannot invoke; request MessageContext was null");
         }
         
         // Setup the MessageContext for the response
@@ -253,7 +254,7 @@
                 wrapper.setAsyncHandler(callback);
             }
             else {
-                throw new WebServiceException("Cannot call asynchronous invoke with null callback");
+                throw ExceptionFactory.makeWebServiceException("Cannot call asynchronous invoke with null callback");
             }
             
             // Get the request message from the MessageContext and send it
@@ -263,7 +264,7 @@
                 client.sendReceiveNonBlocking(ServiceClient.ANON_OUT_IN_OP, reqEnvelope, axisCallback);
             } catch (AxisFault e) {
                 e.printStackTrace();
-                throw new WebServiceException(e);
+                throw ExceptionFactory.makeWebServiceException(e);
             }
             
             // Now that the request has been sent, start the listener thread so that it can
@@ -281,10 +282,10 @@
                 future.get();
             } catch (InterruptedException e) {
                 e.printStackTrace();
-                throw new WebServiceException(e.getMessage());
+                throw ExceptionFactory.makeWebServiceException(e.getMessage());
             } catch (ExecutionException e) {
                 e.printStackTrace();
-                throw new WebServiceException(e.getMessage());
+                throw ExceptionFactory.makeWebServiceException(e.getMessage());
             }
             
             return wrapper;
@@ -325,7 +326,7 @@
             AxisOperation operation = service.getOperation(new QName(operationName));
             
             if (operation == null) {
-                throw new WebServiceException("Operation not found.");
+                throw ExceptionFactory.makeWebServiceException("Operation not found.");
             }
             
             try {
@@ -338,7 +339,7 @@
             }            
         }
         else {
-            throw new WebServiceException("Operation name not set.");
+            throw ExceptionFactory.makeWebServiceException("Operation name not set.");
         }
         
         return client;
@@ -353,4 +354,4 @@
         
         return null;
     }
-}
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java Thu Jul 20 10:43:48 2006
@@ -36,6 +36,7 @@
 import org.apache.axis2.description.RobustOutOnlyAxisOperation;
 import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
 import org.apache.axis2.engine.AbstractDispatcher;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.util.WSDL4JWrapper;
 import org.apache.axis2.jaxws.util.WSDLWrapper;
 import org.apache.commons.logging.Log;
@@ -107,13 +108,16 @@
      */
     public ServiceDescription(URL wsdlURL, QName serviceQName, Class serviceClass) {
         if (serviceQName == null) {
-            throw new WebServiceException("Invalid Service QName; cannot be null");
+        	// TODO NLS
+            throw ExceptionFactory.makeWebServiceException("Invalid Service QName; cannot be null");
         }
         if (serviceClass == null) {
-            throw new WebServiceException("Invalid Service Class; cannot be null");
+        	// TODO NLS
+            throw ExceptionFactory.makeWebServiceException("Invalid Service Class; cannot be null");
         }
         if (!javax.xml.ws.Service.class.isAssignableFrom(serviceClass)) {
-            throw new WebServiceException("Invalid Service Class; must be assignable to javax.xml.ws.Service");
+        	// TODO NLS
+            throw ExceptionFactory.makeWebServiceException("Invalid Service Class; must be assignable to javax.xml.ws.Service");
         }
         
         this.wsdlURL = wsdlURL;
@@ -148,9 +152,9 @@
             try {
                 wsdlWrapper = new WSDL4JWrapper(this.wsdlURL);
             } catch (WSDLException e) {
-                // TODO Auto-generated catch block
+                // TODO NLS
                 e.printStackTrace();
-                throw new WebServiceException("caught WSDL Exception" + e.getMessage());
+                throw ExceptionFactory.makeWebServiceException("caught WSDL Exception" + e.getMessage());
             }
         }
     }
@@ -172,7 +176,7 @@
         try {
             axisService = serviceBuilder.populateService();
         } catch (AxisFault e) {
-            // TODO Auto-generated catch block
+            // TODO NLS
             log.warn("ServiceDescription: Caught exception creating AxisService", e);
         }
     }
@@ -209,7 +213,8 @@
         Definition definition = wsdlWrapper.getDefinition();
         Service service = definition.getService(serviceQName);
         if (service == null) {
-            throw new WebServiceException("Service QName not found in WSDL");
+        	// TODO NLS
+            throw ExceptionFactory.makeWebServiceException("Service QName not found in WSDL");
         }
         
         Map ports = service.getPorts();

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java Thu Jul 20 10:43:48 2006
@@ -11,6 +11,8 @@
 import javax.xml.ws.handler.soap.SOAPHandler;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
 
+import org.apache.axis2.jaxws.ExceptionFactory;
+
 
 public class HandlerChainProcessor {
 
@@ -66,7 +68,7 @@
 			if (LogicalHandler.class.isAssignableFrom(handlerClass.getClass())) {
 				if (protocolHandlersStarted)
 					// TODO: NLS better error message
-					throw new WebServiceException("All logical handlers must come before all protocol handlers");
+					throw ExceptionFactory.makeWebServiceException("All logical handlers must come before all protocol handlers");
 				else {
 					logicalLength++;
 				}
@@ -75,10 +77,10 @@
 				protocolHandlersStarted = true;
 			else if (Handler.class.isAssignableFrom(handlerClass.getClass())) {
 				// TODO: NLS better error message
-				throw new WebServiceException("cannot implement Handler directly");
+				throw ExceptionFactory.makeWebServiceException("cannot implement Handler directly");
 			} else {
 				// TODO: NLS better error message
-				throw new WebServiceException("Some error");
+				throw ExceptionFactory.makeWebServiceException("Some error");
 			}
 
 		}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerResolverImpl.java Thu Jul 20 10:43:48 2006
@@ -10,6 +10,7 @@
 import javax.xml.ws.handler.PortInfo;
 import javax.xml.ws.handler.soap.SOAPHandler;
 
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.spi.ServiceDelegate;
 
@@ -78,15 +79,15 @@
 			} catch (ClassNotFoundException e) {
 				// TODO: should we just ignore this problem?
 				// TODO: NLS log and throw
-				throw new WebServiceException(e);
+				throw ExceptionFactory.makeWebServiceException(e);
 			} catch (InstantiationException ie) {
 				// TODO: should we just ignore this problem?
 				// TODO: NLS log and throw
-				throw new WebServiceException(ie);
+				throw ExceptionFactory.makeWebServiceException(ie);
 			} catch (IllegalAccessException e) {
 				// TODO: should we just ignore this problem?
 				// TODO: NLS log and throw
-				throw new WebServiceException(e);
+				throw ExceptionFactory.makeWebServiceException(e);
 			}
 			
 			// 9.2.1.2 sort them by Logical, then SOAP
@@ -97,10 +98,10 @@
 				protocolHandlers.add((SOAPHandler)handlerClass);
 			else if (Handler.class.isAssignableFrom(handlerClass.getClass())) {
 				// TODO: NLS better error message
-				throw new WebServiceException("cannot implement Handler directly");
+				throw ExceptionFactory.makeWebServiceException("cannot implement Handler directly");
 			} else {
 				// TODO: NLS better error message
-				throw new WebServiceException("Some error");
+				throw ExceptionFactory.makeWebServiceException("Some error");
 			}
 		}
 		

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/MessageException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/MessageException.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/MessageException.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/MessageException.java Thu Jul 20 10:43:48 2006
@@ -25,7 +25,7 @@
  * (@see org.apache.axis2.jaxws.message.MessageInternalException)
  */
 public class MessageException extends Exception {
-
+	 
 	/**
 	 * @param message
 	 */

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/JAXBBlockImpl.java Thu Jul 20 10:43:48 2006
@@ -32,6 +32,7 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.databinding.JAXBBlock;
 import org.apache.axis2.jaxws.message.factory.BlockFactory;
@@ -84,7 +85,7 @@
 			setQName(getQName(jaxb, jc));
 			return jaxb;
 		} catch(JAXBException je) {
-			throw new MessageException(je);
+			throw ExceptionFactory.makeMessageException(je);
 		}
 	}
 
@@ -121,7 +122,7 @@
 			m.marshal(busObject, writer);
 		} catch(JAXBException je) {
 			// TODO NLS
-			throw new MessageException(je);
+			throw ExceptionFactory.makeMessageException(je);
 		}
 	}
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/impl/SourceBlockImpl.java Thu Jul 20 10:43:48 2006
@@ -32,6 +32,7 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.MessageInternalException;
 import org.apache.axis2.jaxws.message.databinding.SourceBlock;
@@ -94,7 +95,7 @@
 			// Okay, these are supported Source objects
 		} else {
 			// TODO NLS
-			throw new MessageException("Unexpected Source:" + busObject.getClass());
+			throw ExceptionFactory.makeMessageException("Unexpected Source:" + busObject.getClass());
 		}
 	}
 	
@@ -151,7 +152,7 @@
 			return busObject;
 		} else {
 			// TODO Missing Impl
-			throw new MessageInternalException("Missing Code...Need to make a copy of the Source");
+			throw ExceptionFactory.makeMessageInternalException("Missing Code...Need to make a copy of the Source", null);
 		}
 	}
 	

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/BlockImpl.java Thu Jul 20 10:43:48 2006
@@ -23,6 +23,7 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.factory.BlockFactory;
@@ -105,7 +106,7 @@
 	public Object getBusinessObject(boolean consume) throws XMLStreamException, MessageException {
 		if (consumed) {
 			// TODO NLS
-			throw new MessageException("The block is already consumed");
+			throw ExceptionFactory.makeMessageException("The block is already consumed");
 		}
 		if (busObject != null) {
 			busObject =  _getBOFromBO(busObject, busContext, consume);
@@ -145,7 +146,7 @@
 			}
 			return qName;
 		} catch (XMLStreamException xse) {
-			throw new MessageException(xse);
+			throw ExceptionFactory.makeMessageException(xse);
 		}
 	}
 	
@@ -164,7 +165,7 @@
 		XMLStreamReader newReader = null;
 		if (consumed) {
 			// TODO NLS
-			throw new MessageException("The block is already consumed");
+			throw ExceptionFactory.makeMessageException("The block is already consumed");
 		}
 		if (omElement != null) {
 			if (consume) {
@@ -187,7 +188,7 @@
 		boolean consume =true;  // get the OM consumes the message
 		if (consumed) {
 			// TODO NLS
-			throw new MessageException("The block is already consumed");
+			throw ExceptionFactory.makeMessageException("The block is already consumed");
 		}
 		if (omElement != null) {
 			newOMElement = omElement;
@@ -232,7 +233,7 @@
 	public void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, MessageException {
 		if (consumed) {
 			// TODO NLS
-			throw new MessageException("The block is already consumed");
+			throw ExceptionFactory.makeMessageException("The block is already consumed");
 		}
 		if (omElement != null) {
 			if (consume) {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/MessageImpl.java Thu Jul 20 10:43:48 2006
@@ -25,6 +25,7 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.Attachment;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
@@ -56,10 +57,10 @@
 		this.protocol = protocol;
 		if (protocol.equals(Protocol.unknown)) {
 			// TODO NLS
-			throw new MessageException("Protocol unknown is not supported");
+			throw ExceptionFactory.makeMessageException("Protocol unknown is not supported");
 		} else if (protocol.equals(Protocol.rest)) {
 			// TODO NLS
-			throw new MessageException("Protocol rest is not supported");
+			throw ExceptionFactory.makeMessageException("Protocol rest is not supported");
 		}
 		XMLPartFactory factory = (XMLPartFactory) FactoryRegistry.getFactory(XMLPartFactory.class);
 		xmlPart = factory.create(protocol);
@@ -81,7 +82,7 @@
 	 */
 	public SOAPMessage getAsSOAPMessage() throws MessageException {
 		// TODO Missing implementation
-		throw new MessageException("Not Implemented Yet");
+		throw ExceptionFactory.makeMessageException("Not Implemented Yet");
 	}
 
 	/* (non-Javadoc)

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLPartBase.java Thu Jul 20 10:43:48 2006
@@ -25,6 +25,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.MessageInternalException;
@@ -97,10 +98,10 @@
 		this.protocol = protocol;
 		if (protocol.equals(Protocol.unknown)) {
 			// TODO NLS
-			throw new MessageException("Protocol unknown is not supported");
+			throw ExceptionFactory.makeMessageException("Protocol unknown is not supported");
 		} else if (protocol.equals(Protocol.rest)) {
 			// TODO NLS
-			throw new MessageException("Protocol rest is not supported");
+			throw ExceptionFactory.makeMessageException("Protocol rest is not supported");
 		}
 		content = _createSpine(protocol);
 		contentType = SPINE;
@@ -121,7 +122,7 @@
 		} else if (qName.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
 			protocol = Protocol.soap12;
 		} else {
-			throw new MessageException("Protocol rest is not supported");
+			throw ExceptionFactory.makeMessageException("Protocol rest is not supported");
 		}
 	}
 	
@@ -144,7 +145,7 @@
 			break;
 		default:
 			// TODO NLS
-			throw new MessageInternalException("Unknown type");
+			throw ExceptionFactory.makeMessageInternalException("Unknown type", null);
 		}
 		setContent(om, OM);
 		return om;
@@ -164,7 +165,7 @@
 			break;
 		default:
 			// TODO NLS
-			throw new MessageInternalException("Unknown type");
+			throw ExceptionFactory.makeMessageInternalException("Unknown type", null);
 		}
 		setContent(se, SOAPENVELOPE);
 		return se;
@@ -184,7 +185,7 @@
 			break;
 		default:
 			// TODO NLS
-			throw new MessageInternalException("Unknown type");
+			throw ExceptionFactory.makeMessageInternalException("Unknown type", null);
 		}
 		setContent(spine, SPINE);
 		return spine;
@@ -205,7 +206,7 @@
 	public XMLStreamReader getXMLStreamReader(boolean consume) throws MessageException {
 		if (consumed) {
 			// TODO NLS
-			throw new MessageException("Already consumed");
+			throw ExceptionFactory.makeMessageException("Already consumed");
 		}
 		XMLStreamReader reader = null;
 		if (contentType == SPINE) {
@@ -229,7 +230,7 @@
 	public void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, MessageException {
 		if (consumed) {
 			// TODO NLS
-			throw new MessageException("Already consumed");
+			throw ExceptionFactory.makeMessageException("Already consumed");
 		}
 		if (contentType == SPINE) {
 			getContentAsXMLSpine().outputTo(writer, consume);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/impl/XMLSpineImpl.java Thu Jul 20 10:43:48 2006
@@ -34,6 +34,7 @@
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.MessageInternalException;
@@ -93,7 +94,7 @@
 			protocol = Protocol.soap12;
 		} else {
 			// TODO NLS
-			throw new MessageInternalException("unrecognized protocol");
+			throw ExceptionFactory.makeMessageInternalException("unrecognized protocol", null);
 		}
 	} 
 
@@ -121,7 +122,7 @@
 		} else {
 			// Process the Fault
 			// TODO NLS
-			throw new MessageException("Not Implemented Yet");
+			throw ExceptionFactory.makeMessageException("Not Implemented Yet");
 		}
 		return;
 	}
@@ -154,7 +155,7 @@
 				try { 
 					block = obf.createFrom((OMElement) node, null, null);
 				} catch (XMLStreamException xse) {
-					throw new MessageException(xse);
+					throw ExceptionFactory.makeMessageException(xse);
 				}
 				blocks.add(block);
 			} else {
@@ -171,7 +172,7 @@
 			soapFactory = new SOAP11Factory();
 		} else {
 			// TODO NLS
-			throw new MessageInternalException("unsupported protocol");
+			throw ExceptionFactory.makeMessageInternalException("unsupported protocol", null);
 		}
 		return soapFactory;
 	}
@@ -210,12 +211,12 @@
 
 	public javax.xml.soap.SOAPEnvelope getAsSOAPEnvelope() throws MessageException {
 		// TODO NLS
-		throw new MessageInternalException("Should never be called");
+		throw ExceptionFactory.makeMessageInternalException("Should never be called", null);
 	}
 
 	public OMElement getAsOMElement() throws MessageException {
 		// TODO NLS
-		throw new MessageInternalException("Should never be called");
+		throw ExceptionFactory.makeMessageInternalException("Should never be called", null);
 	}
 
 	/* (non-Javadoc)
@@ -242,7 +243,7 @@
 			}
 			return newBlock;
 		} catch (XMLStreamException xse) {
-			throw new MessageException(xse);
+			throw ExceptionFactory.makeMessageException(xse);
 		}
 	}
 
@@ -276,7 +277,7 @@
 			}
 			return newBlock;
 		} catch (XMLStreamException xse) {
-			throw new MessageException(xse);
+			throw ExceptionFactory.makeMessageException(xse);
 		}
 	}
 

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/Reader.java Thu Jul 20 10:43:48 2006
@@ -22,6 +22,7 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.MessageInternalException;
 
 
@@ -69,7 +70,7 @@
 	public void reset() throws MessageInternalException {
 		if (!resettable) {
 			// TODO NLS
-			throw new MessageInternalException("Can't reset non-resettable XMLStreamReader");
+			throw ExceptionFactory.makeMessageInternalException("Can't reset non-resettable XMLStreamReader", null);
 		}
 		reader = newReader();
 	}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/SAAJConverterImpl.java Thu Jul 20 10:43:48 2006
@@ -36,6 +36,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.message.MessageException;
 import org.apache.axis2.jaxws.message.util.SAAJConverter;
 import org.apache.axis2.jaxws.message.util.SOAPElementReader;
@@ -92,7 +93,7 @@
 		} catch (MessageException e) {
 			throw e;
 		} catch (SOAPException e) {
-			throw new MessageException(e);
+			throw ExceptionFactory.makeMessageException(e);
 		}
 		return soapEnvelope;
 	}
@@ -137,7 +138,7 @@
 		}
 		if (env == null) {
 			// TODO NLS
-			throw new MessageException("SOAPEnvelope is needed!");
+			throw ExceptionFactory.makeMessageException("SOAPEnvelope is needed!");
 		}
 		return buildSOAPTree((SOAPEnvelope) env, null, parent, reader, false);
 	}
@@ -241,9 +242,9 @@
 		} catch (MessageException e) {
 			throw e;
 		} catch (XMLStreamException e) {
-			throw new MessageException(e);
+			throw ExceptionFactory.makeMessageException(e);
 		} catch (SOAPException e) {
-			throw new MessageException(e);
+			throw ExceptionFactory.makeMessageException(e);
 		}
 		return root;
 	}
@@ -375,6 +376,6 @@
 		// Review We need NLS for this message, but this code will probably 
 		// be added to JAX-WS.  So for now we there is no NLS.
 		// TODO NLS
-		throw new MessageException("Unexpected XMLStreamReader event:" + event);
+		throw ExceptionFactory.makeMessageException("Unexpected XMLStreamReader event:" + event);
 	}
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Thu Jul 20 10:43:48 2006
@@ -35,6 +35,7 @@
 import javax.xml.ws.soap.SOAPBinding;
 
 import org.apache.axis2.jaxws.ClientMediator;
+import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.JAXWSClientContext;
 import org.apache.axis2.jaxws.client.JAXBDispatch;
 import org.apache.axis2.jaxws.client.XMLDispatch;
@@ -63,13 +64,15 @@
     	mediator = new ClientMediator();
 
         if(!isValidServiceName()){
-    		throw new WebServiceException("Invalid Service QName, Service Name cannot be null or empty");
+        	// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Invalid Service QName, Service Name cannot be null or empty");
     	}
 
         serviceDescription = new ServiceDescription(url, serviceQname, clazz);
         if (isValidWSDLLocation()) {
             if(!isServiceDefined(serviceQname)){
-                throw new WebServiceException("Service " + serviceQname + " not defined in WSDL");
+            	// TODO NLS
+                throw ExceptionFactory.makeWebServiceException("Service " + serviceQname + " not defined in WSDL");
             }
             readPorts();
         }
@@ -78,13 +81,16 @@
     public void addPort(QName portName, String bindingId, String endpointAddress) throws WebServiceException{
         // TODO Auto-generated method stub
     	if(portName == null ){
-    		throw new WebServiceException("Invalid port, port cannot be null");
+    		// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Invalid port, port cannot be null");
     	}
     	if("".equals(portName)){
-    		throw new WebServiceException("Invalid port name");
+    		// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Invalid port name");
     	}
     	if (endpointAddress == null) {
-    		throw new WebServiceException("Invalid endpointAddress, endpointAddress cannot be null");
+    		// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Invalid endpointAddress, endpointAddress cannot be null");
     	}
     	
     	if(bindingId!=null && !bindingId.equals(SOAPBinding.SOAP11HTTP_BINDING)){
@@ -104,8 +110,8 @@
     		port.setBindingID(bindingId);
     		port.setEndPointAddress(endpointAddress);
     		*/
-    		
-    		throw new WebServiceException("Port is already added");
+    		// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Port is already added");
     	}
     }
     private <T> JAXWSClientContext<T> createClientContext(PortData portData, Class<T> clazz, Mode mode){
@@ -120,11 +126,13 @@
 
     public <T> Dispatch<T> createDispatch(QName qname, Class<T> clazz, Mode mode) throws WebServiceException {
     	if(qname == null){
-    		throw new WebServiceException("Failed to create Dispatch port cannot be null.");
+    		// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Failed to create Dispatch port cannot be null.");
     	}
     	
     	if(!isPortValid(qname)){
-    		throw new WebServiceException("Failed to create Dispatch, Port "+qname+" not found, add port to Service before calling dispatch.");
+    		// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Failed to create Dispatch, Port "+qname+" not found, add port to Service before calling dispatch.");
     	}
     	PortData portData = (PortData)ports.get(qname);
     	if(portData == null){
@@ -141,11 +149,13 @@
     
     public Dispatch<java.lang.Object> createDispatch(QName qname, JAXBContext context, Mode mode) {
         if (qname == null) {
-            throw new WebServiceException("Failed to create Dispatch port cannot be null.");
+        	// TODO NLS
+            throw ExceptionFactory.makeWebServiceException("Failed to create Dispatch port cannot be null.");
         }
         
         if (!isPortValid(qname)) {
-            throw new WebServiceException("Failed to create Dispatch, Port "+qname+" not found, add port to Service before calling dispatch.");
+        	// TODO NLS
+            throw ExceptionFactory.makeWebServiceException("Failed to create Dispatch, Port "+qname+" not found, add port to Service before calling dispatch.");
         }
         
         PortData portData = (PortData) ports.get(qname);
@@ -191,10 +201,11 @@
         
     	if(!isValidWSDLLocation()){
     		//TODO: Should I throw Exception if no WSDL
-    		//throw new WebServiceException("WSLD Not found");
+    		//throw ExceptionFactory.makeWebServiceException("WSLD Not found");
     	}
     	if(sei == null){
-    		throw new WebServiceException("Invalid Service Endpoint Interface Class");
+    		// TODO NLS
+    		throw ExceptionFactory.makeWebServiceException("Invalid Service Endpoint Interface Class");
     	}
     	/*TODO: if portQname is null then fetch it from annotation. 
     	 * if portQname is provided then add that to the ports table.

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java?rev=424001&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/exception/ExceptionFactoryTests.java Thu Jul 20 10:43:48 2006
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * 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.axis2.jaxws.exception;
+
+import org.apache.axis2.jaxws.ExceptionFactory;
+import javax.xml.ws.ProtocolException;
+import javax.xml.ws.http.HTTPException;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.message.MessageInternalException;
+import junit.framework.TestCase;
+import javax.xml.ws.WebServiceException;
+
+/**
+ * Tests the ExceptionFactory
+ */
+public class ExceptionFactoryTests extends TestCase {
+	private static final String sampleText = "Sample";
+
+    /**
+     * @param name
+     */
+    public ExceptionFactoryTests(String name) {
+        super(name);
+    }
+    
+    /**
+     * @teststrategy Tests creation of a WebServiceException
+     */
+    public void testExceptionFactory00() throws Exception {
+    	try{
+    		throw ExceptionFactory.makeWebServiceException(sampleText);
+    	} catch(WebServiceException e){
+    		assertTrue(sampleText.equals(e.getMessage()));
+    		assertTrue(e.getCause() == null);
+    	}
+    }
+    
+    /**
+     * @teststrategy Tests creation of a WebServiceException from another WebServiceException
+     */
+    public void testExceptionFactory01() throws Exception {
+    	try{
+    		WebServiceException wse = (WebServiceException) ExceptionFactory.makeWebServiceException(sampleText);
+    		throw ExceptionFactory.makeWebServiceException(wse);
+    	} catch(WebServiceException e){
+    		// Should only be a single WebServiceException
+    		assertTrue(sampleText.equals(e.getMessage()));
+    		assertTrue(e.getCause() == null);
+    	}
+    }
+    
+    /**
+     * @teststrategy Tests creation of a WebServiceException->WebServiceException->ProtocolException
+     */
+    public void testExceptionFactory02() throws Exception {
+    	ProtocolException pe = new ProtocolException(sampleText);
+    	try{
+    		WebServiceException wse = (WebServiceException) ExceptionFactory.makeWebServiceException(pe);
+    		throw ExceptionFactory.makeWebServiceException(wse);
+    	} catch(WebServiceException e){
+    		// Should only be a single WebServiceException with a Protocol Exception
+    		assertTrue(sampleText.equals(e.getMessage()));
+    		assertTrue(e.getCause() == null);
+    	}
+    }
+    
+    /**
+     * @teststrategy Tests creation of a WebServiceException->WebServiceException->NullPointerException
+     */
+    public void testExceptionFactory03() throws Exception {
+    	NullPointerException npe = new NullPointerException();
+    	try{
+    		WebServiceException wse = (WebServiceException) ExceptionFactory.makeWebServiceException(npe);
+    		throw ExceptionFactory.makeWebServiceException(wse);
+    	} catch(WebServiceException e){
+    		// Should only be a single WebServiceException with a Protocol Exception
+    		assertTrue(e.getMessage() == null);
+    		assertTrue(e.getCause() == npe);
+    	}
+    }
+    
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?rev=424001&r1=424000&r2=424001&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Thu Jul 20 10:43:48 2006
@@ -25,6 +25,7 @@
 import org.apache.axis2.jaxws.description.ServiceDescriptionTests;
 import org.apache.axis2.jaxws.description.WSDLDescriptionTests;
 import org.apache.axis2.jaxws.description.WSDLTests;
+import org.apache.axis2.jaxws.exception.ExceptionFactoryTests;
 import org.apache.axis2.jaxws.handler.HandlerChainProcessorTests;
 import org.apache.axis2.jaxws.message.BlockTests;
 import org.apache.axis2.jaxws.message.MessageTests;
@@ -57,6 +58,8 @@
         
         suite.addTestSuite(StringProviderTests.class);
         suite.addTestSuite(SourceProviderTests.class);
+        
+        suite.addTestSuite(ExceptionFactoryTests.class);
 
         // Start (and stop) the server only once for all the tests
         TestSetup testSetup = new TestSetup(suite) {



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


Mime
View raw message