Author: veithen
Date: Sun Dec  7 10:39:58 2008
New Revision: 724167

URL: http://svn.apache.org/viewvc?rev=724167&view=rev
Log:
OMAbstractFactory:
* Modified the behavior of getSOAP(11|12)Factory to make it consistent with 
getOMFactory, namely to ignore SecurityExceptions thrown by System.getProperty 
(WSCOMMONS-233).
* Completed the Javadoc of this class.

Modified:
    
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAbstractFactory.java

Modified: 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAbstractFactory.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAbstractFactory.java?rev=724167&r1=724166&r2=724167&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAbstractFactory.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMAbstractFactory.java
 Sun Dec  7 10:39:58 2008
@@ -21,6 +21,46 @@
 
 import org.apache.axiom.soap.SOAPFactory;
 
+/**
+ * Provides default instances for plain XML, SOAP 1.1 and SOAP 1.2 object 
model factories.
+ * 
+ * <p>The implementation class for each object model type is determined by a 
specific
+ * system property. If the system property is not set, a default 
implementation class
+ * is chosen. The following table summarizes the system properties and default 
implementation
+ * used:</p>
+ * <table border="1">
+ *   <tr>
+ *     <th>Object model</th>
+ *     <th>Method</th>
+ *     <th>System property</th>
+ *     <th>Default implementation</th>
+ *   </tr>
+ *   <tr>
+ *     <td>Plain XML</td>
+ *     <td>[EMAIL PROTECTED] #getOMFactory()}</td>
+ *     <td><tt>om.factory</tt></td>
+ *     <td>[EMAIL PROTECTED] 
org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory}</td>
+ *   </tr>
+ *   <tr>
+ *     <td>SOAP 1.1</td>
+ *     <td>[EMAIL PROTECTED] #getSOAP11Factory()}</td>
+ *     <td><tt>soap11.factory</tt></td>
+ *     <td>[EMAIL PROTECTED] 
org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory}</td>
+ *   </tr>
+ *   <tr>
+ *     <td>SOAP 1.2</td>
+ *     <td>[EMAIL PROTECTED] #getSOAP12Factory()}</td>
+ *     <td><tt>soap12.factory</tt></td>
+ *     <td>[EMAIL PROTECTED] 
org.apache.axiom.soap.impl.llom.soap12.SOAP12Factory}</td>
+ *   </tr>
+ * </table>
+ * <p>Since [EMAIL PROTECTED] OMFactory} instances are supposed to be 
stateless, each method in this class
+ * returns the same instance on every invocation, i.e. the factory for each OM 
type is instantiated
+ * only once.</p>
+ * <p>Each method in this class uses [EMAIL PROTECTED] 
System#getProperty(String)} to determine the value of
+ * the relevant system property. A [EMAIL PROTECTED] SecurityException} thrown 
by this method is simply ignored
+ * and the default factory implementation is used.</p> 
+ */
 public class OMAbstractFactory {
     public static final String OM_FACTORY_NAME_PROPERTY = "om.factory";
     public static final String SOAP11_FACTORY_NAME_PROPERTY = "soap11.factory";
@@ -37,6 +77,15 @@
     private static SOAPFactory defaultSOAP11OMFactory = null;
     private static SOAPFactory defaultSOAP12OMFactory = null;
 
+    private OMAbstractFactory() {}
+
+    /**
+     * Get the default OM factory instance.
+     *
+     * @return the default OM factory instance
+     * @throws OMException if the factory's implementation class can't be found
+     *                     or if the class can't be instantiated
+     */
     public static OMFactory getOMFactory() {
         if (defaultOMFactory != null) {
             return defaultOMFactory;
@@ -65,19 +114,27 @@
 
 
     /**
-     * Gets the default factory implementation from the classpath.
+     * Get the default SOAP 1.1 OM factory instance.
      *
-     * @return Returns SOAPFactory.
+     * @return the default SOAP 1.1 OM factory instance
+     * @throws OMException if the factory's implementation class can't be found
+     *                     or if the class can't be instantiated
      */
     public static SOAPFactory getSOAP11Factory() {
         if (defaultSOAP11OMFactory != null) {
             return defaultSOAP11OMFactory;
         }
+        String omFactory;
         try {
-            String omFactory = 
System.getProperty(SOAP11_FACTORY_NAME_PROPERTY);
+            omFactory = System.getProperty(SOAP11_FACTORY_NAME_PROPERTY);
             if (omFactory == null || "".equals(omFactory)) {
                 omFactory = DEFAULT_SOAP11_FACTORY_CLASS_NAME;
             }
+        } catch (SecurityException e) {
+            omFactory = DEFAULT_SOAP11_FACTORY_CLASS_NAME;
+        }
+        
+        try {
             defaultSOAP11OMFactory = (SOAPFactory) 
Class.forName(omFactory).newInstance();
         } catch (InstantiationException e) {
             throw new OMException(e);
@@ -91,19 +148,27 @@
 
 
     /**
-     * Gets the default factory implementation from the classpath.
+     * Get the default SOAP 1.2 OM factory instance.
      *
-     * @return Returns SOAPFactory.
+     * @return the default SOAP 1.2 OM factory instance
+     * @throws OMException if the factory's implementation class can't be found
+     *                     or if the class can't be instantiated
      */
     public static SOAPFactory getSOAP12Factory() {
         if (defaultSOAP12OMFactory != null) {
             return defaultSOAP12OMFactory;
         }
+        String omFactory;
         try {
-            String omFactory = 
System.getProperty(SOAP12_FACTORY_NAME_PROPERTY);
+            omFactory = System.getProperty(SOAP12_FACTORY_NAME_PROPERTY);
             if (omFactory == null || "".equals(omFactory)) {
                 omFactory = DEFAULT_SOAP12_FACTORY_CLASS_NAME;
             }
+        } catch (SecurityException e) {
+            omFactory = DEFAULT_SOAP12_FACTORY_CLASS_NAME;
+        }
+        
+        try {
             defaultSOAP12OMFactory = (SOAPFactory) 
Class.forName(omFactory).newInstance();
         } catch (InstantiationException e) {
             throw new OMException(e);


Reply via email to