1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package fi.vtt.simantics.procore;
13 import java.io.IOException;
14 import java.util.Properties;
16 import org.simantics.db.SessionManager;
17 import org.simantics.db.procore.protocol.Constants;
19 import fi.vtt.simantics.procore.internal.SessionManagerFactory;
20 import fi.vtt.simantics.procore.internal.SessionManagerFactoryImpl;
22 public final class SessionManagerSource {
24 public static final long NullSessionId = Constants.NullSessionId;
25 public static final long NullTransactionId = Constants.NullTransactionId;
26 public static final long NullSubjectId = Constants.NullSubjectId;
28 private static SessionManager defaultSessionManager = null;
31 * @param loggerProperties
35 public static synchronized SessionManager getSessionManager(Properties loggerProperties) throws IOException {
36 if (defaultSessionManager == null) {
37 SessionManagerFactory factory = SessionManagerFactoryImpl.getInstance();
38 defaultSessionManager = factory.createSessionManager();
40 return defaultSessionManager;
47 public static synchronized SessionManager getSessionManager() throws IOException {
48 return getSessionManager(nullProperties);
54 public static synchronized void shutdown() {
55 SessionManagerFactoryImpl.finish();
60 * Properties with the default null logger settings.
62 public static Properties nullProperties = new Properties();
64 nullProperties.put("log4j.rootCategory", "INFO, default");
65 nullProperties.put("log4j.appender.default", "org.apache.log4j.varia.NullAppender");