- 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>
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);
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;
try {
// Get iterator on all its fields
it = customer.iterator();
- } catch (final NoSuchMethodException ex) {
+ } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
this.abortProgramWithException(ex);
}
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;
}
@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();
}
<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>