]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java
Better compare this way:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / BasePizzaServiceSystem.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.pizzaapplication;
18
19 import java.text.MessageFormat;
20 import javax.servlet.ServletContext;
21 import org.mxchange.jcore.BaseFrameworkSystem;
22
23 /**
24  * A general class for whole pizza application.
25  *
26  * @author Roland Haeder
27  */
28 public class BasePizzaServiceSystem extends BaseFrameworkSystem {
29         /**
30          * Initializes properties from given servlet configuration
31          * @param context Servlet context instance
32          */
33         protected void initProperties (final ServletContext context) {
34                 // Trace message
35                 this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); //NOI18N
36
37                 // We need some properties that needs to be set
38                 for (final String name : this.getPropertyNames()) {
39                         // Debug log
40                         this.getLogger().debug(MessageFormat.format("name={0}", name)); //NOI18N
41
42                         // Get value
43                         String value = context.getInitParameter(name);
44
45                         // Debug message
46                         this.getLogger().debug(MessageFormat.format("value={0}", value)); //NOI18N
47
48                         // Is it null?
49                         if (null == value) {
50                                 // Value is null
51                                 throw new NullPointerException(MessageFormat.format("value for {0} is null, maybe invalid context parameter?", name)); //NOI18N
52                         } else if (name.equals("database.backend.storagepath")) { //NOI18N
53                                 // Need to expand this path
54                                 value = context.getRealPath(String.format("../../%s", value.trim())); //NOI18N
55                         }
56
57                         // Debug log
58                         this.getLogger().debug(MessageFormat.format("{0}={1}", name, value)); //NOI18N
59
60                         // Set property
61                         this.setProperty(name, value);
62                 }
63
64                 // Trace message
65                 this.getLogger().trace("EXIT!"); //NOI18N
66         }
67 }