diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo')
79 files changed, 6602 insertions, 6602 deletions
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java index 06a7f3f059..a1b399775d 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDONet4jSessionConfigurationImpl.java @@ -1,300 +1,300 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.net4j.CDONet4jSession;
-import org.eclipse.emf.cdo.net4j.CDOSession;
-import org.eclipse.emf.cdo.session.CDORepositoryInfo;
-
-import org.eclipse.emf.internal.cdo.session.CDOSessionConfigurationImpl;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.io.IStreamWrapper;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RepositoryTimeResult;
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-@SuppressWarnings("deprecation")
-public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImpl implements
- org.eclipse.emf.cdo.net4j.CDOSessionConfiguration
-{
- private String repositoryName;
-
- private IConnector connector;
-
- private IStreamWrapper streamWrapper;
-
- private long signalTimeout = SignalProtocol.DEFAULT_TIMEOUT;
-
- public CDONet4jSessionConfigurationImpl()
- {
- }
-
- public String getRepositoryName()
- {
- return repositoryName;
- }
-
- public void setRepositoryName(String repositoryName)
- {
- this.repositoryName = repositoryName;
- }
-
- public IConnector getConnector()
- {
- return connector;
- }
-
- public void setConnector(IConnector connector)
- {
- checkNotOpen();
- uncheckedSetConnector(connector);
- }
-
- protected void uncheckedSetConnector(IConnector connector)
- {
- this.connector = connector;
- }
-
- public IStreamWrapper getStreamWrapper()
- {
- return streamWrapper;
- }
-
- public void setStreamWrapper(IStreamWrapper streamWrapper)
- {
- checkNotOpen();
- this.streamWrapper = streamWrapper;
- }
-
- public long getSignalTimeout()
- {
- return signalTimeout;
- }
-
- public void setSignalTimeout(long signalTimeout)
- {
- this.signalTimeout = signalTimeout;
- }
-
- public CDONet4jSession openNet4jSession()
- {
- return (CDONet4jSession)super.openSession();
- }
-
- @Override
- public CDOSession openSession()
- {
- return (CDOSession)openNet4jSession();
- }
-
- public InternalCDOSession createSession()
- {
- if (isActivateOnOpen())
- {
- CheckUtil.checkState(connector, "connector"); //$NON-NLS-1$
- }
-
- return new CDONet4jSessionImpl();
- }
-
- @Override
- protected void configureSession(InternalCDOSession session)
- {
- super.configureSession(session);
-
- CDONet4jSessionImpl sessionImpl = (CDONet4jSessionImpl)session;
- sessionImpl.setStreamWrapper(streamWrapper);
- sessionImpl.setConnector(connector);
- sessionImpl.setRepositoryName(repositoryName);
- sessionImpl.setSignalTimeout(signalTimeout);
- }
-
- /**
- * @author Eike Stepper
- */
- public static class RepositoryInfo implements CDORepositoryInfo
- {
- private String name;
-
- private String uuid;
-
- private Type type;
-
- private State state;
-
- private String storeType;
-
- private Set<CDOID.ObjectType> objectIDTypes;
-
- private long creationTime;
-
- private RepositoryTimeResult timeResult;
-
- private CDOID rootResourceID;
-
- private boolean supportingAudits;
-
- private boolean supportingBranches;
-
- private boolean supportingEcore;
-
- private boolean ensuringReferentialIntegrity;
-
- private IDGenerationLocation idGenerationLocation;
-
- private InternalCDOSession session;
-
- public RepositoryInfo(String name, OpenSessionResult result, InternalCDOSession session)
- {
- this.name = name;
- uuid = result.getRepositoryUUID();
- type = result.getRepositoryType();
- state = result.getRepositoryState();
- storeType = result.getStoreType();
- objectIDTypes = result.getObjectIDTypes();
- creationTime = result.getRepositoryCreationTime();
- timeResult = result.getRepositoryTimeResult();
- rootResourceID = result.getRootResourceID();
- supportingAudits = result.isRepositorySupportingAudits();
- supportingBranches = result.isRepositorySupportingBranches();
- supportingEcore = result.isRepositorySupportingEcore();
- ensuringReferentialIntegrity = result.isRepositoryEnsuringReferentialIntegrity();
- idGenerationLocation = result.getRepositoryIDGenerationLocation();
- this.session = session;
- }
-
- public String getName()
- {
- return name;
- }
-
- /**
- * Must be callable before session activation has finished!
- */
- public String getUUID()
- {
- return uuid;
- }
-
- public Type getType()
- {
- return type;
- }
-
- public void setType(Type type)
- {
- this.type = type;
- }
-
- public State getState()
- {
- return state;
- }
-
- public void setState(State state)
- {
- this.state = state;
- }
-
- public String getStoreType()
- {
- return storeType;
- }
-
- public Set<CDOID.ObjectType> getObjectIDTypes()
- {
- return objectIDTypes;
- }
-
- public long getCreationTime()
- {
- return creationTime;
- }
-
- public long getTimeStamp()
- {
- return getTimeStamp(false);
- }
-
- public long getTimeStamp(boolean forceRefresh)
- {
- if (timeResult == null || forceRefresh)
- {
- timeResult = refreshTime();
- }
-
- return timeResult.getAproximateRepositoryTime();
- }
-
- public CDOID getRootResourceID()
- {
- return rootResourceID;
- }
-
- public void setRootResourceID(CDOID rootResourceID)
- {
- // The rootResourceID may only be set if it is currently null
- if (this.rootResourceID == null || this.rootResourceID.isNull())
- {
- this.rootResourceID = rootResourceID;
- }
- else if (this.rootResourceID != null && this.rootResourceID.equals(rootResourceID))
- {
- // Do nothing; it is the same.
- }
- else
- {
- throw new IllegalStateException("rootResourceID must not be changed unless it is null");
- }
- }
-
- public boolean isSupportingAudits()
- {
- return supportingAudits;
- }
-
- public boolean isSupportingBranches()
- {
- return supportingBranches;
- }
-
- public boolean isSupportingEcore()
- {
- return supportingEcore;
- }
-
- public boolean isEnsuringReferentialIntegrity()
- {
- return ensuringReferentialIntegrity;
- }
-
- public IDGenerationLocation getIDGenerationLocation()
- {
- return idGenerationLocation;
- }
-
- private RepositoryTimeResult refreshTime()
- {
- return session.getSessionProtocol().getRepositoryTime();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.internal.net4j; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.net4j.CDONet4jSession; +import org.eclipse.emf.cdo.net4j.CDOSession; +import org.eclipse.emf.cdo.session.CDORepositoryInfo; + +import org.eclipse.emf.internal.cdo.session.CDOSessionConfigurationImpl; + +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.io.IStreamWrapper; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult; +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RepositoryTimeResult; +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +import java.util.Set; + +/** + * @author Eike Stepper + */ +@SuppressWarnings("deprecation") +public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImpl implements + org.eclipse.emf.cdo.net4j.CDOSessionConfiguration +{ + private String repositoryName; + + private IConnector connector; + + private IStreamWrapper streamWrapper; + + private long signalTimeout = SignalProtocol.DEFAULT_TIMEOUT; + + public CDONet4jSessionConfigurationImpl() + { + } + + public String getRepositoryName() + { + return repositoryName; + } + + public void setRepositoryName(String repositoryName) + { + this.repositoryName = repositoryName; + } + + public IConnector getConnector() + { + return connector; + } + + public void setConnector(IConnector connector) + { + checkNotOpen(); + uncheckedSetConnector(connector); + } + + protected void uncheckedSetConnector(IConnector connector) + { + this.connector = connector; + } + + public IStreamWrapper getStreamWrapper() + { + return streamWrapper; + } + + public void setStreamWrapper(IStreamWrapper streamWrapper) + { + checkNotOpen(); + this.streamWrapper = streamWrapper; + } + + public long getSignalTimeout() + { + return signalTimeout; + } + + public void setSignalTimeout(long signalTimeout) + { + this.signalTimeout = signalTimeout; + } + + public CDONet4jSession openNet4jSession() + { + return (CDONet4jSession)super.openSession(); + } + + @Override + public CDOSession openSession() + { + return (CDOSession)openNet4jSession(); + } + + public InternalCDOSession createSession() + { + if (isActivateOnOpen()) + { + CheckUtil.checkState(connector, "connector"); //$NON-NLS-1$ + } + + return new CDONet4jSessionImpl(); + } + + @Override + protected void configureSession(InternalCDOSession session) + { + super.configureSession(session); + + CDONet4jSessionImpl sessionImpl = (CDONet4jSessionImpl)session; + sessionImpl.setStreamWrapper(streamWrapper); + sessionImpl.setConnector(connector); + sessionImpl.setRepositoryName(repositoryName); + sessionImpl.setSignalTimeout(signalTimeout); + } + + /** + * @author Eike Stepper + */ + public static class RepositoryInfo implements CDORepositoryInfo + { + private String name; + + private String uuid; + + private Type type; + + private State state; + + private String storeType; + + private Set<CDOID.ObjectType> objectIDTypes; + + private long creationTime; + + private RepositoryTimeResult timeResult; + + private CDOID rootResourceID; + + private boolean supportingAudits; + + private boolean supportingBranches; + + private boolean supportingEcore; + + private boolean ensuringReferentialIntegrity; + + private IDGenerationLocation idGenerationLocation; + + private InternalCDOSession session; + + public RepositoryInfo(String name, OpenSessionResult result, InternalCDOSession session) + { + this.name = name; + uuid = result.getRepositoryUUID(); + type = result.getRepositoryType(); + state = result.getRepositoryState(); + storeType = result.getStoreType(); + objectIDTypes = result.getObjectIDTypes(); + creationTime = result.getRepositoryCreationTime(); + timeResult = result.getRepositoryTimeResult(); + rootResourceID = result.getRootResourceID(); + supportingAudits = result.isRepositorySupportingAudits(); + supportingBranches = result.isRepositorySupportingBranches(); + supportingEcore = result.isRepositorySupportingEcore(); + ensuringReferentialIntegrity = result.isRepositoryEnsuringReferentialIntegrity(); + idGenerationLocation = result.getRepositoryIDGenerationLocation(); + this.session = session; + } + + public String getName() + { + return name; + } + + /** + * Must be callable before session activation has finished! + */ + public String getUUID() + { + return uuid; + } + + public Type getType() + { + return type; + } + + public void setType(Type type) + { + this.type = type; + } + + public State getState() + { + return state; + } + + public void setState(State state) + { + this.state = state; + } + + public String getStoreType() + { + return storeType; + } + + public Set<CDOID.ObjectType> getObjectIDTypes() + { + return objectIDTypes; + } + + public long getCreationTime() + { + return creationTime; + } + + public long getTimeStamp() + { + return getTimeStamp(false); + } + + public long getTimeStamp(boolean forceRefresh) + { + if (timeResult == null || forceRefresh) + { + timeResult = refreshTime(); + } + + return timeResult.getAproximateRepositoryTime(); + } + + public CDOID getRootResourceID() + { + return rootResourceID; + } + + public void setRootResourceID(CDOID rootResourceID) + { + // The rootResourceID may only be set if it is currently null + if (this.rootResourceID == null || this.rootResourceID.isNull()) + { + this.rootResourceID = rootResourceID; + } + else if (this.rootResourceID != null && this.rootResourceID.equals(rootResourceID)) + { + // Do nothing; it is the same. + } + else + { + throw new IllegalStateException("rootResourceID must not be changed unless it is null"); + } + } + + public boolean isSupportingAudits() + { + return supportingAudits; + } + + public boolean isSupportingBranches() + { + return supportingBranches; + } + + public boolean isSupportingEcore() + { + return supportingEcore; + } + + public boolean isEnsuringReferentialIntegrity() + { + return ensuringReferentialIntegrity; + } + + public IDGenerationLocation getIDGenerationLocation() + { + return idGenerationLocation; + } + + private RepositoryTimeResult refreshTime() + { + return session.getSessionProtocol().getRepositoryTime(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java index 210dee04c8..6b60bbe868 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/CDOSessionRecoveryEventImpl.java @@ -1,40 +1,40 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.emf.cdo.net4j.CDOSessionRecoveryEvent;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-/**
- * @author Caspar De Groot
- */
-public class CDOSessionRecoveryEventImpl implements CDOSessionRecoveryEvent
-{
- private CDOSession source;
-
- private Type type;
-
- public CDOSessionRecoveryEventImpl(CDOSession source, Type type)
- {
- this.type = type;
- this.source = source;
- }
-
- public CDOSession getSource()
- {
- return source;
- }
-
- public Type getType()
- {
- return type;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j; + +import org.eclipse.emf.cdo.net4j.CDOSessionRecoveryEvent; +import org.eclipse.emf.cdo.session.CDOSession; + +/** + * @author Caspar De Groot + */ +public class CDOSessionRecoveryEventImpl implements CDOSessionRecoveryEvent +{ + private CDOSession source; + + private Type type; + + public CDOSessionRecoveryEventImpl(CDOSession source, Type type) + { + this.type = type; + this.source = source; + } + + public CDOSession getSource() + { + return source; + } + + public Type getType() + { + return type; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java index 650ccea834..62b030a0c7 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionConfigurationImpl.java @@ -1,84 +1,84 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j;
-
-import org.eclipse.emf.cdo.net4j.FailoverCDOSessionConfiguration;
-import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public class FailoverCDOSessionConfigurationImpl extends RecoveringCDOSessionConfigurationImpl implements
- FailoverCDOSessionConfiguration
-{
- private String monitorConnectorDescription;
-
- private String repositoryGroup;
-
- public FailoverCDOSessionConfigurationImpl(String monitorConnectorDescription, String repositoryGroup,
- IManagedContainer container)
- {
- super(container);
-
- this.monitorConnectorDescription = monitorConnectorDescription;
- this.repositoryGroup = repositoryGroup;
- }
-
- public String getMonitorConnectorDescription()
- {
- return monitorConnectorDescription;
- }
-
- public String getRepositoryGroup()
- {
- return repositoryGroup;
- }
-
- @Override
- public void setRepositoryName(String repositoryName)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setConnector(IConnector connector)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setExceptionHandler(ExceptionHandler exceptionHandler)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public InternalCDOSession createSession()
- {
- return new FailoverCDOSessionImpl();
- }
-
- @Override
- protected void configureSession(InternalCDOSession session)
- {
- super.configureSession(session);
-
- FailoverCDOSessionImpl sessionImpl = (FailoverCDOSessionImpl)session;
- sessionImpl.setMonitorConnectionDescription(monitorConnectorDescription);
- sessionImpl.setRepositoryGroup(repositoryGroup);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j; + +import org.eclipse.emf.cdo.net4j.FailoverCDOSessionConfiguration; +import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler; + +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.util.container.IManagedContainer; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class FailoverCDOSessionConfigurationImpl extends RecoveringCDOSessionConfigurationImpl implements + FailoverCDOSessionConfiguration +{ + private String monitorConnectorDescription; + + private String repositoryGroup; + + public FailoverCDOSessionConfigurationImpl(String monitorConnectorDescription, String repositoryGroup, + IManagedContainer container) + { + super(container); + + this.monitorConnectorDescription = monitorConnectorDescription; + this.repositoryGroup = repositoryGroup; + } + + public String getMonitorConnectorDescription() + { + return monitorConnectorDescription; + } + + public String getRepositoryGroup() + { + return repositoryGroup; + } + + @Override + public void setRepositoryName(String repositoryName) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setConnector(IConnector connector) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setExceptionHandler(ExceptionHandler exceptionHandler) + { + throw new UnsupportedOperationException(); + } + + @Override + public InternalCDOSession createSession() + { + return new FailoverCDOSessionImpl(); + } + + @Override + protected void configureSession(InternalCDOSession session) + { + super.configureSession(session); + + FailoverCDOSessionImpl sessionImpl = (FailoverCDOSessionImpl)session; + sessionImpl.setMonitorConnectionDescription(monitorConnectorDescription); + sessionImpl.setRepositoryGroup(repositoryGroup); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java index 599c6589ab..97cf517060 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/FailoverCDOSessionImpl.java @@ -1,98 +1,98 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class FailoverCDOSessionImpl extends RecoveringCDOSessionImpl
-{
- private String monitorConnectorDescription;
-
- private String repositoryGroup;
-
- public FailoverCDOSessionImpl()
- {
- }
-
- public void setMonitorConnectionDescription(String monitorConnectorDescription)
- {
- this.monitorConnectorDescription = monitorConnectorDescription;
- }
-
- public void setRepositoryGroup(String repositoryGroup)
- {
- this.repositoryGroup = repositoryGroup;
- }
-
- @Override
- protected void updateConnectorAndRepositoryName()
- {
- queryRepositoryInfoFromMonitor();
- IConnector connector = createTCPConnector(getUseHeartBeat());
- setConnector(connector);
- }
-
- protected void queryRepositoryInfoFromMonitor()
- {
- IConnector connector = getTCPConnector(monitorConnectorDescription);
- SignalProtocol<Object> protocol = new SignalProtocol<Object>("failover-client");
- protocol.open(connector);
-
- try
- {
- String oldRepositoryConnectorDescription = getRepositoryConnectorDescription();
- String oldRepositoryName = getRepositoryName();
-
- while (ObjectUtil.equals(getRepositoryConnectorDescription(), oldRepositoryConnectorDescription)
- && ObjectUtil.equals(getRepositoryName(), oldRepositoryName))
- {
- new RequestWithConfirmation<Boolean>(protocol, (short)1, "QueryRepositoryInfo")
- {
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(repositoryGroup);
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in) throws Exception
- {
- setRepositoryConnectorDescription(in.readString());
- setRepositoryName(in.readString());
- return true;
- }
- }.send();
- }
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- finally
- {
- protocol.close();
- if (connector.getChannels().isEmpty())
- {
- connector.close();
- }
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Caspar De Groot - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j; + +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +/** + * @author Eike Stepper + */ +public class FailoverCDOSessionImpl extends RecoveringCDOSessionImpl +{ + private String monitorConnectorDescription; + + private String repositoryGroup; + + public FailoverCDOSessionImpl() + { + } + + public void setMonitorConnectionDescription(String monitorConnectorDescription) + { + this.monitorConnectorDescription = monitorConnectorDescription; + } + + public void setRepositoryGroup(String repositoryGroup) + { + this.repositoryGroup = repositoryGroup; + } + + @Override + protected void updateConnectorAndRepositoryName() + { + queryRepositoryInfoFromMonitor(); + IConnector connector = createTCPConnector(getUseHeartBeat()); + setConnector(connector); + } + + protected void queryRepositoryInfoFromMonitor() + { + IConnector connector = getTCPConnector(monitorConnectorDescription); + SignalProtocol<Object> protocol = new SignalProtocol<Object>("failover-client"); + protocol.open(connector); + + try + { + String oldRepositoryConnectorDescription = getRepositoryConnectorDescription(); + String oldRepositoryName = getRepositoryName(); + + while (ObjectUtil.equals(getRepositoryConnectorDescription(), oldRepositoryConnectorDescription) + && ObjectUtil.equals(getRepositoryName(), oldRepositoryName)) + { + new RequestWithConfirmation<Boolean>(protocol, (short)1, "QueryRepositoryInfo") + { + @Override + protected void requesting(ExtendedDataOutputStream out) throws Exception + { + out.writeString(repositoryGroup); + } + + @Override + protected Boolean confirming(ExtendedDataInputStream in) throws Exception + { + setRepositoryConnectorDescription(in.readString()); + setRepositoryName(in.readString()); + return true; + } + }.send(); + } + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + finally + { + protocol.close(); + if (connector.getChannels().isEmpty()) + { + connector.close(); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jConnectorInjector.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jConnectorInjector.java index 9900a4b195..1c63a9e0a0 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jConnectorInjector.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jConnectorInjector.java @@ -1,83 +1,83 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j;
-
-import org.eclipse.emf.cdo.internal.net4j.messages.Messages;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.container.IElementProcessor;
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class Net4jConnectorInjector implements IElementProcessor
-{
- private static final String INVALID_URI_MESSAGE = Messages.getString("InvalidURIException.0"); //$NON-NLS-1$
-
- private static final String SCHEME_SEPARATOR = "://"; //$NON-NLS-1$
-
- public Net4jConnectorInjector()
- {
- }
-
- public Object process(IManagedContainer container, String productGroup, String factoryType, String description,
- Object element)
- {
- if (element instanceof CDONet4jSessionImpl)
- {
- CDONet4jSessionImpl session = (CDONet4jSessionImpl)element;
- if (session.getConnector() == null)
- {
- IConnector connector = getConnector(container, description);
- session.setConnector(connector);
- }
- }
-
- return element;
- }
-
- protected IConnector getConnector(IManagedContainer container, String description)
- {
- int pos = description.indexOf(SCHEME_SEPARATOR);
- if (pos == -1)
- {
- throw new IllegalArgumentException(MessageFormat.format(INVALID_URI_MESSAGE, description,
- Messages.getString("FailOverStrategyInjector.0"))); //$NON-NLS-1$
- }
-
- String factoryType = description.substring(0, pos);
- if (StringUtil.isEmpty(factoryType))
- {
- throw new IllegalArgumentException(MessageFormat.format(INVALID_URI_MESSAGE, description,
- Messages.getString("FailOverStrategyInjector.1"))); //$NON-NLS-1$
- }
-
- String connectorDescription = description.substring(pos + SCHEME_SEPARATOR.length());
- if (StringUtil.isEmpty(connectorDescription))
- {
- throw new IllegalArgumentException(MessageFormat.format(INVALID_URI_MESSAGE, description,
- Messages.getString("FailOverStrategyInjector.2"))); //$NON-NLS-1$
- }
-
- pos = connectorDescription.indexOf('?');
- if (pos != -1)
- {
- connectorDescription = connectorDescription.substring(0, pos);
- }
-
- return Net4jUtil.getConnector(container, factoryType, connectorDescription);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j; + +import org.eclipse.emf.cdo.internal.net4j.messages.Messages; + +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.container.IElementProcessor; +import org.eclipse.net4j.util.container.IManagedContainer; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class Net4jConnectorInjector implements IElementProcessor +{ + private static final String INVALID_URI_MESSAGE = Messages.getString("InvalidURIException.0"); //$NON-NLS-1$ + + private static final String SCHEME_SEPARATOR = "://"; //$NON-NLS-1$ + + public Net4jConnectorInjector() + { + } + + public Object process(IManagedContainer container, String productGroup, String factoryType, String description, + Object element) + { + if (element instanceof CDONet4jSessionImpl) + { + CDONet4jSessionImpl session = (CDONet4jSessionImpl)element; + if (session.getConnector() == null) + { + IConnector connector = getConnector(container, description); + session.setConnector(connector); + } + } + + return element; + } + + protected IConnector getConnector(IManagedContainer container, String description) + { + int pos = description.indexOf(SCHEME_SEPARATOR); + if (pos == -1) + { + throw new IllegalArgumentException(MessageFormat.format(INVALID_URI_MESSAGE, description, + Messages.getString("FailOverStrategyInjector.0"))); //$NON-NLS-1$ + } + + String factoryType = description.substring(0, pos); + if (StringUtil.isEmpty(factoryType)) + { + throw new IllegalArgumentException(MessageFormat.format(INVALID_URI_MESSAGE, description, + Messages.getString("FailOverStrategyInjector.1"))); //$NON-NLS-1$ + } + + String connectorDescription = description.substring(pos + SCHEME_SEPARATOR.length()); + if (StringUtil.isEmpty(connectorDescription)) + { + throw new IllegalArgumentException(MessageFormat.format(INVALID_URI_MESSAGE, description, + Messages.getString("FailOverStrategyInjector.2"))); //$NON-NLS-1$ + } + + pos = connectorDescription.indexOf('?'); + if (pos != -1) + { + connectorDescription = connectorDescription.substring(0, pos); + } + + return Net4jUtil.getConnector(container, factoryType, connectorDescription); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jSessionFactory.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jSessionFactory.java index 074b5d5082..14bf87e455 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jSessionFactory.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/Net4jSessionFactory.java @@ -1,81 +1,81 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j;
-
-import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
-import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.emf.internal.cdo.session.CDOSessionFactory;
-
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.security.CredentialsProviderFactory;
-import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-/**
- * @author Eike Stepper
- */
-public class Net4jSessionFactory extends CDOSessionFactory
-{
- public static final String TYPE = "cdo"; //$NON-NLS-1$
-
- public Net4jSessionFactory()
- {
- super(TYPE);
- }
-
- /**
- * @since 2.0
- */
- @Override
- protected InternalCDOSession createSession(String repositoryName, boolean automaticPackageRegistry)
- {
- CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration();
- configuration.setRepositoryName(repositoryName);
- configuration.getAuthenticator().setCredentialsProvider(getCredentialsProvider());
-
- // The session will be activated by the container
- configuration.setActivateOnOpen(false);
- return (InternalCDOSession)configuration.openNet4jSession();
- }
-
- protected IPasswordCredentialsProvider getCredentialsProvider()
- {
- try
- {
- IManagedContainer container = getManagedContainer();
- String type = getCredentialsProviderType();
- return (IPasswordCredentialsProvider)container.getElement(CredentialsProviderFactory.PRODUCT_GROUP, type, null);
- }
- catch (Exception ex)
- {
- return null;
- }
- }
-
- protected IManagedContainer getManagedContainer()
- {
- return IPluginContainer.INSTANCE;
- }
-
- protected String getCredentialsProviderType()
- {
- return "interactive";
- }
-
- public static CDOSession get(IManagedContainer container, String description)
- {
- return (CDOSession)container.getElement(PRODUCT_GROUP, TYPE, description);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j; + +import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration; +import org.eclipse.emf.cdo.net4j.CDONet4jUtil; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.emf.internal.cdo.session.CDOSessionFactory; + +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginContainer; +import org.eclipse.net4j.util.security.CredentialsProviderFactory; +import org.eclipse.net4j.util.security.IPasswordCredentialsProvider; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +/** + * @author Eike Stepper + */ +public class Net4jSessionFactory extends CDOSessionFactory +{ + public static final String TYPE = "cdo"; //$NON-NLS-1$ + + public Net4jSessionFactory() + { + super(TYPE); + } + + /** + * @since 2.0 + */ + @Override + protected InternalCDOSession createSession(String repositoryName, boolean automaticPackageRegistry) + { + CDONet4jSessionConfiguration configuration = CDONet4jUtil.createNet4jSessionConfiguration(); + configuration.setRepositoryName(repositoryName); + configuration.getAuthenticator().setCredentialsProvider(getCredentialsProvider()); + + // The session will be activated by the container + configuration.setActivateOnOpen(false); + return (InternalCDOSession)configuration.openNet4jSession(); + } + + protected IPasswordCredentialsProvider getCredentialsProvider() + { + try + { + IManagedContainer container = getManagedContainer(); + String type = getCredentialsProviderType(); + return (IPasswordCredentialsProvider)container.getElement(CredentialsProviderFactory.PRODUCT_GROUP, type, null); + } + catch (Exception ex) + { + return null; + } + } + + protected IManagedContainer getManagedContainer() + { + return IPluginContainer.INSTANCE; + } + + protected String getCredentialsProviderType() + { + return "interactive"; + } + + public static CDOSession get(IManagedContainer container, String description) + { + return (CDOSession)container.getElement(PRODUCT_GROUP, TYPE, description); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java index bd68dd0d12..26da19be3d 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionConfigurationImpl.java @@ -1,90 +1,90 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.emf.cdo.net4j.ReconnectingCDOSessionConfiguration;
-import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler;
-
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-/**
- * @author Caspar De Groot
- */
-public class ReconnectingCDOSessionConfigurationImpl extends RecoveringCDOSessionConfigurationImpl implements
- ReconnectingCDOSessionConfiguration
-{
- private String hostAndPort;
-
- private long reconnectInterval = 0;
-
- private int maxReconnectAttempts = Integer.MAX_VALUE;
-
- public ReconnectingCDOSessionConfigurationImpl(String hostAndPort, String repositoryName, IManagedContainer container)
- {
- super(container);
-
- this.hostAndPort = hostAndPort;
- setRepositoryName(repositoryName);
- }
-
- public long getReconnectInterval()
- {
- return reconnectInterval;
- }
-
- public void setReconnectInterval(long reconnectInterval)
- {
- this.reconnectInterval = reconnectInterval;
- }
-
- public int getMaxReconnectAttempts()
- {
- return maxReconnectAttempts;
- }
-
- public void setMaxReconnectAttempts(int maxReconnectAttempts)
- {
- this.maxReconnectAttempts = maxReconnectAttempts;
- }
-
- @Override
- public void setExceptionHandler(ExceptionHandler handler)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public InternalCDOSession createSession()
- {
- ReconnectingCDOSessionImpl session = new ReconnectingCDOSessionImpl();
-
- // A ReconnectingCDOSessionImpl has its own exceptionHandler; but the configuration mechanism
- // expects the configuration object (i.e. *this*) to hold a reference to the desired handler.
- // We therefore fetch the handler from the session and plug it into *this*, so that the
- // config mechanism can proceed normally. (It will "set" the same handler again.)
- //
- super.setExceptionHandler(session.getExceptionHandler());
- return session;
- }
-
- @Override
- protected void configureSession(InternalCDOSession session)
- {
- super.configureSession(session);
-
- ReconnectingCDOSessionImpl sessionImpl = (ReconnectingCDOSessionImpl)session;
- sessionImpl.setRepositoryConnectorDescription(hostAndPort);
- sessionImpl.setReconnectInterval(reconnectInterval);
- sessionImpl.setMaxReconnectAttempts(maxReconnectAttempts);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j; + +import org.eclipse.emf.cdo.net4j.ReconnectingCDOSessionConfiguration; +import org.eclipse.emf.cdo.session.CDOSession.ExceptionHandler; + +import org.eclipse.net4j.util.container.IManagedContainer; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +/** + * @author Caspar De Groot + */ +public class ReconnectingCDOSessionConfigurationImpl extends RecoveringCDOSessionConfigurationImpl implements + ReconnectingCDOSessionConfiguration +{ + private String hostAndPort; + + private long reconnectInterval = 0; + + private int maxReconnectAttempts = Integer.MAX_VALUE; + + public ReconnectingCDOSessionConfigurationImpl(String hostAndPort, String repositoryName, IManagedContainer container) + { + super(container); + + this.hostAndPort = hostAndPort; + setRepositoryName(repositoryName); + } + + public long getReconnectInterval() + { + return reconnectInterval; + } + + public void setReconnectInterval(long reconnectInterval) + { + this.reconnectInterval = reconnectInterval; + } + + public int getMaxReconnectAttempts() + { + return maxReconnectAttempts; + } + + public void setMaxReconnectAttempts(int maxReconnectAttempts) + { + this.maxReconnectAttempts = maxReconnectAttempts; + } + + @Override + public void setExceptionHandler(ExceptionHandler handler) + { + throw new UnsupportedOperationException(); + } + + @Override + public InternalCDOSession createSession() + { + ReconnectingCDOSessionImpl session = new ReconnectingCDOSessionImpl(); + + // A ReconnectingCDOSessionImpl has its own exceptionHandler; but the configuration mechanism + // expects the configuration object (i.e. *this*) to hold a reference to the desired handler. + // We therefore fetch the handler from the session and plug it into *this*, so that the + // config mechanism can proceed normally. (It will "set" the same handler again.) + // + super.setExceptionHandler(session.getExceptionHandler()); + return session; + } + + @Override + protected void configureSession(InternalCDOSession session) + { + super.configureSession(session); + + ReconnectingCDOSessionImpl sessionImpl = (ReconnectingCDOSessionImpl)session; + sessionImpl.setRepositoryConnectorDescription(hostAndPort); + sessionImpl.setReconnectInterval(reconnectInterval); + sessionImpl.setMaxReconnectAttempts(maxReconnectAttempts); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java index 4c8ba94e38..a1cc98b876 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/ReconnectingCDOSessionImpl.java @@ -1,127 +1,127 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.net4j.connector.ConnectorException;
-import org.eclipse.net4j.connector.IConnector;
-
-/**
- * @author Caspar De Groot
- */
-public class ReconnectingCDOSessionImpl extends RecoveringCDOSessionImpl
-{
- private long reconnectInterval = 0;
-
- private int maxReconnectAttempts = Integer.MAX_VALUE;
-
- public ReconnectingCDOSessionImpl()
- {
- }
-
- public long getReconnectInterval()
- {
- return reconnectInterval;
- }
-
- public void setReconnectInterval(long reconnectInterval)
- {
- this.reconnectInterval = reconnectInterval;
- }
-
- public int getMaxReconnectAttempts()
- {
- return maxReconnectAttempts;
- }
-
- public void setMaxReconnectAttempts(int maxReconnectAttempts)
- {
- this.maxReconnectAttempts = maxReconnectAttempts;
- }
-
- @Override
- public void setConnector(IConnector connector)
- {
- // Do nothing (ignore an externally configured connector)
- // Note: we cannot throw UnsupportedOperationException because the
- // SessionConfig object will call this.
- }
-
- @Override
- public void setRepositoryConnectorDescription(String description)
- {
- if (getRepositoryConnectorDescription() != null)
- {
- throw new IllegalStateException("Don't call setRepositoryConnectorDescription more than once");
- }
-
- super.setRepositoryConnectorDescription(description);
- }
-
- @Override
- protected void updateConnectorAndRepositoryName()
- {
- removeTCPConnector();
-
- IConnector newConnector = null;
- int failedAttempts = 0;
- long startOfLastAttempt = 0;
-
- while (newConnector == null && failedAttempts < maxReconnectAttempts)
- {
- try
- {
- if (startOfLastAttempt > 0)
- {
- delayAsNeeded(startOfLastAttempt);
- }
-
- startOfLastAttempt = System.currentTimeMillis();
- newConnector = createTCPConnector(getUseHeartBeat());
- }
- catch (ConnectorException ex)
- {
- failedAttempts++;
- }
- }
-
- if (newConnector == null)
- {
- throw new RuntimeException("Recovery failed"); // TODO (CD) Create custom exception type?
- }
-
- super.setConnector(newConnector);
- }
-
- private void delayAsNeeded(long startOfLastAttempt)
- {
- long timeToWait = requiredDelay(startOfLastAttempt);
- while (timeToWait > 0)
- {
- try
- {
- Thread.sleep(timeToWait);
- timeToWait = 0;
- }
- catch (InterruptedException ex)
- {
- timeToWait = requiredDelay(startOfLastAttempt);
- }
- }
- }
-
- private long requiredDelay(long startOfLastAttempt)
- {
- long now = System.currentTimeMillis();
- long timeSinceLastAttempt = now - startOfLastAttempt;
- long timeToWait = reconnectInterval - timeSinceLastAttempt;
- return timeToWait;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j; + +import org.eclipse.net4j.connector.ConnectorException; +import org.eclipse.net4j.connector.IConnector; + +/** + * @author Caspar De Groot + */ +public class ReconnectingCDOSessionImpl extends RecoveringCDOSessionImpl +{ + private long reconnectInterval = 0; + + private int maxReconnectAttempts = Integer.MAX_VALUE; + + public ReconnectingCDOSessionImpl() + { + } + + public long getReconnectInterval() + { + return reconnectInterval; + } + + public void setReconnectInterval(long reconnectInterval) + { + this.reconnectInterval = reconnectInterval; + } + + public int getMaxReconnectAttempts() + { + return maxReconnectAttempts; + } + + public void setMaxReconnectAttempts(int maxReconnectAttempts) + { + this.maxReconnectAttempts = maxReconnectAttempts; + } + + @Override + public void setConnector(IConnector connector) + { + // Do nothing (ignore an externally configured connector) + // Note: we cannot throw UnsupportedOperationException because the + // SessionConfig object will call this. + } + + @Override + public void setRepositoryConnectorDescription(String description) + { + if (getRepositoryConnectorDescription() != null) + { + throw new IllegalStateException("Don't call setRepositoryConnectorDescription more than once"); + } + + super.setRepositoryConnectorDescription(description); + } + + @Override + protected void updateConnectorAndRepositoryName() + { + removeTCPConnector(); + + IConnector newConnector = null; + int failedAttempts = 0; + long startOfLastAttempt = 0; + + while (newConnector == null && failedAttempts < maxReconnectAttempts) + { + try + { + if (startOfLastAttempt > 0) + { + delayAsNeeded(startOfLastAttempt); + } + + startOfLastAttempt = System.currentTimeMillis(); + newConnector = createTCPConnector(getUseHeartBeat()); + } + catch (ConnectorException ex) + { + failedAttempts++; + } + } + + if (newConnector == null) + { + throw new RuntimeException("Recovery failed"); // TODO (CD) Create custom exception type? + } + + super.setConnector(newConnector); + } + + private void delayAsNeeded(long startOfLastAttempt) + { + long timeToWait = requiredDelay(startOfLastAttempt); + while (timeToWait > 0) + { + try + { + Thread.sleep(timeToWait); + timeToWait = 0; + } + catch (InterruptedException ex) + { + timeToWait = requiredDelay(startOfLastAttempt); + } + } + } + + private long requiredDelay(long startOfLastAttempt) + { + long now = System.currentTimeMillis(); + long timeSinceLastAttempt = now - startOfLastAttempt; + long timeToWait = reconnectInterval - timeSinceLastAttempt; + return timeToWait; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java index 12b3461588..a809e7e335 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionConfigurationImpl.java @@ -1,102 +1,102 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.emf.cdo.net4j.RecoveringCDOSessionConfiguration;
-
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-/**
- * @author Caspar De Groot
- */
-public abstract class RecoveringCDOSessionConfigurationImpl extends CDONet4jSessionConfigurationImpl implements
- RecoveringCDOSessionConfiguration
-{
- private IManagedContainer container;
-
- private boolean heartBeatEnabled = false;
-
- private long heartBeatPeriod = 1000L;
-
- private long heartBeatTimeout = 5000L;
-
- private long connectorTimeout = 10000L;
-
- public RecoveringCDOSessionConfigurationImpl(IManagedContainer container)
- {
- this.container = container;
- }
-
- protected IManagedContainer getContainer()
- {
- return container;
- }
-
- public long getConnectorTimeout()
- {
- return connectorTimeout;
- }
-
- public void setConnectorTimeout(long timeout)
- {
- connectorTimeout = timeout;
- }
-
- public boolean isHeartBeatEnabled()
- {
- return heartBeatEnabled;
- }
-
- public void setHeartBeatEnabled(boolean enabled)
- {
- heartBeatEnabled = enabled;
- }
-
- public long getHeartBeatTimeout()
- {
- return heartBeatTimeout;
- }
-
- public void setHeartBeatTimeout(long timeout)
- {
- heartBeatTimeout = timeout;
- }
-
- public long getHeartBeatPeriod()
- {
- return heartBeatPeriod;
- }
-
- public void setHeartBeatPeriod(long period)
- {
- heartBeatPeriod = period;
- }
-
- @Override
- protected void configureSession(InternalCDOSession session)
- {
- super.configureSession(session);
-
- if (heartBeatEnabled && (heartBeatPeriod == 0 || heartBeatTimeout == 0))
- {
- throw new IllegalStateException("Cannot use a heartbeat with zero value set for period or timeout.");
- }
-
- RecoveringCDOSessionImpl sessionImpl = (RecoveringCDOSessionImpl)session;
- sessionImpl.setContainer(getContainer());
- sessionImpl.setUseHeartBeat(heartBeatEnabled);
- sessionImpl.setHeartBeatPeriod(heartBeatPeriod);
- sessionImpl.setHeartBeatTimeout(heartBeatTimeout);
- sessionImpl.setConnectorTimeout(connectorTimeout);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j; + +import org.eclipse.emf.cdo.net4j.RecoveringCDOSessionConfiguration; + +import org.eclipse.net4j.util.container.IManagedContainer; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +/** + * @author Caspar De Groot + */ +public abstract class RecoveringCDOSessionConfigurationImpl extends CDONet4jSessionConfigurationImpl implements + RecoveringCDOSessionConfiguration +{ + private IManagedContainer container; + + private boolean heartBeatEnabled = false; + + private long heartBeatPeriod = 1000L; + + private long heartBeatTimeout = 5000L; + + private long connectorTimeout = 10000L; + + public RecoveringCDOSessionConfigurationImpl(IManagedContainer container) + { + this.container = container; + } + + protected IManagedContainer getContainer() + { + return container; + } + + public long getConnectorTimeout() + { + return connectorTimeout; + } + + public void setConnectorTimeout(long timeout) + { + connectorTimeout = timeout; + } + + public boolean isHeartBeatEnabled() + { + return heartBeatEnabled; + } + + public void setHeartBeatEnabled(boolean enabled) + { + heartBeatEnabled = enabled; + } + + public long getHeartBeatTimeout() + { + return heartBeatTimeout; + } + + public void setHeartBeatTimeout(long timeout) + { + heartBeatTimeout = timeout; + } + + public long getHeartBeatPeriod() + { + return heartBeatPeriod; + } + + public void setHeartBeatPeriod(long period) + { + heartBeatPeriod = period; + } + + @Override + protected void configureSession(InternalCDOSession session) + { + super.configureSession(session); + + if (heartBeatEnabled && (heartBeatPeriod == 0 || heartBeatTimeout == 0)) + { + throw new IllegalStateException("Cannot use a heartbeat with zero value set for period or timeout."); + } + + RecoveringCDOSessionImpl sessionImpl = (RecoveringCDOSessionImpl)session; + sessionImpl.setContainer(getContainer()); + sessionImpl.setUseHeartBeat(heartBeatEnabled); + sessionImpl.setHeartBeatPeriod(heartBeatPeriod); + sessionImpl.setHeartBeatTimeout(heartBeatTimeout); + sessionImpl.setConnectorTimeout(connectorTimeout); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java index 6e15530506..412c049944 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/RecoveringCDOSessionImpl.java @@ -1,303 +1,303 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.util.TransportException;
-import org.eclipse.emf.cdo.net4j.CDOSessionRecoveryEvent;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.CDOSessionEvent;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol;
-import org.eclipse.net4j.util.container.IContainerDelta;
-import org.eclipse.net4j.util.container.IContainerEvent;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Caspar De Groot
- */
-public abstract class RecoveringCDOSessionImpl extends CDONet4jSessionImpl
-{
- private IManagedContainer container;
-
- private String repositoryConnectorDescription;
-
- private boolean useHeartBeat;
-
- private long heartBeatPeriod = 1000L;
-
- private long heartBeatTimeout = 5000L;
-
- private long connectorTimeout = 10000L;
-
- public RecoveringCDOSessionImpl()
- {
- setExceptionHandler(new RecoveringExceptionHandler());
- }
-
- public long getConnectorTimeout()
- {
- return connectorTimeout;
- }
-
- public void setConnectorTimeout(long connectorTimeout)
- {
- this.connectorTimeout = connectorTimeout;
- }
-
- public void setContainer(IManagedContainer container)
- {
- this.container = container;
- }
-
- public IManagedContainer getContainer()
- {
- return container;
- }
-
- public void setUseHeartBeat(boolean useHeartBeat)
- {
- this.useHeartBeat = useHeartBeat;
- }
-
- public boolean getUseHeartBeat()
- {
- return useHeartBeat;
- }
-
- public void setHeartBeatTimeout(long timeout)
- {
- heartBeatTimeout = timeout;
- }
-
- public long getHeartBeatTimeout()
- {
- return heartBeatTimeout;
- }
-
- public void setHeartBeatPeriod(long period)
- {
- heartBeatPeriod = period;
- }
-
- public long getHeartBeatPeriod()
- {
- return heartBeatPeriod;
- }
-
- @Override
- protected void sessionProtocolDeactivated()
- {
- recover();
- }
-
- protected void recover()
- {
- fireEvent(createRecoveryStartedEvent());
-
- CDOSessionProtocol oldSessionProtocol = getSessionProtocol();
- unhookSessionProtocol();
- List<AfterRecoveryRunnable> runnables = recoverSession();
-
- // Check if the the sessionProtocol was replaced. (This may not be the case
- // if the protocol is wrapped inside a DelegatingSessionProtocol.)
- //
- CDOSessionProtocol newSessionProtocol = getSessionProtocol();
- if (newSessionProtocol != oldSessionProtocol)
- {
- handleProtocolChange(oldSessionProtocol, newSessionProtocol);
- }
-
- for (AfterRecoveryRunnable runnable : runnables)
- {
- runnable.run(newSessionProtocol);
- }
-
- fireEvent(createRecoveryFinishedEvent());
- }
-
- protected void handleProtocolChange(CDOSessionProtocol oldProtocol, CDOSessionProtocol newProtocol)
- {
- // The revisionManager, branchManager, and commitInfoManager, hold their own
- // references to the sessionProtocol. We need to update those:
-
- InternalCDORevisionManager revisionManager = getRevisionManager();
- revisionManager.deactivate();
- revisionManager.setRevisionLoader(newProtocol);
- revisionManager.activate();
-
- InternalCDOBranchManager branchManager = getBranchManager();
- branchManager.deactivate();
- branchManager.setBranchLoader(newProtocol);
- branchManager.activate();
-
- InternalCDOCommitInfoManager commitInfoManager = getCommitInfoManager();
- commitInfoManager.deactivate();
- commitInfoManager.setCommitInfoLoader(newProtocol);
- commitInfoManager.activate();
- }
-
- protected CDOSessionEvent createRecoveryStartedEvent()
- {
- return new CDOSessionRecoveryEventImpl(this, CDOSessionRecoveryEvent.Type.STARTED);
- }
-
- protected CDOSessionEvent createRecoveryFinishedEvent()
- {
- return new CDOSessionRecoveryEventImpl(this, CDOSessionRecoveryEvent.Type.FINISHED);
- }
-
- protected IConnector createTCPConnector(boolean heartBeat)
- {
- IConnector connector = getTCPConnector(repositoryConnectorDescription);
- if (heartBeat)
- {
- new HeartBeatProtocol(connector, container).start(heartBeatPeriod, heartBeatTimeout);
- }
-
- connector.addListener(new AutoCloser());
- return connector;
- }
-
- protected IConnector getTCPConnector(String description)
- {
- return Net4jUtil.getConnector(getContainer(), "tcp", description, connectorTimeout);
- }
-
- protected List<AfterRecoveryRunnable> recoverSession()
- {
- try
- {
- List<AfterRecoveryRunnable> runnables = new ArrayList<AfterRecoveryRunnable>();
- for (InternalCDOView view : getViews())
- {
- runnables.add(new OpenViewRunnable(view));
- }
-
- updateConnectorAndRepositoryName();
- openSession();
-
- return runnables;
- }
- catch (RuntimeException ex)
- {
- deactivate();
- throw ex;
- }
- catch (Error ex)
- {
- deactivate();
- throw ex;
- }
- }
-
- protected IConnector removeTCPConnector()
- {
- return (IConnector)container.removeElement("org.eclipse.net4j.connectors", "tcp", repositoryConnectorDescription);
- }
-
- protected void setRepositoryConnectorDescription(String description)
- {
- repositoryConnectorDescription = description;
- }
-
- protected String getRepositoryConnectorDescription()
- {
- return repositoryConnectorDescription;
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- updateConnectorAndRepositoryName();
- super.doActivate();
- }
-
- protected abstract void updateConnectorAndRepositoryName();
-
- /**
- * @author Eike Stepper
- */
- public static interface AfterRecoveryRunnable
- {
- public void run(CDOSessionProtocol sessionProtocol);
- }
-
- private class RecoveringExceptionHandler implements ExceptionHandler
- {
- public void handleException(CDOSession session, int attempt, Exception exception) throws Exception
- {
- if (exception instanceof TransportException)
- {
- recover();
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public final class OpenViewRunnable implements AfterRecoveryRunnable
- {
- private int viewID;
-
- private CDOBranchPoint branchPoint;
-
- private boolean transaction;
-
- public OpenViewRunnable(InternalCDOView view)
- {
- viewID = view.getViewID();
- branchPoint = CDOBranchUtil.copyBranchPoint(view);
- transaction = view instanceof CDOTransaction;
- }
-
- public void run(CDOSessionProtocol sessionProtocol)
- {
- sessionProtocol.openView(viewID, !transaction, branchPoint);
- }
- }
-
- private static class AutoCloser implements IListener
- {
- public void notifyEvent(IEvent event)
- {
- if (event instanceof IContainerEvent<?>)
- {
- IContainerEvent<?> containerEvent = (IContainerEvent<?>)event;
- if (containerEvent.getDelta().getKind() == IContainerDelta.Kind.REMOVED)
- {
- IConnector connector = (IConnector)event.getSource();
- if (connector.getChannels().size() == 0)
- {
- LifecycleUtil.deactivate(connector);
- }
- }
- }
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.util.TransportException; +import org.eclipse.emf.cdo.net4j.CDOSessionRecoveryEvent; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.session.CDOSessionEvent; +import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; +import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol; +import org.eclipse.net4j.util.container.IContainerDelta; +import org.eclipse.net4j.util.container.IContainerEvent; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol; +import org.eclipse.emf.spi.cdo.InternalCDOView; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Caspar De Groot + */ +public abstract class RecoveringCDOSessionImpl extends CDONet4jSessionImpl +{ + private IManagedContainer container; + + private String repositoryConnectorDescription; + + private boolean useHeartBeat; + + private long heartBeatPeriod = 1000L; + + private long heartBeatTimeout = 5000L; + + private long connectorTimeout = 10000L; + + public RecoveringCDOSessionImpl() + { + setExceptionHandler(new RecoveringExceptionHandler()); + } + + public long getConnectorTimeout() + { + return connectorTimeout; + } + + public void setConnectorTimeout(long connectorTimeout) + { + this.connectorTimeout = connectorTimeout; + } + + public void setContainer(IManagedContainer container) + { + this.container = container; + } + + public IManagedContainer getContainer() + { + return container; + } + + public void setUseHeartBeat(boolean useHeartBeat) + { + this.useHeartBeat = useHeartBeat; + } + + public boolean getUseHeartBeat() + { + return useHeartBeat; + } + + public void setHeartBeatTimeout(long timeout) + { + heartBeatTimeout = timeout; + } + + public long getHeartBeatTimeout() + { + return heartBeatTimeout; + } + + public void setHeartBeatPeriod(long period) + { + heartBeatPeriod = period; + } + + public long getHeartBeatPeriod() + { + return heartBeatPeriod; + } + + @Override + protected void sessionProtocolDeactivated() + { + recover(); + } + + protected void recover() + { + fireEvent(createRecoveryStartedEvent()); + + CDOSessionProtocol oldSessionProtocol = getSessionProtocol(); + unhookSessionProtocol(); + List<AfterRecoveryRunnable> runnables = recoverSession(); + + // Check if the the sessionProtocol was replaced. (This may not be the case + // if the protocol is wrapped inside a DelegatingSessionProtocol.) + // + CDOSessionProtocol newSessionProtocol = getSessionProtocol(); + if (newSessionProtocol != oldSessionProtocol) + { + handleProtocolChange(oldSessionProtocol, newSessionProtocol); + } + + for (AfterRecoveryRunnable runnable : runnables) + { + runnable.run(newSessionProtocol); + } + + fireEvent(createRecoveryFinishedEvent()); + } + + protected void handleProtocolChange(CDOSessionProtocol oldProtocol, CDOSessionProtocol newProtocol) + { + // The revisionManager, branchManager, and commitInfoManager, hold their own + // references to the sessionProtocol. We need to update those: + + InternalCDORevisionManager revisionManager = getRevisionManager(); + revisionManager.deactivate(); + revisionManager.setRevisionLoader(newProtocol); + revisionManager.activate(); + + InternalCDOBranchManager branchManager = getBranchManager(); + branchManager.deactivate(); + branchManager.setBranchLoader(newProtocol); + branchManager.activate(); + + InternalCDOCommitInfoManager commitInfoManager = getCommitInfoManager(); + commitInfoManager.deactivate(); + commitInfoManager.setCommitInfoLoader(newProtocol); + commitInfoManager.activate(); + } + + protected CDOSessionEvent createRecoveryStartedEvent() + { + return new CDOSessionRecoveryEventImpl(this, CDOSessionRecoveryEvent.Type.STARTED); + } + + protected CDOSessionEvent createRecoveryFinishedEvent() + { + return new CDOSessionRecoveryEventImpl(this, CDOSessionRecoveryEvent.Type.FINISHED); + } + + protected IConnector createTCPConnector(boolean heartBeat) + { + IConnector connector = getTCPConnector(repositoryConnectorDescription); + if (heartBeat) + { + new HeartBeatProtocol(connector, container).start(heartBeatPeriod, heartBeatTimeout); + } + + connector.addListener(new AutoCloser()); + return connector; + } + + protected IConnector getTCPConnector(String description) + { + return Net4jUtil.getConnector(getContainer(), "tcp", description, connectorTimeout); + } + + protected List<AfterRecoveryRunnable> recoverSession() + { + try + { + List<AfterRecoveryRunnable> runnables = new ArrayList<AfterRecoveryRunnable>(); + for (InternalCDOView view : getViews()) + { + runnables.add(new OpenViewRunnable(view)); + } + + updateConnectorAndRepositoryName(); + openSession(); + + return runnables; + } + catch (RuntimeException ex) + { + deactivate(); + throw ex; + } + catch (Error ex) + { + deactivate(); + throw ex; + } + } + + protected IConnector removeTCPConnector() + { + return (IConnector)container.removeElement("org.eclipse.net4j.connectors", "tcp", repositoryConnectorDescription); + } + + protected void setRepositoryConnectorDescription(String description) + { + repositoryConnectorDescription = description; + } + + protected String getRepositoryConnectorDescription() + { + return repositoryConnectorDescription; + } + + @Override + protected void doActivate() throws Exception + { + updateConnectorAndRepositoryName(); + super.doActivate(); + } + + protected abstract void updateConnectorAndRepositoryName(); + + /** + * @author Eike Stepper + */ + public static interface AfterRecoveryRunnable + { + public void run(CDOSessionProtocol sessionProtocol); + } + + private class RecoveringExceptionHandler implements ExceptionHandler + { + public void handleException(CDOSession session, int attempt, Exception exception) throws Exception + { + if (exception instanceof TransportException) + { + recover(); + } + } + } + + /** + * @author Eike Stepper + */ + public final class OpenViewRunnable implements AfterRecoveryRunnable + { + private int viewID; + + private CDOBranchPoint branchPoint; + + private boolean transaction; + + public OpenViewRunnable(InternalCDOView view) + { + viewID = view.getViewID(); + branchPoint = CDOBranchUtil.copyBranchPoint(view); + transaction = view instanceof CDOTransaction; + } + + public void run(CDOSessionProtocol sessionProtocol) + { + sessionProtocol.openView(viewID, !transaction, branchPoint); + } + } + + private static class AutoCloser implements IListener + { + public void notifyEvent(IEvent event) + { + if (event instanceof IContainerEvent<?>) + { + IContainerEvent<?> containerEvent = (IContainerEvent<?>)event; + if (containerEvent.getDelta().getKind() == IContainerDelta.Kind.REMOVED) + { + IConnector connector = (IConnector)event.getSource(); + if (connector.getChannels().size() == 0) + { + LifecycleUtil.deactivate(connector); + } + } + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/bundle/OM.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/bundle/OM.java index 87184c4502..8cf25156c1 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/bundle/OM.java @@ -1,64 +1,64 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.bundle;
-
-import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreference;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.net4j"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
-
- public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION = PERF.tracer("revision"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION_LOADING = PERF_REVISION.tracer("loading"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
- public static final OMPreference<Integer> PREF_COMMIT_MONITOR_PROGRESS_SECONDS = //
- PREFS.init("PREF_COMMIT_MONITOR_PROGRESS_SECONDS", CommitTransactionRequest.DEFAULT_MONITOR_PROGRESS_SECONDS); //$NON-NLS-1$
-
- public static final OMPreference<Integer> PREF_COMMIT_MONITOR_TIMEOUT_SECONDS = //
- PREFS.init("PREF_COMMIT_MONITOR_TIMEOUT_SECONDS", CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS); //$NON-NLS-1$
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.bundle; + +import org.eclipse.emf.cdo.internal.net4j.protocol.CommitTransactionRequest; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.pref.OMPreference; +import org.eclipse.net4j.util.om.pref.OMPreferences; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * The <em>Operations & Maintenance</em> class of this bundle. + * + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo.net4j"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$ + + public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$ + + public static final OMTracer PERF_REVISION = PERF.tracer("revision"); //$NON-NLS-1$ + + public static final OMTracer PERF_REVISION_LOADING = PERF_REVISION.tracer("loading"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + public static final OMPreferences PREFS = BUNDLE.preferences(); + + public static final OMPreference<Integer> PREF_COMMIT_MONITOR_PROGRESS_SECONDS = // + PREFS.init("PREF_COMMIT_MONITOR_PROGRESS_SECONDS", CommitTransactionRequest.DEFAULT_MONITOR_PROGRESS_SECONDS); //$NON-NLS-1$ + + public static final OMPreference<Integer> PREF_COMMIT_MONITOR_TIMEOUT_SECONDS = // + PREFS.init("PREF_COMMIT_MONITOR_TIMEOUT_SECONDS", CommitTransactionRequest.DEFAULT_MONITOR_TIMEOUT_SECONDS); //$NON-NLS-1$ + + /** + * @author Eike Stepper + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/Messages.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/Messages.java index 9a39b10eca..13e07ffd81 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/Messages.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/Messages.java @@ -1,41 +1,41 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j.messages;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class Messages
-{
- private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.internal.net4j.messages.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages()
- {
- }
-
- public static String getString(String key)
- {
- try
- {
- return RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException e)
- {
- return '!' + key + '!';
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j.messages; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * @author Victor Roldan Betancort + */ +public class Messages +{ + private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.internal.net4j.messages.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() + { + } + + public static String getString(String key) + { + try + { + return RESOURCE_BUNDLE.getString(key); + } + catch (MissingResourceException e) + { + return '!' + key + '!'; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/messages.properties b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/messages.properties index 82c295ef5b..809a93b31c 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/messages.properties +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/messages/messages.properties @@ -1,17 +1,17 @@ -# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-# 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
-
-FailOverStrategyInjector.0=Malformed URI, could not find scheme separator ://
-FailOverStrategyInjector.1=factoryType not defined
-FailOverStrategyInjector.2=connectorDescription not defined
-CommitTransactionPhase2Request.1=Missing informations. {0} is not involved in the commit
-CommitTransactionPhase2Request.2=Missing informations. {0} is not mapped in the commit
-OpenSessionRequest.0=Repository {0} not found
-OpenSessionRequest.3=Failed to open session for repository {0}
-SyncRevisionsRequest.2=Did not expect to receive object with id "{0}"
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. +# 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 + +FailOverStrategyInjector.0=Malformed URI, could not find scheme separator :// +FailOverStrategyInjector.1=factoryType not defined +FailOverStrategyInjector.2=connectorDescription not defined +CommitTransactionPhase2Request.1=Missing informations. {0} is not involved in the commit +CommitTransactionPhase2Request.2=Missing informations. {0} is not mapped in the commit +OpenSessionRequest.0=Repository {0} not found +OpenSessionRequest.3=Failed to open session for repository {0} +SyncRevisionsRequest.2=Did not expect to receive object with id "{0}" diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/BranchNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/BranchNotificationIndication.java index bda761a4c8..e8a5e70082 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/BranchNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/BranchNotificationIndication.java @@ -1,40 +1,40 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class BranchNotificationIndication extends CDOClientIndication
-{
- public BranchNotificationIndication(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_BRANCH_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- CDOBranch branch = in.readCDOBranch();
-
- InternalCDOBranchManager branchManager = getSession().getBranchManager();
- branchManager.handleBranchCreated((InternalCDOBranch)branch);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class BranchNotificationIndication extends CDOClientIndication +{ + public BranchNotificationIndication(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_BRANCH_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + CDOBranch branch = in.readCDOBranch(); + + InternalCDOBranchManager branchManager = getSession().getBranchManager(); + branchManager.handleBranchCreated((InternalCDOBranch)branch); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java index 73146f26a1..b9098bf82c 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientIndication.java @@ -1,103 +1,103 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.lob.CDOLobStore;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
-import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl;
-
-import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.StringIO;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOClientIndication extends Indication
-{
- public CDOClientIndication(CDOClientProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- public CDOClientProtocol getProtocol()
- {
- return (CDOClientProtocol)super.getProtocol();
- }
-
- protected InternalCDOSession getSession()
- {
- return (InternalCDOSession)getProtocol().getSession();
- }
-
- @Override
- protected final void indicating(ExtendedDataInputStream in) throws Exception
- {
- indicating(new CDODataInputImpl(in)
- {
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
-
- @Override
- protected CDOListFactory getListFactory()
- {
- return CDOListWithElementProxiesImpl.FACTORY;
- }
-
- @Override
- protected CDOPackageRegistry getPackageRegistry()
- {
- return getSession().getPackageRegistry();
- }
-
- @Override
- protected CDOBranchManager getBranchManager()
- {
- return getSession().getBranchManager();
- }
-
- @Override
- protected CDOCommitInfoManager getCommitInfoManager()
- {
- return getSession().getCommitInfoManager();
- }
-
- @Override
- protected CDORevisionFactory getRevisionFactory()
- {
- return getSession().getRevisionManager().getFactory();
- }
-
- @Override
- protected CDOLobStore getLobStore()
- {
- return getSession().getLobStore();
- }
- });
- }
-
- protected abstract void indicating(CDODataInput in) throws IOException;
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchManager; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; +import org.eclipse.emf.cdo.common.lob.CDOLobStore; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.revision.CDOListFactory; +import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl; +import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl; + +import org.eclipse.net4j.signal.Indication; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.StringIO; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public abstract class CDOClientIndication extends Indication +{ + public CDOClientIndication(CDOClientProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + public CDOClientProtocol getProtocol() + { + return (CDOClientProtocol)super.getProtocol(); + } + + protected InternalCDOSession getSession() + { + return (InternalCDOSession)getProtocol().getSession(); + } + + @Override + protected final void indicating(ExtendedDataInputStream in) throws Exception + { + indicating(new CDODataInputImpl(in) + { + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + + @Override + protected CDOListFactory getListFactory() + { + return CDOListWithElementProxiesImpl.FACTORY; + } + + @Override + protected CDOPackageRegistry getPackageRegistry() + { + return getSession().getPackageRegistry(); + } + + @Override + protected CDOBranchManager getBranchManager() + { + return getSession().getBranchManager(); + } + + @Override + protected CDOCommitInfoManager getCommitInfoManager() + { + return getSession().getCommitInfoManager(); + } + + @Override + protected CDORevisionFactory getRevisionFactory() + { + return getSession().getRevisionManager().getFactory(); + } + + @Override + protected CDOLobStore getLobStore() + { + return getSession().getLobStore(); + } + }); + } + + protected abstract void indicating(CDODataInput in) throws IOException; +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java index f0ab9f9f18..55ee5d22e3 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java @@ -1,551 +1,551 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.lob.CDOLob;
-import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.util.TransportException;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
-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.commit.CDORevisionAvailabilityInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.signal.RemoteException;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.signal.RequestWithMonitoring;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.io.StringCompressor;
-import org.eclipse.net4j.util.io.StringIO;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.PerfTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
-import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class CDOClientProtocol extends SignalProtocol<CDOSession> implements CDOSessionProtocol
-{
- private static final PerfTracer REVISION_LOADING = new PerfTracer(OM.PERF_REVISION_LOADING, CDOClientProtocol.class);
-
- private StringIO packageURICompressor = StringCompressor.BYPASS ? StringIO.DIRECT : new StringCompressor(true);
-
- public CDOClientProtocol()
- {
- super(CDOProtocolConstants.PROTOCOL_NAME);
- }
-
- public CDOSession getSession()
- {
- return getInfraStructure();
- }
-
- public StringIO getPackageURICompressor()
- {
- return packageURICompressor;
- }
-
- public OpenSessionResult openSession(String repositoryName, boolean passiveUpdateEnabled,
- PassiveUpdateMode passiveUpdateMode, LockNotificationMode lockNotificationMode)
- {
- return send(new OpenSessionRequest(this, repositoryName, passiveUpdateEnabled, passiveUpdateMode,
- lockNotificationMode));
- }
-
- public void disablePassiveUpdate()
- {
- send(new DisablePassiveUpdateRequest(this));
- }
-
- public void setPassiveUpdateMode(PassiveUpdateMode mode)
- {
- send(new SetPassiveUpdateModeRequest(this, mode));
- }
-
- public RepositoryTimeResult getRepositoryTime()
- {
- return send(new RepositoryTimeRequest(this));
- }
-
- public EPackage[] loadPackages(CDOPackageUnit packageUnit)
- {
- return send(new LoadPackagesRequest(this, (InternalCDOPackageUnit)packageUnit));
- }
-
- public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo)
- {
- return send(new CreateBranchRequest(this, branchID, branchInfo));
- }
-
- public BranchInfo loadBranch(int branchID)
- {
- return send(new LoadBranchRequest(this, branchID));
- }
-
- public SubBranchInfo[] loadSubBranches(int branchID)
- {
- return send(new LoadSubBranchesRequest(this, branchID));
- }
-
- public int loadBranches(int startID, int endID, CDOBranchHandler handler)
- {
- return send(new LoadBranchesRequest(this, startID, endID, handler));
- }
-
- public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
- {
- send(new LoadCommitInfosRequest(this, branch, startTime, endTime, handler));
- }
-
- public CDOCommitData loadCommitData(long timeStamp)
- {
- return send(new LoadCommitDataRequest(this, timeStamp));
- }
-
- public Object loadChunk(InternalCDORevision revision, EStructuralFeature feature, int accessIndex, int fetchIndex,
- int fromIndex, int toIndex)
- {
- return send(new LoadChunkRequest(this, revision, feature, accessIndex, fetchIndex, fromIndex, toIndex));
- }
-
- public List<InternalCDORevision> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint,
- int referenceChunk, int prefetchDepth)
- {
- return send(new LoadRevisionsRequest(this, infos, branchPoint, referenceChunk, prefetchDepth));
- }
-
- public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk)
- {
- return send(new LoadRevisionByVersionRequest(this, id, branchVersion, referenceChunk));
- }
-
- public RefreshSessionResult refresh(long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize,
- boolean enablePassiveUpdates)
- {
- return send(new RefreshSessionRequest(this, lastUpdateTime, viewedRevisions, initialChunkSize, enablePassiveUpdates));
- }
-
- public void openView(int viewID, boolean readOnly, CDOBranchPoint branchPoint)
- {
- send(new OpenViewRequest(this, viewID, readOnly, branchPoint));
- }
-
- public CDOBranchPoint openView(int viewID, boolean readOnly, String durableLockingID)
- {
- return send(new OpenViewRequest(this, viewID, readOnly, durableLockingID));
- }
-
- public void switchTarget(int viewID, CDOBranchPoint branchPoint, List<InternalCDOObject> invalidObjects,
- List<CDORevisionKey> allChangedObjects, List<CDOIDAndVersion> allDetachedObjects, OMMonitor monitor)
- {
- send(new SwitchTargetRequest(this, viewID, branchPoint, invalidObjects, allChangedObjects, allDetachedObjects),
- monitor);
- }
-
- public void closeView(int viewID)
- {
- send(new CloseViewRequest(this, viewID));
- }
-
- public void changeSubscription(int viewID, List<CDOID> ids, boolean subscribeMode, boolean clear)
- {
- send(new ChangeSubscriptionRequest(this, viewID, ids, subscribeMode, clear));
- }
-
- public void query(CDOView view, AbstractQueryIterator<?> queryResult)
- {
- send(new QueryRequest(this, view, queryResult));
- }
-
- public boolean cancelQuery(int queryId)
- {
- try
- {
- return new QueryCancelRequest(this, queryId).send();
- }
- catch (Exception ignore)
- {
- return false;
- }
- }
-
- @Deprecated
- public LockObjectsResult lockObjects(List<InternalCDORevision> revisions, int viewID, CDOBranch viewedBranch,
- LockType lockType, long timeout) throws InterruptedException
- {
- // List<CDORevisionKey> revisionKeys = new LinkedList<CDORevisionKey>();
- // for (InternalCDORevision rev : revisions)
- // {
- // revisionKeys.add(rev);
- // }
- //
- // return lockObjects2(revisionKeys, viewID, viewedBranch, lockType, false, timeout);
-
- throw new UnsupportedOperationException();
- }
-
- public LockObjectsResult lockObjects2(List<CDORevisionKey> revisionKeys, int viewID, CDOBranch viewedBranch,
- LockType lockType, boolean recursive, long timeout) throws InterruptedException
- {
- InterruptedException interruptedException = null;
- RuntimeException runtimeException = null;
-
- try
- {
- return new LockObjectsRequest(this, revisionKeys, viewID, lockType, recursive, timeout).send();
- }
- catch (RemoteException ex)
- {
- if (ex.getCause() instanceof RuntimeException)
- {
- runtimeException = (RuntimeException)ex.getCause();
- }
- else if (ex.getCause() instanceof InterruptedException)
- {
- interruptedException = (InterruptedException)ex.getCause();
- }
- else
- {
- runtimeException = WrappedException.wrap(ex);
- }
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- if (interruptedException != null)
- {
- throw interruptedException;
- }
-
- throw runtimeException;
- }
-
- public LockObjectsResult delegateLockObjects(String lockAreaID, List<CDORevisionKey> revisionKeys,
- CDOBranch viewedBranch, LockType lockType, boolean recursive, long timeout) throws InterruptedException
- {
- InterruptedException interruptedException = null;
- RuntimeException runtimeException = null;
-
- try
- {
- return new LockDelegationRequest(this, lockAreaID, revisionKeys, viewedBranch, lockType, recursive, timeout)
- .send();
- }
- catch (RemoteException ex)
- {
- if (ex.getCause() instanceof RuntimeException)
- {
- runtimeException = (RuntimeException)ex.getCause();
- }
- else if (ex.getCause() instanceof InterruptedException)
- {
- interruptedException = (InterruptedException)ex.getCause();
- }
- else
- {
- runtimeException = WrappedException.wrap(ex);
- }
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- if (interruptedException != null)
- {
- throw interruptedException;
- }
-
- throw runtimeException;
- }
-
- @Deprecated
- public void unlockObjects(CDOView view, Collection<CDOID> objectIDs, LockType lockType)
- {
- // send(new UnlockObjectsRequest(this, view.getViewID(), objectIDs, lockType, false));
-
- throw new UnsupportedOperationException();
- }
-
- public UnlockObjectsResult unlockObjects2(CDOView view, Collection<CDOID> objectIDs, LockType lockType,
- boolean recursive)
- {
- return send(new UnlockObjectsRequest(this, view.getViewID(), objectIDs, lockType, recursive));
- }
-
- public UnlockObjectsResult delegateUnlockObjects(String lockAreaID, Collection<CDOID> objectIDs, LockType lockType,
- boolean recursive)
- {
- return send(new UnlockDelegationRequest(this, lockAreaID, objectIDs, lockType, recursive));
- }
-
- public boolean isObjectLocked(CDOView view, CDOObject object, LockType lockType, boolean byOthers)
- {
- return send(new ObjectLockedRequest(this, view, object, lockType, byOthers));
- }
-
- public String changeLockArea(CDOView view, boolean create)
- {
- return send(new LockAreaRequest(this, view, create));
- }
-
- public List<byte[]> queryLobs(Set<byte[]> ids)
- {
- return send(new QueryLobsRequest(this, ids));
- }
-
- public void loadLob(CDOLobInfo info, Object outputStreamOrWriter) throws IOException
- {
- try
- {
- new LoadLobRequest(this, info, outputStreamOrWriter).send();
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
- catch (IOException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new TransportException(ex);
- }
- }
-
- public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime,
- CDORevisionHandler handler)
- {
- send(new HandleRevisionsRequest(this, eClass, branch, exactBranch, timeStamp, exactTime, handler));
- }
-
- @Deprecated
- public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks,
- CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor)
- {
- throw new UnsupportedOperationException();
- }
-
- public CommitTransactionResult commitTransaction(InternalCDOCommitContext context, OMMonitor monitor)
- {
- return send(new CommitTransactionRequest(this, context), monitor);
- }
-
- @Deprecated
- public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment,
- CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor)
- {
- throw new UnsupportedOperationException();
- }
-
- public CommitTransactionResult commitDelegation(InternalCDOCommitContext context, OMMonitor monitor)
- {
- return send(new CommitDelegationRequest(this, context), monitor);
- }
-
- public CommitTransactionResult commitXATransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- return send(new CommitXATransactionPhase1Request(this, xaContext), monitor);
- }
-
- public CommitTransactionResult commitXATransactionPhase2(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- return send(new CommitXATransactionPhase2Request(this, xaContext), monitor);
- }
-
- public CommitTransactionResult commitXATransactionPhase3(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- return send(new CommitXATransactionPhase3Request(this, xaContext), monitor);
- }
-
- public CommitTransactionResult commitXATransactionCancel(InternalCDOXACommitContext xaContext, OMMonitor monitor)
- {
- return send(new CommitXATransactionCancelRequest(this, xaContext), monitor);
- }
-
- public List<CDORemoteSession> getRemoteSessions(InternalCDORemoteSessionManager manager, boolean subscribe)
- {
- return send(new GetRemoteSessionsRequest(this, subscribe));
- }
-
- public Set<Integer> sendRemoteMessage(CDORemoteSessionMessage message, List<CDORemoteSession> recipients)
- {
- return send(new RemoteMessageRequest(this, message, recipients));
- }
-
- public boolean unsubscribeRemoteSessions()
- {
- return send(new UnsubscribeRemoteSessionsRequest(this));
- }
-
- public void replicateRepository(CDOReplicationContext context, OMMonitor monitor)
- {
- send(new ReplicateRepositoryRequest(this, context, monitor));
- }
-
- public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor)
- {
- send(new ReplicateRepositoryRawRequest(this, context), monitor);
- }
-
- public CDOChangeSetData[] loadChangeSets(CDOBranchPointRange... ranges)
- {
- return send(new LoadChangeSetsRequest(this, ranges));
- }
-
- public Set<CDOID> loadMergeData(CDORevisionAvailabilityInfo targetInfo, CDORevisionAvailabilityInfo sourceInfo,
- CDORevisionAvailabilityInfo targetBaseInfo, CDORevisionAvailabilityInfo sourceBaseInfo)
- {
- return send(new LoadMergeDataRequest(this, targetInfo, sourceInfo, targetBaseInfo, sourceBaseInfo));
- }
-
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case CDOProtocolConstants.SIGNAL_AUTHENTICATION:
- return new AuthenticationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_BRANCH_NOTIFICATION:
- return new BranchNotificationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REPOSITORY_TYPE_NOTIFICATION:
- return new RepositoryTypeNotificationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REPOSITORY_STATE_NOTIFICATION:
- return new RepositoryStateNotificationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION:
- return new CommitNotificationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REMOTE_SESSION_NOTIFICATION:
- return new RemoteSessionNotificationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE_NOTIFICATION:
- return new RemoteMessageNotificationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOCK_NOTIFICATION:
- return new LockNotificationIndication(this);
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
-
- private <RESULT> RESULT send(RequestWithConfirmation<RESULT> request)
- {
- try
- {
- return request.send();
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new TransportException(ex);
- }
- }
-
- private <RESULT> RESULT send(RequestWithMonitoring<RESULT> request, OMMonitor monitor)
- {
- try
- {
- return request.send(monitor);
- }
- catch (RuntimeException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- throw new TransportException(ex);
- }
- }
-
- private List<InternalCDORevision> send(LoadRevisionsRequest request)
- {
- try
- {
- REVISION_LOADING.start(request);
- return send((RequestWithConfirmation<List<InternalCDORevision>>)request);
- }
- finally
- {
- REVISION_LOADING.stop(request);
- }
- }
-
- public CDOLockState[] getLockStates(int viewID, Collection<CDOID> ids)
- {
- return send(new LockStateRequest(this, viewID, ids));
- }
-
- public void enableLockNotifications(int viewID, boolean on)
- {
- send(new EnableLockNotificationRequest(this, viewID, on));
- }
-
- public void setLockNotificationMode(LockNotificationMode mode)
- {
- send(new SetLockNotificationModeRequest(this, mode));
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode; +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode; +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchHandler; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.commit.CDOCommitData; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.lob.CDOLob; +import org.eclipse.emf.cdo.common.lob.CDOLobInfo; +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.util.TransportException; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.session.remote.CDORemoteSession; +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.commit.CDORevisionAvailabilityInfo; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.signal.RemoteException; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.signal.RequestWithMonitoring; +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.signal.SignalReactor; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.collection.Pair; +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; +import org.eclipse.net4j.util.io.StringCompressor; +import org.eclipse.net4j.util.io.StringIO; +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.trace.PerfTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.spi.cdo.AbstractQueryIterator; +import org.eclipse.emf.spi.cdo.CDOSessionProtocol; +import org.eclipse.emf.spi.cdo.InternalCDOObject; +import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager; +import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext; +import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext; + +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class CDOClientProtocol extends SignalProtocol<CDOSession> implements CDOSessionProtocol +{ + private static final PerfTracer REVISION_LOADING = new PerfTracer(OM.PERF_REVISION_LOADING, CDOClientProtocol.class); + + private StringIO packageURICompressor = StringCompressor.BYPASS ? StringIO.DIRECT : new StringCompressor(true); + + public CDOClientProtocol() + { + super(CDOProtocolConstants.PROTOCOL_NAME); + } + + public CDOSession getSession() + { + return getInfraStructure(); + } + + public StringIO getPackageURICompressor() + { + return packageURICompressor; + } + + public OpenSessionResult openSession(String repositoryName, boolean passiveUpdateEnabled, + PassiveUpdateMode passiveUpdateMode, LockNotificationMode lockNotificationMode) + { + return send(new OpenSessionRequest(this, repositoryName, passiveUpdateEnabled, passiveUpdateMode, + lockNotificationMode)); + } + + public void disablePassiveUpdate() + { + send(new DisablePassiveUpdateRequest(this)); + } + + public void setPassiveUpdateMode(PassiveUpdateMode mode) + { + send(new SetPassiveUpdateModeRequest(this, mode)); + } + + public RepositoryTimeResult getRepositoryTime() + { + return send(new RepositoryTimeRequest(this)); + } + + public EPackage[] loadPackages(CDOPackageUnit packageUnit) + { + return send(new LoadPackagesRequest(this, (InternalCDOPackageUnit)packageUnit)); + } + + public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo) + { + return send(new CreateBranchRequest(this, branchID, branchInfo)); + } + + public BranchInfo loadBranch(int branchID) + { + return send(new LoadBranchRequest(this, branchID)); + } + + public SubBranchInfo[] loadSubBranches(int branchID) + { + return send(new LoadSubBranchesRequest(this, branchID)); + } + + public int loadBranches(int startID, int endID, CDOBranchHandler handler) + { + return send(new LoadBranchesRequest(this, startID, endID, handler)); + } + + public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler) + { + send(new LoadCommitInfosRequest(this, branch, startTime, endTime, handler)); + } + + public CDOCommitData loadCommitData(long timeStamp) + { + return send(new LoadCommitDataRequest(this, timeStamp)); + } + + public Object loadChunk(InternalCDORevision revision, EStructuralFeature feature, int accessIndex, int fetchIndex, + int fromIndex, int toIndex) + { + return send(new LoadChunkRequest(this, revision, feature, accessIndex, fetchIndex, fromIndex, toIndex)); + } + + public List<InternalCDORevision> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint, + int referenceChunk, int prefetchDepth) + { + return send(new LoadRevisionsRequest(this, infos, branchPoint, referenceChunk, prefetchDepth)); + } + + public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk) + { + return send(new LoadRevisionByVersionRequest(this, id, branchVersion, referenceChunk)); + } + + public RefreshSessionResult refresh(long lastUpdateTime, + Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize, + boolean enablePassiveUpdates) + { + return send(new RefreshSessionRequest(this, lastUpdateTime, viewedRevisions, initialChunkSize, enablePassiveUpdates)); + } + + public void openView(int viewID, boolean readOnly, CDOBranchPoint branchPoint) + { + send(new OpenViewRequest(this, viewID, readOnly, branchPoint)); + } + + public CDOBranchPoint openView(int viewID, boolean readOnly, String durableLockingID) + { + return send(new OpenViewRequest(this, viewID, readOnly, durableLockingID)); + } + + public void switchTarget(int viewID, CDOBranchPoint branchPoint, List<InternalCDOObject> invalidObjects, + List<CDORevisionKey> allChangedObjects, List<CDOIDAndVersion> allDetachedObjects, OMMonitor monitor) + { + send(new SwitchTargetRequest(this, viewID, branchPoint, invalidObjects, allChangedObjects, allDetachedObjects), + monitor); + } + + public void closeView(int viewID) + { + send(new CloseViewRequest(this, viewID)); + } + + public void changeSubscription(int viewID, List<CDOID> ids, boolean subscribeMode, boolean clear) + { + send(new ChangeSubscriptionRequest(this, viewID, ids, subscribeMode, clear)); + } + + public void query(CDOView view, AbstractQueryIterator<?> queryResult) + { + send(new QueryRequest(this, view, queryResult)); + } + + public boolean cancelQuery(int queryId) + { + try + { + return new QueryCancelRequest(this, queryId).send(); + } + catch (Exception ignore) + { + return false; + } + } + + @Deprecated + public LockObjectsResult lockObjects(List<InternalCDORevision> revisions, int viewID, CDOBranch viewedBranch, + LockType lockType, long timeout) throws InterruptedException + { + // List<CDORevisionKey> revisionKeys = new LinkedList<CDORevisionKey>(); + // for (InternalCDORevision rev : revisions) + // { + // revisionKeys.add(rev); + // } + // + // return lockObjects2(revisionKeys, viewID, viewedBranch, lockType, false, timeout); + + throw new UnsupportedOperationException(); + } + + public LockObjectsResult lockObjects2(List<CDORevisionKey> revisionKeys, int viewID, CDOBranch viewedBranch, + LockType lockType, boolean recursive, long timeout) throws InterruptedException + { + InterruptedException interruptedException = null; + RuntimeException runtimeException = null; + + try + { + return new LockObjectsRequest(this, revisionKeys, viewID, lockType, recursive, timeout).send(); + } + catch (RemoteException ex) + { + if (ex.getCause() instanceof RuntimeException) + { + runtimeException = (RuntimeException)ex.getCause(); + } + else if (ex.getCause() instanceof InterruptedException) + { + interruptedException = (InterruptedException)ex.getCause(); + } + else + { + runtimeException = WrappedException.wrap(ex); + } + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + + if (interruptedException != null) + { + throw interruptedException; + } + + throw runtimeException; + } + + public LockObjectsResult delegateLockObjects(String lockAreaID, List<CDORevisionKey> revisionKeys, + CDOBranch viewedBranch, LockType lockType, boolean recursive, long timeout) throws InterruptedException + { + InterruptedException interruptedException = null; + RuntimeException runtimeException = null; + + try + { + return new LockDelegationRequest(this, lockAreaID, revisionKeys, viewedBranch, lockType, recursive, timeout) + .send(); + } + catch (RemoteException ex) + { + if (ex.getCause() instanceof RuntimeException) + { + runtimeException = (RuntimeException)ex.getCause(); + } + else if (ex.getCause() instanceof InterruptedException) + { + interruptedException = (InterruptedException)ex.getCause(); + } + else + { + runtimeException = WrappedException.wrap(ex); + } + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + + if (interruptedException != null) + { + throw interruptedException; + } + + throw runtimeException; + } + + @Deprecated + public void unlockObjects(CDOView view, Collection<CDOID> objectIDs, LockType lockType) + { + // send(new UnlockObjectsRequest(this, view.getViewID(), objectIDs, lockType, false)); + + throw new UnsupportedOperationException(); + } + + public UnlockObjectsResult unlockObjects2(CDOView view, Collection<CDOID> objectIDs, LockType lockType, + boolean recursive) + { + return send(new UnlockObjectsRequest(this, view.getViewID(), objectIDs, lockType, recursive)); + } + + public UnlockObjectsResult delegateUnlockObjects(String lockAreaID, Collection<CDOID> objectIDs, LockType lockType, + boolean recursive) + { + return send(new UnlockDelegationRequest(this, lockAreaID, objectIDs, lockType, recursive)); + } + + public boolean isObjectLocked(CDOView view, CDOObject object, LockType lockType, boolean byOthers) + { + return send(new ObjectLockedRequest(this, view, object, lockType, byOthers)); + } + + public String changeLockArea(CDOView view, boolean create) + { + return send(new LockAreaRequest(this, view, create)); + } + + public List<byte[]> queryLobs(Set<byte[]> ids) + { + return send(new QueryLobsRequest(this, ids)); + } + + public void loadLob(CDOLobInfo info, Object outputStreamOrWriter) throws IOException + { + try + { + new LoadLobRequest(this, info, outputStreamOrWriter).send(); + } + catch (RuntimeException ex) + { + throw ex; + } + catch (IOException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new TransportException(ex); + } + } + + public void handleRevisions(EClass eClass, CDOBranch branch, boolean exactBranch, long timeStamp, boolean exactTime, + CDORevisionHandler handler) + { + send(new HandleRevisionsRequest(this, eClass, branch, exactBranch, timeStamp, exactTime, handler)); + } + + @Deprecated + public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks, + CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor) + { + throw new UnsupportedOperationException(); + } + + public CommitTransactionResult commitTransaction(InternalCDOCommitContext context, OMMonitor monitor) + { + return send(new CommitTransactionRequest(this, context), monitor); + } + + @Deprecated + public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment, + CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor) + { + throw new UnsupportedOperationException(); + } + + public CommitTransactionResult commitDelegation(InternalCDOCommitContext context, OMMonitor monitor) + { + return send(new CommitDelegationRequest(this, context), monitor); + } + + public CommitTransactionResult commitXATransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor) + { + return send(new CommitXATransactionPhase1Request(this, xaContext), monitor); + } + + public CommitTransactionResult commitXATransactionPhase2(InternalCDOXACommitContext xaContext, OMMonitor monitor) + { + return send(new CommitXATransactionPhase2Request(this, xaContext), monitor); + } + + public CommitTransactionResult commitXATransactionPhase3(InternalCDOXACommitContext xaContext, OMMonitor monitor) + { + return send(new CommitXATransactionPhase3Request(this, xaContext), monitor); + } + + public CommitTransactionResult commitXATransactionCancel(InternalCDOXACommitContext xaContext, OMMonitor monitor) + { + return send(new CommitXATransactionCancelRequest(this, xaContext), monitor); + } + + public List<CDORemoteSession> getRemoteSessions(InternalCDORemoteSessionManager manager, boolean subscribe) + { + return send(new GetRemoteSessionsRequest(this, subscribe)); + } + + public Set<Integer> sendRemoteMessage(CDORemoteSessionMessage message, List<CDORemoteSession> recipients) + { + return send(new RemoteMessageRequest(this, message, recipients)); + } + + public boolean unsubscribeRemoteSessions() + { + return send(new UnsubscribeRemoteSessionsRequest(this)); + } + + public void replicateRepository(CDOReplicationContext context, OMMonitor monitor) + { + send(new ReplicateRepositoryRequest(this, context, monitor)); + } + + public void replicateRepositoryRaw(CDORawReplicationContext context, OMMonitor monitor) + { + send(new ReplicateRepositoryRawRequest(this, context), monitor); + } + + public CDOChangeSetData[] loadChangeSets(CDOBranchPointRange... ranges) + { + return send(new LoadChangeSetsRequest(this, ranges)); + } + + public Set<CDOID> loadMergeData(CDORevisionAvailabilityInfo targetInfo, CDORevisionAvailabilityInfo sourceInfo, + CDORevisionAvailabilityInfo targetBaseInfo, CDORevisionAvailabilityInfo sourceBaseInfo) + { + return send(new LoadMergeDataRequest(this, targetInfo, sourceInfo, targetBaseInfo, sourceBaseInfo)); + } + + @Override + protected SignalReactor createSignalReactor(short signalID) + { + switch (signalID) + { + case CDOProtocolConstants.SIGNAL_AUTHENTICATION: + return new AuthenticationIndication(this); + + case CDOProtocolConstants.SIGNAL_BRANCH_NOTIFICATION: + return new BranchNotificationIndication(this); + + case CDOProtocolConstants.SIGNAL_REPOSITORY_TYPE_NOTIFICATION: + return new RepositoryTypeNotificationIndication(this); + + case CDOProtocolConstants.SIGNAL_REPOSITORY_STATE_NOTIFICATION: + return new RepositoryStateNotificationIndication(this); + + case CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION: + return new CommitNotificationIndication(this); + + case CDOProtocolConstants.SIGNAL_REMOTE_SESSION_NOTIFICATION: + return new RemoteSessionNotificationIndication(this); + + case CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE_NOTIFICATION: + return new RemoteMessageNotificationIndication(this); + + case CDOProtocolConstants.SIGNAL_LOCK_NOTIFICATION: + return new LockNotificationIndication(this); + + default: + return super.createSignalReactor(signalID); + } + } + + private <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) + { + try + { + return request.send(); + } + catch (RuntimeException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new TransportException(ex); + } + } + + private <RESULT> RESULT send(RequestWithMonitoring<RESULT> request, OMMonitor monitor) + { + try + { + return request.send(monitor); + } + catch (RuntimeException ex) + { + throw ex; + } + catch (Exception ex) + { + throw new TransportException(ex); + } + } + + private List<InternalCDORevision> send(LoadRevisionsRequest request) + { + try + { + REVISION_LOADING.start(request); + return send((RequestWithConfirmation<List<InternalCDORevision>>)request); + } + finally + { + REVISION_LOADING.stop(request); + } + } + + public CDOLockState[] getLockStates(int viewID, Collection<CDOID> ids) + { + return send(new LockStateRequest(this, viewID, ids)); + } + + public void enableLockNotifications(int viewID, boolean on) + { + send(new EnableLockNotificationRequest(this, viewID, on)); + } + + public void setLockNotificationMode(LockNotificationMode mode) + { + send(new SetLockNotificationModeRequest(this, mode)); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocolFactory.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocolFactory.java index 166ffff2e4..fe6c88fa3d 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocolFactory.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocolFactory.java @@ -1,40 +1,40 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-import org.eclipse.spi.net4j.ClientProtocolFactory;
-
-/**
- * @author Eike Stepper
- */
-public final class CDOClientProtocolFactory extends ClientProtocolFactory
-{
- public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME;
-
- public CDOClientProtocolFactory()
- {
- super(TYPE);
- }
-
- public CDOClientProtocol create(String description)
- {
- return new CDOClientProtocol();
- }
-
- public static CDOClientProtocol get(IManagedContainer container, String description)
- {
- return (CDOClientProtocol)container.getElement(PRODUCT_GROUP, TYPE, description);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.container.IManagedContainer; + +import org.eclipse.spi.net4j.ClientProtocolFactory; + +/** + * @author Eike Stepper + */ +public final class CDOClientProtocolFactory extends ClientProtocolFactory +{ + public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME; + + public CDOClientProtocolFactory() + { + super(TYPE); + } + + public CDOClientProtocol create(String description) + { + return new CDOClientProtocol(); + } + + public static CDOClientProtocol get(IManagedContainer container, String description) + { + return (CDOClientProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java index e9ce6c2b5d..b3e3e69447 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequest.java @@ -1,139 +1,139 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.lob.CDOLobStore;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
-import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl;
-
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.io.StringIO;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOClientRequest<RESULT> extends RequestWithConfirmation<RESULT>
-{
- public CDOClientRequest(CDOClientProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- public CDOClientProtocol getProtocol()
- {
- return (CDOClientProtocol)super.getProtocol();
- }
-
- protected InternalCDOSession getSession()
- {
- return (InternalCDOSession)getProtocol().getSession();
- }
-
- protected CDOIDProvider getIDProvider()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- requesting(new CDODataOutputImpl(out)
- {
- @Override
- public CDOPackageRegistry getPackageRegistry()
- {
- return getSession().getPackageRegistry();
- }
-
- @Override
- public CDOIDProvider getIDProvider()
- {
- return CDOClientRequest.this.getIDProvider();
- }
-
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
- });
- }
-
- @Override
- protected RESULT confirming(ExtendedDataInputStream in) throws Exception
- {
- return confirming(new CDODataInputImpl(in)
- {
- @Override
- protected CDOPackageRegistry getPackageRegistry()
- {
- return getSession().getPackageRegistry();
- }
-
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
-
- @Override
- protected CDOBranchManager getBranchManager()
- {
- return getSession().getBranchManager();
- }
-
- @Override
- protected CDOCommitInfoManager getCommitInfoManager()
- {
- return getSession().getCommitInfoManager();
- }
-
- @Override
- protected CDORevisionFactory getRevisionFactory()
- {
- return getSession().getRevisionManager().getFactory();
- }
-
- @Override
- protected CDOLobStore getLobStore()
- {
- return getSession().getLobStore();
- }
-
- @Override
- protected CDOListFactory getListFactory()
- {
- return CDOListWithElementProxiesImpl.FACTORY;
- }
- });
- }
-
- protected abstract void requesting(CDODataOutput out) throws IOException;
-
- protected abstract RESULT confirming(CDODataInput in) throws IOException;
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchManager; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.lob.CDOLobStore; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDOListFactory; +import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl; +import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl; + +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; +import org.eclipse.net4j.util.io.StringIO; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public abstract class CDOClientRequest<RESULT> extends RequestWithConfirmation<RESULT> +{ + public CDOClientRequest(CDOClientProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + public CDOClientProtocol getProtocol() + { + return (CDOClientProtocol)super.getProtocol(); + } + + protected InternalCDOSession getSession() + { + return (InternalCDOSession)getProtocol().getSession(); + } + + protected CDOIDProvider getIDProvider() + { + throw new UnsupportedOperationException(); + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws Exception + { + requesting(new CDODataOutputImpl(out) + { + @Override + public CDOPackageRegistry getPackageRegistry() + { + return getSession().getPackageRegistry(); + } + + @Override + public CDOIDProvider getIDProvider() + { + return CDOClientRequest.this.getIDProvider(); + } + + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + }); + } + + @Override + protected RESULT confirming(ExtendedDataInputStream in) throws Exception + { + return confirming(new CDODataInputImpl(in) + { + @Override + protected CDOPackageRegistry getPackageRegistry() + { + return getSession().getPackageRegistry(); + } + + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + + @Override + protected CDOBranchManager getBranchManager() + { + return getSession().getBranchManager(); + } + + @Override + protected CDOCommitInfoManager getCommitInfoManager() + { + return getSession().getCommitInfoManager(); + } + + @Override + protected CDORevisionFactory getRevisionFactory() + { + return getSession().getRevisionManager().getFactory(); + } + + @Override + protected CDOLobStore getLobStore() + { + return getSession().getLobStore(); + } + + @Override + protected CDOListFactory getListFactory() + { + return CDOListWithElementProxiesImpl.FACTORY; + } + }); + } + + protected abstract void requesting(CDODataOutput out) throws IOException; + + protected abstract RESULT confirming(CDODataInput in) throws IOException; +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java index a63e337ab9..7676875b90 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientRequestWithMonitoring.java @@ -1,166 +1,166 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 215688
- * Simon McDuff - bug 213402
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.lob.CDOLobStore;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
-import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl;
-
-import org.eclipse.net4j.signal.RequestWithMonitoring;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.io.StringIO;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOClientRequestWithMonitoring<RESULT> extends RequestWithMonitoring<RESULT>
-{
- private ExtendedDataOutputStream requestStream;
-
- private ExtendedDataInputStream confirmationStream;
-
- public CDOClientRequestWithMonitoring(CDOClientProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- public CDOClientProtocol getProtocol()
- {
- return (CDOClientProtocol)super.getProtocol();
- }
-
- protected ExtendedDataOutputStream getRequestStream()
- {
- return requestStream;
- }
-
- protected ExtendedDataInputStream getConfirmationStream()
- {
- return confirmationStream;
- }
-
- protected InternalCDOSession getSession()
- {
- return (InternalCDOSession)getProtocol().getSession();
- }
-
- protected CDOIDProvider getIDProvider()
- {
- return null;
- }
-
- @Override
- protected int getMonitorProgressSeconds()
- {
- org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)getSession();
- return session.options().getProgressInterval();
- }
-
- @Override
- protected final void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- requestStream = out;
- requesting(new CDODataOutputImpl(out)
- {
- @Override
- public CDOPackageRegistry getPackageRegistry()
- {
- return getSession().getPackageRegistry();
- }
-
- @Override
- public CDOIDProvider getIDProvider()
- {
- return CDOClientRequestWithMonitoring.this.getIDProvider();
- }
-
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
- }, monitor);
- }
-
- @Override
- protected final RESULT confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- confirmationStream = in;
- return confirming(new CDODataInputImpl(in)
- {
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
-
- @Override
- protected CDOPackageRegistry getPackageRegistry()
- {
- return getSession().getPackageRegistry();
- }
-
- @Override
- protected CDOBranchManager getBranchManager()
- {
- return getSession().getBranchManager();
- }
-
- @Override
- protected CDOCommitInfoManager getCommitInfoManager()
- {
- return getSession().getCommitInfoManager();
- }
-
- @Override
- protected CDORevisionFactory getRevisionFactory()
- {
- return getSession().getRevisionManager().getFactory();
- }
-
- @Override
- protected CDOLobStore getLobStore()
- {
- return getSession().getLobStore();
- }
-
- @Override
- protected CDOListFactory getListFactory()
- {
- return CDOListWithElementProxiesImpl.FACTORY;
- }
- }, monitor);
- }
-
- protected abstract void requesting(CDODataOutput out, OMMonitor monitor) throws IOException;
-
- protected abstract RESULT confirming(CDODataInput in, OMMonitor monitor) throws IOException;
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 201266 + * Simon McDuff - bug 215688 + * Simon McDuff - bug 213402 + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchManager; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.lob.CDOLobStore; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDOListFactory; +import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl; +import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImpl; + +import org.eclipse.net4j.signal.RequestWithMonitoring; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; +import org.eclipse.net4j.util.io.StringIO; +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public abstract class CDOClientRequestWithMonitoring<RESULT> extends RequestWithMonitoring<RESULT> +{ + private ExtendedDataOutputStream requestStream; + + private ExtendedDataInputStream confirmationStream; + + public CDOClientRequestWithMonitoring(CDOClientProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + public CDOClientProtocol getProtocol() + { + return (CDOClientProtocol)super.getProtocol(); + } + + protected ExtendedDataOutputStream getRequestStream() + { + return requestStream; + } + + protected ExtendedDataInputStream getConfirmationStream() + { + return confirmationStream; + } + + protected InternalCDOSession getSession() + { + return (InternalCDOSession)getProtocol().getSession(); + } + + protected CDOIDProvider getIDProvider() + { + return null; + } + + @Override + protected int getMonitorProgressSeconds() + { + org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)getSession(); + return session.options().getProgressInterval(); + } + + @Override + protected final void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception + { + requestStream = out; + requesting(new CDODataOutputImpl(out) + { + @Override + public CDOPackageRegistry getPackageRegistry() + { + return getSession().getPackageRegistry(); + } + + @Override + public CDOIDProvider getIDProvider() + { + return CDOClientRequestWithMonitoring.this.getIDProvider(); + } + + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + }, monitor); + } + + @Override + protected final RESULT confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception + { + confirmationStream = in; + return confirming(new CDODataInputImpl(in) + { + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + + @Override + protected CDOPackageRegistry getPackageRegistry() + { + return getSession().getPackageRegistry(); + } + + @Override + protected CDOBranchManager getBranchManager() + { + return getSession().getBranchManager(); + } + + @Override + protected CDOCommitInfoManager getCommitInfoManager() + { + return getSession().getCommitInfoManager(); + } + + @Override + protected CDORevisionFactory getRevisionFactory() + { + return getSession().getRevisionManager().getFactory(); + } + + @Override + protected CDOLobStore getLobStore() + { + return getSession().getLobStore(); + } + + @Override + protected CDOListFactory getListFactory() + { + return CDOListWithElementProxiesImpl.FACTORY; + } + }, monitor); + } + + protected abstract void requesting(CDODataOutput out, OMMonitor monitor) throws IOException; + + protected abstract RESULT confirming(CDODataInput in, OMMonitor monitor) throws IOException; +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOTimeRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOTimeRequest.java index 0c7ad1da01..58c06800d2 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOTimeRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOTimeRequest.java @@ -1,76 +1,76 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RepositoryTimeResult;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOTimeRequest<RESULT> extends CDOClientRequest<RESULT>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CDOTimeRequest.class);
-
- private RepositoryTimeResult repositoryTimeResult = new RepositoryTimeResult();
-
- public CDOTimeRequest(CDOClientProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- public RepositoryTimeResult getRepositoryTimeResult()
- {
- return repositoryTimeResult;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- repositoryTimeResult.setRequested(System.currentTimeMillis());
- if (TRACER.isEnabled())
- {
- TRACER.format("Requested: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getRequested())); //$NON-NLS-1$
- }
- }
-
- @Override
- protected RESULT confirming(CDODataInput in) throws IOException
- {
- repositoryTimeResult.setConfirmed(System.currentTimeMillis());
- if (TRACER.isEnabled())
- {
- TRACER.format("Confirmed: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getConfirmed())); //$NON-NLS-1$
- }
-
- repositoryTimeResult.setIndicated(in.readLong());
- if (TRACER.isEnabled())
- {
- TRACER.format("Read indicated: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getIndicated())); //$NON-NLS-1$
- }
-
- repositoryTimeResult.setResponded(in.readLong());
- if (TRACER.isEnabled())
- {
- TRACER.format("Read responded: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getResponded())); //$NON-NLS-1$
- }
-
- return null;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RepositoryTimeResult; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public abstract class CDOTimeRequest<RESULT> extends CDOClientRequest<RESULT> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CDOTimeRequest.class); + + private RepositoryTimeResult repositoryTimeResult = new RepositoryTimeResult(); + + public CDOTimeRequest(CDOClientProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + public RepositoryTimeResult getRepositoryTimeResult() + { + return repositoryTimeResult; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + repositoryTimeResult.setRequested(System.currentTimeMillis()); + if (TRACER.isEnabled()) + { + TRACER.format("Requested: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getRequested())); //$NON-NLS-1$ + } + } + + @Override + protected RESULT confirming(CDODataInput in) throws IOException + { + repositoryTimeResult.setConfirmed(System.currentTimeMillis()); + if (TRACER.isEnabled()) + { + TRACER.format("Confirmed: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getConfirmed())); //$NON-NLS-1$ + } + + repositoryTimeResult.setIndicated(in.readLong()); + if (TRACER.isEnabled()) + { + TRACER.format("Read indicated: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getIndicated())); //$NON-NLS-1$ + } + + repositoryTimeResult.setResponded(in.readLong()); + if (TRACER.isEnabled()) + { + TRACER.format("Read responded: {0}", CDOCommonUtil.formatTimeStamp(repositoryTimeResult.getResponded())); //$NON-NLS-1$ + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ChangeSubscriptionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ChangeSubscriptionRequest.java index d10d68dfc9..d0f2fe1605 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ChangeSubscriptionRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ChangeSubscriptionRequest.java @@ -1,77 +1,77 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- * Simon McDuff - bug 230832
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public class ChangeSubscriptionRequest extends CDOClientRequest<Boolean>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, ChangeSubscriptionRequest.class);
-
- private int viewID;
-
- private List<CDOID> ids;
-
- /**
- * true - it will subscribe id's. <br>
- * false - it will unsubscribe id's.
- */
- private boolean subscribeMode;
-
- private boolean clear;
-
- public ChangeSubscriptionRequest(CDOClientProtocol protocol, int viewID, List<CDOID> ids, boolean subscribeMode,
- boolean clear)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION);
- this.viewID = viewID;
- this.ids = ids;
- this.subscribeMode = subscribeMode;
- this.clear = clear;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("View " + viewID + " subscribing to " + ids.size()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- out.writeInt(viewID);
- out.writeBoolean(clear);
- out.writeInt(subscribeMode ? ids.size() : -ids.size());
- for (CDOID id : ids)
- {
- out.writeCDOID(id);
- }
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + * Simon McDuff - bug 230832 + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; +import java.util.List; + +/** + * @author Simon McDuff + */ +public class ChangeSubscriptionRequest extends CDOClientRequest<Boolean> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, ChangeSubscriptionRequest.class); + + private int viewID; + + private List<CDOID> ids; + + /** + * true - it will subscribe id's. <br> + * false - it will unsubscribe id's. + */ + private boolean subscribeMode; + + private boolean clear; + + public ChangeSubscriptionRequest(CDOClientProtocol protocol, int viewID, List<CDOID> ids, boolean subscribeMode, + boolean clear) + { + super(protocol, CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION); + this.viewID = viewID; + this.ids = ids; + this.subscribeMode = subscribeMode; + this.clear = clear; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.trace("View " + viewID + " subscribing to " + ids.size()); //$NON-NLS-1$ //$NON-NLS-2$ + } + + out.writeInt(viewID); + out.writeBoolean(clear); + out.writeInt(subscribeMode ? ids.size() : -ids.size()); + for (CDOID id : ids) + { + out.writeCDOID(id); + } + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CloseViewRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CloseViewRequest.java index 3d0dafd84f..948754df29 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CloseViewRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CloseViewRequest.java @@ -1,43 +1,43 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class CloseViewRequest extends CDOClientRequest<Boolean>
-{
- private int viewID;
-
- public CloseViewRequest(CDOClientProtocol protocol, int viewID)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_CLOSE_VIEW);
- this.viewID = viewID;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(viewID);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class CloseViewRequest extends CDOClientRequest<Boolean> +{ + private int viewID; + + public CloseViewRequest(CDOClientProtocol protocol, int viewID) + { + super(protocol, CDOProtocolConstants.SIGNAL_CLOSE_VIEW); + this.viewID = viewID; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(viewID); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java index 0edd51e88d..035c8bbc99 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java @@ -1,73 +1,73 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class CommitDelegationRequest extends CommitTransactionRequest
-{
- private CDOBranch branch;
-
- private String userID;
-
- private static final DelegationIDProvider delegationIDProvider = new DelegationIDProvider();
-
- public CommitDelegationRequest(CDOClientProtocol protocol, InternalCDOCommitContext context)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION, context);
-
- branch = context.getBranch();
- userID = context.getUserID();
- }
-
- @Override
- protected void requestingTransactionInfo(CDODataOutput out) throws IOException
- {
- out.writeCDOBranch(branch);
- out.writeString(userID);
- }
-
- @Override
- protected EClass getObjectType(CDOID id)
- {
- // The types of detached objects are delivered through the wire and don't need to be queried locally.
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected CDOIDProvider getIDProvider()
- {
- return delegationIDProvider;
- }
-
- /**
- * @author Eike Stepper
- */
- private static class DelegationIDProvider implements CDOIDProvider
- {
- public CDOID provideCDOID(Object idOrObject)
- {
- return (CDOID)idOrObject;
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class CommitDelegationRequest extends CommitTransactionRequest +{ + private CDOBranch branch; + + private String userID; + + private static final DelegationIDProvider delegationIDProvider = new DelegationIDProvider(); + + public CommitDelegationRequest(CDOClientProtocol protocol, InternalCDOCommitContext context) + { + super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION, context); + + branch = context.getBranch(); + userID = context.getUserID(); + } + + @Override + protected void requestingTransactionInfo(CDODataOutput out) throws IOException + { + out.writeCDOBranch(branch); + out.writeString(userID); + } + + @Override + protected EClass getObjectType(CDOID id) + { + // The types of detached objects are delivered through the wire and don't need to be queried locally. + throw new UnsupportedOperationException(); + } + + @Override + protected CDOIDProvider getIDProvider() + { + return delegationIDProvider; + } + + /** + * @author Eike Stepper + */ + private static class DelegationIDProvider implements CDOIDProvider + { + public CDOID provideCDOID(Object idOrObject) + { + return (CDOID)idOrObject; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java index e281b4600b..77588ac82f 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitNotificationIndication.java @@ -1,39 +1,39 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class CommitNotificationIndication extends CDOClientIndication
-{
- public CommitNotificationIndication(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- InternalCDOSession session = getSession();
- CDOCommitInfo commitInfo = in.readCDOCommitInfo();
- session.handleCommitNotification(commitInfo);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class CommitNotificationIndication extends CDOClientIndication +{ + public CommitNotificationIndication(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + InternalCDOSession session = getSession(); + CDOCommitInfo commitInfo = in.readCDOCommitInfo(); + session.handleCommitNotification(commitInfo); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java index 60ccc656dd..4a54858412 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java @@ -1,323 +1,323 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 215688
- * Simon McDuff - bug 213402
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOObjectReference;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.id.CDOIDReference;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.lob.CDOBlob;
-import org.eclipse.emf.cdo.common.lob.CDOClob;
-import org.eclipse.emf.cdo.common.lob.CDOLob;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.emf.internal.cdo.object.CDOObjectReferenceImpl;
-
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
-
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<CommitTransactionResult>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionRequest.class);
-
- private static long sleepMillisForTesting = 0L;
-
- private CDOIDProvider idProvider; // CDOTransaction
-
- private String comment;
-
- private boolean releaseLocks;
-
- private CDOCommitData commitData;
-
- private Collection<CDOLob<?>> lobs;
-
- private Collection<CDOLockState> locksOnNewObjects;
-
- private int viewID;
-
- private CDOTransaction transaction;
-
- public CommitTransactionRequest(CDOClientProtocol protocol, InternalCDOCommitContext context)
- {
- this(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION, context);
- }
-
- public CommitTransactionRequest(CDOClientProtocol protocol, short signalID, InternalCDOCommitContext context)
- {
- super(protocol, signalID);
-
- transaction = context.getTransaction();
- comment = context.getCommitComment();
- releaseLocks = context.isAutoReleaseLocks();
- idProvider = context.getTransaction();
- commitData = context.getCommitData();
- lobs = context.getLobs();
- locksOnNewObjects = context.getLocksOnNewObjects();
- viewID = context.getViewID();
- }
-
- @Override
- protected int getMonitorTimeoutSeconds()
- {
- org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)getSession();
- return session.options().getCommitTimeout();
- }
-
- @Override
- protected CDOIDProvider getIDProvider()
- {
- return idProvider;
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- requestingTransactionInfo(out);
- requestingCommit(out);
- }
-
- protected void requestingTransactionInfo(CDODataOutput out) throws IOException
- {
- out.writeInt(viewID);
- }
-
- protected void requestingCommit(CDODataOutput out) throws IOException
- {
- List<CDOPackageUnit> newPackageUnits = commitData.getNewPackageUnits();
- List<CDOIDAndVersion> newObjects = commitData.getNewObjects();
- List<CDORevisionKey> changedObjects = commitData.getChangedObjects();
- List<CDOIDAndVersion> detachedObjects = commitData.getDetachedObjects();
-
- out.writeBoolean(releaseLocks);
- out.writeString(comment);
- out.writeInt(newPackageUnits.size());
- out.writeInt(locksOnNewObjects.size());
- out.writeInt(newObjects.size());
- out.writeInt(changedObjects.size());
- out.writeInt(detachedObjects.size());
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} new package units", newPackageUnits.size()); //$NON-NLS-1$
- }
-
- for (CDOPackageUnit newPackageUnit : newPackageUnits)
- {
- out.writeCDOPackageUnit(newPackageUnit, true);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} locks on new objects", locksOnNewObjects.size()); //$NON-NLS-1$
- }
-
- for (CDOLockState lockState : locksOnNewObjects)
- {
- out.writeCDOLockState(lockState);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} new objects", newObjects.size()); //$NON-NLS-1$
- }
-
- for (CDOIDAndVersion newObject : newObjects)
- {
- out.writeCDORevision((CDORevision)newObject, CDORevision.UNCHUNKED);
-
- if (sleepMillisForTesting != 0L)
- {
- ConcurrencyUtil.sleep(sleepMillisForTesting);
- }
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} dirty objects", changedObjects.size()); //$NON-NLS-1$
- }
-
- for (CDORevisionKey changedObject : changedObjects)
- {
- out.writeCDORevisionDelta((CDORevisionDelta)changedObject);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} detached objects", detachedObjects.size()); //$NON-NLS-1$
- }
-
- boolean ensuringReferentialIntegrity = getSession().getRepositoryInfo().isEnsuringReferentialIntegrity();
- for (CDOIDAndVersion detachedObject : detachedObjects)
- {
- CDOID id = detachedObject.getID();
- out.writeCDOID(id);
- if (ensuringReferentialIntegrity)
- {
- EClass eClass = getObjectType(id);
- out.writeCDOClassifierRef(eClass);
- }
- }
-
- requestingLobs();
- }
-
- protected void requestingLobs() throws IOException
- {
- ExtendedDataOutputStream out = getRequestStream();
- out.writeInt(lobs.size());
- for (CDOLob<?> lob : lobs)
- {
- out.writeByteArray(lob.getID());
- long size = lob.getSize();
- if (lob instanceof CDOBlob)
- {
- CDOBlob blob = (CDOBlob)lob;
- out.writeLong(size);
- IOUtil.copyBinary(blob.getContents(), out, size);
- }
- else
- {
- CDOClob clob = (CDOClob)lob;
- out.writeLong(-size);
- IOUtil.copyCharacter(clob.getContents(), new OutputStreamWriter(out), size);
- }
- }
- }
-
- protected EClass getObjectType(CDOID id)
- {
- CDOObject object = transaction.getObject(id);
- return object.eClass();
- }
-
- @Override
- protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- CommitTransactionResult result = confirmingCheckError(in);
- if (result != null)
- {
- return result;
- }
-
- result = confirmingResult(in);
- confirmingMappingNewObjects(in, result);
- confirmingNewLockStates(in, result);
- return result;
- }
-
- protected CommitTransactionResult confirmingCheckError(CDODataInput in) throws IOException
- {
- boolean success = in.readBoolean();
- if (!success)
- {
- String rollbackMessage = in.readString();
- OM.LOG.error(rollbackMessage);
-
- CDOBranchPoint branchPoint = in.readCDOBranchPoint();
- long previousTimeStamp = in.readLong();
-
- List<CDOObjectReference> xRefs = null;
- int size = in.readInt();
- if (size != 0)
- {
- xRefs = new ArrayList<CDOObjectReference>(size);
- for (int i = 0; i < size; i++)
- {
- CDOIDReference idReference = in.readCDOIDReference();
- xRefs.add(new CDOObjectReferenceImpl(transaction, idReference));
- }
- }
-
- return new CommitTransactionResult(idProvider, rollbackMessage, branchPoint, previousTimeStamp, xRefs);
- }
-
- return null;
- }
-
- protected CommitTransactionResult confirmingResult(CDODataInput in) throws IOException
- {
- CDOBranchPoint branchPoint = in.readCDOBranchPoint();
- long previousTimeStamp = in.readLong();
- return new CommitTransactionResult(idProvider, branchPoint, previousTimeStamp);
- }
-
- protected void confirmingMappingNewObjects(CDODataInput in, CommitTransactionResult result) throws IOException
- {
- for (;;)
- {
- CDOID id = in.readCDOID();
- if (CDOIDUtil.isNull(id))
- {
- break;
- }
-
- if (id instanceof CDOIDTemp)
- {
- CDOIDTemp oldID = (CDOIDTemp)id;
- CDOID newID = in.readCDOID();
- result.addIDMapping(oldID, newID);
- }
- else
- {
- throw new ClassCastException("Not a temporary ID: " + id);
- }
- }
- }
-
- protected void confirmingNewLockStates(CDODataInput in, CommitTransactionResult result) throws IOException
- {
- int n = in.readInt();
- CDOLockState[] newLockStates = new CDOLockState[n];
-
- for (int i = 0; i < n; i++)
- {
- newLockStates[i] = in.readCDOLockState();
- }
-
- result.setNewLockStates(newLockStates);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 201266 + * Simon McDuff - bug 215688 + * Simon McDuff - bug 213402 + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.CDOObjectReference; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.commit.CDOCommitData; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.id.CDOIDReference; +import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.lob.CDOBlob; +import org.eclipse.emf.cdo.common.lob.CDOClob; +import org.eclipse.emf.cdo.common.lob.CDOLob; +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.emf.internal.cdo.object.CDOObjectReferenceImpl; + +import org.eclipse.net4j.util.concurrent.ConcurrencyUtil; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; +import org.eclipse.net4j.util.io.IOUtil; +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; +import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<CommitTransactionResult> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionRequest.class); + + private static long sleepMillisForTesting = 0L; + + private CDOIDProvider idProvider; // CDOTransaction + + private String comment; + + private boolean releaseLocks; + + private CDOCommitData commitData; + + private Collection<CDOLob<?>> lobs; + + private Collection<CDOLockState> locksOnNewObjects; + + private int viewID; + + private CDOTransaction transaction; + + public CommitTransactionRequest(CDOClientProtocol protocol, InternalCDOCommitContext context) + { + this(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION, context); + } + + public CommitTransactionRequest(CDOClientProtocol protocol, short signalID, InternalCDOCommitContext context) + { + super(protocol, signalID); + + transaction = context.getTransaction(); + comment = context.getCommitComment(); + releaseLocks = context.isAutoReleaseLocks(); + idProvider = context.getTransaction(); + commitData = context.getCommitData(); + lobs = context.getLobs(); + locksOnNewObjects = context.getLocksOnNewObjects(); + viewID = context.getViewID(); + } + + @Override + protected int getMonitorTimeoutSeconds() + { + org.eclipse.emf.cdo.net4j.CDONet4jSession session = (org.eclipse.emf.cdo.net4j.CDONet4jSession)getSession(); + return session.options().getCommitTimeout(); + } + + @Override + protected CDOIDProvider getIDProvider() + { + return idProvider; + } + + @Override + protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException + { + requestingTransactionInfo(out); + requestingCommit(out); + } + + protected void requestingTransactionInfo(CDODataOutput out) throws IOException + { + out.writeInt(viewID); + } + + protected void requestingCommit(CDODataOutput out) throws IOException + { + List<CDOPackageUnit> newPackageUnits = commitData.getNewPackageUnits(); + List<CDOIDAndVersion> newObjects = commitData.getNewObjects(); + List<CDORevisionKey> changedObjects = commitData.getChangedObjects(); + List<CDOIDAndVersion> detachedObjects = commitData.getDetachedObjects(); + + out.writeBoolean(releaseLocks); + out.writeString(comment); + out.writeInt(newPackageUnits.size()); + out.writeInt(locksOnNewObjects.size()); + out.writeInt(newObjects.size()); + out.writeInt(changedObjects.size()); + out.writeInt(detachedObjects.size()); + + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} new package units", newPackageUnits.size()); //$NON-NLS-1$ + } + + for (CDOPackageUnit newPackageUnit : newPackageUnits) + { + out.writeCDOPackageUnit(newPackageUnit, true); + } + + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} locks on new objects", locksOnNewObjects.size()); //$NON-NLS-1$ + } + + for (CDOLockState lockState : locksOnNewObjects) + { + out.writeCDOLockState(lockState); + } + + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} new objects", newObjects.size()); //$NON-NLS-1$ + } + + for (CDOIDAndVersion newObject : newObjects) + { + out.writeCDORevision((CDORevision)newObject, CDORevision.UNCHUNKED); + + if (sleepMillisForTesting != 0L) + { + ConcurrencyUtil.sleep(sleepMillisForTesting); + } + } + + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} dirty objects", changedObjects.size()); //$NON-NLS-1$ + } + + for (CDORevisionKey changedObject : changedObjects) + { + out.writeCDORevisionDelta((CDORevisionDelta)changedObject); + } + + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} detached objects", detachedObjects.size()); //$NON-NLS-1$ + } + + boolean ensuringReferentialIntegrity = getSession().getRepositoryInfo().isEnsuringReferentialIntegrity(); + for (CDOIDAndVersion detachedObject : detachedObjects) + { + CDOID id = detachedObject.getID(); + out.writeCDOID(id); + if (ensuringReferentialIntegrity) + { + EClass eClass = getObjectType(id); + out.writeCDOClassifierRef(eClass); + } + } + + requestingLobs(); + } + + protected void requestingLobs() throws IOException + { + ExtendedDataOutputStream out = getRequestStream(); + out.writeInt(lobs.size()); + for (CDOLob<?> lob : lobs) + { + out.writeByteArray(lob.getID()); + long size = lob.getSize(); + if (lob instanceof CDOBlob) + { + CDOBlob blob = (CDOBlob)lob; + out.writeLong(size); + IOUtil.copyBinary(blob.getContents(), out, size); + } + else + { + CDOClob clob = (CDOClob)lob; + out.writeLong(-size); + IOUtil.copyCharacter(clob.getContents(), new OutputStreamWriter(out), size); + } + } + } + + protected EClass getObjectType(CDOID id) + { + CDOObject object = transaction.getObject(id); + return object.eClass(); + } + + @Override + protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + CommitTransactionResult result = confirmingCheckError(in); + if (result != null) + { + return result; + } + + result = confirmingResult(in); + confirmingMappingNewObjects(in, result); + confirmingNewLockStates(in, result); + return result; + } + + protected CommitTransactionResult confirmingCheckError(CDODataInput in) throws IOException + { + boolean success = in.readBoolean(); + if (!success) + { + String rollbackMessage = in.readString(); + OM.LOG.error(rollbackMessage); + + CDOBranchPoint branchPoint = in.readCDOBranchPoint(); + long previousTimeStamp = in.readLong(); + + List<CDOObjectReference> xRefs = null; + int size = in.readInt(); + if (size != 0) + { + xRefs = new ArrayList<CDOObjectReference>(size); + for (int i = 0; i < size; i++) + { + CDOIDReference idReference = in.readCDOIDReference(); + xRefs.add(new CDOObjectReferenceImpl(transaction, idReference)); + } + } + + return new CommitTransactionResult(idProvider, rollbackMessage, branchPoint, previousTimeStamp, xRefs); + } + + return null; + } + + protected CommitTransactionResult confirmingResult(CDODataInput in) throws IOException + { + CDOBranchPoint branchPoint = in.readCDOBranchPoint(); + long previousTimeStamp = in.readLong(); + return new CommitTransactionResult(idProvider, branchPoint, previousTimeStamp); + } + + protected void confirmingMappingNewObjects(CDODataInput in, CommitTransactionResult result) throws IOException + { + for (;;) + { + CDOID id = in.readCDOID(); + if (CDOIDUtil.isNull(id)) + { + break; + } + + if (id instanceof CDOIDTemp) + { + CDOIDTemp oldID = (CDOIDTemp)id; + CDOID newID = in.readCDOID(); + result.addIDMapping(oldID, newID); + } + else + { + throw new ClassCastException("Not a temporary ID: " + id); + } + } + } + + protected void confirmingNewLockStates(CDODataInput in, CommitTransactionResult result) throws IOException + { + int n = in.readInt(); + CDOLockState[] newLockStates = new CDOLockState[n]; + + for (int i = 0; i < n; i++) + { + newLockStates[i] = in.readCDOLockState(); + } + + result.setNewLockStates(newLockStates); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionCancelRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionCancelRequest.java index 7cb49f2b1e..888be64cbb 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionCancelRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionCancelRequest.java @@ -1,52 +1,52 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
-import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
-
-import java.io.IOException;
-
-/**
- * Determine at which moment the server side can complete the transaction.
- * <p>
- * At this stage, everything on the database was done except to flush on the disk.
- * <p>
- * It is useful to assure that all {@link CDOTransaction} involve in that commit are synchronize.
- *
- * @author Simon McDuff
- */
-public class CommitXATransactionCancelRequest extends CommitXATransactionRequest
-{
- public CommitXATransactionCancelRequest(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_CANCEL, xaContext);
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- requestingTransactionInfo(out);
- }
-
- @Override
- protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- return confirmingCheckError(in);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; +import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext; + +import java.io.IOException; + +/** + * Determine at which moment the server side can complete the transaction. + * <p> + * At this stage, everything on the database was done except to flush on the disk. + * <p> + * It is useful to assure that all {@link CDOTransaction} involve in that commit are synchronize. + * + * @author Simon McDuff + */ +public class CommitXATransactionCancelRequest extends CommitXATransactionRequest +{ + public CommitXATransactionCancelRequest(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_CANCEL, xaContext); + } + + @Override + protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException + { + requestingTransactionInfo(out); + } + + @Override + protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + return confirmingCheckError(in); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase1Request.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase1Request.java index 5492cd5384..f7c0ec1fbb 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase1Request.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase1Request.java @@ -1,59 +1,59 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
-import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
-
-import java.io.IOException;
-
-/**
- * Phase 1 will send all the modifications to the server.
- * <p>
- * It needs to fill id mappings for objects immediately to be use by other {@link CDOTransaction} involve in that
- * commit.
- *
- * @author Simon McDuff
- */
-public class CommitXATransactionPhase1Request extends CommitXATransactionRequest
-{
- public CommitXATransactionPhase1Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE1, xaContext);
- }
-
- @Override
- protected CDOIDProvider getIDProvider()
- {
- return getCommitContext();
- }
-
- @Override
- protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- CommitTransactionResult result = confirmingCheckError(in);
- if (result != null)
- {
- return result;
- }
-
- result = confirmingResult(in);
- confirmingMappingNewObjects(in, result);
- return result;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; +import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext; + +import java.io.IOException; + +/** + * Phase 1 will send all the modifications to the server. + * <p> + * It needs to fill id mappings for objects immediately to be use by other {@link CDOTransaction} involve in that + * commit. + * + * @author Simon McDuff + */ +public class CommitXATransactionPhase1Request extends CommitXATransactionRequest +{ + public CommitXATransactionPhase1Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE1, xaContext); + } + + @Override + protected CDOIDProvider getIDProvider() + { + return getCommitContext(); + } + + @Override + protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + CommitTransactionResult result = confirmingCheckError(in); + if (result != null) + { + return result; + } + + result = confirmingResult(in); + confirmingMappingNewObjects(in, result); + return result; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java index 5acf3b9722..c91980f524 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase2Request.java @@ -1,115 +1,115 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.internal.net4j.messages.Messages;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
-import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * <p>
- * Phase 2 consist of sending the mapping of temporary/persistent CDOID from other CDOTransaction.
- * <p>
- * It will return confirmation only when the commit is ready to flush to disk.
- *
- * @author Simon McDuff
- */
-public class CommitXATransactionPhase2Request extends CommitXATransactionRequest
-{
- private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL,
- CommitXATransactionPhase1Request.class);
-
- public CommitXATransactionPhase2Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE2, xaContext);
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- requestingTransactionInfo(out);
- requestingIDMapping(out);
- }
-
- /**
- * Write IDs that are needed. only If it needs to
- */
- protected void requestingIDMapping(CDODataOutput out) throws IOException
- {
- InternalCDOXACommitContext context = getCommitContext();
- Map<CDOIDTempObjectExternalImpl, InternalCDOTransaction> requestedIDs = context.getRequestedIDs();
- int size = requestedIDs.size();
- out.writeInt(size);
- if (PROTOCOL.isEnabled())
- {
- PROTOCOL.format("Number of ids requested: {0}", size); //$NON-NLS-1$
- }
-
- for (Entry<CDOIDTempObjectExternalImpl, InternalCDOTransaction> entry : requestedIDs.entrySet())
- {
- CDOIDTempObjectExternalImpl tempID = entry.getKey();
- URI oldURIExternal = URI.createURI(tempID.toURIFragment());
- CDOID oldCDOID = CDOIDUtil.read(oldURIExternal.fragment());
-
- InternalCDOXACommitContext commitContext = context.getTransactionManager().getCommitContext(entry.getValue());
- if (commitContext == null)
- {
- throw new IllegalStateException(MessageFormat.format(
- Messages.getString("CommitTransactionPhase2Request.1"), entry //$NON-NLS-1$
- .getValue()));
- }
-
- CDOID newID = commitContext.getResult().getIDMappings().get(oldCDOID);
- if (newID == null)
- {
- throw new IllegalStateException(MessageFormat.format(
- Messages.getString("CommitTransactionPhase2Request.2"), oldCDOID //$NON-NLS-1$
- .toURIFragment()));
- }
-
- CDOID newIDExternal = CDOURIUtil.convertExternalCDOID(oldURIExternal, newID);
- if (PROTOCOL.isEnabled())
- {
- PROTOCOL.format("ID mapping: {0} --> {1}", tempID.toURIFragment(), newIDExternal.toURIFragment()); //$NON-NLS-1$
- }
-
- out.writeCDOID(tempID);
- out.writeCDOID(newIDExternal);
-
- context.getResult().addIDMapping(tempID, newIDExternal);
- }
- }
-
- @Override
- protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- return confirmingCheckError(in);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.internal.net4j.messages.Messages; +import org.eclipse.emf.cdo.util.CDOURIUtil; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; +import org.eclipse.emf.spi.cdo.InternalCDOTransaction; +import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext; + +import java.io.IOException; +import java.text.MessageFormat; +import java.util.Map; +import java.util.Map.Entry; + +/** + * <p> + * Phase 2 consist of sending the mapping of temporary/persistent CDOID from other CDOTransaction. + * <p> + * It will return confirmation only when the commit is ready to flush to disk. + * + * @author Simon McDuff + */ +public class CommitXATransactionPhase2Request extends CommitXATransactionRequest +{ + private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, + CommitXATransactionPhase1Request.class); + + public CommitXATransactionPhase2Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE2, xaContext); + } + + @Override + protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException + { + requestingTransactionInfo(out); + requestingIDMapping(out); + } + + /** + * Write IDs that are needed. only If it needs to + */ + protected void requestingIDMapping(CDODataOutput out) throws IOException + { + InternalCDOXACommitContext context = getCommitContext(); + Map<CDOIDTempObjectExternalImpl, InternalCDOTransaction> requestedIDs = context.getRequestedIDs(); + int size = requestedIDs.size(); + out.writeInt(size); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Number of ids requested: {0}", size); //$NON-NLS-1$ + } + + for (Entry<CDOIDTempObjectExternalImpl, InternalCDOTransaction> entry : requestedIDs.entrySet()) + { + CDOIDTempObjectExternalImpl tempID = entry.getKey(); + URI oldURIExternal = URI.createURI(tempID.toURIFragment()); + CDOID oldCDOID = CDOIDUtil.read(oldURIExternal.fragment()); + + InternalCDOXACommitContext commitContext = context.getTransactionManager().getCommitContext(entry.getValue()); + if (commitContext == null) + { + throw new IllegalStateException(MessageFormat.format( + Messages.getString("CommitTransactionPhase2Request.1"), entry //$NON-NLS-1$ + .getValue())); + } + + CDOID newID = commitContext.getResult().getIDMappings().get(oldCDOID); + if (newID == null) + { + throw new IllegalStateException(MessageFormat.format( + Messages.getString("CommitTransactionPhase2Request.2"), oldCDOID //$NON-NLS-1$ + .toURIFragment())); + } + + CDOID newIDExternal = CDOURIUtil.convertExternalCDOID(oldURIExternal, newID); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("ID mapping: {0} --> {1}", tempID.toURIFragment(), newIDExternal.toURIFragment()); //$NON-NLS-1$ + } + + out.writeCDOID(tempID); + out.writeCDOID(newIDExternal); + + context.getResult().addIDMapping(tempID, newIDExternal); + } + } + + @Override + protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + return confirmingCheckError(in); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase3Request.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase3Request.java index 6d726ee421..f904ecb0fc 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase3Request.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionPhase3Request.java @@ -1,59 +1,59 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
-import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
-
-import java.io.IOException;
-
-/**
- * Determine at which moment the server side can complete the transaction.
- * <p>
- * At this stage, everything on the database was done except to flush on the disk.
- * <p>
- * It is useful to assure that all {@link CDOTransaction} involve in that commit are synchronize.
- *
- * @author Simon McDuff
- */
-public class CommitXATransactionPhase3Request extends CommitXATransactionRequest
-{
- public CommitXATransactionPhase3Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE3, xaContext);
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- requestingTransactionInfo(out);
- }
-
- @Override
- protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- CommitTransactionResult result = confirmingCheckError(in);
- if (result != null)
- {
- return result;
- }
-
- InternalCDOXACommitContext context = getCommitContext();
- return context.getResult();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; +import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext; + +import java.io.IOException; + +/** + * Determine at which moment the server side can complete the transaction. + * <p> + * At this stage, everything on the database was done except to flush on the disk. + * <p> + * It is useful to assure that all {@link CDOTransaction} involve in that commit are synchronize. + * + * @author Simon McDuff + */ +public class CommitXATransactionPhase3Request extends CommitXATransactionRequest +{ + public CommitXATransactionPhase3Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE3, xaContext); + } + + @Override + protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException + { + requestingTransactionInfo(out); + } + + @Override + protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + CommitTransactionResult result = confirmingCheckError(in); + if (result != null) + { + return result; + } + + InternalCDOXACommitContext context = getCommitContext(); + return context.getResult(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java index 4126cce66e..27aca47951 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java @@ -1,32 +1,32 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
-
-/**
- * @author Eike Stepper
- */
-public class CommitXATransactionRequest extends CommitTransactionRequest
-{
- private InternalCDOXACommitContext xaContext;
-
- public CommitXATransactionRequest(CDOClientProtocol protocol, short signalID, InternalCDOXACommitContext xaContext)
- {
- super(protocol, signalID, xaContext);
- this.xaContext = xaContext;
- }
-
- protected InternalCDOXACommitContext getCommitContext()
- {
- return xaContext;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext; + +/** + * @author Eike Stepper + */ +public class CommitXATransactionRequest extends CommitTransactionRequest +{ + private InternalCDOXACommitContext xaContext; + + public CommitXATransactionRequest(CDOClientProtocol protocol, short signalID, InternalCDOXACommitContext xaContext) + { + super(protocol, signalID, xaContext); + this.xaContext = xaContext; + } + + protected InternalCDOXACommitContext getCommitContext() + { + return xaContext; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CreateBranchRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CreateBranchRequest.java index ffe5867d78..a7a859c18c 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CreateBranchRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CreateBranchRequest.java @@ -1,52 +1,52 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import org.eclipse.net4j.util.collection.Pair;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class CreateBranchRequest extends CDOClientRequest<Pair<Integer, Long>>
-{
- private int branchID;
-
- private BranchInfo branchInfo;
-
- public CreateBranchRequest(CDOClientProtocol protocol, int branchID, BranchInfo branchInfo)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_CREATE_BRANCH);
- this.branchID = branchID;
- this.branchInfo = branchInfo;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(branchID);
- branchInfo.write(out);
- }
-
- @Override
- protected Pair<Integer, Long> confirming(CDODataInput in) throws IOException
- {
- branchID = in.readInt();
- long baseTimeStamp = in.readLong();
- return new Pair<Integer, Long>(branchID, baseTimeStamp);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; + +import org.eclipse.net4j.util.collection.Pair; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class CreateBranchRequest extends CDOClientRequest<Pair<Integer, Long>> +{ + private int branchID; + + private BranchInfo branchInfo; + + public CreateBranchRequest(CDOClientProtocol protocol, int branchID, BranchInfo branchInfo) + { + super(protocol, CDOProtocolConstants.SIGNAL_CREATE_BRANCH); + this.branchID = branchID; + this.branchInfo = branchInfo; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(branchID); + branchInfo.write(out); + } + + @Override + protected Pair<Integer, Long> confirming(CDODataInput in) throws IOException + { + branchID = in.readInt(); + long baseTimeStamp = in.readLong(); + return new Pair<Integer, Long>(branchID, baseTimeStamp); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/DisablePassiveUpdateRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/DisablePassiveUpdateRequest.java index d842d2e3de..c3d2f2a9fe 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/DisablePassiveUpdateRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/DisablePassiveUpdateRequest.java @@ -1,40 +1,40 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class DisablePassiveUpdateRequest extends CDOClientRequest<Boolean>
-{
- public DisablePassiveUpdateRequest(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_DISABLE_PASSIVE_UPDATE);
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class DisablePassiveUpdateRequest extends CDOClientRequest<Boolean> +{ + public DisablePassiveUpdateRequest(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_DISABLE_PASSIVE_UPDATE); + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/EnableLockNotificationRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/EnableLockNotificationRequest.java index e161606ea7..edebee6245 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/EnableLockNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/EnableLockNotificationRequest.java @@ -1,47 +1,47 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class EnableLockNotificationRequest extends CDOClientRequest<Boolean>
-{
- private int viewID;
-
- private boolean on;
-
- public EnableLockNotificationRequest(CDOClientProtocol protocol, int viewID, boolean on)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_ENABLE_LOCK_NOTIFICATION);
- this.viewID = viewID;
- this.on = on;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(viewID);
- out.writeBoolean(on);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class EnableLockNotificationRequest extends CDOClientRequest<Boolean> +{ + private int viewID; + + private boolean on; + + public EnableLockNotificationRequest(CDOClientProtocol protocol, int viewID, boolean on) + { + super(protocol, CDOProtocolConstants.SIGNAL_ENABLE_LOCK_NOTIFICATION); + this.viewID = viewID; + this.on = on; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(viewID); + out.writeBoolean(on); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/GetRemoteSessionsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/GetRemoteSessionsRequest.java index 822d333081..22d4b03032 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/GetRemoteSessionsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/GetRemoteSessionsRequest.java @@ -1,75 +1,75 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class GetRemoteSessionsRequest extends CDOClientRequest<List<CDORemoteSession>>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, GetRemoteSessionsRequest.class);
-
- private boolean subscribe;
-
- public GetRemoteSessionsRequest(CDOClientProtocol protocol, boolean subscribe)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_GET_REMOTE_SESSIONS);
- this.subscribe = subscribe;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing subscribe: {0}", subscribe); //$NON-NLS-1$
- }
-
- out.writeBoolean(subscribe);
- }
-
- @Override
- protected List<CDORemoteSession> confirming(CDODataInput in) throws IOException
- {
- List<CDORemoteSession> result = new ArrayList<CDORemoteSession>();
-
- for (;;)
- {
- int sessionID = in.readInt();
- if (sessionID == CDOProtocolConstants.NO_MORE_REMOTE_SESSIONS)
- {
- break;
- }
-
- String userID = in.readString();
- boolean subscribed = in.readBoolean();
- InternalCDORemoteSessionManager manager = getSession().getRemoteSessionManager();
- CDORemoteSession remoteSession = manager.createRemoteSession(sessionID, userID, subscribed);
- result.add(remoteSession);
- }
-
- return result;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.remote.CDORemoteSession; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class GetRemoteSessionsRequest extends CDOClientRequest<List<CDORemoteSession>> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, GetRemoteSessionsRequest.class); + + private boolean subscribe; + + public GetRemoteSessionsRequest(CDOClientProtocol protocol, boolean subscribe) + { + super(protocol, CDOProtocolConstants.SIGNAL_GET_REMOTE_SESSIONS); + this.subscribe = subscribe; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.format("Writing subscribe: {0}", subscribe); //$NON-NLS-1$ + } + + out.writeBoolean(subscribe); + } + + @Override + protected List<CDORemoteSession> confirming(CDODataInput in) throws IOException + { + List<CDORemoteSession> result = new ArrayList<CDORemoteSession>(); + + for (;;) + { + int sessionID = in.readInt(); + if (sessionID == CDOProtocolConstants.NO_MORE_REMOTE_SESSIONS) + { + break; + } + + String userID = in.readString(); + boolean subscribed = in.readBoolean(); + InternalCDORemoteSessionManager manager = getSession().getRemoteSessionManager(); + CDORemoteSession remoteSession = manager.createRemoteSession(sessionID, userID, subscribed); + result.add(remoteSession); + } + + return result; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/HandleRevisionsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/HandleRevisionsRequest.java index 81cb185d65..d90f8fbd70 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/HandleRevisionsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/HandleRevisionsRequest.java @@ -1,127 +1,127 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class HandleRevisionsRequest extends CDOClientRequest<Boolean>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, HandleRevisionsRequest.class);
-
- private EClass eClass;
-
- private CDOBranch branch;
-
- private boolean exactBranch;
-
- private long timeStamp;
-
- private boolean exactTime;
-
- private CDORevisionHandler handler;
-
- public HandleRevisionsRequest(CDOClientProtocol protocol, EClass eClass, CDOBranch branch, boolean exactBranch,
- long timeStamp, boolean exactTime, CDORevisionHandler handler)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_HANDLE_REVISIONS);
- this.eClass = eClass;
- this.branch = branch;
- this.exactBranch = exactBranch;
- this.timeStamp = timeStamp;
- this.exactTime = exactTime;
- this.handler = handler;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (eClass != null)
- {
- out.writeBoolean(true);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing eClass: {0}", eClass); //$NON-NLS-1$
- }
-
- out.writeCDOClassifierRef(eClass);
- }
- else
- {
- out.writeBoolean(false);
- }
-
- if (branch != null)
- {
- out.writeBoolean(true);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing branch: {0}", branch); //$NON-NLS-1$
- }
-
- out.writeCDOBranch(branch);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing exactBranch: {0}", exactBranch); //$NON-NLS-1$
- }
-
- out.writeBoolean(exactBranch);
- }
- else
- {
- out.writeBoolean(false);
- }
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing timeStamp: {0}", CDOCommonUtil.formatTimeStamp(timeStamp)); //$NON-NLS-1$
- }
-
- out.writeLong(timeStamp);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing exactTime: {0}", exactTime); //$NON-NLS-1$
- }
-
- out.writeBoolean(exactTime);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- while (in.readBoolean())
- {
- CDORevision revision = in.readCDORevision();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read revision: {0}", revision); //$NON-NLS-1$
- }
-
- handler.handleRevision(revision);
- }
-
- return true;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class HandleRevisionsRequest extends CDOClientRequest<Boolean> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, HandleRevisionsRequest.class); + + private EClass eClass; + + private CDOBranch branch; + + private boolean exactBranch; + + private long timeStamp; + + private boolean exactTime; + + private CDORevisionHandler handler; + + public HandleRevisionsRequest(CDOClientProtocol protocol, EClass eClass, CDOBranch branch, boolean exactBranch, + long timeStamp, boolean exactTime, CDORevisionHandler handler) + { + super(protocol, CDOProtocolConstants.SIGNAL_HANDLE_REVISIONS); + this.eClass = eClass; + this.branch = branch; + this.exactBranch = exactBranch; + this.timeStamp = timeStamp; + this.exactTime = exactTime; + this.handler = handler; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (eClass != null) + { + out.writeBoolean(true); + if (TRACER.isEnabled()) + { + TRACER.format("Writing eClass: {0}", eClass); //$NON-NLS-1$ + } + + out.writeCDOClassifierRef(eClass); + } + else + { + out.writeBoolean(false); + } + + if (branch != null) + { + out.writeBoolean(true); + if (TRACER.isEnabled()) + { + TRACER.format("Writing branch: {0}", branch); //$NON-NLS-1$ + } + + out.writeCDOBranch(branch); + if (TRACER.isEnabled()) + { + TRACER.format("Writing exactBranch: {0}", exactBranch); //$NON-NLS-1$ + } + + out.writeBoolean(exactBranch); + } + else + { + out.writeBoolean(false); + } + if (TRACER.isEnabled()) + { + TRACER.format("Writing timeStamp: {0}", CDOCommonUtil.formatTimeStamp(timeStamp)); //$NON-NLS-1$ + } + + out.writeLong(timeStamp); + if (TRACER.isEnabled()) + { + TRACER.format("Writing exactTime: {0}", exactTime); //$NON-NLS-1$ + } + + out.writeBoolean(exactTime); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + while (in.readBoolean()) + { + CDORevision revision = in.readCDORevision(); + if (TRACER.isEnabled()) + { + TRACER.format("Read revision: {0}", revision); //$NON-NLS-1$ + } + + handler.handleRevision(revision); + } + + return true; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchRequest.java index 379d10fd67..805e984d1f 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchRequest.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadBranchRequest extends CDOClientRequest<BranchInfo>
-{
- private int branchID;
-
- public LoadBranchRequest(CDOClientProtocol protocol, int branchID)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCH);
- this.branchID = branchID;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(branchID);
- }
-
- @Override
- protected BranchInfo confirming(CDODataInput in) throws IOException
- {
- return new BranchInfo(in);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadBranchRequest extends CDOClientRequest<BranchInfo> +{ + private int branchID; + + public LoadBranchRequest(CDOClientProtocol protocol, int branchID) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCH); + this.branchID = branchID; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(branchID); + } + + @Override + protected BranchInfo confirming(CDODataInput in) throws IOException + { + return new BranchInfo(in); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchesRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchesRequest.java index 22e6a721f7..094f864795 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchesRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadBranchesRequest.java @@ -1,60 +1,60 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadBranchesRequest extends CDOClientRequest<Integer>
-{
- private int startID;
-
- private int endID;
-
- private CDOBranchHandler handler;
-
- public LoadBranchesRequest(CDOClientProtocol protocol, int startID, int endID, CDOBranchHandler handler)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCHES);
- this.startID = startID;
- this.endID = endID;
- this.handler = handler;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(startID);
- out.writeInt(endID);
- }
-
- @Override
- protected Integer confirming(CDODataInput in) throws IOException
- {
- int count = 0;
- while (in.readByte() == CDOProtocolConstants.REPLICATE_BRANCH)
- {
- CDOBranch branch = in.readCDOBranch();
- handler.handleBranch(branch);
- ++count;
- }
-
- return count;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchHandler; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadBranchesRequest extends CDOClientRequest<Integer> +{ + private int startID; + + private int endID; + + private CDOBranchHandler handler; + + public LoadBranchesRequest(CDOClientProtocol protocol, int startID, int endID, CDOBranchHandler handler) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCHES); + this.startID = startID; + this.endID = endID; + this.handler = handler; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(startID); + out.writeInt(endID); + } + + @Override + protected Integer confirming(CDODataInput in) throws IOException + { + int count = 0; + while (in.readByte() == CDOProtocolConstants.REPLICATE_BRANCH) + { + CDOBranch branch = in.readCDOBranch(); + handler.handleBranch(branch); + ++count; + } + + return count; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChangeSetsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChangeSetsRequest.java index 7c952c68fc..62629ae1f1 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChangeSetsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChangeSetsRequest.java @@ -1,57 +1,57 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadChangeSetsRequest extends CDOClientRequest<CDOChangeSetData[]>
-{
- private CDOBranchPointRange[] ranges;
-
- public LoadChangeSetsRequest(CDOClientProtocol protocol, CDOBranchPointRange... ranges)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHANGE_SETS);
- this.ranges = ranges;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(ranges.length);
- for (CDOBranchPointRange range : ranges)
- {
- out.writeCDOBranchPoint(range.getStartPoint());
- out.writeCDOBranchPoint(range.getEndPoint());
- }
- }
-
- @Override
- protected CDOChangeSetData[] confirming(CDODataInput in) throws IOException
- {
- CDOChangeSetData[] result = new CDOChangeSetData[ranges.length];
- for (int i = 0; i < result.length; i++)
- {
- CDOChangeSetData changeSetData = in.readCDOChangeSetData();
- result[i] = changeSetData;
- }
-
- return result;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadChangeSetsRequest extends CDOClientRequest<CDOChangeSetData[]> +{ + private CDOBranchPointRange[] ranges; + + public LoadChangeSetsRequest(CDOClientProtocol protocol, CDOBranchPointRange... ranges) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHANGE_SETS); + this.ranges = ranges; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(ranges.length); + for (CDOBranchPointRange range : ranges) + { + out.writeCDOBranchPoint(range.getStartPoint()); + out.writeCDOBranchPoint(range.getEndPoint()); + } + } + + @Override + protected CDOChangeSetData[] confirming(CDODataInput in) throws IOException + { + CDOChangeSetData[] result = new CDOChangeSetData[ranges.length]; + for (int i = 0; i < result.length; i++) + { + CDOChangeSetData changeSetData = in.readCDOChangeSetData(); + result[i] = changeSetData; + } + + return result; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChunkRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChunkRequest.java index 4b43d7388a..ada38a676b 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChunkRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadChunkRequest.java @@ -1,125 +1,125 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadChunkRequest extends CDOClientRequest<Object>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkRequest.class);
-
- private InternalCDORevision revision;
-
- private EStructuralFeature feature;
-
- private int accessIndex;
-
- private int fromIndex;
-
- private int toIndex;
-
- private int fetchIndex;
-
- public LoadChunkRequest(CDOClientProtocol protocol, InternalCDORevision revision, EStructuralFeature feature,
- int accessIndex, int fetchIndex, int fromIndex, int toIndex)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHUNK);
- this.revision = revision;
- this.feature = feature;
- this.accessIndex = accessIndex;
- this.fetchIndex = fetchIndex;
- this.fromIndex = fromIndex;
- this.toIndex = toIndex;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- CDOID id = revision.getID();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing revision ID: {0}", id); //$NON-NLS-1$
- }
-
- out.writeCDOID(id);
- CDOBranch branch = revision.getBranch();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing branch: {0}", branch); //$NON-NLS-1$
- }
-
- out.writeCDOBranch(branch);
- int version = revision.getVersion();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing version: {0}", version); //$NON-NLS-1$
- }
-
- out.writeInt(version);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing feature: {0}", feature); //$NON-NLS-1$
- }
-
- out.writeCDOClassifierRef(feature.getEContainingClass());
- out.writeInt(feature.getFeatureID());
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing fromIndex: {0}", fromIndex); //$NON-NLS-1$
- }
-
- int diffIndex = accessIndex - fetchIndex;
- out.writeInt(fromIndex - diffIndex);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing toIndex: {0}", toIndex); //$NON-NLS-1$
- }
-
- out.writeInt(toIndex - diffIndex);
- }
-
- @Override
- protected Object confirming(CDODataInput in) throws IOException
- {
- CDOType type = CDOModelUtil.getType(feature);
- Object accessID = null;
- InternalCDOList list = (InternalCDOList)revision.getList(feature);
- for (int i = fromIndex; i <= toIndex; i++)
- {
- Object value = type.readValue(in);
- list.setWithoutFrozenCheck(i, value);
- if (i == accessIndex)
- {
- accessID = value;
- }
- }
-
- return accessID;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOType; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadChunkRequest extends CDOClientRequest<Object> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkRequest.class); + + private InternalCDORevision revision; + + private EStructuralFeature feature; + + private int accessIndex; + + private int fromIndex; + + private int toIndex; + + private int fetchIndex; + + public LoadChunkRequest(CDOClientProtocol protocol, InternalCDORevision revision, EStructuralFeature feature, + int accessIndex, int fetchIndex, int fromIndex, int toIndex) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHUNK); + this.revision = revision; + this.feature = feature; + this.accessIndex = accessIndex; + this.fetchIndex = fetchIndex; + this.fromIndex = fromIndex; + this.toIndex = toIndex; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + CDOID id = revision.getID(); + if (TRACER.isEnabled()) + { + TRACER.format("Writing revision ID: {0}", id); //$NON-NLS-1$ + } + + out.writeCDOID(id); + CDOBranch branch = revision.getBranch(); + if (TRACER.isEnabled()) + { + TRACER.format("Writing branch: {0}", branch); //$NON-NLS-1$ + } + + out.writeCDOBranch(branch); + int version = revision.getVersion(); + if (TRACER.isEnabled()) + { + TRACER.format("Writing version: {0}", version); //$NON-NLS-1$ + } + + out.writeInt(version); + if (TRACER.isEnabled()) + { + TRACER.format("Writing feature: {0}", feature); //$NON-NLS-1$ + } + + out.writeCDOClassifierRef(feature.getEContainingClass()); + out.writeInt(feature.getFeatureID()); + if (TRACER.isEnabled()) + { + TRACER.format("Writing fromIndex: {0}", fromIndex); //$NON-NLS-1$ + } + + int diffIndex = accessIndex - fetchIndex; + out.writeInt(fromIndex - diffIndex); + if (TRACER.isEnabled()) + { + TRACER.format("Writing toIndex: {0}", toIndex); //$NON-NLS-1$ + } + + out.writeInt(toIndex - diffIndex); + } + + @Override + protected Object confirming(CDODataInput in) throws IOException + { + CDOType type = CDOModelUtil.getType(feature); + Object accessID = null; + InternalCDOList list = (InternalCDOList)revision.getList(feature); + for (int i = fromIndex; i <= toIndex; i++) + { + Object value = type.readValue(in); + list.setWithoutFrozenCheck(i, value); + if (i == accessIndex) + { + accessID = value; + } + } + + return accessID; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitDataRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitDataRequest.java index 43cb767d03..36b4b6e4e3 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitDataRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitDataRequest.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadCommitDataRequest extends CDOClientRequest<CDOCommitData>
-{
- private long timeStamp;
-
- public LoadCommitDataRequest(CDOClientProtocol protocol, long timeStamp)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_DATA);
- this.timeStamp = timeStamp;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeLong(timeStamp);
- }
-
- @Override
- protected CDOCommitData confirming(CDODataInput in) throws IOException
- {
- return in.readCDOCommitData();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.commit.CDOCommitData; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadCommitDataRequest extends CDOClientRequest<CDOCommitData> +{ + private long timeStamp; + + public LoadCommitDataRequest(CDOClientProtocol protocol, long timeStamp) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_DATA); + this.timeStamp = timeStamp; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeLong(timeStamp); + } + + @Override + protected CDOCommitData confirming(CDODataInput in) throws IOException + { + return in.readCDOCommitData(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitInfosRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitInfosRequest.java index 50724e0791..e5fd2b0ff8 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitInfosRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadCommitInfosRequest.java @@ -1,89 +1,89 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadCommitInfosRequest extends CDOClientRequest<Boolean>
-{
- private CDOBranch branch;
-
- private long startTime;
-
- private long endTime;
-
- private CDOCommitInfoHandler handler;
-
- public LoadCommitInfosRequest(CDOClientProtocol protocol, CDOBranch branch, long startTime, long endTime,
- CDOCommitInfoHandler handler)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_INFOS);
- this.branch = branch;
- this.startTime = startTime;
- this.endTime = endTime;
- this.handler = handler;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (branch == null)
- {
- out.writeBoolean(false);
- }
- else
- {
- out.writeBoolean(true);
- out.writeCDOBranch(branch);
- }
-
- out.writeLong(startTime);
- out.writeLong(endTime);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- InternalCDOCommitInfoManager manager = getSession().getCommitInfoManager();
- while (in.readBoolean())
- {
- long id = in.readLong();
- CDOBranch branch = this.branch == null ? in.readCDOBranch() : this.branch;
- long timeStamp = in.readLong();
- String userID = in.readString();
- String comment = in.readString();
-
- try
- {
- CDOCommitInfo commitInfo = manager.createCommitInfo(branch, timeStamp, id, userID, comment, null);
- handler.handleCommitInfo(commitInfo);
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
-
- return true;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadCommitInfosRequest extends CDOClientRequest<Boolean> +{ + private CDOBranch branch; + + private long startTime; + + private long endTime; + + private CDOCommitInfoHandler handler; + + public LoadCommitInfosRequest(CDOClientProtocol protocol, CDOBranch branch, long startTime, long endTime, + CDOCommitInfoHandler handler) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_INFOS); + this.branch = branch; + this.startTime = startTime; + this.endTime = endTime; + this.handler = handler; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (branch == null) + { + out.writeBoolean(false); + } + else + { + out.writeBoolean(true); + out.writeCDOBranch(branch); + } + + out.writeLong(startTime); + out.writeLong(endTime); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + InternalCDOCommitInfoManager manager = getSession().getCommitInfoManager(); + while (in.readBoolean()) + { + long id = in.readLong(); + CDOBranch branch = this.branch == null ? in.readCDOBranch() : this.branch; + long timeStamp = in.readLong(); + String userID = in.readString(); + String comment = in.readString(); + + try + { + CDOCommitInfo commitInfo = manager.createCommitInfo(branch, timeStamp, id, userID, comment, null); + handler.handleCommitInfo(commitInfo); + } + catch (Exception ex) + { + OM.LOG.error(ex); + } + } + + return true; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadLobRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadLobRequest.java index b2e24b26cf..0206cdccb2 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadLobRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadLobRequest.java @@ -1,68 +1,68 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.IOUtil;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Writer;
-
-/**
- * @author Eike Stepper
- */
-public class LoadLobRequest extends CDOClientRequest<Boolean>
-{
- private CDOLobInfo info;
-
- private Object out;
-
- public LoadLobRequest(CDOClientProtocol protocol, CDOLobInfo info, Object out)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_LOB);
- this.info = info;
- this.out = out;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeByteArray(info.getID());
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in) throws Exception
- {
- if (out instanceof OutputStream)
- {
- IOUtil.copyBinary(in, (OutputStream)out, info.getSize());
- }
- else
- {
- IOUtil.copyCharacter(new InputStreamReader(in), (Writer)out, info.getSize());
- }
-
- return true;
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.lob.CDOLobInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.IOUtil; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Writer; + +/** + * @author Eike Stepper + */ +public class LoadLobRequest extends CDOClientRequest<Boolean> +{ + private CDOLobInfo info; + + private Object out; + + public LoadLobRequest(CDOClientProtocol protocol, CDOLobInfo info, Object out) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_LOB); + this.info = info; + this.out = out; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeByteArray(info.getID()); + } + + @Override + protected Boolean confirming(ExtendedDataInputStream in) throws Exception + { + if (out instanceof OutputStream) + { + IOUtil.copyBinary(in, (OutputStream)out, info.getSize()); + } + else + { + IOUtil.copyCharacter(new InputStreamReader(in), (Writer)out, info.getSize()); + } + + return true; + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + throw new UnsupportedOperationException(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java index beb11464ea..0b0e74ffda 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadMergeDataRequest.java @@ -1,217 +1,217 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class LoadMergeDataRequest extends CDOClientRequestWithMonitoring<Set<CDOID>>
-{
- private CDORevisionAvailabilityInfo targetInfo;
-
- private CDORevisionAvailabilityInfo sourceInfo;
-
- private CDORevisionAvailabilityInfo targetBaseInfo;
-
- private CDORevisionAvailabilityInfo sourceBaseInfo;
-
- private int infos;
-
- public LoadMergeDataRequest(CDOClientProtocol protocol, CDORevisionAvailabilityInfo targetInfo,
- CDORevisionAvailabilityInfo sourceInfo, CDORevisionAvailabilityInfo targetBaseInfo,
- CDORevisionAvailabilityInfo sourceBaseInfo)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_MERGE_DATA);
- this.targetInfo = targetInfo;
- this.sourceInfo = sourceInfo;
- this.targetBaseInfo = targetBaseInfo;
- this.sourceBaseInfo = sourceBaseInfo;
- infos = 2 + (targetBaseInfo != null ? 1 : 0) + (sourceBaseInfo != null ? 1 : 0);
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- out.writeInt(infos);
- monitor.begin(infos);
-
- try
- {
- writeRevisionAvailabilityInfo(out, targetInfo, monitor.fork());
- writeRevisionAvailabilityInfo(out, sourceInfo, monitor.fork());
-
- if (infos > 2)
- {
- writeRevisionAvailabilityInfo(out, targetBaseInfo, monitor.fork());
- }
-
- if (infos > 3)
- {
- writeRevisionAvailabilityInfo(out, sourceBaseInfo, monitor.fork());
- }
- }
- finally
- {
- monitor.done();
- }
- }
-
- private void writeRevisionAvailabilityInfo(CDODataOutput out, CDORevisionAvailabilityInfo info, OMMonitor monitor)
- throws IOException
- {
- Set<CDOID> availableRevisions = info.getAvailableRevisions().keySet();
- int size = availableRevisions.size();
-
- out.writeCDOBranchPoint(info.getBranchPoint());
- out.writeInt(size);
-
- monitor.begin(size);
-
- try
- {
- for (CDOID id : availableRevisions)
- {
- out.writeCDOID(id);
- monitor.worked();
- }
- }
- finally
- {
- monitor.done();
- }
- }
-
- @Override
- protected Set<CDOID> confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- Set<CDOID> result = new HashSet<CDOID>();
-
- int size = in.readInt();
- monitor.begin(size + infos);
-
- try
- {
- for (int i = 0; i < size; i++)
- {
- CDOID id = in.readCDOID();
- result.add(id);
- monitor.worked();
- }
-
- readRevisionAvailabilityInfo(in, targetInfo, result, monitor.fork());
- readRevisionAvailabilityInfo(in, sourceInfo, result, monitor.fork());
-
- if (infos > 2)
- {
- readRevisionAvailabilityInfo(in, targetBaseInfo, result, monitor.fork());
- }
-
- if (infos > 3)
- {
- readRevisionAvailabilityInfo(in, sourceBaseInfo, result, monitor.fork());
- }
-
- return result;
- }
- finally
- {
- monitor.done();
- }
- }
-
- private void readRevisionAvailabilityInfo(CDODataInput in, CDORevisionAvailabilityInfo info, Set<CDOID> result,
- OMMonitor monitor) throws IOException
- {
- int size = in.readInt();
- monitor.begin(size + 1);
-
- try
- {
- for (int i = 0; i < size; i++)
- {
- CDORevision revision;
- if (in.readBoolean())
- {
- revision = in.readCDORevision();
- }
- else
- {
- CDORevisionKey key = in.readCDORevisionKey();
- revision = getRevision(key, targetInfo);
-
- if (revision == null && sourceInfo != null)
- {
- revision = getRevision(key, sourceInfo);
- }
-
- if (revision == null && targetBaseInfo != null)
- {
- revision = getRevision(key, targetBaseInfo);
- }
-
- if (revision == null)
- {
- throw new IllegalStateException("Missing revision: " + key);
- }
- }
-
- info.addRevision(revision);
- monitor.worked();
- }
-
- Set<Map.Entry<CDOID, CDORevisionKey>> entrySet = info.getAvailableRevisions().entrySet();
- for (Iterator<Map.Entry<CDOID, CDORevisionKey>> it = entrySet.iterator(); it.hasNext();)
- {
- Map.Entry<CDOID, CDORevisionKey> entry = it.next();
- if (!result.contains(entry.getKey()))
- {
- it.remove();
- }
- }
-
- monitor.worked();
- }
- finally
- {
- monitor.done();
- }
- }
-
- private CDORevision getRevision(CDORevisionKey key, CDORevisionAvailabilityInfo info)
- {
- CDORevisionKey revision = info.getRevision(key.getID());
- if (revision instanceof CDORevision)
- {
- if (key.equals(revision))
- {
- return (CDORevision)revision;
- }
- }
-
- return null;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class LoadMergeDataRequest extends CDOClientRequestWithMonitoring<Set<CDOID>> +{ + private CDORevisionAvailabilityInfo targetInfo; + + private CDORevisionAvailabilityInfo sourceInfo; + + private CDORevisionAvailabilityInfo targetBaseInfo; + + private CDORevisionAvailabilityInfo sourceBaseInfo; + + private int infos; + + public LoadMergeDataRequest(CDOClientProtocol protocol, CDORevisionAvailabilityInfo targetInfo, + CDORevisionAvailabilityInfo sourceInfo, CDORevisionAvailabilityInfo targetBaseInfo, + CDORevisionAvailabilityInfo sourceBaseInfo) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_MERGE_DATA); + this.targetInfo = targetInfo; + this.sourceInfo = sourceInfo; + this.targetBaseInfo = targetBaseInfo; + this.sourceBaseInfo = sourceBaseInfo; + infos = 2 + (targetBaseInfo != null ? 1 : 0) + (sourceBaseInfo != null ? 1 : 0); + } + + @Override + protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException + { + out.writeInt(infos); + monitor.begin(infos); + + try + { + writeRevisionAvailabilityInfo(out, targetInfo, monitor.fork()); + writeRevisionAvailabilityInfo(out, sourceInfo, monitor.fork()); + + if (infos > 2) + { + writeRevisionAvailabilityInfo(out, targetBaseInfo, monitor.fork()); + } + + if (infos > 3) + { + writeRevisionAvailabilityInfo(out, sourceBaseInfo, monitor.fork()); + } + } + finally + { + monitor.done(); + } + } + + private void writeRevisionAvailabilityInfo(CDODataOutput out, CDORevisionAvailabilityInfo info, OMMonitor monitor) + throws IOException + { + Set<CDOID> availableRevisions = info.getAvailableRevisions().keySet(); + int size = availableRevisions.size(); + + out.writeCDOBranchPoint(info.getBranchPoint()); + out.writeInt(size); + + monitor.begin(size); + + try + { + for (CDOID id : availableRevisions) + { + out.writeCDOID(id); + monitor.worked(); + } + } + finally + { + monitor.done(); + } + } + + @Override + protected Set<CDOID> confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + Set<CDOID> result = new HashSet<CDOID>(); + + int size = in.readInt(); + monitor.begin(size + infos); + + try + { + for (int i = 0; i < size; i++) + { + CDOID id = in.readCDOID(); + result.add(id); + monitor.worked(); + } + + readRevisionAvailabilityInfo(in, targetInfo, result, monitor.fork()); + readRevisionAvailabilityInfo(in, sourceInfo, result, monitor.fork()); + + if (infos > 2) + { + readRevisionAvailabilityInfo(in, targetBaseInfo, result, monitor.fork()); + } + + if (infos > 3) + { + readRevisionAvailabilityInfo(in, sourceBaseInfo, result, monitor.fork()); + } + + return result; + } + finally + { + monitor.done(); + } + } + + private void readRevisionAvailabilityInfo(CDODataInput in, CDORevisionAvailabilityInfo info, Set<CDOID> result, + OMMonitor monitor) throws IOException + { + int size = in.readInt(); + monitor.begin(size + 1); + + try + { + for (int i = 0; i < size; i++) + { + CDORevision revision; + if (in.readBoolean()) + { + revision = in.readCDORevision(); + } + else + { + CDORevisionKey key = in.readCDORevisionKey(); + revision = getRevision(key, targetInfo); + + if (revision == null && sourceInfo != null) + { + revision = getRevision(key, sourceInfo); + } + + if (revision == null && targetBaseInfo != null) + { + revision = getRevision(key, targetBaseInfo); + } + + if (revision == null) + { + throw new IllegalStateException("Missing revision: " + key); + } + } + + info.addRevision(revision); + monitor.worked(); + } + + Set<Map.Entry<CDOID, CDORevisionKey>> entrySet = info.getAvailableRevisions().entrySet(); + for (Iterator<Map.Entry<CDOID, CDORevisionKey>> it = entrySet.iterator(); it.hasNext();) + { + Map.Entry<CDOID, CDORevisionKey> entry = it.next(); + if (!result.contains(entry.getKey())) + { + it.remove(); + } + } + + monitor.worked(); + } + finally + { + monitor.done(); + } + } + + private CDORevision getRevision(CDORevisionKey key, CDORevisionAvailabilityInfo info) + { + CDORevisionKey revision = info.getRevision(key.getID()); + if (revision instanceof CDORevision) + { + if (key.equals(revision)) + { + return (CDORevision)revision; + } + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadPackagesRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadPackagesRequest.java index be8f8981f1..e1b811b0ea 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadPackagesRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadPackagesRequest.java @@ -1,62 +1,62 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadPackagesRequest extends CDOClientRequest<EPackage[]>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadPackagesRequest.class);
-
- private InternalCDOPackageUnit packageUnit;
-
- public LoadPackagesRequest(CDOClientProtocol protocol, InternalCDOPackageUnit packageUnit)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_PACKAGES);
- this.packageUnit = packageUnit;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- String packageUnitID = packageUnit.getID();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing packageUnitID: {0}", packageUnitID); //$NON-NLS-1$
- }
-
- out.writeCDOPackageURI(packageUnitID);
- }
-
- @Override
- protected EPackage[] confirming(CDODataInput in) throws IOException
- {
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(packageUnit.getPackageRegistry());
- EPackage ePackage = CDOModelUtil.readPackage(in, resourceSet, false);
- return EMFUtil.getAllPackages(ePackage);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadPackagesRequest extends CDOClientRequest<EPackage[]> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadPackagesRequest.class); + + private InternalCDOPackageUnit packageUnit; + + public LoadPackagesRequest(CDOClientProtocol protocol, InternalCDOPackageUnit packageUnit) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_PACKAGES); + this.packageUnit = packageUnit; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + String packageUnitID = packageUnit.getID(); + if (TRACER.isEnabled()) + { + TRACER.format("Writing packageUnitID: {0}", packageUnitID); //$NON-NLS-1$ + } + + out.writeCDOPackageURI(packageUnitID); + } + + @Override + protected EPackage[] confirming(CDODataInput in) throws IOException + { + ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(packageUnit.getPackageRegistry()); + EPackage ePackage = CDOModelUtil.readPackage(in, resourceSet, false); + return EMFUtil.getAllPackages(ePackage); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionByVersionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionByVersionRequest.java index d25270f92b..2624cc50bc 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionByVersionRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadRevisionByVersionRequest.java @@ -1,84 +1,84 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class LoadRevisionByVersionRequest extends CDOClientRequest<InternalCDORevision>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionByVersionRequest.class);
-
- private CDOID id;
-
- private CDOBranchVersion branchVersion;
-
- private int referenceChunk;
-
- public LoadRevisionByVersionRequest(CDOClientProtocol protocol, CDOID id, CDOBranchVersion branchVersion,
- int referenceChunk)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_VERSION);
- this.id = id;
- this.branchVersion = branchVersion;
- this.referenceChunk = referenceChunk;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing id: {0}", id); //$NON-NLS-1$
- }
-
- out.writeCDOID(id);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing branchVersion: {0}", branchVersion); //$NON-NLS-1$
- }
-
- out.writeCDOBranchVersion(branchVersion);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing referenceChunk: {0}", referenceChunk); //$NON-NLS-1$
- }
-
- out.writeInt(referenceChunk);
- }
-
- @Override
- protected InternalCDORevision confirming(CDODataInput in) throws IOException
- {
- return RevisionInfo.readResult(in, id, branchVersion.getBranch());
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("LoadRevisionByVersionRequest(id={0}, branchVersion={1}, referenceChunk={2})", id,
- branchVersion, referenceChunk);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class LoadRevisionByVersionRequest extends CDOClientRequest<InternalCDORevision> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionByVersionRequest.class); + + private CDOID id; + + private CDOBranchVersion branchVersion; + + private int referenceChunk; + + public LoadRevisionByVersionRequest(CDOClientProtocol protocol, CDOID id, CDOBranchVersion branchVersion, + int referenceChunk) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_VERSION); + this.id = id; + this.branchVersion = branchVersion; + this.referenceChunk = referenceChunk; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.format("Writing id: {0}", id); //$NON-NLS-1$ + } + + out.writeCDOID(id); + if (TRACER.isEnabled()) + { + TRACER.format("Writing branchVersion: {0}", branchVersion); //$NON-NLS-1$ + } + + out.writeCDOBranchVersion(branchVersion); + if (TRACER.isEnabled()) + { + TRACER.format("Writing referenceChunk: {0}", referenceChunk); //$NON-NLS-1$ + } + + out.writeInt(referenceChunk); + } + + @Override + protected InternalCDORevision confirming(CDODataInput in) throws IOException + { + return RevisionInfo.readResult(in, id, branchVersion.getBranch()); + } + + @Override + public String toString() + { + return MessageFormat.format("LoadRevisionByVersionRequest(id={0}, branchVersion={1}, referenceChunk={2})", id, + branchVersion, referenceChunk); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadSubBranchesRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadSubBranchesRequest.java index 9bb0573e19..db612a1a7a 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadSubBranchesRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LoadSubBranchesRequest.java @@ -1,51 +1,51 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadSubBranchesRequest extends CDOClientRequest<SubBranchInfo[]>
-{
- private int branchID;
-
- public LoadSubBranchesRequest(CDOClientProtocol protocol, int branchID)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_SUB_BRANCHES);
- this.branchID = branchID;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(branchID);
- }
-
- @Override
- protected SubBranchInfo[] confirming(CDODataInput in) throws IOException
- {
- int size = in.readInt();
- SubBranchInfo[] infos = new SubBranchInfo[size];
- for (int i = 0; i < infos.length; i++)
- {
- infos[i] = new SubBranchInfo(in);
- }
-
- return infos;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadSubBranchesRequest extends CDOClientRequest<SubBranchInfo[]> +{ + private int branchID; + + public LoadSubBranchesRequest(CDOClientProtocol protocol, int branchID) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_SUB_BRANCHES); + this.branchID = branchID; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(branchID); + } + + @Override + protected SubBranchInfo[] confirming(CDODataInput in) throws IOException + { + int size = in.readInt(); + SubBranchInfo[] infos = new SubBranchInfo[size]; + for (int i = 0; i < infos.length; i++) + { + infos[i] = new SubBranchInfo(in); + } + + return infos; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockAreaRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockAreaRequest.java index e65225c30d..90a36c5485 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockAreaRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockAreaRequest.java @@ -1,48 +1,48 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LockAreaRequest extends CDOClientRequest<String>
-{
- private CDOView view;
-
- private boolean create;
-
- public LockAreaRequest(CDOClientProtocol protocol, CDOView view, boolean create)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_AREA);
- this.view = view;
- this.create = create;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(view.getViewID());
- out.writeBoolean(create);
- }
-
- @Override
- protected String confirming(CDODataInput in) throws IOException
- {
- return in.readString();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.view.CDOView; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LockAreaRequest extends CDOClientRequest<String> +{ + private CDOView view; + + private boolean create; + + public LockAreaRequest(CDOClientProtocol protocol, CDOView view, boolean create) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_AREA); + this.view = view; + this.create = create; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(view.getViewID()); + out.writeBoolean(create); + } + + @Override + protected String confirming(CDODataInput in) throws IOException + { + return in.readString(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockDelegationRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockDelegationRequest.java index 5b59cbafa4..9dc23ccbc9 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockDelegationRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockDelegationRequest.java @@ -1,47 +1,47 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author Caspar De Groot
- */
-public class LockDelegationRequest extends LockObjectsRequest
-{
- private String lockAreaID;
-
- private CDOBranch viewedBranch;
-
- public LockDelegationRequest(CDOClientProtocol protocol, String lockAreaID, List<CDORevisionKey> revisionKeys,
- CDOBranch viewedBranch, LockType lockType, boolean recursive, long timeout)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_DELEGATION, revisionKeys, 0, lockType, recursive, timeout);
- this.lockAreaID = lockAreaID;
- this.viewedBranch = viewedBranch;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeString(lockAreaID);
- out.writeCDOBranch(viewedBranch);
- super.requesting(out);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import java.io.IOException; +import java.util.List; + +/** + * @author Caspar De Groot + */ +public class LockDelegationRequest extends LockObjectsRequest +{ + private String lockAreaID; + + private CDOBranch viewedBranch; + + public LockDelegationRequest(CDOClientProtocol protocol, String lockAreaID, List<CDORevisionKey> revisionKeys, + CDOBranch viewedBranch, LockType lockType, boolean recursive, long timeout) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_DELEGATION, revisionKeys, 0, lockType, recursive, timeout); + this.lockAreaID = lockAreaID; + this.viewedBranch = viewedBranch; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeString(lockAreaID); + out.writeCDOBranch(viewedBranch); + super.requesting(out); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockNotificationIndication.java index 568c3e4d8b..ec04b5da28 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockNotificationIndication.java @@ -1,38 +1,38 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class LockNotificationIndication extends CDOClientIndication
-{
- public LockNotificationIndication(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- CDOLockChangeInfo lockChangeInfo = in.readCDOLockChangeInfo();
- InternalCDOSession session = getSession();
- session.handleLockNotification(lockChangeInfo, null);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.emf.spi.cdo.InternalCDOSession; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class LockNotificationIndication extends CDOClientIndication +{ + public LockNotificationIndication(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + CDOLockChangeInfo lockChangeInfo = in.readCDOLockChangeInfo(); + InternalCDOSession session = getSession(); + session.handleLockNotification(lockChangeInfo, null); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java index b7c8b2ef9f..fbbf1e2537 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockObjectsRequest.java @@ -1,103 +1,103 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager;
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.LockObjectsResult;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author Eike Stepper, Caspar De Groot
- */
-public class LockObjectsRequest extends CDOClientRequest<LockObjectsResult>
-{
- private int viewID;
-
- private IRWLockManager.LockType lockType;
-
- private long timeout;
-
- private List<CDORevisionKey> revisionKeys;
-
- private boolean recursive;
-
- public LockObjectsRequest(CDOClientProtocol protocol, List<CDORevisionKey> revisionKeys, int viewID,
- LockType lockType, boolean recursive, long timeout)
- {
- this(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS, revisionKeys, viewID, lockType, recursive, timeout);
- }
-
- protected LockObjectsRequest(CDOClientProtocol protocol, short signalID, List<CDORevisionKey> revisionKeys,
- int viewID, LockType lockType, boolean recursive, long timeout)
- {
- super(protocol, signalID);
-
- this.viewID = viewID;
- this.lockType = lockType;
- this.timeout = timeout;
- this.revisionKeys = revisionKeys;
- this.recursive = recursive;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(viewID);
- out.writeCDOLockType(lockType);
- out.writeBoolean(recursive);
- out.writeLong(timeout);
-
- out.writeInt(revisionKeys.size());
- for (CDORevisionKey revKey : revisionKeys)
- {
- out.writeCDORevisionKey(revKey);
- }
- }
-
- @Override
- protected LockObjectsResult confirming(CDODataInput in) throws IOException
- {
- boolean succesful = in.readBoolean();
- boolean timeout = in.readBoolean();
- boolean waitForUpdate = in.readBoolean();
- long requiredTimestamp = in.readLong();
-
- int nStaleRevisions = in.readInt();
- CDORevisionKey[] staleRevisions = new CDORevisionKey[nStaleRevisions];
- for (int i = 0; i < nStaleRevisions; i++)
- {
- staleRevisions[i] = in.readCDORevisionKey();
- }
-
- long timestamp = in.readLong();
-
- int n = in.readInt();
- CDOLockState[] newLockStates = new CDOLockState[n];
- for (int i = 0; i < n; i++)
- {
- newLockStates[i] = in.readCDOLockState();
- }
-
- return new LockObjectsResult(succesful, timeout, waitForUpdate, requiredTimestamp, staleRevisions, newLockStates,
- timestamp);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Caspar De Groot - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; + +import org.eclipse.net4j.util.concurrent.IRWLockManager; +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.LockObjectsResult; + +import java.io.IOException; +import java.util.List; + +/** + * @author Eike Stepper, Caspar De Groot + */ +public class LockObjectsRequest extends CDOClientRequest<LockObjectsResult> +{ + private int viewID; + + private IRWLockManager.LockType lockType; + + private long timeout; + + private List<CDORevisionKey> revisionKeys; + + private boolean recursive; + + public LockObjectsRequest(CDOClientProtocol protocol, List<CDORevisionKey> revisionKeys, int viewID, + LockType lockType, boolean recursive, long timeout) + { + this(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS, revisionKeys, viewID, lockType, recursive, timeout); + } + + protected LockObjectsRequest(CDOClientProtocol protocol, short signalID, List<CDORevisionKey> revisionKeys, + int viewID, LockType lockType, boolean recursive, long timeout) + { + super(protocol, signalID); + + this.viewID = viewID; + this.lockType = lockType; + this.timeout = timeout; + this.revisionKeys = revisionKeys; + this.recursive = recursive; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(viewID); + out.writeCDOLockType(lockType); + out.writeBoolean(recursive); + out.writeLong(timeout); + + out.writeInt(revisionKeys.size()); + for (CDORevisionKey revKey : revisionKeys) + { + out.writeCDORevisionKey(revKey); + } + } + + @Override + protected LockObjectsResult confirming(CDODataInput in) throws IOException + { + boolean succesful = in.readBoolean(); + boolean timeout = in.readBoolean(); + boolean waitForUpdate = in.readBoolean(); + long requiredTimestamp = in.readLong(); + + int nStaleRevisions = in.readInt(); + CDORevisionKey[] staleRevisions = new CDORevisionKey[nStaleRevisions]; + for (int i = 0; i < nStaleRevisions; i++) + { + staleRevisions[i] = in.readCDORevisionKey(); + } + + long timestamp = in.readLong(); + + int n = in.readInt(); + CDOLockState[] newLockStates = new CDOLockState[n]; + for (int i = 0; i < n; i++) + { + newLockStates[i] = in.readCDOLockState(); + } + + return new LockObjectsResult(succesful, timeout, waitForUpdate, requiredTimestamp, staleRevisions, newLockStates, + timestamp); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockStateRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockStateRequest.java index 22d8b03ed6..3d3c2c81c6 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockStateRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/LockStateRequest.java @@ -1,61 +1,61 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * @author Caspar De Groot
- */
-public class LockStateRequest extends CDOClientRequest<CDOLockState[]>
-{
- private int viewID;
-
- private Collection<CDOID> ids;
-
- public LockStateRequest(CDOClientProtocol protocol, int viewID, Collection<CDOID> ids)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_STATE);
- this.viewID = viewID;
- this.ids = ids;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(viewID);
- out.writeInt(ids.size());
- for (CDOID id : ids)
- {
- out.writeCDOID(id);
- }
- }
-
- @Override
- protected CDOLockState[] confirming(CDODataInput in) throws IOException
- {
- int n = in.readInt();
- CDOLockState[] lockStates = new CDOLockState[n];
- for (int i = 0; i < n; i++)
- {
- lockStates[i] = in.readCDOLockState();
- }
-
- return lockStates;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; +import java.util.Collection; + +/** + * @author Caspar De Groot + */ +public class LockStateRequest extends CDOClientRequest<CDOLockState[]> +{ + private int viewID; + + private Collection<CDOID> ids; + + public LockStateRequest(CDOClientProtocol protocol, int viewID, Collection<CDOID> ids) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_STATE); + this.viewID = viewID; + this.ids = ids; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(viewID); + out.writeInt(ids.size()); + for (CDOID id : ids) + { + out.writeCDOID(id); + } + } + + @Override + protected CDOLockState[] confirming(CDODataInput in) throws IOException + { + int n = in.readInt(); + CDOLockState[] lockStates = new CDOLockState[n]; + for (int i = 0; i < n; i++) + { + lockStates[i] = in.readCDOLockState(); + } + + return lockStates; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ObjectLockedRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ObjectLockedRequest.java index 17618f662c..85e73bcddc 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ObjectLockedRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ObjectLockedRequest.java @@ -1,70 +1,70 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class ObjectLockedRequest extends CDOClientRequest<Boolean>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, ObjectLockedRequest.class);
-
- private CDOView view;
-
- private CDOObject object;
-
- private LockType lockType;
-
- private boolean byOthers;
-
- public ObjectLockedRequest(CDOClientProtocol protocol, CDOView view, CDOObject object, LockType lockType,
- boolean byOthers)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_OBJECT_LOCKED);
- this.view = view;
- this.object = object;
- this.lockType = lockType;
- this.byOthers = byOthers;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Requesting if object {0} has of lock for object {1}", object.cdoID(), //$NON-NLS-1$
- lockType == LockType.READ ? "read" : "write"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- out.writeInt(view.getViewID());
- out.writeCDOLockType(lockType);
- out.writeCDOID(object.cdoID());
- out.writeBoolean(byOthers);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class ObjectLockedRequest extends CDOClientRequest<Boolean> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, ObjectLockedRequest.class); + + private CDOView view; + + private CDOObject object; + + private LockType lockType; + + private boolean byOthers; + + public ObjectLockedRequest(CDOClientProtocol protocol, CDOView view, CDOObject object, LockType lockType, + boolean byOthers) + { + super(protocol, CDOProtocolConstants.SIGNAL_OBJECT_LOCKED); + this.view = view; + this.object = object; + this.lockType = lockType; + this.byOthers = byOthers; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.format("Requesting if object {0} has of lock for object {1}", object.cdoID(), //$NON-NLS-1$ + lockType == LockType.READ ? "read" : "write"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + out.writeInt(view.getViewID()); + out.writeCDOLockType(lockType); + out.writeCDOID(object.cdoID()); + out.writeBoolean(byOthers); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenViewRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenViewRequest.java index d7771ed62b..e45b9c34b6 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenViewRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/OpenViewRequest.java @@ -1,89 +1,89 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockAreaNotFoundException;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class OpenViewRequest extends CDOClientRequest<CDOBranchPoint>
-{
- private int viewID;
-
- private boolean readOnly;
-
- private CDOBranchPoint branchPoint;
-
- private String durableLockingID;
-
- public OpenViewRequest(CDOClientProtocol protocol, int viewID, boolean readOnly, CDOBranchPoint branchPoint)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_OPEN_VIEW);
- this.viewID = viewID;
- this.readOnly = readOnly;
- this.branchPoint = branchPoint;
- }
-
- public OpenViewRequest(CDOClientProtocol protocol, int viewID, boolean readOnly, String durableLockingID)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_OPEN_VIEW);
- this.viewID = viewID;
- this.readOnly = readOnly;
- this.durableLockingID = durableLockingID;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(viewID);
- out.writeBoolean(readOnly);
-
- if (branchPoint != null)
- {
- out.writeBoolean(true);
- out.writeCDOBranchPoint(branchPoint);
- }
- else
- {
- out.writeBoolean(false);
- out.writeString(durableLockingID);
- }
- }
-
- @Override
- protected CDOBranchPoint confirming(CDODataInput in) throws IOException
- {
- if (in.readBoolean())
- {
- return in.readCDOBranchPoint();
- }
-
- if (durableLockingID != null)
- {
- String message = in.readString();
- if (message != null)
- {
- throw new IllegalStateException(message);
- }
-
- throw new LockAreaNotFoundException(durableLockingID);
- }
-
- return null;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockAreaNotFoundException; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class OpenViewRequest extends CDOClientRequest<CDOBranchPoint> +{ + private int viewID; + + private boolean readOnly; + + private CDOBranchPoint branchPoint; + + private String durableLockingID; + + public OpenViewRequest(CDOClientProtocol protocol, int viewID, boolean readOnly, CDOBranchPoint branchPoint) + { + super(protocol, CDOProtocolConstants.SIGNAL_OPEN_VIEW); + this.viewID = viewID; + this.readOnly = readOnly; + this.branchPoint = branchPoint; + } + + public OpenViewRequest(CDOClientProtocol protocol, int viewID, boolean readOnly, String durableLockingID) + { + super(protocol, CDOProtocolConstants.SIGNAL_OPEN_VIEW); + this.viewID = viewID; + this.readOnly = readOnly; + this.durableLockingID = durableLockingID; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(viewID); + out.writeBoolean(readOnly); + + if (branchPoint != null) + { + out.writeBoolean(true); + out.writeCDOBranchPoint(branchPoint); + } + else + { + out.writeBoolean(false); + out.writeString(durableLockingID); + } + } + + @Override + protected CDOBranchPoint confirming(CDODataInput in) throws IOException + { + if (in.readBoolean()) + { + return in.readCDOBranchPoint(); + } + + if (durableLockingID != null) + { + String message = in.readString(); + if (message != null) + { + throw new IllegalStateException(message); + } + + throw new LockAreaNotFoundException(durableLockingID); + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryCancelRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryCancelRequest.java index 9e48679faa..cf85023a78 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryCancelRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryCancelRequest.java @@ -1,61 +1,61 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class QueryCancelRequest extends CDOClientRequest<Boolean>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryCancelRequest.class);
-
- private int queryID;
-
- public QueryCancelRequest(CDOClientProtocol protocol, int queryID)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_QUERY_CANCEL);
- this.queryID = queryID;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Cancel query " + queryID); //$NON-NLS-1$
- }
-
- out.writeInt(queryID);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- boolean exception = in.readBoolean();
- if (exception)
- {
- String message = in.readString();
- throw new RuntimeException(message);
- }
-
- return true;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class QueryCancelRequest extends CDOClientRequest<Boolean> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryCancelRequest.class); + + private int queryID; + + public QueryCancelRequest(CDOClientProtocol protocol, int queryID) + { + super(protocol, CDOProtocolConstants.SIGNAL_QUERY_CANCEL); + this.queryID = queryID; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.trace("Cancel query " + queryID); //$NON-NLS-1$ + } + + out.writeInt(queryID); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + boolean exception = in.readBoolean(); + if (exception) + { + String message = in.readString(); + throw new RuntimeException(message); + } + + return true; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryLobsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryLobsRequest.java index a79bc78305..c71934782d 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryLobsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/QueryLobsRequest.java @@ -1,57 +1,57 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class QueryLobsRequest extends CDOClientRequest<List<byte[]>>
-{
- private Collection<byte[]> ids;
-
- public QueryLobsRequest(CDOClientProtocol protocol, Collection<byte[]> ids)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_QUERY_LOBS);
- this.ids = ids;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(ids.size());
- for (byte[] id : ids)
- {
- out.writeByteArray(id);
- }
- }
-
- @Override
- protected List<byte[]> confirming(CDODataInput in) throws IOException
- {
- int size = in.readInt();
- List<byte[]> result = new ArrayList<byte[]>(size);
- for (int i = 0; i < size; i++)
- {
- result.add(in.readByteArray());
- }
-
- return result;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class QueryLobsRequest extends CDOClientRequest<List<byte[]>> +{ + private Collection<byte[]> ids; + + public QueryLobsRequest(CDOClientProtocol protocol, Collection<byte[]> ids) + { + super(protocol, CDOProtocolConstants.SIGNAL_QUERY_LOBS); + this.ids = ids; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(ids.size()); + for (byte[] id : ids) + { + out.writeByteArray(id); + } + } + + @Override + protected List<byte[]> confirming(CDODataInput in) throws IOException + { + int size = in.readInt(); + List<byte[]> result = new ArrayList<byte[]>(size); + for (int i = 0; i < size; i++) + { + result.add(in.readByteArray()); + } + + return result; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RefreshSessionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RefreshSessionRequest.java index e24ad08087..b3cc44db89 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RefreshSessionRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RefreshSessionRequest.java @@ -1,127 +1,127 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author Simon McDuff
- * @since 2.0
- */
-public class RefreshSessionRequest extends CDOClientRequest<RefreshSessionResult>
-{
- private long lastUpdateTime;
-
- private Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions;
-
- private int initialChunkSize;
-
- private boolean enablePassiveUpdates;
-
- public RefreshSessionRequest(CDOClientProtocol protocol, long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize,
- boolean enablePassiveUpdates)
- {
- this(protocol, CDOProtocolConstants.SIGNAL_REFRESH_SESSION, lastUpdateTime, viewedRevisions, initialChunkSize,
- enablePassiveUpdates);
- }
-
- protected RefreshSessionRequest(CDOClientProtocol protocol, short signalID, long lastUpdateTime,
- Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize,
- boolean enablePassiveUpdates)
- {
- super(protocol, signalID);
- this.lastUpdateTime = lastUpdateTime;
- this.viewedRevisions = viewedRevisions;
- this.initialChunkSize = initialChunkSize;
- this.enablePassiveUpdates = enablePassiveUpdates;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeLong(lastUpdateTime);
- out.writeInt(initialChunkSize);
- out.writeBoolean(enablePassiveUpdates);
-
- out.writeInt(viewedRevisions.size());
- for (Entry<CDOBranch, Map<CDOID, InternalCDORevision>> entry : viewedRevisions.entrySet())
- {
- CDOBranch branch = entry.getKey();
- Map<CDOID, InternalCDORevision> revisions = entry.getValue();
-
- out.writeCDOBranch(branch);
- out.writeInt(revisions.size());
- for (InternalCDORevision revision : revisions.values())
- {
- out.writeCDORevisionKey(revision);
- }
- }
- }
-
- @Override
- protected RefreshSessionResult confirming(CDODataInput in) throws IOException
- {
- lastUpdateTime = in.readLong();
- RefreshSessionResult result = new RefreshSessionResult(lastUpdateTime);
-
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet();
- for (;;)
- {
- byte type = in.readByte();
- switch (type)
- {
- case CDOProtocolConstants.REFRESH_PACKAGE_UNIT:
- {
- CDOPackageUnit packageUnit = in.readCDOPackageUnit(resourceSet);
- result.addPackageUnit(packageUnit);
- break;
- }
-
- case CDOProtocolConstants.REFRESH_CHANGED_OBJECT:
- {
- InternalCDORevision revision = (InternalCDORevision)in.readCDORevision();
- result.addChangedObject(revision);
- break;
- }
-
- case CDOProtocolConstants.REFRESH_DETACHED_OBJECT:
- {
- CDORevisionKey key = in.readCDORevisionKey();
- result.addDetachedObject(key);
- break;
- }
-
- case CDOProtocolConstants.REFRESH_FINISHED:
- return result;
-
- default:
- throw new IOException("Invalid refresh type: " + type);
- }
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult; + +import java.io.IOException; +import java.util.Map; +import java.util.Map.Entry; + +/** + * @author Simon McDuff + * @since 2.0 + */ +public class RefreshSessionRequest extends CDOClientRequest<RefreshSessionResult> +{ + private long lastUpdateTime; + + private Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions; + + private int initialChunkSize; + + private boolean enablePassiveUpdates; + + public RefreshSessionRequest(CDOClientProtocol protocol, long lastUpdateTime, + Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize, + boolean enablePassiveUpdates) + { + this(protocol, CDOProtocolConstants.SIGNAL_REFRESH_SESSION, lastUpdateTime, viewedRevisions, initialChunkSize, + enablePassiveUpdates); + } + + protected RefreshSessionRequest(CDOClientProtocol protocol, short signalID, long lastUpdateTime, + Map<CDOBranch, Map<CDOID, InternalCDORevision>> viewedRevisions, int initialChunkSize, + boolean enablePassiveUpdates) + { + super(protocol, signalID); + this.lastUpdateTime = lastUpdateTime; + this.viewedRevisions = viewedRevisions; + this.initialChunkSize = initialChunkSize; + this.enablePassiveUpdates = enablePassiveUpdates; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeLong(lastUpdateTime); + out.writeInt(initialChunkSize); + out.writeBoolean(enablePassiveUpdates); + + out.writeInt(viewedRevisions.size()); + for (Entry<CDOBranch, Map<CDOID, InternalCDORevision>> entry : viewedRevisions.entrySet()) + { + CDOBranch branch = entry.getKey(); + Map<CDOID, InternalCDORevision> revisions = entry.getValue(); + + out.writeCDOBranch(branch); + out.writeInt(revisions.size()); + for (InternalCDORevision revision : revisions.values()) + { + out.writeCDORevisionKey(revision); + } + } + } + + @Override + protected RefreshSessionResult confirming(CDODataInput in) throws IOException + { + lastUpdateTime = in.readLong(); + RefreshSessionResult result = new RefreshSessionResult(lastUpdateTime); + + ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(); + for (;;) + { + byte type = in.readByte(); + switch (type) + { + case CDOProtocolConstants.REFRESH_PACKAGE_UNIT: + { + CDOPackageUnit packageUnit = in.readCDOPackageUnit(resourceSet); + result.addPackageUnit(packageUnit); + break; + } + + case CDOProtocolConstants.REFRESH_CHANGED_OBJECT: + { + InternalCDORevision revision = (InternalCDORevision)in.readCDORevision(); + result.addChangedObject(revision); + break; + } + + case CDOProtocolConstants.REFRESH_DETACHED_OBJECT: + { + CDORevisionKey key = in.readCDORevisionKey(); + result.addDetachedObject(key); + break; + } + + case CDOProtocolConstants.REFRESH_FINISHED: + return result; + + default: + throw new IOException("Invalid refresh type: " + type); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageNotificationIndication.java index ac97b4b9d4..2f9017100d 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageNotificationIndication.java @@ -1,56 +1,56 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RemoteMessageNotificationIndication extends CDOClientIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL,
- RemoteMessageNotificationIndication.class);
-
- public RemoteMessageNotificationIndication(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int senderID = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.trace("Read senderID: " + senderID); //$NON-NLS-1$
- }
-
- CDORemoteSessionMessage message = new CDORemoteSessionMessage(in);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Read message: " + message); //$NON-NLS-1$
- }
-
- InternalCDORemoteSessionManager remoteSessionManager = getSession().getRemoteSessionManager();
- remoteSessionManager.handleRemoteSessionMessage(senderID, message);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RemoteMessageNotificationIndication extends CDOClientIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, + RemoteMessageNotificationIndication.class); + + public RemoteMessageNotificationIndication(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int senderID = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.trace("Read senderID: " + senderID); //$NON-NLS-1$ + } + + CDORemoteSessionMessage message = new CDORemoteSessionMessage(in); + if (TRACER.isEnabled()) + { + TRACER.trace("Read message: " + message); //$NON-NLS-1$ + } + + InternalCDORemoteSessionManager remoteSessionManager = getSession().getRemoteSessionManager(); + remoteSessionManager.handleRemoteSessionMessage(senderID, message); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageRequest.java index a0a0846c0a..b86d231aaa 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteMessageRequest.java @@ -1,85 +1,85 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class RemoteMessageRequest extends CDOClientRequest<Set<Integer>>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, RemoteMessageRequest.class);
-
- private CDORemoteSessionMessage message;
-
- private List<CDORemoteSession> recipients;
-
- public RemoteMessageRequest(CDOClientProtocol protocol, CDORemoteSessionMessage message,
- List<CDORemoteSession> recipients)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE);
- this.message = message;
- this.recipients = recipients;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Writing message: " + message); //$NON-NLS-1$
- }
-
- message.write(out);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0} recipients", recipients.size()); //$NON-NLS-1$
- }
-
- out.writeInt(recipients.size());
- for (CDORemoteSession recipient : recipients)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Writing recipient: " + recipient); //$NON-NLS-1$
- }
-
- out.writeInt(recipient.getSessionID());
- }
- }
-
- @Override
- protected Set<Integer> confirming(CDODataInput in) throws IOException
- {
- Set<Integer> sessionIDs = new HashSet<Integer>();
- int count = in.readInt();
- for (int i = 0; i < count; i++)
- {
- int sessionID = in.readInt();
- sessionIDs.add(sessionID);
- }
-
- return sessionIDs;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.remote.CDORemoteSession; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class RemoteMessageRequest extends CDOClientRequest<Set<Integer>> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, RemoteMessageRequest.class); + + private CDORemoteSessionMessage message; + + private List<CDORemoteSession> recipients; + + public RemoteMessageRequest(CDOClientProtocol protocol, CDORemoteSessionMessage message, + List<CDORemoteSession> recipients) + { + super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE); + this.message = message; + this.recipients = recipients; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.trace("Writing message: " + message); //$NON-NLS-1$ + } + + message.write(out); + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0} recipients", recipients.size()); //$NON-NLS-1$ + } + + out.writeInt(recipients.size()); + for (CDORemoteSession recipient : recipients) + { + if (TRACER.isEnabled()) + { + TRACER.trace("Writing recipient: " + recipient); //$NON-NLS-1$ + } + + out.writeInt(recipient.getSessionID()); + } + } + + @Override + protected Set<Integer> confirming(CDODataInput in) throws IOException + { + Set<Integer> sessionIDs = new HashSet<Integer>(); + int count = in.readInt(); + for (int i = 0; i < count; i++) + { + int sessionID = in.readInt(); + sessionIDs.add(sessionID); + } + + return sessionIDs; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteSessionNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteSessionNotificationIndication.java index 70347cfc30..7c402c8481 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteSessionNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RemoteSessionNotificationIndication.java @@ -1,54 +1,54 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RemoteSessionNotificationIndication extends CDOClientIndication
-{
- public RemoteSessionNotificationIndication(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_SESSION_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int sessionID = in.readInt();
- byte opcode = in.readByte();
- switch (opcode)
- {
- case CDOProtocolConstants.REMOTE_SESSION_OPENED:
- String userID = in.readString();
- getSession().getRemoteSessionManager().handleRemoteSessionOpened(sessionID, userID);
- break;
-
- case CDOProtocolConstants.REMOTE_SESSION_CLOSED:
- getSession().getRemoteSessionManager().handleRemoteSessionClosed(sessionID);
- break;
-
- case CDOProtocolConstants.REMOTE_SESSION_SUBSCRIBED:
- getSession().getRemoteSessionManager().handleRemoteSessionSubscribed(sessionID, true);
- break;
-
- case CDOProtocolConstants.REMOTE_SESSION_UNSUBSCRIBED:
- getSession().getRemoteSessionManager().handleRemoteSessionSubscribed(sessionID, false);
- break;
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RemoteSessionNotificationIndication extends CDOClientIndication +{ + public RemoteSessionNotificationIndication(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_SESSION_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int sessionID = in.readInt(); + byte opcode = in.readByte(); + switch (opcode) + { + case CDOProtocolConstants.REMOTE_SESSION_OPENED: + String userID = in.readString(); + getSession().getRemoteSessionManager().handleRemoteSessionOpened(sessionID, userID); + break; + + case CDOProtocolConstants.REMOTE_SESSION_CLOSED: + getSession().getRemoteSessionManager().handleRemoteSessionClosed(sessionID); + break; + + case CDOProtocolConstants.REMOTE_SESSION_SUBSCRIBED: + getSession().getRemoteSessionManager().handleRemoteSessionSubscribed(sessionID, true); + break; + + case CDOProtocolConstants.REMOTE_SESSION_UNSUBSCRIBED: + getSession().getRemoteSessionManager().handleRemoteSessionSubscribed(sessionID, false); + break; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java index ae4fe4a9d4..dd80a267c2 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRawRequest.java @@ -1,48 +1,48 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.CDORawReplicationContext;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class ReplicateRepositoryRawRequest extends CDOClientRequestWithMonitoring<Boolean>
-{
- private CDORawReplicationContext context;
-
- public ReplicateRepositoryRawRequest(CDOClientProtocol protocol, CDORawReplicationContext context)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY_RAW);
- this.context = context;
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- out.writeInt(context.getLastReplicatedBranchID());
- out.writeLong(context.getLastReplicatedCommitTime());
- }
-
- @Override
- protected Boolean confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- context.replicateRaw(in, monitor);
- return true;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.CDORawReplicationContext; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class ReplicateRepositoryRawRequest extends CDOClientRequestWithMonitoring<Boolean> +{ + private CDORawReplicationContext context; + + public ReplicateRepositoryRawRequest(CDOClientProtocol protocol, CDORawReplicationContext context) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY_RAW); + this.context = context; + } + + @Override + protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException + { + out.writeInt(context.getLastReplicatedBranchID()); + out.writeLong(context.getLastReplicatedCommitTime()); + } + + @Override + protected Boolean confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + context.replicateRaw(in, monitor); + return true; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java index 3cb4a30921..87f9bb161c 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/ReplicateRepositoryRequest.java @@ -1,89 +1,89 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.CDOReplicationContext;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class ReplicateRepositoryRequest extends CDOClientRequest<Boolean>
-{
- private CDOReplicationContext context;
-
- public ReplicateRepositoryRequest(CDOClientProtocol protocol, CDOReplicationContext context, OMMonitor monitor)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY);
- this.context = context;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(context.getLastReplicatedBranchID());
- out.writeLong(context.getLastReplicatedCommitTime());
-
- String[] lockAreaIDs = context.getLockAreaIDs();
- out.writeInt(lockAreaIDs.length);
- for (int i = 0; i < lockAreaIDs.length; i++)
- {
- out.writeString(lockAreaIDs[i]);
- }
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- for (;;)
- {
- byte opcode = in.readByte();
- switch (opcode)
- {
- case CDOProtocolConstants.REPLICATE_FINISHED:
- return true;
-
- case CDOProtocolConstants.REPLICATE_BRANCH:
- context.handleBranch(in.readCDOBranch());
- break;
-
- case CDOProtocolConstants.REPLICATE_COMMIT:
- context.handleCommitInfo(in.readCDOCommitInfo());
- break;
-
- case CDOProtocolConstants.REPLICATE_LOCKAREA:
- boolean missing = !in.readBoolean();
- if (missing)
- {
- String missingLockAreaID = in.readString();
- LockArea area = CDOLockUtil.createLockArea(missingLockAreaID);
- context.handleLockArea(area);
- }
- else
- {
- context.handleLockArea(in.readCDOLockArea());
- }
- break;
-
- default:
- throw new IllegalStateException("Invalid replicate opcode: " + opcode);
- }
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.lock.CDOLockUtil; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.CDOReplicationContext; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class ReplicateRepositoryRequest extends CDOClientRequest<Boolean> +{ + private CDOReplicationContext context; + + public ReplicateRepositoryRequest(CDOClientProtocol protocol, CDOReplicationContext context, OMMonitor monitor) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY); + this.context = context; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(context.getLastReplicatedBranchID()); + out.writeLong(context.getLastReplicatedCommitTime()); + + String[] lockAreaIDs = context.getLockAreaIDs(); + out.writeInt(lockAreaIDs.length); + for (int i = 0; i < lockAreaIDs.length; i++) + { + out.writeString(lockAreaIDs[i]); + } + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + for (;;) + { + byte opcode = in.readByte(); + switch (opcode) + { + case CDOProtocolConstants.REPLICATE_FINISHED: + return true; + + case CDOProtocolConstants.REPLICATE_BRANCH: + context.handleBranch(in.readCDOBranch()); + break; + + case CDOProtocolConstants.REPLICATE_COMMIT: + context.handleCommitInfo(in.readCDOCommitInfo()); + break; + + case CDOProtocolConstants.REPLICATE_LOCKAREA: + boolean missing = !in.readBoolean(); + if (missing) + { + String missingLockAreaID = in.readString(); + LockArea area = CDOLockUtil.createLockArea(missingLockAreaID); + context.handleLockArea(area); + } + else + { + context.handleLockArea(in.readCDOLockArea()); + } + break; + + default: + throw new IllegalStateException("Invalid replicate opcode: " + opcode); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryStateNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryStateNotificationIndication.java index 66ff88f532..07b3a7fad0 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryStateNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryStateNotificationIndication.java @@ -1,47 +1,47 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl.RepositoryInfo;
-import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionImpl;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RepositoryStateNotificationIndication extends CDOClientIndication
-{
- public RepositoryStateNotificationIndication(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_STATE_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- CDOCommonRepository.State oldState = in.readEnum(CDOCommonRepository.State.class);
- CDOCommonRepository.State newState = in.readEnum(CDOCommonRepository.State.class);
- CDOID rootResourceID = in.readCDOID();
-
- CDONet4jSessionImpl session = (CDONet4jSessionImpl)getSession();
- RepositoryInfo repositoryInfo = (RepositoryInfo)session.getRepositoryInfo();
- repositoryInfo.setState(newState);
- repositoryInfo.setRootResourceID(rootResourceID);
-
- session.handleRepositoryStateChanged(oldState, newState);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonRepository; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl.RepositoryInfo; +import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionImpl; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RepositoryStateNotificationIndication extends CDOClientIndication +{ + public RepositoryStateNotificationIndication(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_STATE_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + CDOCommonRepository.State oldState = in.readEnum(CDOCommonRepository.State.class); + CDOCommonRepository.State newState = in.readEnum(CDOCommonRepository.State.class); + CDOID rootResourceID = in.readCDOID(); + + CDONet4jSessionImpl session = (CDONet4jSessionImpl)getSession(); + RepositoryInfo repositoryInfo = (RepositoryInfo)session.getRepositoryInfo(); + repositoryInfo.setState(newState); + repositoryInfo.setRootResourceID(rootResourceID); + + session.handleRepositoryStateChanged(oldState, newState); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTimeRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTimeRequest.java index 602067a0d7..c4f0eb6b24 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTimeRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTimeRequest.java @@ -1,36 +1,36 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RepositoryTimeResult;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RepositoryTimeRequest extends CDOTimeRequest<RepositoryTimeResult>
-{
- public RepositoryTimeRequest(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TIME);
- }
-
- @Override
- protected RepositoryTimeResult confirming(CDODataInput in) throws IOException
- {
- super.confirming(in);
- return getRepositoryTimeResult();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RepositoryTimeResult; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RepositoryTimeRequest extends CDOTimeRequest<RepositoryTimeResult> +{ + public RepositoryTimeRequest(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TIME); + } + + @Override + protected RepositoryTimeResult confirming(CDODataInput in) throws IOException + { + super.confirming(in); + return getRepositoryTimeResult(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTypeNotificationIndication.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTypeNotificationIndication.java index 9e40db41fd..04918808da 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTypeNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/RepositoryTypeNotificationIndication.java @@ -1,43 +1,43 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl.RepositoryInfo;
-import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionImpl;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RepositoryTypeNotificationIndication extends CDOClientIndication
-{
- public RepositoryTypeNotificationIndication(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TYPE_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- CDOCommonRepository.Type oldType = in.readEnum(CDOCommonRepository.Type.class);
- CDOCommonRepository.Type newType = in.readEnum(CDOCommonRepository.Type.class);
-
- CDONet4jSessionImpl session = (CDONet4jSessionImpl)getSession();
- RepositoryInfo repositoryInfo = (RepositoryInfo)session.getRepositoryInfo();
- repositoryInfo.setType(newType);
- session.handleRepositoryTypeChanged(oldType, newType);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonRepository; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionConfigurationImpl.RepositoryInfo; +import org.eclipse.emf.cdo.internal.net4j.CDONet4jSessionImpl; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RepositoryTypeNotificationIndication extends CDOClientIndication +{ + public RepositoryTypeNotificationIndication(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TYPE_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + CDOCommonRepository.Type oldType = in.readEnum(CDOCommonRepository.Type.class); + CDOCommonRepository.Type newType = in.readEnum(CDOCommonRepository.Type.class); + + CDONet4jSessionImpl session = (CDONet4jSessionImpl)getSession(); + RepositoryInfo repositoryInfo = (RepositoryInfo)session.getRepositoryInfo(); + repositoryInfo.setType(newType); + session.handleRepositoryTypeChanged(oldType, newType); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetLockNotificationModeRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetLockNotificationModeRequest.java index f8ad3ec10b..b9c6830f42 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetLockNotificationModeRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetLockNotificationModeRequest.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class SetLockNotificationModeRequest extends CDOClientRequest<Boolean>
-{
- private LockNotificationMode mode;
-
- public SetLockNotificationModeRequest(CDOClientProtocol protocol, LockNotificationMode mode)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_SET_LOCK_NOTIFICATION_MODE);
- this.mode = mode;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeEnum(mode);
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class SetLockNotificationModeRequest extends CDOClientRequest<Boolean> +{ + private LockNotificationMode mode; + + public SetLockNotificationModeRequest(CDOClientProtocol protocol, LockNotificationMode mode) + { + super(protocol, CDOProtocolConstants.SIGNAL_SET_LOCK_NOTIFICATION_MODE); + this.mode = mode; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeEnum(mode); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetPassiveUpdateModeRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetPassiveUpdateModeRequest.java index 0fe22f8abd..044182b0d8 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetPassiveUpdateModeRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SetPassiveUpdateModeRequest.java @@ -1,45 +1,45 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class SetPassiveUpdateModeRequest extends CDOClientRequest<Boolean>
-{
- private PassiveUpdateMode mode;
-
- public SetPassiveUpdateModeRequest(CDOClientProtocol protocol, PassiveUpdateMode mode)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_SET_PASSIVE_UPDATE_MODE);
- this.mode = mode;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeByte(mode.ordinal());
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class SetPassiveUpdateModeRequest extends CDOClientRequest<Boolean> +{ + private PassiveUpdateMode mode; + + public SetPassiveUpdateModeRequest(CDOClientProtocol protocol, PassiveUpdateMode mode) + { + super(protocol, CDOProtocolConstants.SIGNAL_SET_PASSIVE_UPDATE_MODE); + this.mode = mode; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeByte(mode.ordinal()); + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SwitchTargetRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SwitchTargetRequest.java index 94d07b9454..e9e867e5a4 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SwitchTargetRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/SwitchTargetRequest.java @@ -1,88 +1,88 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class SwitchTargetRequest extends CDOClientRequestWithMonitoring<Object>
-{
- private int viewID;
-
- private CDOBranchPoint branchPoint;
-
- private List<InternalCDOObject> invalidObjects;
-
- private List<CDORevisionKey> allChangedObjects;
-
- private List<CDOIDAndVersion> allDetachedObjects;
-
- public SwitchTargetRequest(CDOClientProtocol protocol, int viewID, CDOBranchPoint branchPoint,
- List<InternalCDOObject> invalidObjects, List<CDORevisionKey> allChangedObjects,
- List<CDOIDAndVersion> allDetachedObjects)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_SWITCH_TARGET);
- this.viewID = viewID;
- this.branchPoint = branchPoint;
- this.invalidObjects = invalidObjects;
- this.allChangedObjects = allChangedObjects;
- this.allDetachedObjects = allDetachedObjects;
- }
-
- @Override
- protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- out.writeInt(viewID);
- out.writeCDOBranchPoint(branchPoint);
-
- out.writeInt(invalidObjects.size());
- for (InternalCDOObject object : invalidObjects)
- {
- out.writeCDOID(object.cdoID());
- }
- }
-
- @Override
- protected boolean[] confirming(CDODataInput in, OMMonitor monitor) throws IOException
- {
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- allChangedObjects.add(in.readCDORevisionDelta());
- }
-
- size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- CDOID id = in.readCDOID();
- allDetachedObjects.add(CDOIDUtil.createIDAndVersion(id, CDOBranchVersion.UNSPECIFIED_VERSION));
- }
-
- return null;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import org.eclipse.emf.spi.cdo.InternalCDOObject; + +import java.io.IOException; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class SwitchTargetRequest extends CDOClientRequestWithMonitoring<Object> +{ + private int viewID; + + private CDOBranchPoint branchPoint; + + private List<InternalCDOObject> invalidObjects; + + private List<CDORevisionKey> allChangedObjects; + + private List<CDOIDAndVersion> allDetachedObjects; + + public SwitchTargetRequest(CDOClientProtocol protocol, int viewID, CDOBranchPoint branchPoint, + List<InternalCDOObject> invalidObjects, List<CDORevisionKey> allChangedObjects, + List<CDOIDAndVersion> allDetachedObjects) + { + super(protocol, CDOProtocolConstants.SIGNAL_SWITCH_TARGET); + this.viewID = viewID; + this.branchPoint = branchPoint; + this.invalidObjects = invalidObjects; + this.allChangedObjects = allChangedObjects; + this.allDetachedObjects = allDetachedObjects; + } + + @Override + protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException + { + out.writeInt(viewID); + out.writeCDOBranchPoint(branchPoint); + + out.writeInt(invalidObjects.size()); + for (InternalCDOObject object : invalidObjects) + { + out.writeCDOID(object.cdoID()); + } + } + + @Override + protected boolean[] confirming(CDODataInput in, OMMonitor monitor) throws IOException + { + int size = in.readInt(); + for (int i = 0; i < size; i++) + { + allChangedObjects.add(in.readCDORevisionDelta()); + } + + size = in.readInt(); + for (int i = 0; i < size; i++) + { + CDOID id = in.readCDOID(); + allDetachedObjects.add(CDOIDUtil.createIDAndVersion(id, CDOBranchVersion.UNSPECIFIED_VERSION)); + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockDelegationRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockDelegationRequest.java index ac15fb2a7e..dc53a8f80a 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockDelegationRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockDelegationRequest.java @@ -1,42 +1,42 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * @author Caspar De Groot
- */
-public class UnlockDelegationRequest extends UnlockObjectsRequest
-{
- private String lockAreaID;
-
- public UnlockDelegationRequest(CDOClientProtocol protocol, String lockAreaID, Collection<CDOID> objectIDs,
- LockType lockType, boolean recursive)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_DELEGATION, 0, objectIDs, lockType, recursive);
- this.lockAreaID = lockAreaID;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeString(lockAreaID);
- super.requesting(out);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import java.io.IOException; +import java.util.Collection; + +/** + * @author Caspar De Groot + */ +public class UnlockDelegationRequest extends UnlockObjectsRequest +{ + private String lockAreaID; + + public UnlockDelegationRequest(CDOClientProtocol protocol, String lockAreaID, Collection<CDOID> objectIDs, + LockType lockType, boolean recursive) + { + super(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_DELEGATION, 0, objectIDs, lockType, recursive); + this.lockAreaID = lockAreaID; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeString(lockAreaID); + super.requesting(out); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockObjectsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockObjectsRequest.java index 7032567181..1dd7f4d5aa 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockObjectsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnlockObjectsRequest.java @@ -1,107 +1,107 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.UnlockObjectsResult;
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * @author Simon McDuff
- */
-public class UnlockObjectsRequest extends CDOClientRequest<UnlockObjectsResult>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, UnlockObjectsRequest.class);
-
- private int viewID;
-
- private Collection<CDOID> objectIDs;
-
- private LockType lockType;
-
- private boolean recursive;
-
- public UnlockObjectsRequest(CDOClientProtocol protocol, int viewID, Collection<CDOID> objects, LockType lockType,
- boolean recursive)
- {
- this(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS, viewID, objects, lockType, recursive);
- }
-
- protected UnlockObjectsRequest(CDOClientProtocol protocol, short signalID, int viewID, Collection<CDOID> objectIDs,
- LockType lockType, boolean recursive)
- {
- super(protocol, signalID);
- this.viewID = viewID;
- this.objectIDs = objectIDs;
- this.lockType = lockType;
- this.recursive = recursive;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(viewID);
- out.writeCDOLockType(lockType);
- out.writeBoolean(recursive);
- if (objectIDs == null)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Unlocking all objects for view {0}", viewID); //$NON-NLS-1$
- }
-
- out.writeInt(CDOProtocolConstants.RELEASE_ALL_LOCKS);
- }
- else
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Unlocking of type {0} requested for view {1}", lockType == LockType.READ ? "read" //$NON-NLS-1$ //$NON-NLS-2$
- : "write", viewID); //$NON-NLS-1$
- }
-
- out.writeInt(objectIDs.size());
- for (CDOID id : objectIDs)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Unlocking requested for object {0}", id); //$NON-NLS-1$
- }
-
- out.writeCDOID(id);
- }
- }
- }
-
- @Override
- protected UnlockObjectsResult confirming(CDODataInput in) throws IOException
- {
- long timestamp = in.readLong();
- int n = in.readInt();
- CDOLockState[] newLockStates = new CDOLockState[n];
- for (int i = 0; i < n; i++)
- {
- newLockStates[i] = in.readCDOLockState();
- }
- return new UnlockObjectsResult(newLockStates, timestamp);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.UnlockObjectsResult; + +import java.io.IOException; +import java.util.Collection; + +/** + * @author Simon McDuff + */ +public class UnlockObjectsRequest extends CDOClientRequest<UnlockObjectsResult> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, UnlockObjectsRequest.class); + + private int viewID; + + private Collection<CDOID> objectIDs; + + private LockType lockType; + + private boolean recursive; + + public UnlockObjectsRequest(CDOClientProtocol protocol, int viewID, Collection<CDOID> objects, LockType lockType, + boolean recursive) + { + this(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS, viewID, objects, lockType, recursive); + } + + protected UnlockObjectsRequest(CDOClientProtocol protocol, short signalID, int viewID, Collection<CDOID> objectIDs, + LockType lockType, boolean recursive) + { + super(protocol, signalID); + this.viewID = viewID; + this.objectIDs = objectIDs; + this.lockType = lockType; + this.recursive = recursive; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(viewID); + out.writeCDOLockType(lockType); + out.writeBoolean(recursive); + if (objectIDs == null) + { + if (TRACER.isEnabled()) + { + TRACER.format("Unlocking all objects for view {0}", viewID); //$NON-NLS-1$ + } + + out.writeInt(CDOProtocolConstants.RELEASE_ALL_LOCKS); + } + else + { + if (TRACER.isEnabled()) + { + TRACER.format("Unlocking of type {0} requested for view {1}", lockType == LockType.READ ? "read" //$NON-NLS-1$ //$NON-NLS-2$ + : "write", viewID); //$NON-NLS-1$ + } + + out.writeInt(objectIDs.size()); + for (CDOID id : objectIDs) + { + if (TRACER.isEnabled()) + { + TRACER.format("Unlocking requested for object {0}", id); //$NON-NLS-1$ + } + + out.writeCDOID(id); + } + } + } + + @Override + protected UnlockObjectsResult confirming(CDODataInput in) throws IOException + { + long timestamp = in.readLong(); + int n = in.readInt(); + CDOLockState[] newLockStates = new CDOLockState[n]; + for (int i = 0; i < n; i++) + { + newLockStates[i] = in.readCDOLockState(); + } + return new UnlockObjectsResult(newLockStates, timestamp); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnsubscribeRemoteSessionsRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnsubscribeRemoteSessionsRequest.java index b294347686..724d8b21c7 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnsubscribeRemoteSessionsRequest.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/UnsubscribeRemoteSessionsRequest.java @@ -1,49 +1,49 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class UnsubscribeRemoteSessionsRequest extends CDOClientRequest<Boolean>
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL,
- UnsubscribeRemoteSessionsRequest.class);
-
- public UnsubscribeRemoteSessionsRequest(CDOClientProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS);
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Unsubscribing"); //$NON-NLS-1$
- }
- }
-
- @Override
- protected Boolean confirming(CDODataInput in) throws IOException
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class UnsubscribeRemoteSessionsRequest extends CDOClientRequest<Boolean> +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, + UnsubscribeRemoteSessionsRequest.class); + + public UnsubscribeRemoteSessionsRequest(CDOClientProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS); + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.trace("Unsubscribing"); //$NON-NLS-1$ + } + } + + @Override + protected Boolean confirming(CDODataInput in) throws IOException + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSession.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSession.java index 5b14ac8d50..15e9028244 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSession.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSession.java @@ -1,74 +1,74 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Simon McDuff - maintenance
- * Victor Roldan Betancort - maintenance
- */
-package org.eclipse.emf.cdo.net4j;
-
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.net4j.signal.ISignalProtocol;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-
-/**
- * A Net4j-specific CDO {@link CDOSession session}.
- *
- * @since 4.1
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @apiviz.landmark
- * @apiviz.has {@link CDONet4jSession.Options}
- */
-public interface CDONet4jSession extends org.eclipse.emf.cdo.session.CDOSession
-{
- /**
- * Returns the {@link Options options} of this session.
- */
- public Options options();
-
- /**
- * Encapsulates a set of notifying {@link CDONet4jSession session} configuration options.
- *
- * @since 4.1
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
- public interface Options extends org.eclipse.emf.cdo.session.CDOSession.Options
- {
- /**
- * Returns the Net4j {@link CDOSessionProtocol protocol} instance that represents the underlying
- * <em>signalling connection</em> to the repository of this session.
- */
- public ISignalProtocol<CDONet4jSession> getNet4jProtocol();
-
- /**
- * Returns the timeout for commit operations in <b>seconds</b>.
- */
- public int getCommitTimeout();
-
- /**
- * Sets the timeout for commit operations in <b>seconds</b>.
- */
- public void setCommitTimeout(int commitTimeout);
-
- /**
- * Returns the interval for progress reports of commit operations in <b>seconds</b>.
- */
- public int getProgressInterval();
-
- /**
- * Sets the interval for progress reports of commit operations in <b>seconds</b>.
- */
- public void setProgressInterval(int progressInterval);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Simon McDuff - maintenance + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.cdo.net4j; + +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.net4j.signal.ISignalProtocol; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol; + +/** + * A Net4j-specific CDO {@link CDOSession session}. + * + * @since 4.1 + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @apiviz.landmark + * @apiviz.has {@link CDONet4jSession.Options} + */ +public interface CDONet4jSession extends org.eclipse.emf.cdo.session.CDOSession +{ + /** + * Returns the {@link Options options} of this session. + */ + public Options options(); + + /** + * Encapsulates a set of notifying {@link CDONet4jSession session} configuration options. + * + * @since 4.1 + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ + public interface Options extends org.eclipse.emf.cdo.session.CDOSession.Options + { + /** + * Returns the Net4j {@link CDOSessionProtocol protocol} instance that represents the underlying + * <em>signalling connection</em> to the repository of this session. + */ + public ISignalProtocol<CDONet4jSession> getNet4jProtocol(); + + /** + * Returns the timeout for commit operations in <b>seconds</b>. + */ + public int getCommitTimeout(); + + /** + * Sets the timeout for commit operations in <b>seconds</b>. + */ + public void setCommitTimeout(int commitTimeout); + + /** + * Returns the interval for progress reports of commit operations in <b>seconds</b>. + */ + public int getProgressInterval(); + + /** + * Sets the interval for progress reports of commit operations in <b>seconds</b>. + */ + public void setProgressInterval(int progressInterval); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSessionConfiguration.java index 12a53f4931..a9c5966035 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSessionConfiguration.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDONet4jSessionConfiguration.java @@ -1,93 +1,93 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.util.io.IStreamWrapper;
-
-/**
- * Configures and opens new Net4j-specific CDO {@link CDOSession sessions}.
- *
- * @since 4.1
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @apiviz.landmark
- * @apiviz.uses {@link CDONet4jSession} - - opens
- */
-public interface CDONet4jSessionConfiguration extends org.eclipse.emf.cdo.session.CDOSessionConfiguration
-{
- public String getRepositoryName();
-
- public void setRepositoryName(String repositoryName);
-
- public IConnector getConnector();
-
- public void setConnector(IConnector connector);
-
- public IStreamWrapper getStreamWrapper();
-
- public void setStreamWrapper(IStreamWrapper streamWrapper);
-
- /**
- * @since 4.0
- */
- public long getSignalTimeout();
-
- /**
- * @since 4.0
- */
- public void setSignalTimeout(long timeout);
-
- /**
- * @see CDONet4jSession#getPackageRegistry()
- */
- public CDOPackageRegistry getPackageRegistry();
-
- /**
- * A special package registry can be set <b>before</b> the session is opened and can not be changed thereafter.
- *
- * @see CDONet4jSession#getPackageRegistry()
- */
- public void setPackageRegistry(CDOPackageRegistry packageRegistry);
-
- public CDOBranchManager getBranchManager();
-
- public void setBranchManager(CDOBranchManager branchManager);
-
- /**
- * @see CDONet4jSession#getRevisionManager()
- * @since 3.0
- */
- public CDORevisionManager getRevisionManager();
-
- /**
- * @see CDONet4jSession#getRevisionManager()
- * @since 3.0
- */
- public void setRevisionManager(CDORevisionManager revisionManager);
-
- /**
- * @since 4.1
- */
- public CDONet4jSession openNet4jSession();
-
- /**
- * @deprecated Use {@link #openNet4jSession() openNet4jSession()}.
- */
- @Deprecated
- public org.eclipse.emf.cdo.net4j.CDOSession openSession();
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j; + +import org.eclipse.emf.cdo.common.branch.CDOBranchManager; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.revision.CDORevisionManager; +import org.eclipse.emf.cdo.session.CDOSession; + +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.util.io.IStreamWrapper; + +/** + * Configures and opens new Net4j-specific CDO {@link CDOSession sessions}. + * + * @since 4.1 + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @apiviz.landmark + * @apiviz.uses {@link CDONet4jSession} - - opens + */ +public interface CDONet4jSessionConfiguration extends org.eclipse.emf.cdo.session.CDOSessionConfiguration +{ + public String getRepositoryName(); + + public void setRepositoryName(String repositoryName); + + public IConnector getConnector(); + + public void setConnector(IConnector connector); + + public IStreamWrapper getStreamWrapper(); + + public void setStreamWrapper(IStreamWrapper streamWrapper); + + /** + * @since 4.0 + */ + public long getSignalTimeout(); + + /** + * @since 4.0 + */ + public void setSignalTimeout(long timeout); + + /** + * @see CDONet4jSession#getPackageRegistry() + */ + public CDOPackageRegistry getPackageRegistry(); + + /** + * A special package registry can be set <b>before</b> the session is opened and can not be changed thereafter. + * + * @see CDONet4jSession#getPackageRegistry() + */ + public void setPackageRegistry(CDOPackageRegistry packageRegistry); + + public CDOBranchManager getBranchManager(); + + public void setBranchManager(CDOBranchManager branchManager); + + /** + * @see CDONet4jSession#getRevisionManager() + * @since 3.0 + */ + public CDORevisionManager getRevisionManager(); + + /** + * @see CDONet4jSession#getRevisionManager() + * @since 3.0 + */ + public void setRevisionManager(CDORevisionManager revisionManager); + + /** + * @since 4.1 + */ + public CDONet4jSession openNet4jSession(); + + /** + * @deprecated Use {@link #openNet4jSession() openNet4jSession()}. + */ + @Deprecated + public org.eclipse.emf.cdo.net4j.CDOSession openSession(); +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSession.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSession.java index f9b09bdf47..84a34b94c7 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSession.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSession.java @@ -1,58 +1,58 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j;
-
-import org.eclipse.net4j.signal.ISignalProtocol;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
-
-/**
- * Deprecated, use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession CDONet4jSession}.
- *
- * @since 2.0
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession CDONet4jSession}.
- */
-@Deprecated
-public interface CDOSession extends CDONet4jSession
-{
- /**
- * Returns the {@link Options options} of this session.
- *
- * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession#options() CDONet4jSession.options()}.
- */
- @Deprecated
- public Options options();
-
- /**
- * Deprecated, use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession.Options CDONet4jSession.Options}.
- *
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession.Options CDONet4jSession.Options}.
- */
- @Deprecated
- public interface Options extends CDONet4jSession.Options
- {
- /**
- * Returns the Net4j {@link CDOSessionProtocol protocol} instance that represents the underlying
- * <em>signalling connection</em> to the repository of this session.
- *
- * @see #getNet4jProtocol()
- * @deprecated Kept for 4.0 compatibility. Newer code should call {@link #getNet4jProtocol()}.
- */
- @Deprecated
- public ISignalProtocol<CDOSession> getProtocol();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j; + +import org.eclipse.net4j.signal.ISignalProtocol; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol; + +/** + * Deprecated, use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession CDONet4jSession}. + * + * @since 2.0 + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession CDONet4jSession}. + */ +@Deprecated +public interface CDOSession extends CDONet4jSession +{ + /** + * Returns the {@link Options options} of this session. + * + * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession#options() CDONet4jSession.options()}. + */ + @Deprecated + public Options options(); + + /** + * Deprecated, use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession.Options CDONet4jSession.Options}. + * + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSession.Options CDONet4jSession.Options}. + */ + @Deprecated + public interface Options extends CDONet4jSession.Options + { + /** + * Returns the Net4j {@link CDOSessionProtocol protocol} instance that represents the underlying + * <em>signalling connection</em> to the repository of this session. + * + * @see #getNet4jProtocol() + * @deprecated Kept for 4.0 compatibility. Newer code should call {@link #getNet4jProtocol()}. + */ + @Deprecated + public ISignalProtocol<CDOSession> getProtocol(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java index b7ce165d63..a3a6677a5a 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java @@ -1,26 +1,26 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j;
-
-/**
- * Deprecated, use {@link org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration CDONet4jSessionConfiguration}.
- *
- * @since 3.0
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration CDONet4jSessionConfiguration}.
- */
-@Deprecated
-public interface CDOSessionConfiguration extends CDONet4jSessionConfiguration
-{
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j; + +/** + * Deprecated, use {@link org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration CDONet4jSessionConfiguration}. + * + * @since 3.0 + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @deprecated Use {@link org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration CDONet4jSessionConfiguration}. + */ +@Deprecated +public interface CDOSessionConfiguration extends CDONet4jSessionConfiguration +{ + +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionRecoveryEvent.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionRecoveryEvent.java index d9f67abad0..f8f1377934 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionRecoveryEvent.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/CDOSessionRecoveryEvent.java @@ -1,39 +1,39 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.net4j;
-
-import org.eclipse.emf.cdo.session.CDOSessionEvent;
-
-/**
- * A {@link CDOSessionEvent session event} fired from {@link RecoveringCDOSessionConfiguration recovering session} when
- * recovery has started or finished.
- *
- * @author Eike Stepper
- * @since 4.0
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface CDOSessionRecoveryEvent extends CDOSessionEvent
-{
- public Type getType();
-
- /**
- * Enumerates the possible types of {@link CDOSessionRecoveryEvent session recovery events}.
- *
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- */
- public enum Type
- {
- STARTED, FINISHED
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + * Caspar De Groot - maintenance + */ +package org.eclipse.emf.cdo.net4j; + +import org.eclipse.emf.cdo.session.CDOSessionEvent; + +/** + * A {@link CDOSessionEvent session event} fired from {@link RecoveringCDOSessionConfiguration recovering session} when + * recovery has started or finished. + * + * @author Eike Stepper + * @since 4.0 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface CDOSessionRecoveryEvent extends CDOSessionEvent +{ + public Type getType(); + + /** + * Enumerates the possible types of {@link CDOSessionRecoveryEvent session recovery events}. + * + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + */ + public enum Type + { + STARTED, FINISHED + } +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java index dab61975d3..94b119b89b 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/FailoverCDOSessionConfiguration.java @@ -1,27 +1,27 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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.net4j;
-
-/**
- * A {@link RecoveringCDOSessionConfiguration session configuration} that recovers from network problems by failing over
- * to backup repositories as directed by a fail-over monitor.
- *
- * @author Eike Stepper
- * @since 4.0
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface FailoverCDOSessionConfiguration extends RecoveringCDOSessionConfiguration
-{
- public String getMonitorConnectorDescription();
-
- public String getRepositoryGroup();
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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.net4j; + +/** + * A {@link RecoveringCDOSessionConfiguration session configuration} that recovers from network problems by failing over + * to backup repositories as directed by a fail-over monitor. + * + * @author Eike Stepper + * @since 4.0 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface FailoverCDOSessionConfiguration extends RecoveringCDOSessionConfiguration +{ + public String getMonitorConnectorDescription(); + + public String getRepositoryGroup(); +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java index 397deae1b1..0585e2de65 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/ReconnectingCDOSessionConfiguration.java @@ -1,31 +1,31 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.net4j;
-
-/**
- * A {@link RecoveringCDOSessionConfiguration session configuration} that recovers from network problems by attempting
- * to reconnect to the same repository in specific intervals.
- *
- * @author Caspar De Groot
- * @since 4.0
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ReconnectingCDOSessionConfiguration extends RecoveringCDOSessionConfiguration
-{
- public long getReconnectInterval();
-
- public void setReconnectInterval(long interval);
-
- public int getMaxReconnectAttempts();
-
- public void setMaxReconnectAttempts(int attempts);
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.net4j; + +/** + * A {@link RecoveringCDOSessionConfiguration session configuration} that recovers from network problems by attempting + * to reconnect to the same repository in specific intervals. + * + * @author Caspar De Groot + * @since 4.0 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ReconnectingCDOSessionConfiguration extends RecoveringCDOSessionConfiguration +{ + public long getReconnectInterval(); + + public void setReconnectInterval(long interval); + + public int getMaxReconnectAttempts(); + + public void setMaxReconnectAttempts(int attempts); +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java index 7362193bfd..6ca23dacd9 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/RecoveringCDOSessionConfiguration.java @@ -1,42 +1,42 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.net4j;
-
-import org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol;
-
-/**
- * A {@link CDONet4jSessionConfiguration session configuration} that uses a {@link HeartBeatProtocol heart beat
- * protocol} to detect network problems. Subtypes specify the exact behaviour to recover from these problems.
- *
- * @author Caspar De Groot
- * @since 4.0
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-@SuppressWarnings("deprecation")
-public interface RecoveringCDOSessionConfiguration extends CDOSessionConfiguration
-{
- public boolean isHeartBeatEnabled();
-
- public void setHeartBeatEnabled(boolean enabled);
-
- public long getHeartBeatPeriod();
-
- public void setHeartBeatPeriod(long period);
-
- public long getHeartBeatTimeout();
-
- public void setHeartBeatTimeout(long timeout);
-
- public long getConnectorTimeout();
-
- public void setConnectorTimeout(long timeout);
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.net4j; + +import org.eclipse.net4j.signal.heartbeat.HeartBeatProtocol; + +/** + * A {@link CDONet4jSessionConfiguration session configuration} that uses a {@link HeartBeatProtocol heart beat + * protocol} to detect network problems. Subtypes specify the exact behaviour to recover from these problems. + * + * @author Caspar De Groot + * @since 4.0 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +@SuppressWarnings("deprecation") +public interface RecoveringCDOSessionConfiguration extends CDOSessionConfiguration +{ + public boolean isHeartBeatEnabled(); + + public void setHeartBeatEnabled(boolean enabled); + + public long getHeartBeatPeriod(); + + public void setHeartBeatPeriod(long period); + + public long getHeartBeatTimeout(); + + public void setHeartBeatTimeout(long timeout); + + public long getConnectorTimeout(); + + public void setConnectorTimeout(long timeout); +} diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/package-info.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/package-info.java index b3aa2c5155..a707d4e0ac 100644 --- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/package-info.java +++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/net4j/package-info.java @@ -1,19 +1,19 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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
- */
-
-/**
- * Client concepts for dealing with Net4j-based sessions to remote repositories.
- *
- * @apiviz.exclude .*Event
- * @apiviz.exclude .*Event\.Type
- */
-package org.eclipse.emf.cdo.net4j;
-
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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 + */ + +/** + * Client concepts for dealing with Net4j-based sessions to remote repositories. + * + * @apiviz.exclude .*Event + * @apiviz.exclude .*Event\.Type + */ +package org.eclipse.emf.cdo.net4j; + |