Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java')
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
new file mode 100644
index 0000000000..d299f99afc
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/SessionManager.java
@@ -0,0 +1,85 @@
+/***************************************************************************
+ * Copyright (c) 2004-2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.internal.server;
+
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.server.bundle.CDOServer;
+import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocol;
+import org.eclipse.emf.cdo.server.ISessionManager;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class SessionManager implements ISessionManager
+{
+ private static final ContextTracer TRACER = new ContextTracer(CDOServer.DEBUG_SESSION, SessionManager.class);
+
+ private Repository repository;
+
+ private Map<Integer, Session> sessions = new HashMap();
+
+ private int lastSessionID;
+
+ public SessionManager(Repository repository)
+ {
+ this.repository = repository;
+ }
+
+ public Repository getRepository()
+ {
+ return repository;
+ }
+
+ public Session[] getSessions()
+ {
+ synchronized (sessions)
+ {
+ return sessions.values().toArray(new Session[sessions.size()]);
+ }
+ }
+
+ public Session openSession(CDOServerProtocol protocol)
+ {
+ int id = ++lastSessionID;
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Opening session " + id);
+ }
+
+ Session session = new Session(this, protocol, id);
+ synchronized (sessions)
+ {
+ sessions.put(id, session);
+ }
+
+ return session;
+ }
+
+ public void sessionClosed(Session session)
+ {
+ }
+
+ public void notifyInvalidation(long timeStamp, CDORevisionImpl[] dirtyObjects, Session excludedSession)
+ {
+ for (Session session : getSessions())
+ {
+ if (session != excludedSession)
+ {
+ session.notifyInvalidation(timeStamp, dirtyObjects);
+ }
+ }
+ }
+}

Back to the top