From: Roland Haeder Date: Wed, 12 Aug 2015 11:48:30 +0000 (+0200) Subject: Continued with project: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ce1a767bf2510303a75386ce4ec43dc24113195f;p=pizzaservice-war.git Continued with project: - 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 --- diff --git a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java index 0e0e7541..e85b321e 100644 --- a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java +++ b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java @@ -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); diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index c86e9328..06487532 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -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); } diff --git a/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java b/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java index 74f53fce..a3b06d43 100644 --- a/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java +++ b/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java @@ -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> iterator () throws NoSuchMethodException { + public Iterator> iterator () throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { // Deligate to "hidden" object return this.getContact().iterator(); } diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 2676cd9a..ee0a8d0d 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -25,6 +25,11 @@ database.mysql.dbname test + + 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. + database.backend.storagepath + data + A filter for setting character encoding to UTF-8 Utf8HttpFilter