X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.management%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fmanagement%2Finternal%2FSessionManagerProvider.java;fp=bundles%2Forg.simantics.db.management%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fmanagement%2Finternal%2FSessionManagerProvider.java;h=81967124d6562b78919ea8e994219eb7ebc7a57b;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=6b9bc68ca3b9e79e461ca6665d648704a91999b6;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java b/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java index 6b9bc68ca..81967124d 100644 --- a/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java +++ b/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java @@ -1,68 +1,68 @@ -/******************************************************************************* - * 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; - } - -} +/******************************************************************************* + * 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; + } + +}