2 * Copyright (C) 2015 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.jsfcore;
19 import java.text.MessageFormat;
20 import javax.servlet.ServletContext;
21 import org.mxchange.jcore.BaseFrameworkSystem;
24 * A general shop class
25 * @author Roland Haeder
27 public class BaseServletSystem extends BaseFrameworkSystem {
29 * Initializes properties from given servlet configuration
30 * @param context Servlet context instance
32 protected void initProperties (final ServletContext context) {
34 this.getLogger().trace(MessageFormat.format("context={0} - CALLED!", context)); //NOI18N
36 // context shall not be null
37 if (null == context) {
39 throw new NullPointerException("context is null"); //NOI18N
42 // We need some properties that needs to be set
43 for (final String name : this.getPropertyNames()) {
45 this.getLogger().debug(MessageFormat.format("name={0}", name)); //NOI18N
48 String value = context.getInitParameter(name);
51 this.getLogger().debug(MessageFormat.format("value={0}", value)); //NOI18N
56 throw new NullPointerException(MessageFormat.format("value for {0} is null, maybe invalid context parameter?", name)); //NOI18N
57 } else if (name.equals("database.backend.storagepath")) { //NOI18N
58 // Need to expand this path
59 value = context.getRealPath(String.format("../../%s", value.trim())); //NOI18N
63 this.getLogger().debug(MessageFormat.format("{0}={1}", name, value)); //NOI18N
66 this.setProperty(name, value);
70 this.getLogger().trace("EXIT!"); //NOI18N