-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.db.management.internal;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.net.URL;\r
-import java.util.Properties;\r
-\r
-import org.eclipse.core.runtime.Platform;\r
-import org.osgi.framework.Bundle;\r
-import org.simantics.db.SessionManager;\r
-import org.simantics.utils.FileUtils;\r
-\r
-import fi.vtt.simantics.procore.SessionManagerSource;\r
-\r
-/**\r
- * Complete hack for the time being. Simply provides the SessionManager behind\r
- * procore's SessionManagerSource with proper initialization.\r
- */\r
-public final class SessionManagerProvider {\r
-\r
- // TODO: move this into BundleContext as a service ?\r
- private static SessionManagerProvider provider;\r
-\r
- private SessionManager sessionManager;\r
-\r
- public static SessionManagerProvider getInstance() {\r
- if (provider == null)\r
- provider = new SessionManagerProvider();\r
- return provider;\r
- }\r
-\r
- public SessionManager getSessionManager() throws IOException {\r
- if (sessionManager == null) {\r
- sessionManager = SessionManagerSource.getSessionManager(loadProperties());\r
- }\r
- return sessionManager;\r
- }\r
-\r
- private Properties loadProperties() {\r
- Bundle procore = Platform.getBundle("org.simantics.db.procore");\r
- URL url = procore.getResource("log4j.properties");\r
- if (url != null) {\r
- InputStream in = null;\r
- try {\r
- in = url.openStream();\r
- Properties props = new Properties();\r
- props.load(in);\r
- return props;\r
- } catch (Exception e) {\r
- } finally {\r
- FileUtils.uncheckedClose(in);\r
- }\r
- }\r
- return null;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.management.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+import org.simantics.db.SessionManager;
+import org.simantics.utils.FileUtils;
+
+import fi.vtt.simantics.procore.SessionManagerSource;
+
+/**
+ * Complete hack for the time being. Simply provides the SessionManager behind
+ * procore's SessionManagerSource with proper initialization.
+ */
+public final class SessionManagerProvider {
+
+ // TODO: move this into BundleContext as a service ?
+ private static SessionManagerProvider provider;
+
+ private SessionManager sessionManager;
+
+ public static SessionManagerProvider getInstance() {
+ if (provider == null)
+ provider = new SessionManagerProvider();
+ return provider;
+ }
+
+ public SessionManager getSessionManager() throws IOException {
+ if (sessionManager == null) {
+ sessionManager = SessionManagerSource.getSessionManager(loadProperties());
+ }
+ return sessionManager;
+ }
+
+ private Properties loadProperties() {
+ Bundle procore = Platform.getBundle("org.simantics.db.procore");
+ URL url = procore.getResource("log4j.properties");
+ if (url != null) {
+ InputStream in = null;
+ try {
+ in = url.openStream();
+ Properties props = new Properties();
+ props.load(in);
+ return props;
+ } catch (Exception e) {
+ } finally {
+ FileUtils.uncheckedClose(in);
+ }
+ }
+ return null;
+ }
+
+}