[jbossws-commits] JBossWS SVN: r4583 - in stack/native/trunk/src/main/java: org/jboss/ws/core/soap and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Sep 18 09:15:44 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-09-18 09:15:44 -0400 (Tue, 18 Sep 2007)
New Revision: 4583

Added:
   stack/native/trunk/src/main/java/javax/xml/soap/SAAJFactoryLoader.java
Removed:
   stack/native/trunk/src/main/java/org/jboss/ws/soap/SAAJFactoryLoader.java
Modified:
   stack/native/trunk/src/main/java/javax/xml/soap/MessageFactory.java
   stack/native/trunk/src/main/java/javax/xml/soap/SAAJMetaFactory.java
   stack/native/trunk/src/main/java/javax/xml/soap/SOAPConnection.java
   stack/native/trunk/src/main/java/javax/xml/soap/SOAPFactory.java
   stack/native/trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java
   stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java
Log:
Rollback -r4525 Fix JBCTS-312: javax.xml.soap.sig_1.3.javaee

Modified: stack/native/trunk/src/main/java/javax/xml/soap/MessageFactory.java
===================================================================
--- stack/native/trunk/src/main/java/javax/xml/soap/MessageFactory.java	2007-09-18 10:43:43 UTC (rev 4582)
+++ stack/native/trunk/src/main/java/javax/xml/soap/MessageFactory.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -23,7 +23,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Method;
 
 /**
  A factory for creating SOAPMessage objects.
@@ -71,12 +70,9 @@
       try
       {
          String propertyName = "javax.xml.soap.MessageFactory";
-
-         Class loaderClass = Class.forName("org.jboss.ws.soap.SAAJFactoryLoader");         
-         Method m = loaderClass.getMethod("loadFactory", new Class[] {String.class, String.class});
-         factory = (MessageFactory)m.invoke(null, new Object[] {propertyName, null});
+         factory = (MessageFactory)SAAJFactoryLoader.loadFactory(propertyName, null);
       }
-      catch (Exception rte)
+      catch (RuntimeException rte)
       {
          throw new SOAPException(rte);
       }

Copied: stack/native/trunk/src/main/java/javax/xml/soap/SAAJFactoryLoader.java (from rev 4510, stack/native/trunk/src/main/java/javax/xml/soap/SAAJFactoryLoader.java)
===================================================================
--- stack/native/trunk/src/main/java/javax/xml/soap/SAAJFactoryLoader.java	                        (rev 0)
+++ stack/native/trunk/src/main/java/javax/xml/soap/SAAJFactoryLoader.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -0,0 +1,194 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package javax.xml.soap;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Properties;
+
+
+// $Id$
+
+/**
+ * Load a factory using this ordered lookup procedure
+ *
+ * <ol>
+ *  <li>Use the system property
+ *  <li>Use the properties file "lib/jaxm.properties" in the JRE directory
+ *  <li>Use the Services API (as detailed in the JAR specification), if available, to determine the classname
+ *  <li>Use the default factory implementation class
+ * </ol>
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 14-Dec-2006
+ */
+class SAAJFactoryLoader
+{
+   private SAAJFactoryLoader()
+   {
+   }
+
+   /**   
+    *  
+    *  @return the factory impl, or null 
+    */
+   public static Object loadFactory(String propertyName, String defaultFactory) 
+   {
+      Object factory = null;
+      ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+      // Use the system property
+      PrivilegedAction action = new PropertyAccessAction(propertyName);
+      String factoryName = (String)AccessController.doPrivileged(action);
+      if (factoryName != null)
+      {
+         try
+         {
+            //if(log.isDebugEnabled()) log.debug("Load from system property: " + factoryName);
+            Class factoryClass = loader.loadClass(factoryName);
+            factory = factoryClass.newInstance();
+         }
+         catch (Throwable t)
+         {
+            throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+         }
+      }
+
+      // Use the properties file "lib/jaxm.properties" in the JRE directory.
+      // This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above.
+      if (factory == null)
+      {
+         action = new PropertyAccessAction("java.home");
+         String javaHome = (String)AccessController.doPrivileged(action);
+         File jaxmFile = new File(javaHome + "/lib/jaxm.properties");
+         if (jaxmFile.exists())
+         {
+            try
+            {
+               action = new PropertyFileAccessAction(jaxmFile.getCanonicalPath());
+               Properties jaxmProperties = (Properties)AccessController.doPrivileged(action);
+               factoryName = jaxmProperties.getProperty(propertyName);
+               if (factoryName != null)
+               {
+                  //if(log.isDebugEnabled()) log.debug("Load from " + jaxmFile + ": " + factoryName);
+                  Class factoryClass = loader.loadClass(factoryName);
+                  factory = factoryClass.newInstance();
+               }
+            }
+            catch (Throwable t)
+            {
+               throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+            }
+         }
+      }
+
+      // Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
+      if (factory == null)
+      {
+         String filename = "META-INF/services/" + propertyName;
+         InputStream inStream = loader.getResourceAsStream(filename);
+         if (inStream != null)
+         {
+            try
+            {
+               BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
+               factoryName = br.readLine();
+               br.close();
+               if (factoryName != null)
+               {
+                  //if(log.isTraceEnabled()) log.trace("Load from Service API " + filename + ": " + factoryName);
+                  Class factoryClass = loader.loadClass(factoryName);
+                  factory = factoryClass.newInstance();
+               }
+            }
+            catch (Throwable t)
+            {
+               throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+            }
+         }
+      }
+
+      // Use the default factory implementation class.
+      if (factory == null && defaultFactory != null)
+      {
+         try
+         {
+            factoryName = defaultFactory;
+            //if(log.isDebugEnabled()) log.debug("Load from default: " + factoryName);
+            Class factoryClass = loader.loadClass(factoryName);
+            factory = factoryClass.newInstance();
+         }
+         catch (Throwable t)
+         {
+            throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+         }
+      }
+
+      return factory;
+   }
+
+   private static class PropertyAccessAction implements PrivilegedAction
+   {
+      private String name;
+
+      PropertyAccessAction(String name)
+      {
+         this.name = name;
+      }
+
+      public Object run()
+      {
+         return System.getProperty(name);
+      }
+   }
+
+   private static class PropertyFileAccessAction implements PrivilegedAction
+   {
+      private String filename;
+
+      PropertyFileAccessAction(String filename)
+      {
+         this.filename = filename;
+      }
+
+      public Object run()
+      {
+         try
+         {
+            InputStream inStream = new FileInputStream(filename);
+            Properties props = new Properties();
+            props.load(inStream);
+            return props;
+         }
+         catch (IOException ex)
+         {
+            throw new SecurityException("Cannot load properties: " + filename, ex);
+         }
+      }
+   }
+}

Modified: stack/native/trunk/src/main/java/javax/xml/soap/SAAJMetaFactory.java
===================================================================
--- stack/native/trunk/src/main/java/javax/xml/soap/SAAJMetaFactory.java	2007-09-18 10:43:43 UTC (rev 4582)
+++ stack/native/trunk/src/main/java/javax/xml/soap/SAAJMetaFactory.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -21,8 +21,6 @@
  */
 package javax.xml.soap;
 
-import java.lang.reflect.Method;
-
 // $Id$
 
 /**
@@ -59,19 +57,8 @@
    {
       String propertyName = "javax.xml.soap.MetaFactory";
       String defaultImpl = "org.jboss.ws.core.soap.SAAJMetaFactoryImpl";
-
-      SAAJMetaFactory factory  = null;
-      try
-      {
-         Class loaderClass = Class.forName("org.jboss.ws.soap.SAAJFactoryLoader");
-         Method m = loaderClass.getMethod("loadFactory", new Class[] {String.class, String.class});
-         factory = (SAAJMetaFactory)m.invoke(null, new Object[] {propertyName, defaultImpl});
-      }
-      catch (Exception e)
-      {
-         throw new SOAPException("Failed to load org.jboss.ws.soap.SAAJFactoryLoader", e);
-      }
-
+      SAAJMetaFactory factory = (SAAJMetaFactory)SAAJFactoryLoader.loadFactory(propertyName, defaultImpl);
+      
       if (factory == null)
          throw new SOAPException("Failed to to determine the implementation class for: " + propertyName);
 

Modified: stack/native/trunk/src/main/java/javax/xml/soap/SOAPConnection.java
===================================================================
--- stack/native/trunk/src/main/java/javax/xml/soap/SOAPConnection.java	2007-09-18 10:43:43 UTC (rev 4582)
+++ stack/native/trunk/src/main/java/javax/xml/soap/SOAPConnection.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -21,6 +21,8 @@
  */
 package javax.xml.soap;
 
+import org.jboss.util.NotImplementedException;
+
 /** A point-to-point connection that a client can use for sending messages directly to a remote
  * party (represented by a URL, for instance).
  *
@@ -61,10 +63,7 @@
     * @throws SOAPException if there is a SOAP error
     * @since SAAJ 1.3
     */
-   public SOAPMessage get(Object to) throws SOAPException
-   {
-      throw new IllegalArgumentException("Should be implemented by concrete implementation of this class");
-   }
+   public abstract SOAPMessage get(Object to) throws SOAPException;
    
    /** Closes this SOAPConnection object.
     *

Modified: stack/native/trunk/src/main/java/javax/xml/soap/SOAPFactory.java
===================================================================
--- stack/native/trunk/src/main/java/javax/xml/soap/SOAPFactory.java	2007-09-18 10:43:43 UTC (rev 4582)
+++ stack/native/trunk/src/main/java/javax/xml/soap/SOAPFactory.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -23,11 +23,10 @@
 
 // $Id$
 
-import org.w3c.dom.Element;
-
 import javax.xml.namespace.QName;
-import java.lang.reflect.Method;
 
+import org.w3c.dom.Element;
+
 /** SOAPFactory is a factory for creating various objects that exist in the SOAP XML tree.
  *
  * SOAPFactory can be used to create XML fragments that will eventually end up in the SOAP part.
@@ -62,12 +61,9 @@
          try
          {
             String propertyName = "javax.xml.soap.SOAPFactory";
-
-            Class loaderClass = Class.forName("org.jboss.ws.soap.SAAJFactoryLoader");
-            Method m = loaderClass.getMethod("loadFactory", new Class[] {String.class, String.class});
-            soapFactory  = (SOAPFactory)m.invoke(null, new Object[] {propertyName, null});
+            soapFactory = (SOAPFactory)SAAJFactoryLoader.loadFactory(propertyName, null);
          }
-         catch (Exception rte)
+         catch (RuntimeException rte)
          {
             throw new SOAPException(rte);
          }
@@ -125,10 +121,7 @@
     * @throws SOAPException if there is an error in creating the SOAPElement object
     * @since SAAJ 1.3
     */
-   public SOAPElement createElement(Element domElement) throws SOAPException
-   {
-      throw new IllegalArgumentException("Should be implemented by concrete implementation of this class");
-   }
+   public abstract SOAPElement createElement(Element domElement) throws SOAPException;
 
    /** Create a SOAPElement object initialized with the given local name.
     *
@@ -166,10 +159,7 @@
     * @throws SOAPException if there is an error in creating the SOAPElement object
     * @since SAAJ 1.3
     */
-   public SOAPElement createElement(QName qname) throws SOAPException
-   {
-      throw new IllegalArgumentException("Should be implemented by concrete implementation of this class");
-   }
+   public abstract SOAPElement createElement(QName qname) throws SOAPException;
 
    /**
     * Creates a new SOAPFault object initialized with the given reasonText  and faultCode

Modified: stack/native/trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java
===================================================================
--- stack/native/trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java	2007-09-18 10:43:43 UTC (rev 4582)
+++ stack/native/trunk/src/main/java/javax/xml/soap/SOAPHeaderElement.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -82,7 +82,7 @@
     * @throws UnsupportedOperationException if this message does not support the SOAP 1.2 concept of Fault Role
     * @since SAAJ 1.3
     */
-   public void setRole(String roleURI) throws SOAPException;
+   public void setRole(String roleURI);
 
    /** Sets the actor associated with this SOAPHeaderElement object to the specified actor.
     * The default value of an actor is: SOAPConstants.URI_SOAP_ACTOR_NEXT

Modified: stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java	2007-09-18 10:43:43 UTC (rev 4582)
+++ stack/native/trunk/src/main/java/org/jboss/ws/core/soap/SOAPHeaderElementImpl.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -77,7 +77,7 @@
       return roleAttr != null ? roleAttr.getValue() : null;
    }
 
-   public void setRole(String roleURI) throws SOAPException
+   public void setRole(String roleURI)
    {
       final SOAPElement header = getParentElement();
       final String headerURI = header.getNamespaceURI();
@@ -128,16 +128,7 @@
       if (Constants.NS_SOAP11_ENV.equals(headerURI))
          setAttributeNS(headerURI, header.getPrefix() + ":" + Constants.SOAP11_ATTR_ACTOR, actorURI);
       else
-      {
-         try
-         {
-            setRole(actorURI);
-         }
-         catch (SOAPException e)
-         {
-            throw new IllegalArgumentException("Failed to setRole: " + actorURI, e);
-         }
-      }
+         setRole(actorURI);
    }
 
    public boolean getMustUnderstand()

Deleted: stack/native/trunk/src/main/java/org/jboss/ws/soap/SAAJFactoryLoader.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/soap/SAAJFactoryLoader.java	2007-09-18 10:43:43 UTC (rev 4582)
+++ stack/native/trunk/src/main/java/org/jboss/ws/soap/SAAJFactoryLoader.java	2007-09-18 13:15:44 UTC (rev 4583)
@@ -1,194 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.soap;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Properties;
-
-
-// $Id$
-
-/**
- * Load a factory using this ordered lookup procedure
- *
- * <ol>
- *  <li>Use the system property
- *  <li>Use the properties file "lib/jaxm.properties" in the JRE directory
- *  <li>Use the Services API (as detailed in the JAR specification), if available, to determine the classname
- *  <li>Use the default factory implementation class
- * </ol>
- *
- * @author Thomas.Diesler at jboss.com
- * @since 14-Dec-2006
- */
-public class SAAJFactoryLoader
-{
-   private SAAJFactoryLoader()
-   {
-   }
-
-   /**   
-    *  
-    *  @return the factory impl, or null 
-    */
-   public static Object loadFactory(String propertyName, String defaultFactory) 
-   {
-      Object factory = null;
-      ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
-      // Use the system property
-      PrivilegedAction action = new PropertyAccessAction(propertyName);
-      String factoryName = (String)AccessController.doPrivileged(action);
-      if (factoryName != null)
-      {
-         try
-         {
-            //if(log.isDebugEnabled()) log.debug("Load from system property: " + factoryName);
-            Class factoryClass = loader.loadClass(factoryName);
-            factory = factoryClass.newInstance();
-         }
-         catch (Throwable t)
-         {
-            throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
-         }
-      }
-
-      // Use the properties file "lib/jaxm.properties" in the JRE directory.
-      // This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above.
-      if (factory == null)
-      {
-         action = new PropertyAccessAction("java.home");
-         String javaHome = (String)AccessController.doPrivileged(action);
-         File jaxmFile = new File(javaHome + "/lib/jaxm.properties");
-         if (jaxmFile.exists())
-         {
-            try
-            {
-               action = new PropertyFileAccessAction(jaxmFile.getCanonicalPath());
-               Properties jaxmProperties = (Properties)AccessController.doPrivileged(action);
-               factoryName = jaxmProperties.getProperty(propertyName);
-               if (factoryName != null)
-               {
-                  //if(log.isDebugEnabled()) log.debug("Load from " + jaxmFile + ": " + factoryName);
-                  Class factoryClass = loader.loadClass(factoryName);
-                  factory = factoryClass.newInstance();
-               }
-            }
-            catch (Throwable t)
-            {
-               throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
-            }
-         }
-      }
-
-      // Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
-      if (factory == null)
-      {
-         String filename = "META-INF/services/" + propertyName;
-         InputStream inStream = loader.getResourceAsStream(filename);
-         if (inStream != null)
-         {
-            try
-            {
-               BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
-               factoryName = br.readLine();
-               br.close();
-               if (factoryName != null)
-               {
-                  //if(log.isTraceEnabled()) log.trace("Load from Service API " + filename + ": " + factoryName);
-                  Class factoryClass = loader.loadClass(factoryName);
-                  factory = factoryClass.newInstance();
-               }
-            }
-            catch (Throwable t)
-            {
-               throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
-            }
-         }
-      }
-
-      // Use the default factory implementation class.
-      if (factory == null && defaultFactory != null)
-      {
-         try
-         {
-            factoryName = defaultFactory;
-            //if(log.isDebugEnabled()) log.debug("Load from default: " + factoryName);
-            Class factoryClass = loader.loadClass(factoryName);
-            factory = factoryClass.newInstance();
-         }
-         catch (Throwable t)
-         {
-            throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
-         }
-      }
-
-      return factory;
-   }
-
-   private static class PropertyAccessAction implements PrivilegedAction
-   {
-      private String name;
-
-      PropertyAccessAction(String name)
-      {
-         this.name = name;
-      }
-
-      public Object run()
-      {
-         return System.getProperty(name);
-      }
-   }
-
-   private static class PropertyFileAccessAction implements PrivilegedAction
-   {
-      private String filename;
-
-      PropertyFileAccessAction(String filename)
-      {
-         this.filename = filename;
-      }
-
-      public Object run()
-      {
-         try
-         {
-            InputStream inStream = new FileInputStream(filename);
-            Properties props = new Properties();
-            props.load(inStream);
-            return props;
-         }
-         catch (IOException ex)
-         {
-            throw new SecurityException("Cannot load properties: " + filename, ex);
-         }
-      }
-   }
-}




More information about the jbossws-commits mailing list