]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued with project:
authorRoland Haeder <roland@mxchange.org>
Wed, 12 Aug 2015 11:48:30 +0000 (13:48 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 12 Aug 2015 11:48:30 +0000 (13:48 +0200)
- Added database.backend.storagepath for file-based database backends (very simple)
- Used getRealPath() to get server's full web path, but went 2 up to get away from web-reachable path
- Added catching of more thrown exceptions
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java
src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java
web/WEB-INF/web.xml

index 0e0e754137d467df1df9eb94b69189cbb98540f4..e85b321e09f6ff025439435419450336f06def10 100644 (file)
@@ -40,10 +40,19 @@ public class BasePizzaServiceSystem extends BaseFrameworkSystem {
                        this.getLogger().debug(MessageFormat.format("name={0}", name));
 
                        // Get value
-                       String value = context.getInitParameter(name).trim();
+                       String value = context.getInitParameter(name);
+
+                       // Is it null?
+                       if (value == null) {
+                               // Value is null
+                               throw new NullPointerException(MessageFormat.format("value for {0} is null, maybe invalid context parameter?", name));
+                       } else if (name.equals("database.backend.storagepath")) {
+                               // Need to expand this path
+                               value = context.getRealPath(String.format("../../%s", value.trim()));
+                       }
 
                        // Debug log
-                       this.getLogger().debug(MessageFormat.format("{0}={1}", name, value));
+                       this.getLogger().debug(MessageFormat.format("{0}={1}", name, value.trim()));
 
                        // Set property
                        this.setProperty(name, value);
index c86e9328767a620ce8ea408e2bdd7f09f27a6404..06487532140d90e50ce9c661a9fe46311dad7c49 100644 (file)
@@ -18,6 +18,7 @@ package org.mxchange.pizzaapplication.application;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.sql.SQLException;
 import java.text.MessageFormat;
 import java.util.Iterator;
@@ -1128,7 +1129,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P
                try {
                        // Get iterator on all its fields
                        it = customer.iterator();
-               } catch (final NoSuchMethodException ex) {
+               } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
                        this.abortProgramWithException(ex);
                }
 
index 74f53fce0a52f6405a2ad34ec05ed026d3253719..a3b06d4352dd11fa8778e8075cf634845e40027b 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.pizzaapplication.customer.bean;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Iterator;
 import java.util.Map;
 import org.mxchange.jcore.client.Client;
@@ -244,7 +245,7 @@ public class PizzaServiceCustomerBean extends BasePizzaServiceSystem implements
        }
 
        @Override
-       public Iterator<Map.Entry<Field, Object>> iterator () throws NoSuchMethodException {
+       public Iterator<Map.Entry<Field, Object>> iterator () throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
                // Deligate to "hidden" object
                return this.getContact().iterator();
        }
index 2676cd9a34568aab97c392adedace0413623f2a8..ee0a8d0dd55000e3abe07b3b5f85ec84d42c3cbe 100644 (file)
         <param-name>database.mysql.dbname</param-name>
         <param-value>test</param-value>
     </context-param>
+    <context-param>
+        <description>Data path for file-based database backends. This must be a relative path and it will reside 2 levels up from the server's web path.</description>
+        <param-name>database.backend.storagepath</param-name>
+        <param-value>data</param-value>
+    </context-param>
     <filter>
         <description>A filter for setting character encoding to UTF-8</description>
         <filter-name>Utf8HttpFilter</filter-name>