diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org')
47 files changed, 20 insertions, 3924 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java deleted file mode 100644 index 1e16188097..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDONet4jUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.CDONet4jSessionConfigurationImpl; -import org.eclipse.emf.internal.cdo.net4j.protocol.CDOClientProtocolFactory; - -import org.eclipse.net4j.util.container.IManagedContainer; - -/** - * @since 2.0 - * @author Eike Stepper - */ -public final class CDONet4jUtil -{ - private CDONet4jUtil() - { - } - - public static CDOSessionConfiguration createSessionConfiguration() - { - return new CDONet4jSessionConfigurationImpl(); - } - - public static void prepareContainer(IManagedContainer container) - { - container.registerFactory(new CDOClientProtocolFactory()); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDOSession.java deleted file mode 100644 index fe5f7bcfce..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDOSession.java +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.common.CDOCommonSession; - -import org.eclipse.net4j.signal.ISignalProtocol; - -import org.eclipse.emf.spi.cdo.CDOSessionProtocol; - -/** - * @since 2.0 - * @author Eike Stepper - */ -public interface CDOSession extends org.eclipse.emf.cdo.session.CDOSession -{ - /** - * Returns the {@link Options options} of this session. - */ - public Options options(); - - /** - * @author Eike Stepper - */ - 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<CDOCommonSession> getProtocol(); - - /** - * 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/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java deleted file mode 100644 index a7c2065326..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/net4j/CDOSessionConfiguration.java +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.connector.IConnector; -import org.eclipse.net4j.signal.failover.IFailOverStrategy; - -/** - * @author Eike Stepper - * @since 2.0 - */ -public interface CDOSessionConfiguration extends org.eclipse.emf.cdo.session.CDOSessionConfiguration -{ - public IConnector getConnector(); - - public void setConnector(IConnector connector); - - public IFailOverStrategy getFailOverStrategy(); - - /** - * The fail-over strategy must be set <b>before</b> the session is opened and can not be changed thereafter. - */ - public void setFailOverStrategy(IFailOverStrategy failOverStrategy); - - public org.eclipse.emf.cdo.net4j.CDOSession openSession(); -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java index 7b1f2d3f16..ea16dbc34a 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java @@ -4,7 +4,7 @@ * 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 */ @@ -13,8 +13,6 @@ package org.eclipse.emf.internal.cdo.bundle; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.view.CDOView; -import org.eclipse.emf.internal.cdo.net4j.protocol.CommitTransactionRequest; - import org.eclipse.net4j.util.om.OMBundle; import org.eclipse.net4j.util.om.OMPlatform; import org.eclipse.net4j.util.om.log.OMLogger; @@ -35,29 +33,23 @@ public abstract class OM public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ - public static final OMTracer DEBUG_UTIL = DEBUG.tracer("util"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_MODEL = DEBUG.tracer("model"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$ + public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$ - public static final OMTracer DEBUG_REPOSITORY = DEBUG.tracer("repository"); //$NON-NLS-1$ + public static final OMTracer DEBUG_MODEL = DEBUG_SESSION.tracer("model"); //$NON-NLS-1$ - public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$ + public static final OMTracer DEBUG_REVISION = DEBUG_SESSION.tracer("revision"); //$NON-NLS-1$ public static final OMTracer DEBUG_VIEW = DEBUG.tracer("view"); //$NON-NLS-1$ - public static final OMTracer DEBUG_TRANSCTION = DEBUG.tracer("transaction"); //$NON-NLS-1$ + public static final OMTracer DEBUG_TRANSACTION = DEBUG_VIEW.tracer("transaction"); //$NON-NLS-1$ - public static final OMTracer DEBUG_OBJECT = DEBUG.tracer("object"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_STATEMACHINE = DEBUG.tracer("statemachine"); //$NON-NLS-1$ + public static final OMTracer DEBUG_AUDIT = DEBUG_VIEW.tracer("audit"); //$NON-NLS-1$ - public static final OMTracer DEBUG_STORE = DEBUG.tracer("store"); //$NON-NLS-1$ + public static final OMTracer DEBUG_OBJECT = DEBUG.tracer("object"); //$NON-NLS-1$ - public static final OMTracer DEBUG_RESOURCE = DEBUG.tracer("resource"); //$NON-NLS-1$ + public static final OMTracer DEBUG_STATEMACHINE = DEBUG_OBJECT.tracer("statemachine"); //$NON-NLS-1$ - public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$ + public static final OMTracer DEBUG_STORE = DEBUG_OBJECT.tracer("store"); //$NON-NLS-1$ public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$ @@ -86,10 +78,4 @@ public abstract class OM public static final OMPreference<Integer> PREF_REVISION_LOADING_CHUNK_SIZE = // PREFS.init("PREF_REVISION_LOADING_CHUNK_SIZE", CDOView.Options.NO_REVISION_PREFETCHING); //$NON-NLS-1$ - - 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$ } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionConfigurationImpl.java deleted file mode 100644 index 2b42d0e950..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionConfigurationImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j; - -import org.eclipse.emf.internal.cdo.session.CDOSessionConfigurationImpl; - -import org.eclipse.net4j.connector.IConnector; -import org.eclipse.net4j.signal.failover.IFailOverStrategy; -import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy; -import org.eclipse.net4j.util.CheckUtil; - -import org.eclipse.emf.spi.cdo.InternalCDOSession; - -/** - * @author Eike Stepper - */ -public class CDONet4jSessionConfigurationImpl extends CDOSessionConfigurationImpl implements - org.eclipse.emf.cdo.net4j.CDOSessionConfiguration -{ - private IConnector connector; - - private IFailOverStrategy failOverStrategy; - - public CDONet4jSessionConfigurationImpl() - { - } - - public IConnector getConnector() - { - return connector; - } - - public void setConnector(IConnector connector) - { - checkNotOpen(); - this.connector = connector; - } - - public IFailOverStrategy getFailOverStrategy() - { - return failOverStrategy; - } - - public void setFailOverStrategy(IFailOverStrategy failOverStrategy) - { - checkNotOpen(); - this.failOverStrategy = failOverStrategy; - } - - @Override - public org.eclipse.emf.cdo.net4j.CDOSession openSession() - { - return (org.eclipse.emf.cdo.net4j.CDOSession)super.openSession(); - } - - @Override - protected InternalCDOSession createSession() - { - if (isActivateOnOpen()) - { - CheckUtil.checkState(connector != null ^ failOverStrategy != null, - "Specify exactly one of connector or failOverStrategy"); //$NON-NLS-1$ - } - - CDONet4jSessionImpl session = new CDONet4jSessionImpl(); - if (connector != null) - { - session.setFailOverStrategy(new NOOPFailOverStrategy(connector)); - } - else if (failOverStrategy != null) - { - session.setFailOverStrategy(failOverStrategy); - } - - return session; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionFactory.java deleted file mode 100644 index 3568040fd7..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionFactory.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j; - -import org.eclipse.emf.cdo.net4j.CDONet4jUtil; -import org.eclipse.emf.cdo.net4j.CDOSessionConfiguration; -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.emf.spi.cdo.InternalCDOSession; - -/** - * @author Eike Stepper - */ -public class CDONet4jSessionFactory extends CDOSessionFactory -{ - public static final String TYPE = "cdo"; //$NON-NLS-1$ - - public CDONet4jSessionFactory() - { - super(TYPE); - } - - public static CDOSession get(IManagedContainer container, String description) - { - return (CDOSession)container.getElement(PRODUCT_GROUP, TYPE, description); - } - - /** - * @since 2.0 - */ - @Override - protected InternalCDOSession createSession(String repositoryName, boolean automaticPackageRegistry) - { - CDOSessionConfiguration configuration = CDONet4jUtil.createSessionConfiguration(); - - // The session will be activated by the container - configuration.setActivateOnOpen(false); - configuration.setRepositoryName(repositoryName); - // if (automaticPackageRegistry) - // { - // configuration.setPackageRegistry(new CDOPackageRegistryImpl.Eager()); - // } - - return (InternalCDOSession)configuration.openSession(); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionImpl.java deleted file mode 100644 index 9488544414..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/CDONet4jSessionImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/226778 - * Simon McDuff - http://bugs.eclipse.org/230832 - * Simon McDuff - http://bugs.eclipse.org/233490 - * Simon McDuff - http://bugs.eclipse.org/213402 - * Victor Roldan Betancort - maintenance - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j; - -import org.eclipse.emf.internal.cdo.bundle.OM; -import org.eclipse.emf.internal.cdo.net4j.protocol.CDOClientProtocol; -import org.eclipse.emf.internal.cdo.session.CDOSessionImpl; - -import org.eclipse.net4j.signal.failover.IFailOverStrategy; - -import org.eclipse.emf.spi.cdo.CDOSessionProtocol; - -/** - * @author Eike Stepper - */ -public class CDONet4jSessionImpl extends CDOSessionImpl implements org.eclipse.emf.cdo.net4j.CDOSession -{ - private IFailOverStrategy failOverStrategy; - - public CDONet4jSessionImpl() - { - } - - public void setFailOverStrategy(IFailOverStrategy failOverStrategy) - { - this.failOverStrategy = failOverStrategy; - } - - @Override - public OptionsImpl options() - { - return (OptionsImpl)super.options(); - } - - @Override - protected OptionsImpl createOptions() - { - return new OptionsImpl(); - } - - @Override - protected CDOClientProtocol createSessionProtocol() - { - CDOClientProtocol protocol = new CDOClientProtocol(); - protocol.setInfraStructure(this); - protocol.setFailOverStrategy(options().getFailOverStrategy()); - return protocol; - } - - /** - * @author Eike Stepper - */ - protected class OptionsImpl extends org.eclipse.emf.internal.cdo.session.CDOSessionImpl.OptionsImpl implements - org.eclipse.emf.cdo.net4j.CDOSession.Options - { - private int commitTimeout = OM.PREF_COMMIT_MONITOR_TIMEOUT_SECONDS.getValue(); - - private int progressInterval = OM.PREF_COMMIT_MONITOR_PROGRESS_SECONDS.getValue(); - - public OptionsImpl() - { - } - - public IFailOverStrategy getFailOverStrategy() - { - return failOverStrategy; - } - - public CDOClientProtocol getProtocol() - { - CDOSessionProtocol protocol = getSessionProtocol(); - if (protocol instanceof DelegatingSessionProtocol) - { - protocol = ((DelegatingSessionProtocol)protocol).getDelegate(); - } - - return (CDOClientProtocol)protocol; - } - - public int getCommitTimeout() - { - return commitTimeout; - } - - public synchronized void setCommitTimeout(int commitTimeout) - { - this.commitTimeout = commitTimeout; - } - - public int getProgressInterval() - { - return progressInterval; - } - - public synchronized void setProgressInterval(int progressInterval) - { - this.progressInterval = progressInterval; - } - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/FailOverStrategyInjector.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/FailOverStrategyInjector.java deleted file mode 100644 index 19b3645c57..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/FailOverStrategyInjector.java +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j; - -import org.eclipse.emf.internal.cdo.messages.Messages; - -import org.eclipse.net4j.connector.IConnector; -import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy; -import org.eclipse.net4j.util.StringUtil; -import org.eclipse.net4j.util.container.IElementProcessor; -import org.eclipse.net4j.util.container.IManagedContainer; - -import org.eclipse.spi.net4j.ConnectorFactory; - -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class FailOverStrategyInjector 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 FailOverStrategyInjector() - { - } - - public Object process(IManagedContainer container, String productGroup, String factoryType, String description, - Object element) - { - if (element instanceof CDONet4jSessionImpl) - { - CDONet4jSessionImpl session = (CDONet4jSessionImpl)element; - NOOPFailOverStrategy failOverStrategy = getFailOverStrategy(container, description); - session.setFailOverStrategy(failOverStrategy); - } - - return element; - } - - protected NOOPFailOverStrategy getFailOverStrategy(IManagedContainer container, String description) - { - IConnector connector = getConnector(container, description); - return new NOOPFailOverStrategy(connector); - } - - 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 (IConnector)container.getElement(ConnectorFactory.PRODUCT_GROUP, factoryType, connectorDescription); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/AbstractSyncRevisionsRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/AbstractSyncRevisionsRequest.java deleted file mode 100644 index fa1bc99322..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/AbstractSyncRevisionsRequest.java +++ /dev/null @@ -1,139 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.id.CDOIDUtil; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.transaction.CDOTimeStampContext; - -import org.eclipse.emf.internal.cdo.bundle.OM; -import org.eclipse.emf.internal.cdo.messages.Messages; -import org.eclipse.emf.internal.cdo.session.CDORevisionManagerImpl; -import org.eclipse.emf.internal.cdo.transaction.CDOTimeStampContextImpl; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * @author Simon McDuff - * @since 2.0 - */ -public abstract class AbstractSyncRevisionsRequest extends CDOClientRequest<Collection<CDOTimeStampContext>> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, AbstractSyncRevisionsRequest.class); - - protected Map<CDOID, CDOIDAndVersion> idAndVersions; - - protected int referenceChunk; - - public AbstractSyncRevisionsRequest(CDOClientProtocol protocol, short signalID, - Map<CDOID, CDOIDAndVersion> idAndVersions, int referenceChunk) - { - super(protocol, signalID); - this.idAndVersions = idAndVersions; - this.referenceChunk = referenceChunk; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - if (TRACER.isEnabled()) - { - TRACER.trace("Synchronization " + idAndVersions.size() + " objects"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - out.writeInt(referenceChunk); - out.writeInt(idAndVersions.size()); - for (CDOIDAndVersion idAndVersion : idAndVersions.values()) - { - out.writeCDOIDAndVersion(idAndVersion); - } - } - - @Override - protected Collection<CDOTimeStampContext> confirming(CDODataInput in) throws IOException - { - CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)getSession().getRevisionManager(); - TreeMap<Long, CDOTimeStampContext> mapofContext = new TreeMap<Long, CDOTimeStampContext>(); - - int size = in.readInt(); - for (int i = 0; i < size; i++) - { - CDORevision revision = in.readCDORevision(); - long revised = in.readLong(); - - CDOIDAndVersion idAndVersion = idAndVersions.get(revision.getID()); - if (idAndVersion == null) - { - throw new IllegalStateException(MessageFormat.format( - Messages.getString("SyncRevisionsRequest.2"), revision.getID())); //$NON-NLS-1$ - } - - Set<CDOIDAndVersion> dirtyObjects = getMap(mapofContext, revised).getDirtyObjects(); - dirtyObjects.add(CDOIDUtil.createIDAndVersion(idAndVersion.getID(), idAndVersion.getVersion())); - revisionManager.addCachedRevision((InternalCDORevision)revision); - } - - if (TRACER.isEnabled()) - { - TRACER.trace("Synchronization received " + size + " dirty objects"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - size = in.readInt(); - for (int i = 0; i < size; i++) - { - CDOID id = in.readCDOID(); - long revised = in.readLong(); - - Collection<CDOID> detachedObjects = getMap(mapofContext, revised).getDetachedObjects(); - detachedObjects.add(id); - } - - for (CDOTimeStampContext timestampContext : mapofContext.values()) - { - Set<CDOIDAndVersion> dirtyObjects = timestampContext.getDirtyObjects(); - Collection<CDOID> detachedObjects = timestampContext.getDetachedObjects(); - - dirtyObjects = Collections.unmodifiableSet(dirtyObjects); - detachedObjects = Collections.unmodifiableCollection(detachedObjects); - - ((CDOTimeStampContextImpl)timestampContext).setDirtyObjects(dirtyObjects); - ((CDOTimeStampContextImpl)timestampContext).setDetachedObjects(detachedObjects); - } - - return Collections.unmodifiableCollection(mapofContext.values()); - } - - private CDOTimeStampContext getMap(Map<Long, CDOTimeStampContext> mapOfContext, long timestamp) - { - CDOTimeStampContext result = mapOfContext.get(timestamp); - if (result == null) - { - result = new CDOTimeStampContextImpl(timestamp); - mapOfContext.put(timestamp, result); - } - - return result; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/AuthenticationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/AuthenticationIndication.java deleted file mode 100644 index 77634121f6..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/AuthenticationIndication.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.protocol.CDOAuthenticationResult; -import org.eclipse.emf.cdo.common.protocol.CDOAuthenticator; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.net4j.signal.IndicationWithResponse; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import org.eclipse.emf.spi.cdo.InternalCDOSession; - -/** - * @author Eike Stepper - */ -public class AuthenticationIndication extends IndicationWithResponse -{ - private byte[] randomToken; - - public AuthenticationIndication(SignalProtocol<?> protocol) - { - super(protocol, CDOProtocolConstants.SIGNAL_AUTHENTICATION); - } - - @Override - public CDOClientProtocol getProtocol() - { - return (CDOClientProtocol)super.getProtocol(); - } - - protected InternalCDOSession getSession() - { - return (InternalCDOSession)getProtocol().getSession(); - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws Exception - { - randomToken = in.readByteArray(); - } - - @Override - protected void responding(ExtendedDataOutputStream out) throws Exception - { - try - { - InternalCDOSession session = getSession(); - CDOAuthenticator authenticator = session.getAuthenticator(); - if (authenticator == null) - { - throw new IllegalStateException("No authenticator configured"); //$NON-NLS-1$ - } - - CDOAuthenticationResult result = authenticator.authenticate(randomToken); - if (result == null) - { - throw new SecurityException("Not authenticated"); //$NON-NLS-1$ - } - - String userID = result.getUserID(); - if (userID == null) - { - throw new SecurityException("No user ID"); //$NON-NLS-1$ - } - - byte[] cryptedToken = result.getCryptedToken(); - if (cryptedToken == null) - { - throw new SecurityException("No crypted token"); //$NON-NLS-1$ - } - - out.writeBoolean(true); - result.write(out); - } - catch (Exception ex) - { - out.writeBoolean(false); - throw ex; - } - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientIndication.java deleted file mode 100644 index 889712abe9..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientIndication.java +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/233490 - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; -import org.eclipse.emf.cdo.common.revision.CDOListFactory; -import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; -import org.eclipse.emf.cdo.internal.common.io.CDODataInputImpl; - -import org.eclipse.emf.internal.cdo.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 CDOIDObjectFactory getIDFactory() - { - return getSession(); - } - - @Override - protected StringIO getPackageURICompressor() - { - return getProtocol().getPackageURICompressor(); - } - - @Override - protected CDOListFactory getListFactory() - { - return CDOListWithElementProxiesImpl.FACTORY; - } - - @Override - protected CDOPackageRegistry getPackageRegistry() - { - return getSession().getPackageRegistry(); - } - - @Override - protected CDORevisionResolver getRevisionResolver() - { - return getSession().getRevisionManager(); - } - }); - } - - protected abstract void indicating(CDODataInput in) throws IOException; -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientProtocol.java deleted file mode 100644 index 21e4d3fbad..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientProtocol.java +++ /dev/null @@ -1,326 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.common.util.TransportException; -import org.eclipse.emf.cdo.internal.common.protocol.CDOProtocolImpl; -import org.eclipse.emf.cdo.session.CDOSession; -import org.eclipse.emf.cdo.session.remote.CDORemoteSession; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.transaction.CDOTimeStampContext; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.internal.cdo.bundle.OM; -import org.eclipse.emf.internal.cdo.messages.Messages; -import org.eclipse.emf.internal.cdo.session.CDORevisionManagerImpl; - -import org.eclipse.net4j.signal.RemoteException; -import org.eclipse.net4j.signal.RequestWithConfirmation; -import org.eclipse.net4j.signal.SignalReactor; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.concurrent.RWLockManager.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.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.File; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class CDOClientProtocol extends CDOProtocolImpl implements CDOSessionProtocol -{ - private static final PerfTracer REVISION_LOADING = new PerfTracer(OM.PERF_REVISION_LOADING, - CDORevisionManagerImpl.class); - - private StringIO packageURICompressor = new StringCompressor(true); - - public CDOClientProtocol() - { - } - - public StringIO getPackageURICompressor() - { - return packageURICompressor; - } - - public OpenSessionResult openSession(String repositoryName, boolean passiveUpdateEnabled) - { - open(); - return send(new OpenSessionRequest(this, repositoryName, passiveUpdateEnabled)); - } - - public void loadLibraries(Set<String> missingLibraries, File cacheFolder) - { - send(new LoadLibrariesRequest(this, missingLibraries, cacheFolder)); - } - - public void setPassiveUpdate(Map<CDOID, CDOIDAndVersion> idAndVersions, int initialChunkSize, - boolean passiveUpdateEnabled) - { - send(new SetPassiveUpdateRequest(this, idAndVersions, initialChunkSize, passiveUpdateEnabled)); - } - - public RepositoryTimeResult getRepositoryTime() - { - return send(new RepositoryTimeRequest(this)); - } - - public EPackage[] loadPackages(CDOPackageUnit packageUnit) - { - return send(new LoadPackagesRequest(this, (InternalCDOPackageUnit)packageUnit)); - } - - 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(Collection<CDOID> ids, int referenceChunk) - { - return send(new LoadRevisionRequest(this, ids, referenceChunk)); - } - - public List<InternalCDORevision> loadRevisionsByTime(Collection<CDOID> ids, int referenceChunk, long timeStamp) - { - return send(new LoadRevisionByTimeRequest(this, ids, referenceChunk, timeStamp)); - } - - public InternalCDORevision loadRevisionByVersion(CDOID id, int referenceChunk, int version) - { - return send(new LoadRevisionByVersionRequest(this, id, referenceChunk, version)).get(0); - } - - public List<InternalCDORevision> verifyRevision(List<InternalCDORevision> revisions) throws TransportException - { - return send(new VerifyRevisionRequest(this, revisions)); - } - - public Collection<CDOTimeStampContext> syncRevisions(Map<CDOID, CDOIDAndVersion> idAndVersions, int initialChunkSize) - { - return send(new SyncRevisionsRequest(this, idAndVersions, initialChunkSize)); - } - - public void openView(int viewId, byte protocolViewType, long timeStamp) - { - send(new ViewsChangedRequest(this, viewId, protocolViewType, timeStamp)); - } - - public void closeView(int viewId) - { - send(new ViewsChangedRequest(this, viewId)); - } - - public boolean[] setAudit(int viewId, long timeStamp, List<InternalCDOObject> invalidObjects) - { - return send(new SetAuditRequest(this, viewId, timeStamp, invalidObjects)); - } - - public void changeSubscription(int viewId, List<CDOID> cdoIDs, boolean subscribeMode, boolean clear) - { - send(new ChangeSubscriptionRequest(this, viewId, cdoIDs, subscribeMode, clear)); - } - - public List<Object> query(int viewID, AbstractQueryIterator<?> queryResult) - { - return send(new QueryRequest(this, viewID, queryResult)); - } - - public boolean cancelQuery(int queryId) - { - try - { - return new QueryCancelRequest(this, queryId).send(); - } - catch (Exception ignore) - { - return false; - } - } - - public void lockObjects(CDOView view, Map<CDOID, CDOIDAndVersion> objects, long timeout, LockType lockType) - throws InterruptedException - { - InterruptedException interruptedException = null; - RuntimeException runtimeException = null; - - try - { - new LockObjectsRequest(this, view, objects, view.getSession().options().getCollectionLoadingPolicy() - .getInitialChunkSize(), timeout, lockType).send(); - } - catch (RemoteException ex) - { - if (ex.getCause() instanceof RuntimeException) - { - runtimeException = (RuntimeException)ex.getCause(); - } - else if (ex.getCause() instanceof InterruptedException) - { - interruptedException = (InterruptedException)ex.getCause(); - } - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - - if (interruptedException != null) - { - throw interruptedException; - } - - if (runtimeException != null) - { - throw runtimeException; - } - } - - public void unlockObjects(CDOView view, Collection<? extends CDOObject> objects, LockType lockType) - { - send(new UnlockObjectsRequest(this, view, objects, lockType)); - } - - public boolean isObjectLocked(CDOView view, CDOObject object, LockType lockType, boolean byOthers) - { - return send(new ObjectLockedRequest(this, view, object, lockType, byOthers)); - } - - public CommitTransactionResult commitTransaction(InternalCDOCommitContext commitContext, OMMonitor monitor) - { - return send(new CommitTransactionRequest(this, commitContext), monitor); - } - - public CommitTransactionResult commitTransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor) - { - return send(new CommitTransactionPhase1Request(this, xaContext), monitor); - } - - public CommitTransactionResult commitTransactionPhase2(InternalCDOXACommitContext xaContext, OMMonitor monitor) - { - return send(new CommitTransactionPhase2Request(this, xaContext), monitor); - } - - public CommitTransactionResult commitTransactionPhase3(InternalCDOXACommitContext xaContext, OMMonitor monitor) - { - return send(new CommitTransactionPhase3Request(this, xaContext), monitor); - } - - public CommitTransactionResult commitTransactionCancel(InternalCDOXACommitContext xaContext, OMMonitor monitor) - { - return send(new CommitTransactionCancelRequest(this, xaContext), monitor); - } - - public List<CDORemoteSession> getRemoteSessions(InternalCDORemoteSessionManager manager, boolean subscribe) - { - return send(new GetRemoteSessionsRequest(this, manager, subscribe)); - } - - public void unsubscribeRemoteSessions() - { - send(new UnsubscribeRemoteSessionsRequest(this)); - } - - @Override - protected SignalReactor createSignalReactor(short signalID) - { - switch (signalID) - { - case CDOProtocolConstants.SIGNAL_AUTHENTICATION: - return new AuthenticationIndication(this); - - case CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION: - return new CommitNotificationIndication(this); - - case CDOProtocolConstants.SIGNAL_REMOTE_SESSION_NOTIFICATION: - return new RemoteSessionNotificationIndication(this); - - default: - return super.createSignalReactor(signalID); - } - } - - @Override - protected void doBeforeActivate() throws Exception - { - super.doBeforeActivate(); - if (!(getInfraStructure() instanceof CDOSession)) - { - throw new IllegalStateException(Messages.getString("CDOClientProtocol.0")); //$NON-NLS-1$ - } - } - - private <RESULT> RESULT send(RequestWithConfirmation<RESULT> request) - { - try - { - return request.send(); - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new TransportException(ex); - } - } - - private CommitTransactionResult send(CommitTransactionRequest request, OMMonitor monitor) - { - try - { - return request.send(monitor); - } - catch (RuntimeException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new TransportException(ex); - } - } - - private List<InternalCDORevision> send(LoadRevisionRequest request) - { - try - { - REVISION_LOADING.start(request); - return send((RequestWithConfirmation<List<InternalCDORevision>>)request); - } - finally - { - REVISION_LOADING.stop(request); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientProtocolFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientProtocolFactory.java deleted file mode 100644 index ee16bcdd5d..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientProtocolFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.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/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientRequest.java deleted file mode 100644 index 714973e61c..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOClientRequest.java +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; -import org.eclipse.emf.cdo.common.revision.CDOListFactory; -import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; -import org.eclipse.emf.cdo.internal.common.io.CDODataInputImpl; -import org.eclipse.emf.cdo.internal.common.io.CDODataOutputImpl; - -import org.eclipse.emf.internal.cdo.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(); - } - - @Override - protected final void requesting(ExtendedDataOutputStream out) throws Exception - { - requesting(new CDODataOutputImpl(out) - { - public CDOIDProvider getIDProvider() - { - throw new UnsupportedOperationException(); - } - - @Override - protected StringIO getPackageURICompressor() - { - return getProtocol().getPackageURICompressor(); - } - }); - } - - @Override - protected final RESULT confirming(ExtendedDataInputStream in) throws Exception - { - return confirming(new CDODataInputImpl(in) - { - @Override - protected CDOIDObjectFactory getIDFactory() - { - return getSession(); - } - - @Override - protected CDOListFactory getListFactory() - { - return CDOListWithElementProxiesImpl.FACTORY; - } - - @Override - protected CDOPackageRegistry getPackageRegistry() - { - return getSession().getPackageRegistry(); - } - - @Override - protected StringIO getPackageURICompressor() - { - return getProtocol().getPackageURICompressor(); - } - - @Override - protected CDORevisionResolver getRevisionResolver() - { - return getSession().getRevisionManager(); - } - }); - } - - protected abstract void requesting(CDODataOutput out) throws IOException; - - protected abstract RESULT confirming(CDODataInput in) throws IOException; -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOTimeRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOTimeRequest.java deleted file mode 100644 index 6622eb78b5..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CDOTimeRequest.java +++ /dev/null @@ -1,76 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; - -import org.eclipse.emf.internal.cdo.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,date} {0,time}", repositoryTimeResult.getRequested()); //$NON-NLS-1$ - } - } - - @Override - protected RESULT confirming(CDODataInput in) throws IOException - { - repositoryTimeResult.setConfirmed(System.currentTimeMillis()); - if (TRACER.isEnabled()) - { - TRACER.format("Confirmed: {0,date} {0,time}", repositoryTimeResult.getConfirmed()); //$NON-NLS-1$ - } - - repositoryTimeResult.setIndicated(in.readLong()); - if (TRACER.isEnabled()) - { - TRACER.format("Read indicated: {0,date} {0,time}", repositoryTimeResult.getIndicated()); //$NON-NLS-1$ - } - - repositoryTimeResult.setResponded(in.readLong()); - if (TRACER.isEnabled()) - { - TRACER.format("Read responded: {0,date} {0,time}", repositoryTimeResult.getResponded()); //$NON-NLS-1$ - } - - return null; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ChangeSubscriptionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ChangeSubscriptionRequest.java deleted file mode 100644 index 969c31b8ba..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ChangeSubscriptionRequest.java +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/230832 - * Eike Stepper - maintenance - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.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> cdoIDs; - - /** - * 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> cdoIDs, boolean subscribeMode, - boolean clear) - { - super(protocol, CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION); - this.viewID = viewID; - this.cdoIDs = cdoIDs; - this.subscribeMode = subscribeMode; - this.clear = clear; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - if (TRACER.isEnabled()) - { - TRACER.trace("View " + viewID + " subscribing to " + cdoIDs.size()); //$NON-NLS-1$ //$NON-NLS-2$ - } - - out.writeInt(viewID); - out.writeBoolean(clear); - out.writeInt(subscribeMode ? cdoIDs.size() : -cdoIDs.size()); - for (CDOID id : cdoIDs) - { - out.writeCDOID(id); - } - } - - @Override - protected Boolean confirming(CDODataInput in) throws IOException - { - return in.readBoolean(); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitNotificationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitNotificationIndication.java deleted file mode 100644 index 2b44719737..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitNotificationIndication.java +++ /dev/null @@ -1,110 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/233490 - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.spi.cdo.InternalCDOSession; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public class CommitNotificationIndication extends CDOClientIndication -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CommitNotificationIndication.class); - - public CommitNotificationIndication(CDOClientProtocol protocol) - { - super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_NOTIFICATION); - } - - @Override - protected void indicating(CDODataInput in) throws IOException - { - long timeStamp = in.readLong(); - if (TRACER.isEnabled()) - { - TRACER.format("Read timeStamp: {0,date} {0,time}", timeStamp); //$NON-NLS-1$ - } - - CDOPackageUnit[] packageUnits = in.readCDOPackageUnits(null); - InternalCDOPackageRegistry packageRegistry = getSession().getPackageRegistry(); - for (int i = 0; i < packageUnits.length; i++) - { - packageRegistry.putPackageUnit((InternalCDOPackageUnit)packageUnits[i]); - } - - int size = in.readInt(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0} dirty IDs", size); //$NON-NLS-1$ - } - - InternalCDOSession session = getSession(); - Set<CDOIDAndVersion> dirtyOIDs = new HashSet<CDOIDAndVersion>(); - for (int i = 0; i < size; i++) - { - CDOIDAndVersion dirtyOID = in.readCDOIDAndVersion(); - if (TRACER.isEnabled()) - { - TRACER.format("Read dirty ID: {0}", dirtyOID); //$NON-NLS-1$ - } - - dirtyOIDs.add(dirtyOID); - } - - size = in.readInt(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0} Deltas", size); //$NON-NLS-1$ - } - - List<CDORevisionDelta> deltas = new ArrayList<CDORevisionDelta>(); - for (int i = 0; i < size; i++) - { - CDORevisionDelta revisionDelta = in.readCDORevisionDelta(); - deltas.add(revisionDelta); - } - - size = in.readInt(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0} Detach Objects", size); //$NON-NLS-1$ - } - - List<CDOID> detachedObjects = new ArrayList<CDOID>(); - for (int i = 0; i < size; i++) - { - detachedObjects.add(in.readCDOID()); - } - - session.handleCommitNotification(timeStamp, Arrays.asList(packageUnits), dirtyOIDs, detachedObjects, deltas, null); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionCancelRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionCancelRequest.java deleted file mode 100644 index 4c9941983d..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionCancelRequest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.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 CommitTransactionCancelRequest extends CommitTransactionRequest -{ - public CommitTransactionCancelRequest(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) - { - super(protocol, CDOProtocolConstants.SIGNAL_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/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase1Request.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase1Request.java deleted file mode 100644 index 743d442577..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase1Request.java +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOIDProvider; -import org.eclipse.emf.cdo.common.io.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 CommitTransactionPhase1Request extends CommitTransactionRequest -{ - public CommitTransactionPhase1Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) - { - super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE1, xaContext); - } - - @Override - protected CDOIDProvider getIDProvider() - { - return (CDOIDProvider)commitContext; - } - - @Override - protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException - { - CommitTransactionResult result = confirmingCheckError(in); - if (result != null) - { - return result; - } - - result = confirmingTransactionResult(in); - confirmingIDMappings(in, result); - return result; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase2Request.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase2Request.java deleted file mode 100644 index 54e29d81f0..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase2Request.java +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDUtil; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.internal.common.id.CDOIDExternalTempImpl; -import org.eclipse.emf.cdo.util.CDOURIUtil; - -import org.eclipse.emf.internal.cdo.bundle.OM; -import org.eclipse.emf.internal.cdo.messages.Messages; - -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.InternalCDOTransaction; -import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; -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 CommitTransactionPhase2Request extends CommitTransactionRequest -{ - private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, - CommitTransactionPhase1Request.class); - - public CommitTransactionPhase2Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) - { - super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION_PHASE2, xaContext); - } - - @Override - protected InternalCDOXACommitContext getCommitContext() - { - return (InternalCDOXACommitContext)super.getCommitContext(); - } - - @Override - protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException - { - requestingTransactionInfo(out); - requestingIdMapping(out); - } - - @Override - protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException - { - return confirmingCheckError(in); - } - - /** - * Write ids that are needed. only If it needs to - */ - protected void requestingIdMapping(CDODataOutput out) throws IOException - { - InternalCDOXACommitContext context = getCommitContext(); - Map<CDOIDExternalTempImpl, 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<CDOIDExternalTempImpl, InternalCDOTransaction> entry : requestedIDs.entrySet()) - { - CDOIDExternalTempImpl tempID = entry.getKey(); - URI oldURIExternal = URI.createURI(tempID.toURIFragment()); - CDOID oldCDOID = CDOIDUtil.read(oldURIExternal.fragment(), null); - - 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); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase3Request.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase3Request.java deleted file mode 100644 index caab413d98..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionPhase3Request.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.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 CommitTransactionPhase3Request extends CommitTransactionRequest -{ - public CommitTransactionPhase3Request(CDOClientProtocol protocol, InternalCDOXACommitContext xaContext) - { - super(protocol, CDOProtocolConstants.SIGNAL_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 = (InternalCDOXACommitContext)getCommitContext(); - confirmingNewPackage(in, context.getResult()); - return context.getResult(); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionRequest.java deleted file mode 100644 index cb18d6029c..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/CommitTransactionRequest.java +++ /dev/null @@ -1,310 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/201266 - * Simon McDuff - http://bugs.eclipse.org/215688 - * Simon McDuff - http://bugs.eclipse.org/213402 - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDMetaRange; -import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; -import org.eclipse.emf.cdo.common.id.CDOIDTemp; -import org.eclipse.emf.cdo.common.id.CDOIDUtil; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.model.CDOPackageInfo; -import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.common.revision.CDOListFactory; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; -import org.eclipse.emf.cdo.eresource.CDOResource; -import org.eclipse.emf.cdo.internal.common.io.CDODataInputImpl; -import org.eclipse.emf.cdo.internal.common.io.CDODataOutputImpl; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; - -import org.eclipse.emf.internal.cdo.bundle.OM; -import org.eclipse.emf.internal.cdo.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.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.spi.cdo.InternalCDOSession; -import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult; -import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext; - -import java.io.IOException; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class CommitTransactionRequest extends RequestWithMonitoring<CommitTransactionResult> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionRequest.class); - - protected InternalCDOCommitContext commitContext; - - public CommitTransactionRequest(CDOClientProtocol protocol, InternalCDOCommitContext commitContext) - { - this(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION, commitContext); - } - - public CommitTransactionRequest(CDOClientProtocol protocol, short signalID, InternalCDOCommitContext commitContext) - { - super(protocol, signalID); - this.commitContext = commitContext; - } - - protected InternalCDOCommitContext getCommitContext() - { - return commitContext; - } - - @Override - public CDOClientProtocol getProtocol() - { - return (CDOClientProtocol)super.getProtocol(); - } - - protected InternalCDOSession getSession() - { - return (InternalCDOSession)getProtocol().getSession(); - } - - protected CDOIDProvider getIDProvider() - { - return commitContext.getTransaction(); - } - - @Override - protected final void requesting(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception - { - requesting(new CDODataOutputImpl(out) - { - @Override - protected StringIO getPackageURICompressor() - { - return getProtocol().getPackageURICompressor(); - } - - public CDOIDProvider getIDProvider() - { - return CommitTransactionRequest.this.getIDProvider(); - } - }, monitor); - } - - @Override - protected final CommitTransactionResult confirming(ExtendedDataInputStream in, OMMonitor monitor) throws Exception - { - return confirming(new CDODataInputImpl(in) - { - @Override - protected StringIO getPackageURICompressor() - { - return getProtocol().getPackageURICompressor(); - } - - @Override - protected CDOPackageRegistry getPackageRegistry() - { - return getSession().getPackageRegistry(); - } - - @Override - protected CDORevisionResolver getRevisionResolver() - { - return getSession().getRevisionManager(); - } - - @Override - protected CDOIDObjectFactory getIDFactory() - { - return getSession(); - } - - @Override - protected CDOListFactory getListFactory() - { - return CDOListWithElementProxiesImpl.FACTORY; - } - }, monitor); - } - - protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException - { - requestingTransactionInfo(out); - requestingCommit(out); - } - - protected CommitTransactionResult confirming(CDODataInput in, OMMonitor monitor) throws IOException - { - CommitTransactionResult result = confirmingCheckError(in); - if (result != null) - { - return result; - } - - result = confirmingTransactionResult(in); - confirmingNewPackage(in, result); - confirmingIDMappings(in, result); - return result; - } - - protected void requestingTransactionInfo(CDODataOutput out) throws IOException - { - out.writeInt(commitContext.getTransaction().getViewID()); - } - - protected void requestingCommit(CDODataOutput out) throws IOException - { - List<CDOPackageUnit> newPackageUnits = commitContext.getNewPackageUnits(); - Collection<CDOResource> newResources = commitContext.getNewResources().values(); - Collection<CDOObject> newObjects = commitContext.getNewObjects().values(); - Collection<CDORevisionDelta> revisionDeltas = commitContext.getRevisionDeltas().values(); - Collection<CDOID> detachedObjects = commitContext.getDetachedObjects().keySet(); - - out.writeBoolean(commitContext.getTransaction().options().isAutoReleaseLocksEnabled()); - out.writeInt(newPackageUnits.size()); - out.writeInt(newResources.size() + newObjects.size()); - out.writeInt(revisionDeltas.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} new objects", newResources.size() + newObjects.size()); //$NON-NLS-1$ - } - - writeRevisions(out, newResources); - writeRevisions(out, newObjects); - - if (TRACER.isEnabled()) - { - TRACER.format("Writing {0} dirty objects", revisionDeltas.size()); //$NON-NLS-1$ - } - - for (CDORevisionDelta revisionDelta : revisionDeltas) - { - out.writeCDORevisionDelta(revisionDelta); - } - - for (CDOID id : detachedObjects) - { - out.writeCDOID(id); - } - } - - protected CommitTransactionResult confirmingCheckError(CDODataInput in) throws IOException - { - boolean success = in.readBoolean(); - if (!success) - { - String rollbackMessage = in.readString(); - OM.LOG.error(rollbackMessage); - return new CommitTransactionResult(commitContext, rollbackMessage); - } - - return null; - } - - protected CommitTransactionResult confirmingTransactionResult(CDODataInput in) throws IOException - { - long timeStamp = in.readLong(); - return new CommitTransactionResult(commitContext, timeStamp); - } - - protected void confirmingNewPackage(CDODataInput in, CommitTransactionResult result) throws IOException - { - InternalCDOPackageRegistry packageRegistry = getSession().getPackageRegistry(); - for (CDOPackageUnit newPackageUnit : commitContext.getNewPackageUnits()) - { - for (CDOPackageInfo packageInfo : newPackageUnit.getPackageInfos()) - { - CDOIDMetaRange oldRange = packageInfo.getMetaIDRange(); - CDOIDMetaRange newRange = in.readCDOIDMetaRange(); - ((InternalCDOPackageInfo)packageInfo).setMetaIDRange(newRange); - for (int i = 0; i < oldRange.size(); i++) - { - CDOIDTemp oldID = (CDOIDTemp)oldRange.get(i); - CDOID newID = newRange.get(i); - packageRegistry.getMetaInstanceMapper().remapMetaInstanceID(oldID, newID); - result.addIDMapping(oldID, newID); - } - } - } - } - - /* - * Write IDs that are needed - */ - protected void confirmingIDMappings(CDODataInput in, CommitTransactionResult result) throws IOException - { - for (;;) - { - CDOIDTemp oldID = (CDOIDTemp)in.readCDOID(); - if (CDOIDUtil.isNull(oldID)) - { - break; - } - - CDOID newID = in.readCDOID(); - result.addIDMapping(oldID, newID); - } - } - - @Override - protected int getMonitorProgressSeconds() - { - org.eclipse.emf.cdo.net4j.CDOSession session = (org.eclipse.emf.cdo.net4j.CDOSession)commitContext.getTransaction() - .getSession(); - return session.options().getProgressInterval(); - } - - @Override - protected int getMonitorTimeoutSeconds() - { - org.eclipse.emf.cdo.net4j.CDOSession session = (org.eclipse.emf.cdo.net4j.CDOSession)commitContext.getTransaction() - .getSession(); - return session.options().getCommitTimeout(); - } - - private void writeRevisions(CDODataOutput out, Collection<?> objects) throws IOException - { - for (Iterator<?> it = objects.iterator(); it.hasNext();) - { - CDOObject object = (CDOObject)it.next(); - CDORevision revision = object.cdoRevision(); - out.writeCDORevision(revision, CDORevision.UNCHUNKED); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/GetRemoteSessionsRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/GetRemoteSessionsRequest.java deleted file mode 100644 index c3753dfe28..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/GetRemoteSessionsRequest.java +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.session.remote.CDORemoteSession; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -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 InternalCDORemoteSessionManager manager; - - private boolean subscribe; - - public GetRemoteSessionsRequest(CDOClientProtocol protocol, InternalCDORemoteSessionManager manager, boolean subscribe) - { - super(protocol, CDOProtocolConstants.SIGNAL_GET_REMOTE_SESSIONS); - this.manager = manager; - 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(); - CDORemoteSession remoteSession = manager.createRemoteSession(sessionID, userID, subscribed); - result.add(remoteSession); - } - - return result; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadChunkRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadChunkRequest.java deleted file mode 100644 index a6d23642ec..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadChunkRequest.java +++ /dev/null @@ -1,123 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.model.CDOModelUtil; -import org.eclipse.emf.cdo.common.model.CDOType; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.collection.MoveableList; -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); - int version = revision.getVersion(); - if (revision.isTransactional()) - { - --version; - } - - if (TRACER.isEnabled()) - { - TRACER.format("Writing revision 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; - MoveableList<Object> list = revision.getList(feature); - for (int i = fromIndex; i <= toIndex; i++) - { - Object value = type.readValue(in); - list.set(i, value); - if (i == accessIndex) - { - accessID = value; - } - } - - return accessID; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadLibrariesRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadLibrariesRequest.java deleted file mode 100644 index 4db958e6d9..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadLibrariesRequest.java +++ /dev/null @@ -1,97 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -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.IOUtil; -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.File; -import java.io.FileOutputStream; -import java.util.Collection; - -/** - * @author Eike Stepper - */ -public class LoadLibrariesRequest extends RequestWithConfirmation<Integer> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadLibrariesRequest.class); - - private Collection<String> libraryNames; - - private File cacheFolder; - - public LoadLibrariesRequest(CDOClientProtocol protocol, Collection<String> libraryNames, File cacheFolder) - { - super(protocol, CDOProtocolConstants.SIGNAL_LOAD_LIBRARIES); - this.libraryNames = libraryNames; - this.cacheFolder = cacheFolder; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - int size = libraryNames.size(); - if (TRACER.isEnabled()) - { - TRACER.format("Writing {0} library names", size); //$NON-NLS-1$ - } - - out.writeInt(size); - for (String libraryName : libraryNames) - { - if (TRACER.isEnabled()) - { - TRACER.format("Writing library name: {0}", libraryName); //$NON-NLS-1$ - } - - out.writeString(libraryName); - } - } - - @Override - protected Integer confirming(ExtendedDataInputStream in) throws Exception - { - byte[] buffer = new byte[IOUtil.DEFAULT_BUFFER_SIZE]; - int count = 0; - for (String libraryName : libraryNames) - { - int size = in.readInt(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading library {0}: {1} bytes", libraryName, size); //$NON-NLS-1$ - } - - File file = new File(cacheFolder, libraryName); - FileOutputStream out = null; - - try - { - out = new FileOutputStream(file); - IOUtil.copy(in, out, size, buffer); - } - finally - { - IOUtil.close(out); - } - - ++count; - } - - return count; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadPackagesRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadPackagesRequest.java deleted file mode 100644 index 710eb488f8..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadPackagesRequest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.model.CDOModelUtil; -import org.eclipse.emf.cdo.common.model.EMFUtil; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.ecore.EPackage; - -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 - { - EPackage ePackage = CDOModelUtil.readPackage(in, packageUnit.getPackageRegistry()); - return EMFUtil.getAllPackages(ePackage); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionByTimeRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionByTimeRequest.java deleted file mode 100644 index 22f2867e52..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionByTimeRequest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Collection; - -/** - * @author Eike Stepper - */ -public class LoadRevisionByTimeRequest extends LoadRevisionRequest -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionByTimeRequest.class); - - private long timeStamp; - - public LoadRevisionByTimeRequest(CDOClientProtocol protocol, Collection<CDOID> ids, int referenceChunk, long timeStamp) - { - super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_TIME, ids, referenceChunk); - this.timeStamp = timeStamp; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - super.requesting(out); - if (TRACER.isEnabled()) - { - TRACER.format("Writing timeStamp: {0}", timeStamp); //$NON-NLS-1$ - } - - out.writeLong(timeStamp); - } - - @Override - public String toString() - { - return MessageFormat.format("{0}(ids={1}, referenceChunk={2}, timeStamp={3})", getClass().getSimpleName(), //$NON-NLS-1$ - getIDs(), getReferenceChunk(), timeStamp); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionByVersionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionByVersionRequest.java deleted file mode 100644 index 78bebd6370..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionByVersionRequest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Collections; - -/** - * @author Eike Stepper - */ -public class LoadRevisionByVersionRequest extends LoadRevisionRequest -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionByVersionRequest.class); - - private int version; - - public LoadRevisionByVersionRequest(CDOClientProtocol protocol, CDOID id, int referenceChunk, int version) - { - super(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_VERSION, Collections.singleton(id), referenceChunk); - this.version = version; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - super.requesting(out); - if (TRACER.isEnabled()) - { - TRACER.format("Writing version: {0}", version); //$NON-NLS-1$ - } - - out.writeInt(version); - } - - @Override - public String toString() - { - return MessageFormat.format("{0}(ids={1}, referenceChunk={2}, version={3})", getClass().getSimpleName(), getIDs(), //$NON-NLS-1$ - getReferenceChunk(), version); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionRequest.java deleted file mode 100644 index 1bbc073b70..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LoadRevisionRequest.java +++ /dev/null @@ -1,157 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.CDOFetchRule; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.view.CDOFetchRuleManager; - -import org.eclipse.emf.internal.cdo.bundle.OM; -import org.eclipse.emf.internal.cdo.session.CDORevisionManagerImpl; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class LoadRevisionRequest extends CDOClientRequest<List<InternalCDORevision>> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadRevisionRequest.class); - - private Collection<CDOID> ids; - - private int referenceChunk; - - public LoadRevisionRequest(CDOClientProtocol protocol, Collection<CDOID> ids, int referenceChunk) - { - this(protocol, CDOProtocolConstants.SIGNAL_LOAD_REVISION, ids, referenceChunk); - } - - public LoadRevisionRequest(CDOClientProtocol protocol, short signalID, Collection<CDOID> ids, int referenceChunk) - { - super(protocol, signalID); - this.ids = ids; - this.referenceChunk = referenceChunk; - } - - public Collection<CDOID> getIDs() - { - return ids; - } - - public int getReferenceChunk() - { - return referenceChunk; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - if (TRACER.isEnabled()) - { - TRACER.format("Writing referenceChunk: {0}", referenceChunk); //$NON-NLS-1$ - } - - out.writeInt(referenceChunk); - if (TRACER.isEnabled()) - { - TRACER.format("Writing {0} IDs", ids.size()); //$NON-NLS-1$ - } - - out.writeInt(ids.size()); - for (CDOID id : ids) - { - if (TRACER.isEnabled()) - { - TRACER.format("Writing ID: {0}", id); //$NON-NLS-1$ - } - - out.writeCDOID(id); - } - - CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)getSession().getRevisionManager(); - CDOFetchRuleManager ruleManager = revisionManager.getRuleManager(); - List<CDOFetchRule> fetchRules = ruleManager.getFetchRules(ids); - if (fetchRules == null || fetchRules.size() <= 0) - { - out.writeInt(0); - } - else - { - // At this point, fetch size is more than one. - int fetchSize = fetchRules.size(); - CDOID contextID = ruleManager.getContext(); - - out.writeInt(fetchSize); - out.writeInt(ruleManager.getCollectionLoadingPolicy().getInitialChunkSize()); - out.writeCDOID(contextID); - - for (CDOFetchRule fetchRule : fetchRules) - { - fetchRule.write(out); - } - } - } - - @Override - protected List<InternalCDORevision> confirming(CDODataInput in) throws IOException - { - int idSize = ids.size(); - ArrayList<InternalCDORevision> revisions = new ArrayList<InternalCDORevision>(idSize); - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0} revisions", idSize); //$NON-NLS-1$ - } - - for (int i = 0; i < idSize; i++) - { - InternalCDORevision revision = (InternalCDORevision)in.readCDORevision(); - revisions.add(revision); - } - - int additionalSize = in.readInt(); - if (additionalSize != 0) - { - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0} additional revisions", additionalSize); //$NON-NLS-1$ - } - - CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)getSession().getRevisionManager(); - for (int i = 0; i < additionalSize; i++) - { - InternalCDORevision revision = (InternalCDORevision)in.readCDORevision(); - if (revision != null) - { - revisionManager.addCachedRevision(revision); - } - } - } - - return revisions; - } - - @Override - public String toString() - { - return MessageFormat.format("{0}(ids={1}, referenceChunk={2})", getClass().getSimpleName(), ids, referenceChunk); //$NON-NLS-1$ - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LockObjectsRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LockObjectsRequest.java deleted file mode 100644 index 95532f4bcd..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/LockObjectsRequest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.transaction.CDOTimeStampContext; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.concurrent.RWLockManager; -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.spi.cdo.InternalCDOObject; -import org.eclipse.emf.spi.cdo.InternalCDOView; - -import java.io.IOException; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; - -/** - * @author Simon McDuff - */ -public class LockObjectsRequest extends AbstractSyncRevisionsRequest -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LockObjectsRequest.class); - - private CDOView view; - - private RWLockManager.LockType lockType; - - private long timeout; - - public LockObjectsRequest(CDOClientProtocol protocol, CDOView view, Map<CDOID, CDOIDAndVersion> idAndVersions, - int referenceChunk, long timeout, RWLockManager.LockType lockType) - { - super(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS, idAndVersions, referenceChunk); - this.view = view; - - this.timeout = timeout; - this.lockType = lockType; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - super.requesting(out); - out.writeInt(view.getViewID()); - out.writeCDOLockType(lockType); - out.writeLong(timeout); - - if (TRACER.isEnabled()) - { - TRACER.format("Locking of type {0} requested for view {1} with timeout {2}", //$NON-NLS-1$ - lockType == RWLockManager.LockType.READ ? "read" : "write", view.getViewID(), timeout); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - @Override - protected Collection<CDOTimeStampContext> confirming(CDODataInput in) throws IOException - { - Collection<CDOTimeStampContext> contexts = super.confirming(in); - for (CDOTimeStampContext timestampContext : contexts) - { - getSession().handleUpdateRevision(timestampContext.getTimeStamp(), timestampContext.getDirtyObjects(), - timestampContext.getDetachedObjects()); - ((InternalCDOView)view).handleInvalidationWithoutNotification(timestampContext.getDirtyObjects(), - timestampContext.getDetachedObjects(), new HashSet<InternalCDOObject>(), new HashSet<InternalCDOObject>()); - } - - return contexts; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ObjectLockedRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ObjectLockedRequest.java deleted file mode 100644 index 3863b357c9..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ObjectLockedRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.concurrent.RWLockManager; -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 RWLockManager.LockType lockType; - - private boolean byOthers; - - public ObjectLockedRequest(CDOClientProtocol protocol, CDOView view, CDOObject object, - RWLockManager.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 == RWLockManager.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/src/org/eclipse/emf/internal/cdo/net4j/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/OpenSessionRequest.java deleted file mode 100644 index 2e5ae461cc..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/OpenSessionRequest.java +++ /dev/null @@ -1,130 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/230832 - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOIDLibraryDescriptor; -import org.eclipse.emf.cdo.common.id.CDOIDUtil; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; -import org.eclipse.emf.cdo.util.ServerException; - -import org.eclipse.emf.internal.cdo.bundle.OM; -import org.eclipse.emf.internal.cdo.messages.Messages; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.spi.cdo.CDOSessionProtocol.OpenSessionResult; - -import java.io.IOException; -import java.text.MessageFormat; - -/** - * @author Eike Stepper - */ -public class OpenSessionRequest extends CDOTimeRequest<OpenSessionResult> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, OpenSessionRequest.class); - - private String repositoryName; - - private boolean passiveUpdateEnabled; - - private OpenSessionResult result; - - public OpenSessionRequest(CDOClientProtocol protocol, String repositoryName, boolean passiveUpdateEnabled) - { - super(protocol, CDOProtocolConstants.SIGNAL_OPEN_SESSION); - this.repositoryName = repositoryName; - this.passiveUpdateEnabled = passiveUpdateEnabled; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - super.requesting(out); - if (TRACER.isEnabled()) - { - TRACER.format("Writing repositoryName: {0}", repositoryName); //$NON-NLS-1$ - } - - out.writeString(repositoryName); - - if (TRACER.isEnabled()) - { - TRACER.format("Writing passiveUpdateEnabled: {0}", passiveUpdateEnabled); //$NON-NLS-1$ - } - - out.writeBoolean(passiveUpdateEnabled); - } - - @Override - protected OpenSessionResult confirming(CDODataInput in) throws IOException - { - int sessionID = in.readInt(); - if (sessionID == CDOProtocolConstants.ERROR_REPOSITORY_NOT_FOUND) - { - String msg = MessageFormat.format(Messages.getString("OpenSessionRequest.0"), repositoryName); //$NON-NLS-1$ - throw new ServerException(msg); - } - - if (sessionID == CDOProtocolConstants.ERROR_NO_SESSION) - { - String msg = MessageFormat.format(Messages.getString("OpenSessionRequest.3"), repositoryName); //$NON-NLS-1$ - throw new ServerException(msg); - } - - if (TRACER.isEnabled()) - { - TRACER.format("Read sessionID: {0}", sessionID); //$NON-NLS-1$ - } - - String repositoryUUID = in.readString(); - if (TRACER.isEnabled()) - { - TRACER.format("Read repositoryUUID: {0}", repositoryUUID); //$NON-NLS-1$ - } - - long repositoryCreationTime = in.readLong(); - if (TRACER.isEnabled()) - { - TRACER.format("Read repositoryCreationTime: {0,date} {0,time}", repositoryCreationTime); //$NON-NLS-1$ - } - - boolean repositorySupportingAudits = in.readBoolean(); - if (TRACER.isEnabled()) - { - TRACER.format("Read repositorySupportingAudits: {0}", repositorySupportingAudits); //$NON-NLS-1$ - } - - CDOIDLibraryDescriptor libraryDescriptor = CDOIDUtil.readLibraryDescriptor(in); - if (TRACER.isEnabled()) - { - TRACER.format("Read libraryDescriptor: {0}", libraryDescriptor); //$NON-NLS-1$ - } - - result = new OpenSessionResult(sessionID, repositoryUUID, repositoryCreationTime, repositorySupportingAudits, - libraryDescriptor); - - CDOPackageUnit[] packageUnits = in.readCDOPackageUnits(null); - for (int i = 0; i < packageUnits.length; i++) - { - result.getPackageUnits().add((InternalCDOPackageUnit)packageUnits[i]); - } - - super.confirming(in); - result.setRepositoryTimeResult(getRepositoryTimeResult()); - return result; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/QueryCancelRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/QueryCancelRequest.java deleted file mode 100644 index b3bf7caf5c..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/QueryCancelRequest.java +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.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/src/org/eclipse/emf/internal/cdo/net4j/protocol/QueryRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/QueryRequest.java deleted file mode 100644 index a62e821899..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/QueryRequest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.common.util.CDOQueryQueue; -import org.eclipse.emf.cdo.internal.common.CDOQueryInfoImpl; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.spi.cdo.AbstractQueryIterator; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Simon McDuff - */ -public class QueryRequest extends CDOClientRequest<List<Object>> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryRequest.class); - - private int viewID; - - private AbstractQueryIterator<?> queryResult; - - public QueryRequest(CDOClientProtocol protocol, int viewID, AbstractQueryIterator<?> queryResult) - { - super(protocol, CDOProtocolConstants.SIGNAL_QUERY); - this.viewID = viewID; - this.queryResult = queryResult; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - out.writeInt(viewID); - // TODO Simon: Move I/O logic to CDODataInput/OutputStream?! - ((CDOQueryInfoImpl)queryResult.getQueryInfo()).write(out); - } - - @Override - protected List<Object> confirming(CDODataInput in) throws IOException - { - int queryID = in.readInt(); - queryResult.setQueryID(queryID); - - CDOQueryQueue<Object> resultQueue = queryResult.getQueue(); - List<Object> result = new ArrayList<Object>(); - - try - { - int numberOfObjectsReceived = 0; - while (in.readBoolean()) - { - // result - Object element = in.readCDORevisionOrPrimitive(); - resultQueue.add(element); - numberOfObjectsReceived++; - } - - if (TRACER.isEnabled()) - { - TRACER.format("Query executed [{0} elements received]", numberOfObjectsReceived); //$NON-NLS-1$ - } - } - catch (RuntimeException ex) - { - resultQueue.setException(ex); - } - catch (Throwable throwable) - { - resultQueue.setException(new RuntimeException(throwable.getMessage(), throwable)); - } - finally - { - resultQueue.close(); - } - - return result; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/RemoteSessionNotificationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/RemoteSessionNotificationIndication.java deleted file mode 100644 index f4f2214948..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/RemoteSessionNotificationIndication.java +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/233490 - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager; - -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 - { - byte opcode = in.readByte(); - int sessionID = in.readInt(); - InternalCDORemoteSessionManager manager = (InternalCDORemoteSessionManager)getSession().getRemoteSessionManager(); - - switch (opcode) - { - case CDOProtocolConstants.REMOTE_SESSION_OPENED: - String userID = in.readString(); - manager.handleRemoteSessionOpened(sessionID, userID); - break; - - case CDOProtocolConstants.REMOTE_SESSION_CLOSED: - manager.handleRemoteSessionClosed(sessionID); - break; - - case CDOProtocolConstants.REMOTE_SESSION_SUBSCRIBED: - manager.handleRemoteSessionSubscribed(sessionID, true); - break; - - case CDOProtocolConstants.REMOTE_SESSION_UNSUBSCRIBED: - manager.handleRemoteSessionSubscribed(sessionID, false); - break; - } - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/RepositoryTimeRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/RepositoryTimeRequest.java deleted file mode 100644 index f41f0d248b..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/RepositoryTimeRequest.java +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.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/src/org/eclipse/emf/internal/cdo/net4j/protocol/ResourceIDRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ResourceIDRequest.java deleted file mode 100644 index 1937f58974..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ResourceIDRequest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class ResourceIDRequest extends CDOClientRequest<CDOID> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, ResourceIDRequest.class); - - private int viewID; - - private String path; - - public ResourceIDRequest(CDOClientProtocol protocol, int viewID, String path) - { - super(protocol, CDOProtocolConstants.SIGNAL_RESOURCE_ID); - this.viewID = viewID; - this.path = path; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - if (TRACER.isEnabled()) - { - TRACER.format("Writing viewID: {0}", viewID); //$NON-NLS-1$ - } - - out.writeInt(viewID); - if (TRACER.isEnabled()) - { - TRACER.format("Writing path: {0}", path); //$NON-NLS-1$ - } - - out.writeString(path); - } - - @Override - protected CDOID confirming(CDODataInput in) throws IOException - { - CDOID id = in.readCDOID(); - if (TRACER.isEnabled()) - { - TRACER.format("Read ID: {0}", id); //$NON-NLS-1$ - } - - return id; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SetAuditRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SetAuditRequest.java deleted file mode 100644 index 178c22ef74..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SetAuditRequest.java +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import org.eclipse.emf.spi.cdo.InternalCDOObject; - -import java.io.IOException; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class SetAuditRequest extends CDOClientRequest<boolean[]> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, SetAuditRequest.class); - - private int viewID; - - private long timeStamp; - - private List<InternalCDOObject> invalidObjects; - - public SetAuditRequest(CDOClientProtocol protocol, int viewID, long timeStamp, List<InternalCDOObject> invalidObjects) - { - super(protocol, CDOProtocolConstants.SIGNAL_SET_AUDIT); - this.viewID = viewID; - this.timeStamp = timeStamp; - this.invalidObjects = invalidObjects; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - if (TRACER.isEnabled()) - { - TRACER.format("Writing viewID: {0}", viewID); //$NON-NLS-1$ - } - - out.writeInt(viewID); - if (TRACER.isEnabled()) - { - TRACER.format("Writing timeStamp: {0,date} {0,time}", timeStamp); //$NON-NLS-1$ - } - - out.writeLong(timeStamp); - - int size = invalidObjects.size(); - if (TRACER.isEnabled()) - { - TRACER.format("Writing {0} IDs", size); //$NON-NLS-1$ - } - - out.writeInt(size); - for (InternalCDOObject object : invalidObjects) - { - if (TRACER.isEnabled()) - { - TRACER.format("Writing ID: {0}", object.cdoID()); //$NON-NLS-1$ - } - - out.writeCDOID(object.cdoID()); - } - } - - @Override - protected boolean[] confirming(CDODataInput in) throws IOException - { - int size = in.readInt(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0} existanceFlags", size); //$NON-NLS-1$ - } - - boolean[] existanceFlags = new boolean[size]; - for (int i = 0; i < size; i++) - { - boolean existanceFlag = in.readBoolean(); - existanceFlags[i] = existanceFlag; - if (TRACER.isEnabled()) - { - TRACER.format("Read existanceFlag: {0}", existanceFlag); //$NON-NLS-1$ - } - } - - return existanceFlags; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SetPassiveUpdateRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SetPassiveUpdateRequest.java deleted file mode 100644 index 18545f7ff0..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SetPassiveUpdateRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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 - http://bugs.eclipse.org/230832 - **************************************************************************/ -package org.eclipse.emf.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; -import java.util.Map; - -/** - * @author Simon McDuff - * @since 2.0 - */ -public class SetPassiveUpdateRequest extends SyncRevisionsRequest -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, SetPassiveUpdateRequest.class); - - private boolean passiveUpdateEnabled; - - public SetPassiveUpdateRequest(CDOClientProtocol protocol, Map<CDOID, CDOIDAndVersion> idAndVersions, - int referenceChunk, boolean passiveUpdateEnabled) - { - super(protocol, CDOProtocolConstants.SIGNAL_PASSIVE_UPDATE, idAndVersions, referenceChunk); - this.passiveUpdateEnabled = passiveUpdateEnabled; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - if (TRACER.isEnabled()) - { - TRACER.trace("Turning " + (passiveUpdateEnabled ? "on" : "off") + " passive update"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - - super.requesting(out); - out.writeBoolean(passiveUpdateEnabled); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SyncRevisionsRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SyncRevisionsRequest.java deleted file mode 100644 index b3982417cf..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/SyncRevisionsRequest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.transaction.CDOTimeStampContext; - -import java.io.IOException; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -/** - * @author Simon McDuff - * @since 2.0 - */ -public class SyncRevisionsRequest extends AbstractSyncRevisionsRequest -{ - public SyncRevisionsRequest(CDOClientProtocol protocol, Map<CDOID, CDOIDAndVersion> idAndVersions, int referenceChunk) - { - this(protocol, CDOProtocolConstants.SIGNAL_SYNC_REVISIONS, idAndVersions, referenceChunk); - } - - public SyncRevisionsRequest(CDOClientProtocol protocol, short signalID, Map<CDOID, CDOIDAndVersion> idAndVersions, - int referenceChunk) - { - super(protocol, signalID, idAndVersions, referenceChunk); - } - - @Override - protected Collection<CDOTimeStampContext> confirming(CDODataInput in) throws IOException - { - Collection<CDOTimeStampContext> contexts = super.confirming(in); - Collection<CDOPackageUnit> emptyNewPackageUnits = Collections.emptyList(); - for (CDOTimeStampContext timestampContext : contexts) - { - getSession().handleSyncResponse(timestampContext.getTimeStamp(), emptyNewPackageUnits, - timestampContext.getDirtyObjects(), timestampContext.getDetachedObjects()); - } - - return contexts; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/UnlockObjectsRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/UnlockObjectsRequest.java deleted file mode 100644 index abe74b88bd..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/UnlockObjectsRequest.java +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.CDOObject; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.view.CDOView; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.concurrent.RWLockManager; -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; -import java.util.Collection; - -/** - * @author Simon McDuff - */ -public class UnlockObjectsRequest extends CDOClientRequest<Boolean> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, UnlockObjectsRequest.class); - - private CDOView view; - - private Collection<? extends CDOObject> objects; - - private RWLockManager.LockType lockType; - - public UnlockObjectsRequest(CDOClientProtocol protocol, CDOView view, Collection<? extends CDOObject> objects, - RWLockManager.LockType lockType) - { - super(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS); - this.view = view; - this.objects = objects; - this.lockType = lockType; - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - out.writeInt(view.getViewID()); - out.writeCDOLockType(lockType); - if (objects == null) - { - if (TRACER.isEnabled()) - { - TRACER.format("Unlocking all objects for view {0}", view.getViewID()); //$NON-NLS-1$ - } - - out.writeInt(CDOProtocolConstants.RELEASE_ALL_LOCKS); - } - else - { - if (TRACER.isEnabled()) - { - TRACER.format("Unlocking of type {0} requested for view {1}", lockType == RWLockManager.LockType.READ ? "read" //$NON-NLS-1$ //$NON-NLS-2$ - : "write", view.getViewID()); //$NON-NLS-1$ - } - - out.writeInt(objects.size()); - for (CDOObject object : objects) - { - if (TRACER.isEnabled()) - { - TRACER.format("Unlocking requested for objects {0}", object.cdoID()); //$NON-NLS-1$ - } - - out.writeCDOID(object.cdoID()); - } - } - } - - @Override - protected Boolean confirming(CDODataInput in) throws IOException - { - return in.readBoolean(); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/UnsubscribeRemoteSessionsRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/UnsubscribeRemoteSessionsRequest.java deleted file mode 100644 index cdb38e098f..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/UnsubscribeRemoteSessionsRequest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import org.eclipse.emf.internal.cdo.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/src/org/eclipse/emf/internal/cdo/net4j/protocol/VerifyRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/VerifyRevisionRequest.java deleted file mode 100644 index 93c1bfb49a..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/VerifyRevisionRequest.java +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; - -import org.eclipse.emf.internal.cdo.bundle.OM; - -import org.eclipse.net4j.util.om.trace.ContextTracer; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * @author Eike Stepper - */ -public class VerifyRevisionRequest extends CDOClientRequest<List<InternalCDORevision>> -{ - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, VerifyRevisionRequest.class); - - private Collection<InternalCDORevision> revisions; - - public VerifyRevisionRequest(CDOClientProtocol protocol, Collection<InternalCDORevision> revisions) - { - super(protocol, CDOProtocolConstants.SIGNAL_VERIFY_REVISION); - this.revisions = revisions; - } - - public VerifyRevisionRequest(CDOClientProtocol protocol, InternalCDORevision revision) - { - this(protocol, Collections.singleton(revision)); - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - if (TRACER.isEnabled()) - { - TRACER.format("Writing {0} IDs and versions", revisions.size()); //$NON-NLS-1$ - } - - out.writeInt(revisions.size()); - for (InternalCDORevision revision : revisions) - { - CDOID id = revision.getID(); - int version = revision.getVersion(); - if (TRACER.isEnabled()) - { - TRACER.format("Writing ID and version: {0}v{1}", id, version); //$NON-NLS-1$ - } - - out.writeCDOID(id); - out.writeInt(version); - } - } - - @Override - protected List<InternalCDORevision> confirming(CDODataInput in) throws IOException - { - ArrayList<InternalCDORevision> result = new ArrayList<InternalCDORevision>(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading {0} timeStamps", revisions.size()); //$NON-NLS-1$ - } - - for (InternalCDORevision revision : revisions) - { - long revised = in.readLong(); - if (TRACER.isEnabled()) - { - TRACER.format("Reading timeStamp: {0}", revised); //$NON-NLS-1$ - } - - if (revised != CDORevision.UNSPECIFIED_DATE) - { - revision.setRevised(revised); - result.add(revision); - } - } - - return result; - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ViewsChangedRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ViewsChangedRequest.java deleted file mode 100644 index 88d936b376..0000000000 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/net4j/protocol/ViewsChangedRequest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2004 - 2009 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.internal.cdo.net4j.protocol; - -import org.eclipse.emf.cdo.common.CDOCommonView; -import org.eclipse.emf.cdo.common.io.CDODataInput; -import org.eclipse.emf.cdo.common.io.CDODataOutput; -import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; - -import java.io.IOException; - -/** - * @author Eike Stepper - */ -public class ViewsChangedRequest extends CDOClientRequest<Boolean> -{ - private int viewID; - - private byte kind; - - private long timeStamp; - - public ViewsChangedRequest(CDOClientProtocol protocol, int viewID, byte kind, long timeStamp) - { - super(protocol, CDOProtocolConstants.SIGNAL_VIEWS_CHANGED); - this.viewID = viewID; - this.kind = kind; - this.timeStamp = timeStamp; - } - - public ViewsChangedRequest(CDOClientProtocol protocol, int viewID) - { - this(protocol, viewID, CDOProtocolConstants.VIEW_CLOSED, CDOCommonView.UNSPECIFIED_DATE); - } - - @Override - protected void requesting(CDODataOutput out) throws IOException - { - out.writeInt(viewID); - out.writeByte(kind); - if (kind == CDOProtocolConstants.VIEW_AUDIT) - { - out.writeLong(timeStamp); - } - } - - @Override - protected Boolean confirming(CDODataInput in) throws IOException - { - return in.readBoolean(); - } -} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java index e6a957feaa..924b49aa19 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java @@ -34,7 +34,7 @@ public class CDOSingleTransactionStrategyImpl implements CDOTransactionStrategy { public static final CDOSingleTransactionStrategyImpl INSTANCE = new CDOSingleTransactionStrategyImpl(); - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSCTION, + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSACTION, CDOSingleTransactionStrategyImpl.class); public CDOSingleTransactionStrategyImpl() diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java index 1d3171e954..538e32fe0f 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java @@ -90,7 +90,7 @@ import java.util.concurrent.locks.ReentrantLock; */ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransaction { - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSCTION, CDOTransactionImpl.class); + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TRANSACTION, CDOTransactionImpl.class); /** * TODO Optimize by storing an array. See {@link Notifier}. diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOAuditImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOAuditImpl.java index 397ed699a4..6431d60ba3 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOAuditImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOAuditImpl.java @@ -17,6 +17,9 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.view.CDOAudit; import org.eclipse.emf.internal.cdo.CDOStateMachine; +import org.eclipse.emf.internal.cdo.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.emf.spi.cdo.InternalCDOObject; import org.eclipse.emf.spi.cdo.InternalCDOSession; @@ -29,6 +32,8 @@ import java.util.List; */ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit { + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_AUDIT, CDOAuditImpl.class); + private long timeStamp; /** @@ -62,6 +67,10 @@ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit List<InternalCDOObject> invalidObjects = getInvalidObjects(timeStamp); boolean[] existanceFlags = getSession().getSessionProtocol().setAudit(getViewID(), timeStamp, invalidObjects); this.timeStamp = timeStamp; + if (TRACER.isEnabled()) + { + TRACER.format("Changed audit time: {0,date} {0,time}", timeStamp); + } int i = 0; for (InternalCDOObject invalidObject : invalidObjects) |