portals-wsrp4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlou...@apache.org
Subject svn commit: r477280 - in /portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons: exception/WSRPXHelper.java persistence/driver/PersistentAccess.java
Date Mon, 20 Nov 2006 18:45:06 GMT
Author: dlouzan
Date: Mon Nov 20 10:45:06 2006
New Revision: 477280

URL: http://svn.apache.org/viewvc?view=rev&rev=477280
Log:
Unified the configuration files on wsrp4j-config.properties using ConfigurationParametersManager
class

Modified:
    portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/exception/WSRPXHelper.java
    portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/persistence/driver/PersistentAccess.java

Modified: portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/exception/WSRPXHelper.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/exception/WSRPXHelper.java?view=diff&rev=477280&r1=477279&r2=477280
==============================================================================
--- portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/exception/WSRPXHelper.java
(original)
+++ portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/exception/WSRPXHelper.java
Mon Nov 20 10:45:06 2006
@@ -66,7 +66,7 @@
     
     // the name of the .properties file which contains exception mappings
     private static String EXCEPTION_MAPPING_FILE =
-            "ExceptionMapping.properties";
+            "exception-mapping.properties";
     private static final String MSG_EXCEPTION_MAPPING_ON_LOAD =
             "Error while loading exception mappings from " +
             EXCEPTION_MAPPING_FILE + ".";

Modified: portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/persistence/driver/PersistentAccess.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/persistence/driver/PersistentAccess.java?view=diff&rev=477280&r1=477279&r2=477280
==============================================================================
--- portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/persistence/driver/PersistentAccess.java
(original)
+++ portals/wsrp4j/trunk/commons/src/java/org/apache/wsrp4j/commons/persistence/driver/PersistentAccess.java
Mon Nov 20 10:45:06 2006
@@ -25,6 +25,9 @@
 import org.apache.wsrp4j.commons.exception.WSRPException;
 import org.apache.wsrp4j.commons.exception.WSRPXHelper;
 
+import org.apache.wsrp4j.commons.util.configuration.ConfigurationParametersManager;
+import org.apache.wsrp4j.commons.util.configuration.MissingConfigurationParameterException;
+
 import org.apache.wsrp4j.commons.persistence.ConsumerPersistentFactory;
 import org.apache.wsrp4j.commons.persistence.ProducerPersistentFactory;
 import org.apache.wsrp4j.commons.persistence.ProxyPersistentFactory;
@@ -40,33 +43,29 @@
     
     private static Log log = LogFactory.getLog(PersistentAccess.class);
 
-    // the name of the .properties file for the server
-    private static String PRODUCER_PROPERTIES = "WSRPServices.properties";
-
-    // the name of the .properties file for the client
-    private static String CONSUMER_PROPERTIES = "SwingConsumer.properties";
-    
-    private static String PROXY_PROPERTIES = "ProxyPortlet.properties";
-
-    // property name of the producer factory
-    private static String PRODUCER_PERSISTENT_FACTORY = "producer.persistent.factory";
-
-    // property name of the consumer factory
-    private static String CONSUMER_PERSISTENT_FACTORY = "consumer.persistent.factory";
+    /* property name of the producer factory */
+    private static String PRODUCER_PERSISTENT_FACTORY = 
+            "wsrp4j.producer.persistent.factory";
+
+    /* property name of the consumer factory */
+    private static String CONSUMER_PERSISTENT_FACTORY = 
+            "wsrp4j.consumer.persistent.factory";
     
-    private static String PROXY_PERSISTENT_FACTORY = "proxy.persistent.factory";
+    /* property name of the proxyportlet factory */
+    private static String PROXY_PERSISTENT_FACTORY = 
+            "wsrp4j.proxyportlet.persistent.factory";
 
-    // the content of the properties file
+    /* the content of the properties file */
     private static Properties pFactories;
 
-    // holds the instance of the server factory after initializing
+    /* holds the instance of the server factory after initializing */
     private static ProducerPersistentFactory producerPersistentFactory;
 
-    // holds the instance of the client factory after initializing
+    /* holds the instance of the client factory after initializing */
     private static ConsumerPersistentFactory consumerPersistentFactory;
 
+    /* holds the instance of the proxyportlet factory after initializing */
     private static ProxyPersistentFactory proxyPersistentFactory;
-    // log and trace support
 
     /**
      * Fetches a server factory-instance.
@@ -78,8 +77,9 @@
     throws WSRPException {
 
         if (producerPersistentFactory == null) {
-            producerPersistentFactory = (ProducerPersistentFactory) getFactory(
-                    PRODUCER_PERSISTENT_FACTORY, PRODUCER_PROPERTIES);
+            producerPersistentFactory = 
+                    (ProducerPersistentFactory)
+                    getFactory(PRODUCER_PERSISTENT_FACTORY);
         }
         
         if (log.isDebugEnabled()) {
@@ -100,8 +100,9 @@
     throws WSRPException {
 
         if (consumerPersistentFactory == null) {
-            consumerPersistentFactory = (ConsumerPersistentFactory) getFactory(
-                    CONSUMER_PERSISTENT_FACTORY, CONSUMER_PROPERTIES);
+            consumerPersistentFactory =
+                    (ConsumerPersistentFactory)
+                    getFactory(CONSUMER_PERSISTENT_FACTORY);
         }
 
         if (log.isDebugEnabled()) {
@@ -115,8 +116,9 @@
     throws WSRPException {
 
         if (proxyPersistentFactory == null) {
-            proxyPersistentFactory = (ProxyPersistentFactory) getFactory(
-                    PROXY_PERSISTENT_FACTORY, PROXY_PROPERTIES);
+            proxyPersistentFactory = 
+                    (ProxyPersistentFactory) 
+                    getFactory(PROXY_PERSISTENT_FACTORY);
         }
 
         if (log.isDebugEnabled()) {
@@ -135,15 +137,15 @@
      *            name of the property file as string value
      * @throws WSRPException
      */
-    private static Object getFactory(String type, String propertyFile) 
+    private static Object getFactory(String type) 
     throws WSRPException {
 
         Object obj = null;
 
         try {
-            loadPropertyFile(propertyFile);
-
-            String factoryName = (String) pFactories.get(type);
+            
+            String factoryName =
+                    ConfigurationParametersManager.getParameter(type);
 
             Class cl = Class.forName(factoryName);
 
@@ -160,40 +162,4 @@
         return obj;
     }
 
-    /**
-     * Loads the content of a properties file into a private Properties object.
-     * The properties file to load contains the factory information.
-     * 
-     * @param propertyFile
-     *            name of the property file as string value
-     * @throws WSRPException
-     */
-    private static void loadPropertyFile(String propertyFile) 
-    throws WSRPException {
-
-        try {
-            // read in .properties-file
-            InputStream in = getThisClass().getClassLoader().getResourceAsStream(propertyFile);
-            pFactories = new Properties();
-            pFactories.load(in);
-            
-            if (log.isDebugEnabled()) {
-                log.debug("Successfully loaded property file: " + propertyFile);
-            }
-
-        } catch (Exception e) {
-            WSRPXHelper.throwX(log, ErrorCodes.PROPERTY_FILE_NOT_FOUND, e);
-        }
-    }
-
-    /**
-     * Returns the class object of PersistentrAccess
-     * 
-     * @return java.lang.Class
-     */
-    private static Class getThisClass() {
-
-        return PersistentAccess.class;
-
-    }
 }



Mime
View raw message