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%2FSessionContext.java;h=dae8bea7545184cbf7faf82dbc76f6ababa8ab35;hp=ef5f270531021b890888c3016ae2f08e8ed096f9;hb=627664d06302d454ea3b3fe14d13bb5ab739d666;hpb=eae2657463e387cb764e7e5780d5c56f5311c0af diff --git a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java index ef5f27053..dae8bea75 100644 --- a/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java +++ b/bundles/org.simantics.db.management/src/org/simantics/db/management/SessionContext.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.simantics.db.management; -import java.io.IOException; import java.lang.reflect.Method; import java.util.Arrays; import java.util.UUID; @@ -20,17 +19,12 @@ import java.util.concurrent.TimeoutException; import org.eclipse.core.runtime.IStatus; import org.simantics.db.Disposable; import org.simantics.db.ReadGraph; -import org.simantics.db.ServerReference; import org.simantics.db.Session; -import org.simantics.db.SessionManager; -import org.simantics.db.SessionReference; import org.simantics.db.VirtualGraph; -import org.simantics.db.authentication.UserAuthenticationAgent; import org.simantics.db.common.processor.MergingDelayedWriteProcessor; import org.simantics.db.common.processor.MergingGraphRequestProcessor; import org.simantics.db.common.request.ReadRequest; import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.InternalException; import org.simantics.db.management.internal.Activator; import org.simantics.db.service.LifecycleSupport; import org.simantics.db.service.VirtualGraphSupport; @@ -43,10 +37,6 @@ import org.simantics.utils.datastructures.hints.HintContext; import org.simantics.utils.threads.IThreadWorkQueue; import org.simantics.utils.threads.SyncListenerList; -import fi.vtt.simantics.procore.ProCoreServerReference; -import fi.vtt.simantics.procore.ProCoreSessionReference; -import fi.vtt.simantics.procore.SessionManagerSource; - /** * Holds all information that is needed to create and manage a single database * session in the Simantics workbench UI. @@ -62,8 +52,6 @@ public class SessionContext extends HintContext implements ISessionContext, Disp private Session session; - private UserAuthenticationAgent authenticator; - private boolean servicesRegistered = false; private IStatus servicesRegisteredStatus = null; @@ -72,72 +60,12 @@ public class SessionContext extends HintContext implements ISessionContext, Disp return new SessionContext(session, initialize); } -// public static SessionContext openSession(IServerAddress info, UserAuthenticationAgent auth) throws IOException, DatabaseException { -// return new SessionContext(info, auth, false); -// } -// -// public static SessionContext openAndInitializeSession(IServerAddress info, UserAuthenticationAgent auth) throws IOException, DatabaseException { -// return new SessionContext(info, auth, true); -// } - - private static SessionReference createSessionReference(/*IServerAddress address,*/ long sessionId) throws InternalException { - ProCoreServerReference server = new ProCoreServerReference(); - ProCoreSessionReference ref = new ProCoreSessionReference(server, sessionId); - return ref; - } - -// private SessionContext(IServerAddress addr, UserAuthenticationAgent auth, boolean initialize) throws IOException, DatabaseException { -// if (addr == null) -// throw new IllegalArgumentException("null address"); -//// this.address = addr; -// this.authenticator = auth; -// -// SessionManager sessionManager = SessionManagerProvider.getInstance().getSessionManager(); -// -// if (initialize) { -// initializeSession(sessionManager); -// if (SESSION_DEBUG) { -// System.err.println("Initialized session: " + addr); -// System.err.flush(); -// } -// } else { -// SessionReference ref = createSessionReference(SessionManagerSource.NullSessionId); -// this.session = sessionManager.createSession(ref, auth); -// if (SESSION_DEBUG) { -// System.err.println("Opened session: " + addr); -// System.err.flush(); -// } -// } -// -// } - private SessionContext(Session session, boolean initialize) throws DatabaseException { if (initialize) initializeSession(session); - ServerReference ref = session.getService( LifecycleSupport.class ).getSessionReference().getServerReference(); -// this.address = ref.serverAddress(); this.session = session; } - private void initializeSession(SessionManager sessionManager) throws DatabaseException, IOException { - Session s = null; - boolean success = false; - try { - SessionReference ref = createSessionReference(SessionManagerSource.NullSessionId); - s = sessionManager.createSession(ref, authenticator); - initializeSession(s); - this.session = s; - success = true; - } finally { - if (!success) { - if (s != null) { - LifecycleSupport support = s.getService(LifecycleSupport.class); - support.close(); - } - } - } - } - private void initializeSession(Session s) throws DatabaseException { s.registerService(MergingGraphRequestProcessor.class, new MergingGraphRequestProcessor("SessionService", s, 20)); s.registerService(MergingDelayedWriteProcessor.class, new MergingDelayedWriteProcessor(s, 20));