]> git.mxchange.org Git - pizzaservice-war.git/blobdiff - src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java
Added more thrown exceptions
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / BasePizzaServiceSystem.java
index 84f1e1c5a7b65fb9e889b7d3121d699358171093..031f2f92997823dd4d4470b6bef28abd46210933 100644 (file)
@@ -16,6 +16,8 @@
  */
 package org.mxchange.pizzaapplication;
 
+import java.text.MessageFormat;
+import javax.servlet.ServletContext;
 import org.mxchange.jcore.BaseFrameworkSystem;
 
 /**
@@ -24,5 +26,42 @@ import org.mxchange.jcore.BaseFrameworkSystem;
  * @author Roland Haeder
  */
 public class BasePizzaServiceSystem extends BaseFrameworkSystem {
-       
+       /**
+        * Initializes properties from given servlet configuration
+        * @param context Servlet context instance
+        */
+       protected void initProperties (final ServletContext context) {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context));
+
+               // We need some properties that needs to be set
+               for (final String name : this.getPropertyNames()) {
+                       // Debug log
+                       this.getLogger().debug(MessageFormat.format("name={0}", name));
+
+                       // Get value
+                       String value = context.getInitParameter(name);
+
+                       // Debug message
+                       this.getLogger().debug(MessageFormat.format("value={0}", value));
+
+                       // 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));
+
+                       // Set property
+                       this.setProperty(name, value);
+               }
+
+               // Trace message
+               this.getLogger().trace("EXIT!");
+       }
 }