geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r693676 - in /geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap: FactoryFinder.java MessageFactory.java SOAPFactory.java
Date Wed, 10 Sep 2008 01:53:24 GMT
Author: gawor
Date: Tue Sep  9 18:53:23 2008
New Revision: 693676

URL: http://svn.apache.org/viewvc?rev=693676&view=rev
Log:
fall back to SAAJMetaFactory for MessageFactory and SOAPFactory. Based on patch from Dims.
(GERONIMO-4289)

Modified:
    geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/FactoryFinder.java
    geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/MessageFactory.java
    geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/SOAPFactory.java

Modified: geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/FactoryFinder.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/FactoryFinder.java?rev=693676&r1=693675&r2=693676&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/FactoryFinder.java
(original)
+++ geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/FactoryFinder.java
Tue Sep  9 18:53:23 2008
@@ -83,6 +83,29 @@
      */
     static Object find(String factoryPropertyName,
                        String defaultFactoryClassName) throws SOAPException {
+        Object factory = find(factoryPropertyName);
+        if (factory != null) {
+            return factory;
+        }
+
+        if (defaultFactoryClassName == null) {
+            throw new SOAPException(
+                    "Provider for " + factoryPropertyName + " cannot be found",
+                    null);
+        } else {
+            return newInstance(defaultFactoryClassName);
+        }
+    }
+
+    /**
+     * Instantiates a factory object given the factory's property name.
+     *
+     * @param factoryPropertyName
+     * @param defaultFactoryClassName
+     * @return a factory object
+     * @throws SOAPException
+     */
+    static Object find(String factoryPropertyName) throws SOAPException {
         try {
             String factoryClassName = System.getProperty(factoryPropertyName);
             if (factoryClassName != null) {
@@ -109,7 +132,6 @@
         }
 
         String factoryResource = "META-INF/services/" + factoryPropertyName;
-
         try {
             InputStream inputstream = getResource(factoryResource);
             if (inputstream != null) {
@@ -118,25 +140,13 @@
                 String factoryClassName = bufferedreader.readLine();
                 bufferedreader.close();
                 if ((factoryClassName != null) && !"".equals(factoryClassName)) {
-                    try {
-                        return newInstance(factoryClassName);
-                    } catch (Exception e) {
-                        throw new SOAPException(
-                                "Provider for " + factoryPropertyName + " cannot be found",
-                                null);
-                    }
+                    return newInstance(factoryClassName);
                 }
             }
         } catch (Exception exception2) {
         }
 
-        if (defaultFactoryClassName == null) {
-            throw new SOAPException(
-                    "Provider for " + factoryPropertyName + " cannot be found",
-                    null);
-        } else {
-            return newInstance(defaultFactoryClassName);
-        }
+        return null;
     }
 
     /**

Modified: geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/MessageFactory.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/MessageFactory.java?rev=693676&r1=693675&r2=693676&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/MessageFactory.java
(original)
+++ geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/MessageFactory.java
Tue Sep  9 18:53:23 2008
@@ -80,14 +80,14 @@
      *                       <CODE> MessageFactory</CODE>
      */
     public static MessageFactory newInstance() throws SOAPException {
-
         try {
-            return (MessageFactory)FactoryFinder.find(
-                    MESSAGE_FACTORY_PROPERTY,
-                    DEFAULT_MESSAGE_FACTORY);
+            MessageFactory factory = (MessageFactory)FactoryFinder.find(MESSAGE_FACTORY_PROPERTY);
+            if (factory == null) {
+            	factory = newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
+            }
+            return factory;
         } catch (Exception exception) {
-            throw new SOAPException("Unable to create message factory for SOAP: "
-                    + exception.getMessage());
+            throw new SOAPException("Unable to create MessageFactory: " + exception.getMessage());
         }
     }
 
@@ -130,9 +130,6 @@
         return SAAJMetaFactory.getInstance().newMessageFactory(soapVersion);
     }
 
-    private static final String DEFAULT_MESSAGE_FACTORY =
-            "org.apache.axis2.saaj.MessageFactoryImpl";
-
     private static final String MESSAGE_FACTORY_PROPERTY =
             "javax.xml.soap.MessageFactory";
 }

Modified: geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/SOAPFactory.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/SOAPFactory.java?rev=693676&r1=693675&r2=693676&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/SOAPFactory.java
(original)
+++ geronimo/specs/trunk/geronimo-saaj_1.3_spec/src/main/java/javax/xml/soap/SOAPFactory.java
Tue Sep  9 18:53:23 2008
@@ -119,12 +119,14 @@
      * @throws SOAPException if there was an error creating the default <code>SOAPFactory</code>
      */
     public static SOAPFactory newInstance() throws SOAPException {
-
         try {
-            return (SOAPFactory)FactoryFinder.find(SF_PROPERTY, DEFAULT_SF);
+            SOAPFactory factory = (SOAPFactory)FactoryFinder.find(SOAP_FACTORY_PROPERTY);
+            if (factory == null) {
+                factory = newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
+            }
+            return factory;
         } catch (Exception exception) {
-            throw new SOAPException("Unable to create SOAP Factory: "
-                    + exception.getMessage());
+            throw new SOAPException("Unable to create SOAPFactory: " + exception.getMessage());
         }
     }
 
@@ -142,8 +144,8 @@
      * @throws SOAPException - if there is an error creating the specified SOAPFactory
      * @see <CODE>SAAJMetaFactory</CODE>
      */
-    public static SOAPFactory newInstance(String s) throws SOAPException {
-        return SAAJMetaFactory.getInstance().newSOAPFactory(s);
+    public static SOAPFactory newInstance(String protocol) throws SOAPException {
+        return SAAJMetaFactory.getInstance().newSOAPFactory(protocol);
     }
 
 
@@ -191,8 +193,6 @@
                                           javax.xml.namespace.QName faultCode)
             throws SOAPException;
 
-    private static final String SF_PROPERTY = "javax.xml.soap.SOAPFactory";
+    private static final String SOAP_FACTORY_PROPERTY = "javax.xml.soap.SOAPFactory";
 
-    private static final String DEFAULT_SF =
-            "org.apache.axis2.saaj.SOAPFactoryImpl";
 }



Mime
View raw message