1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 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 org.simantics.db.management.internal;
14 import java.io.InputStream;
16 import java.util.Properties;
18 import org.eclipse.core.runtime.Platform;
19 import org.osgi.framework.Bundle;
20 import org.simantics.db.SessionManager;
21 import org.simantics.utils.FileUtils;
24 * Complete hack for the time being. Simply provides the SessionManager behind
25 * procore's SessionManagerSource with proper initialization.
27 public final class SessionManagerProvider {
29 // TODO: move this into BundleContext as a service ?
30 private static SessionManagerProvider provider;
32 private SessionManager sessionManager;
34 public static SessionManagerProvider getInstance() {
36 provider = new SessionManagerProvider();
40 // public SessionManager getSessionManager() throws IOException {
41 // if (sessionManager == null) {
42 // sessionManager = SessionManagerSource.getSessionManager(loadProperties());
44 // return sessionManager;
47 private Properties loadProperties() {
48 Bundle procore = Platform.getBundle("org.simantics.db.procore");
49 URL url = procore.getResource("log4j.properties");
51 InputStream in = null;
53 in = url.openStream();
54 Properties props = new Properties();
57 } catch (Exception e) {
59 FileUtils.uncheckedClose(in);