diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java | 192 |
1 files changed, 127 insertions, 65 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java index e627d0351b..9817b3fce6 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java @@ -58,11 +58,14 @@ import org.eclipse.emf.cdo.session.CDORepositoryInfo; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent; import org.eclipse.emf.cdo.session.remote.CDORemoteSession; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionManager; import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; import org.eclipse.emf.cdo.spi.common.CDORawReplicationContext; import org.eclipse.emf.cdo.spi.common.CDOReplicationContext; import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo; +import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; import org.eclipse.emf.cdo.spi.common.model.CDOLobStoreImpl; import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; @@ -78,6 +81,7 @@ import org.eclipse.emf.cdo.view.CDOView; import org.eclipse.emf.internal.cdo.CDOFactoryImpl; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.emf.internal.cdo.messages.Messages; +import org.eclipse.emf.internal.cdo.session.remote.CDORemoteSessionManagerImpl; import org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl; import org.eclipse.emf.internal.cdo.view.CDOViewImpl; @@ -118,7 +122,6 @@ import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult; import org.eclipse.emf.spi.cdo.InternalCDOObject; import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager; import org.eclipse.emf.spi.cdo.InternalCDOSession; -import org.eclipse.emf.spi.cdo.InternalCDOSessionConfiguration; import org.eclipse.emf.spi.cdo.InternalCDOTransaction; import org.eclipse.emf.spi.cdo.InternalCDOView; import org.eclipse.emf.spi.cdo.InternalCDOViewSet; @@ -149,10 +152,16 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, CDOSessionImpl.class); - private InternalCDOSessionConfiguration configuration; - private ExceptionHandler exceptionHandler; + private InternalCDOPackageRegistry packageRegistry; + + private InternalCDOBranchManager branchManager; + + private InternalCDORevisionManager revisionManager; + + private InternalCDOCommitInfoManager commitInfoManager; + private CDOSessionProtocol sessionProtocol; @ExcludeFromDump @@ -210,14 +219,8 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter @ExcludeFromDump private int lastViewID; - public CDOSessionImpl(InternalCDOSessionConfiguration configuration) + public CDOSessionImpl() { - this.configuration = configuration; - } - - public InternalCDOSessionConfiguration getConfiguration() - { - return configuration; } public CDORepositoryInfo getRepositoryInfo() @@ -261,20 +264,44 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter this.exceptionHandler = exceptionHandler; } - /** - * @since 2.0 - */ - public CDOSession.Options options() + public InternalCDOPackageRegistry getPackageRegistry() { - return options; + return packageRegistry; } - /** - * @since 2.0 - */ - protected CDOSession.Options createOptions() + public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry) { - return new OptionsImpl(); + this.packageRegistry = packageRegistry; + } + + public InternalCDOBranchManager getBranchManager() + { + return branchManager; + } + + public void setBranchManager(InternalCDOBranchManager branchManager) + { + this.branchManager = branchManager; + } + + public InternalCDORevisionManager getRevisionManager() + { + return revisionManager; + } + + public void setRevisionManager(InternalCDORevisionManager revisionManager) + { + this.revisionManager = revisionManager; + } + + public InternalCDOCommitInfoManager getCommitInfoManager() + { + return commitInfoManager; + } + + public void setCommitInfoManager(InternalCDOCommitInfoManager commitInfoManager) + { + this.commitInfoManager = commitInfoManager; } public CDOSessionProtocol getSessionProtocol() @@ -287,6 +314,42 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter this.sessionProtocol = sessionProtocol; } + /** + * @since 3.0 + */ + public CDOFetchRuleManager getFetchRuleManager() + { + return ruleManager; + } + + /** + * @since 3.0 + */ + public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager) + { + ruleManager = fetchRuleManager; + } + + public CDOAuthenticator getAuthenticator() + { + return authenticator; + } + + public void setAuthenticator(CDOAuthenticator authenticator) + { + this.authenticator = authenticator; + } + + public InternalCDORemoteSessionManager getRemoteSessionManager() + { + return remoteSessionManager; + } + + public void setRemoteSessionManager(InternalCDORemoteSessionManager remoteSessionManager) + { + this.remoteSessionManager = remoteSessionManager; + } + public CDOLobStore getLobStore() { final CDOLobStore cache = options().getLobCache(); @@ -314,7 +377,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter } } } - + @Override public Reader getCharacter(CDOLobInfo info) throws IOException { @@ -337,12 +400,12 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter } } } - + private void loadBinary(final CDOLobInfo info) throws IOException { final File file = getDelegate().getBinaryFile(info.getID()); final FileOutputStream out = new FileOutputStream(file); - + loadLobAsync(info, new Runnable() { public void run() @@ -359,12 +422,12 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter } }); } - + private void loadCharacter(final CDOLobInfo info) throws IOException { final File file = getDelegate().getCharacterFile(info.getID()); final FileWriter out = new FileWriter(file); - + loadLobAsync(info, new Runnable() { public void run() @@ -381,7 +444,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter } }); } - + @Override protected CDOLobStore getDelegate() { @@ -408,6 +471,22 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter return !isActive(); } + /** + * @since 2.0 + */ + public CDOSession.Options options() + { + return options; + } + + /** + * @since 2.0 + */ + protected CDOSession.Options createOptions() + { + return new OptionsImpl(); + } + public Object processPackage(Object value) { CDOFactoryImpl.prepareDynamicEPackage(value); @@ -423,7 +502,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter throw new CDOException(MessageFormat.format(Messages.getString("CDOSessionImpl.0"), packageUnit)); //$NON-NLS-1$ } } - + return getSessionProtocol().loadPackages(packageUnit); } @@ -444,42 +523,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter lockmanager.unlock(LockType.WRITE, key, singletonCollection); } - /** - * @since 3.0 - */ - public CDOFetchRuleManager getFetchRuleManager() - { - return ruleManager; - } - - /** - * @since 3.0 - */ - public void setFetchRuleManager(CDOFetchRuleManager fetchRuleManager) - { - ruleManager = fetchRuleManager; - } - - public CDOAuthenticator getAuthenticator() - { - return authenticator; - } - - public void setAuthenticator(CDOAuthenticator authenticator) - { - this.authenticator = authenticator; - } - - public InternalCDORemoteSessionManager getRemoteSessionManager() - { - return remoteSessionManager; - } - - public void setRemoteSessionManager(InternalCDORemoteSessionManager remoteSessionManager) - { - this.remoteSessionManager = remoteSessionManager; - } - public InternalCDOTransaction openTransaction(CDOBranch branch, ResourceSet resourceSet) { checkActive(); @@ -1128,12 +1171,31 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter protected void doActivate() throws Exception { super.doActivate(); - getConfiguration().activateSession(this); + activateSession(); checkState(sessionProtocol, "sessionProtocol"); //$NON-NLS-1$ checkState(remoteSessionManager, "remoteSessionManager"); //$NON-NLS-1$ hookSessionProtocol(); } + protected void activateSession() throws Exception + { + InternalCDORemoteSessionManager remoteSessionManager = new CDORemoteSessionManagerImpl(); + remoteSessionManager.setLocalSession(this); + setRemoteSessionManager(remoteSessionManager); + remoteSessionManager.activate(); + } + + protected void deactivateSession() throws Exception + { + CDORemoteSessionManager remoteSessionManager = getRemoteSessionManager(); + setRemoteSessionManager(null); + LifecycleUtil.deactivate(remoteSessionManager); + + CDOSessionProtocol sessionProtocol = getSessionProtocol(); + LifecycleUtil.deactivate(sessionProtocol); + setSessionProtocol(null); + } + @Override protected void doDeactivate() throws Exception { @@ -1157,7 +1219,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter } unhookSessionProtocol(); - getConfiguration().deactivateSession(this); + deactivateSession(); super.doDeactivate(); } |