X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;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=0000000000000000000000000000000000000000;hp=81967124d6562b78919ea8e994219eb7ebc7a57b;hb=c61c54a6d841c663bd43b40577fe469bffa15453;hpb=342a2b006b88330280060c16c2ab50374468a4c6 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 deleted file mode 100644 index 81967124d..000000000 --- a/bundles/org.simantics.db.management/src/org/simantics/db/management/internal/SessionManagerProvider.java +++ /dev/null @@ -1,68 +0,0 @@ -/******************************************************************************* - * 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; - } - -}