aboutsummaryrefslogtreecommitdiff
path: root/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java
diff options
context:
space:
mode:
Diffstat (limited to 'spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java')
-rw-r--r--spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java121
1 files changed, 121 insertions, 0 deletions
diff --git a/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java b/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java
new file mode 100644
index 000000000..fb5f2cb21
--- /dev/null
+++ b/spss/server/serverlib/src/main/java/at/gv/egovernment/moa/spss/server/init/SystemInitializer.java
@@ -0,0 +1,121 @@
+/*
+* Copyright 2003 Federal Chancellery Austria
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egovernment.moa.spss.server.init;
+
+import java.io.IOException;
+
+import iaik.ixsil.init.IXSILInit;
+
+import at.gv.egovernment.moa.logging.LogMsg;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.logging.LoggingContext;
+import at.gv.egovernment.moa.logging.LoggingContextManager;
+import at.gv.egovernment.moa.util.Constants;
+import at.gv.egovernment.moa.util.DOMUtils;
+
+import at.gv.egovernment.moa.spss.MOAException;
+import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider;
+import at.gv.egovernment.moa.spss.server.iaik.config.IaikConfigurator;
+import at.gv.egovernment.moa.spss.server.logging.IaikLog;
+import at.gv.egovernment.moa.spss.server.service.RevocationArchiveCleaner;
+import at.gv.egovernment.moa.spss.util.MessageProvider;
+
+/**
+ * MOA SP/SS web service initialization.
+ *
+ * @author Patrick Peck
+ * @version $Id$
+ */
+public class SystemInitializer {
+ /** Interval between archive cleanups in seconds */
+ private static final long ARCHIVE_CLEANUP_INTERVAL = 60 * 60; // 1h
+ /** The MOA SP/SS logging hierarchy. */
+ private static final String LOGGING_HIERARCHY = "moa.spss.server";
+ /** Whether XML schema grammars have been initialized. */
+ private static boolean grammarsInitialized = false;
+
+ /**
+ * Initialize the MOA SP/SS webservice.
+ */
+ public static void init() {
+ MessageProvider msg = MessageProvider.getInstance();
+
+ Thread archiveCleaner;
+
+ // set up the MOA SPSS logging hierarchy
+ Logger.setHierarchy(LOGGING_HIERARCHY);
+
+ // set up a logging context for logging the startup
+ LoggingContextManager.getInstance().setLoggingContext(
+ new LoggingContext("startup"));
+
+// AxisProperties.setProperty("enableNamespacePrefixOptimization","false");
+// AxisProperties.setProperty("disablePrettyXML", "true");
+// AxisProperties.setProperty("axis.doAutoTypes", "true");
+
+ // initialize preparsed Xerces grammar pool for faster XML
+ // parsing/validating
+ try {
+ if (!grammarsInitialized) {
+ Class clazz = SystemInitializer.class;
+ // preparse XML schema
+ DOMUtils.addSchemaToPool(
+ clazz.getResourceAsStream(Constants.XML_SCHEMA_LOCATION),
+ Constants.XML_NS_URI);
+ // preparse XMLDsig Filter2 schema
+ DOMUtils.addSchemaToPool(
+ clazz.getResourceAsStream(Constants.DSIG_FILTER2_SCHEMA_LOCATION),
+ Constants.DSIG_FILTER2_NS_URI);
+ // preparse XMLDsig schema
+ DOMUtils.addSchemaToPool(
+ clazz.getResourceAsStream(Constants.DSIG_SCHEMA_LOCATION),
+ Constants.DSIG_NS_URI);
+ // preparse MOA schema
+ DOMUtils.addSchemaToPool(
+ clazz.getResourceAsStream(Constants.MOA_SCHEMA_LOCATION),
+ Constants.MOA_NS_URI);
+ grammarsInitialized = true;
+ }
+ } catch (IOException e) {
+ Logger.warn(new LogMsg(msg.getMessage("init.04", null)), e);
+ }
+
+ // initialize configuration
+ try {
+ ConfigurationProvider config = ConfigurationProvider.getInstance();
+ new IaikConfigurator().configure(config);
+ Logger.info(new LogMsg(msg.getMessage("init.01", null)));
+ } catch (MOAException e) {
+ Logger.fatal(new LogMsg(msg.getMessage("init.00", null)), e);
+ }
+
+ // set IXSIL debug output
+ IXSILInit.setPrintDebugLog(
+ Logger.isDebugEnabled(IaikLog.IAIK_LOG_HIERARCHY));
+
+ // start the archive cleanup thread
+ archiveCleaner =
+ new Thread(new RevocationArchiveCleaner(ARCHIVE_CLEANUP_INTERVAL));
+ archiveCleaner.setName("RevocationArchiveCleaner");
+ archiveCleaner.setDaemon(true);
+ archiveCleaner.setPriority(Thread.MIN_PRIORITY);
+ archiveCleaner.start();
+
+ // unset the startup logging context
+ LoggingContextManager.getInstance().setLoggingContext(null);
+ }
+
+}