diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.net4j')
59 files changed, 4069 insertions, 4069 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.server.net4j/.settings/.api_filters index a491d67f25..64694f0c60 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/.settings/.api_filters +++ b/plugins/org.eclipse.emf.cdo.server.net4j/.settings/.api_filters @@ -1,19 +1,19 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<component id="org.eclipse.emf.cdo.server.net4j" version="2">
- <resource path="src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java" type="org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerProtocol">
- <filter id="574619656">
- <message_arguments>
- <message_argument value="ISessionProtocol"/>
- <message_argument value="CDOServerProtocol"/>
- </message_arguments>
- </filter>
- </resource>
- <resource path="src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java" type="org.eclipse.emf.cdo.server.internal.net4j.protocol.ReplicateRepositoryIndication">
- <filter id="574619656">
- <message_arguments>
- <message_argument value="CDOReplicationContext"/>
- <message_argument value="ReplicateRepositoryIndication"/>
- </message_arguments>
- </filter>
- </resource>
-</component>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<component id="org.eclipse.emf.cdo.server.net4j" version="2"> + <resource path="src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java" type="org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerProtocol"> + <filter id="574619656"> + <message_arguments> + <message_argument value="ISessionProtocol"/> + <message_argument value="CDOServerProtocol"/> + </message_arguments> + </filter> + </resource> + <resource path="src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryIndication.java" type="org.eclipse.emf.cdo.server.internal.net4j.protocol.ReplicateRepositoryIndication"> + <filter id="574619656"> + <message_arguments> + <message_argument value="CDOReplicationContext"/> + <message_argument value="ReplicateRepositoryIndication"/> + </message_arguments> + </filter> + </resource> +</component> diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.core.resources.prefs index efd833fbf9..313329940e 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.core.resources.prefs +++ b/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,3 @@ -#Mon Jul 04 12:52:06 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 12:52:06 CEST 2011 +eclipse.preferences.version=1 +encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8 diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.jdt.launching.prefs b/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.jdt.launching.prefs index 4658ec1435..556ed07a3c 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.jdt.launching.prefs +++ b/plugins/org.eclipse.emf.cdo.server.net4j/.settings/org.eclipse.jdt.launching.prefs @@ -1,3 +1,3 @@ -#Fri Sep 02 05:38:34 CEST 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore
+#Fri Sep 02 05:38:34 CEST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/copyright.txt b/plugins/org.eclipse.emf.cdo.server.net4j/copyright.txt index 8f6328980e..0a0f67e6d7 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/copyright.txt +++ b/plugins/org.eclipse.emf.cdo.server.net4j/copyright.txt @@ -1,8 +1,8 @@ -Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html + +Contributors: Eike Stepper - initial API and implementation
\ No newline at end of file diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/plugin.properties b/plugins/org.eclipse.emf.cdo.server.net4j/plugin.properties index ea55da395e..3c28fbf1d0 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.server.net4j/plugin.properties @@ -1,17 +1,17 @@ -# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-pluginName = CDO Model Repository Server Net4j Support
-providerName = Eclipse Modeling Project
-
-extension.name = CDOServer
-product.description = A CDO repository server
-product.name = CDO Server
-extension-point.name = CDO Store Factories
-extension-point.name.0 = CDO Repository Factories
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Eike Stepper - initial API and implementation + +pluginName = CDO Model Repository Server Net4j Support +providerName = Eclipse Modeling Project + +extension.name = CDOServer +product.description = A CDO repository server +product.name = CDO Server +extension-point.name = CDO Store Factories +extension-point.name.0 = CDO Repository Factories diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/plugin.xml b/plugins/org.eclipse.emf.cdo.server.net4j/plugin.xml index 1a9e89644d..a6c5277cc9 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.server.net4j/plugin.xml @@ -1,43 +1,43 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<!--
- Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
- Eike Stepper - initial API and implementation
--->
-
-<plugin>
-
- <extension
- point="org.eclipse.net4j.util.factories">
- <factory
- productGroup="org.eclipse.net4j.serverProtocols"
- type="cdo"
- class="org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOPluginProtocolFactory"/>
- <factory
- productGroup="org.eclipse.net4j.serverProtocols"
- type="failover"
- class="org.eclipse.emf.cdo.server.net4j.FailoverMonitor$AgentProtocol$Factory"/>
- <factory
- productGroup="org.eclipse.net4j.serverProtocols"
- type="failover-client"
- class="org.eclipse.emf.cdo.server.net4j.FailoverMonitor$ClientProtocol$Factory"/>
- <factory
- productGroup="org.eclipse.emf.cdo.server.net4j.failoverMonitors"
- type="net4j"
- class="org.eclipse.emf.cdo.server.net4j.FailoverMonitor$Factory"/>
- </extension>
-
- <extension
- point="org.eclipse.emf.cdo.server.appExtensions">
- <appExtension
- class="org.eclipse.emf.cdo.server.internal.net4j.bundle.Net4jAppExtension">
- </appExtension>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<!-- + Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + Eike Stepper - initial API and implementation +--> + +<plugin> + + <extension + point="org.eclipse.net4j.util.factories"> + <factory + productGroup="org.eclipse.net4j.serverProtocols" + type="cdo" + class="org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOPluginProtocolFactory"/> + <factory + productGroup="org.eclipse.net4j.serverProtocols" + type="failover" + class="org.eclipse.emf.cdo.server.net4j.FailoverMonitor$AgentProtocol$Factory"/> + <factory + productGroup="org.eclipse.net4j.serverProtocols" + type="failover-client" + class="org.eclipse.emf.cdo.server.net4j.FailoverMonitor$ClientProtocol$Factory"/> + <factory + productGroup="org.eclipse.emf.cdo.server.net4j.failoverMonitors" + type="net4j" + class="org.eclipse.emf.cdo.server.net4j.FailoverMonitor$Factory"/> + </extension> + + <extension + point="org.eclipse.emf.cdo.server.appExtensions"> + <appExtension + class="org.eclipse.emf.cdo.server.internal.net4j.bundle.Net4jAppExtension"> + </appExtension> + </extension> + +</plugin> diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java index 9179d1f009..1233a447d1 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/bundle/OM.java @@ -1,48 +1,48 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.server.net4j"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * The <em>Operations & Maintenance</em> class of this bundle. + * + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo.server.net4j"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + /** + * @author Eike Stepper + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/BranchNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/BranchNotificationRequest.java index 87867861cb..e0b87228fc 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/BranchNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/BranchNotificationRequest.java @@ -1,39 +1,39 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class BranchNotificationRequest extends CDOServerRequest
-{
- private CDOBranch branch;
-
- public BranchNotificationRequest(CDOServerProtocol serverProtocol, CDOBranch branch)
- {
- super(serverProtocol, CDOProtocolConstants.SIGNAL_BRANCH_NOTIFICATION);
- this.branch = branch;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeCDOBranch(branch);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class BranchNotificationRequest extends CDOServerRequest +{ + private CDOBranch branch; + + public BranchNotificationRequest(CDOServerProtocol serverProtocol, CDOBranch branch) + { + super(serverProtocol, CDOProtocolConstants.SIGNAL_BRANCH_NOTIFICATION); + this.branch = branch; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeCDOBranch(branch); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOPluginProtocolFactory.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOPluginProtocolFactory.java index f622826bbd..9961036ffc 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOPluginProtocolFactory.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOPluginProtocolFactory.java @@ -1,24 +1,24 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.spi.server.PluginRepositoryProvider;
-
-/**
- * @author Eike Stepper
- */
-public final class CDOPluginProtocolFactory extends CDOServerProtocolFactory
-{
- public CDOPluginProtocolFactory()
- {
- super(PluginRepositoryProvider.INSTANCE);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.spi.server.PluginRepositoryProvider; + +/** + * @author Eike Stepper + */ +public final class CDOPluginProtocolFactory extends CDOServerProtocolFactory +{ + public CDOPluginProtocolFactory() + { + super(PluginRepositoryProvider.INSTANCE); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerIndicationWithMonitoring.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerIndicationWithMonitoring.java index a4147c9e89..4793c186f1 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerIndicationWithMonitoring.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerIndicationWithMonitoring.java @@ -1,199 +1,199 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 213402
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.lob.CDOLobStore;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
-import org.eclipse.emf.cdo.internal.common.revision.CDOListImpl;
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.signal.IndicationWithMonitoring;
-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.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOServerIndicationWithMonitoring extends IndicationWithMonitoring
-{
- private ExtendedDataInputStream indicationStream;
-
- private ExtendedDataOutputStream responseStream;
-
- protected CDOServerIndicationWithMonitoring(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- public CDOServerProtocol getProtocol()
- {
- return (CDOServerProtocol)super.getProtocol();
- }
-
- protected ExtendedDataInputStream getIndicationStream()
- {
- return indicationStream;
- }
-
- protected ExtendedDataOutputStream getResponseStream()
- {
- return responseStream;
- }
-
- protected InternalSession getSession()
- {
- return getProtocol().getSession();
- }
-
- protected InternalCDOPackageRegistry getPackageRegistry()
- {
- return getRepository().getPackageRegistry(false);
- }
-
- protected InternalRepository getRepository()
- {
- InternalRepository repository = getSession().getManager().getRepository();
- if (!LifecycleUtil.isActive(repository))
- {
- throw new IllegalStateException("CDORepositoryInfo has been deactivated"); //$NON-NLS-1$
- }
-
- return repository;
- }
-
- protected IStore getStore()
- {
- IStore store = getRepository().getStore();
- if (!LifecycleUtil.isActive(store))
- {
- throw new IllegalStateException("Store has been deactivated"); //$NON-NLS-1$
- }
-
- return store;
- }
-
- @Override
- protected final void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception
- {
- indicationStream = in;
-
- try
- {
- indicating(new CDODataInputImpl(in)
- {
- @Override
- protected CDOPackageRegistry getPackageRegistry()
- {
- return CDOServerIndicationWithMonitoring.this.getPackageRegistry();
- }
-
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
-
- @Override
- protected CDOBranchManager getBranchManager()
- {
- return CDOServerIndicationWithMonitoring.this.getRepository().getBranchManager();
- }
-
- @Override
- protected CDOCommitInfoManager getCommitInfoManager()
- {
- return CDOServerIndicationWithMonitoring.this.getRepository().getCommitInfoManager();
- }
-
- @Override
- protected CDORevisionFactory getRevisionFactory()
- {
- return CDOServerIndicationWithMonitoring.this.getRepository().getRevisionManager().getFactory();
- }
-
- @Override
- protected CDOLobStore getLobStore()
- {
- return null; // Not used on server
- }
-
- @Override
- protected CDOListFactory getListFactory()
- {
- return CDOListImpl.FACTORY;
- }
- }, monitor);
- }
- catch (Exception ex)
- {
- indicatingFailed();
- throw ex;
- }
- catch (Error ex)
- {
- indicatingFailed();
- throw ex;
- }
- }
-
- @Override
- protected final void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception
- {
- responseStream = out;
- responding(new CDODataOutputImpl(out)
- {
- @Override
- public CDOPackageRegistry getPackageRegistry()
- {
- return CDOServerIndicationWithMonitoring.this.getPackageRegistry();
- }
-
- @Override
- public CDOIDProvider getIDProvider()
- {
- return CDOServerIndicationWithMonitoring.this.getSession();
- }
-
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
- }, monitor);
- }
-
- protected void indicatingFailed()
- {
- }
-
- protected abstract void indicating(CDODataInput in, OMMonitor monitor) throws Exception;
-
- protected abstract void responding(CDODataOutput out, OMMonitor monitor) throws Exception;
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 213402 + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchManager; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.lob.CDOLobStore; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDOListFactory; +import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl; +import org.eclipse.emf.cdo.internal.common.revision.CDOListImpl; +import org.eclipse.emf.cdo.server.IStore; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; +import org.eclipse.emf.cdo.spi.server.InternalRepository; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.signal.IndicationWithMonitoring; +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.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +/** + * @author Eike Stepper + */ +public abstract class CDOServerIndicationWithMonitoring extends IndicationWithMonitoring +{ + private ExtendedDataInputStream indicationStream; + + private ExtendedDataOutputStream responseStream; + + protected CDOServerIndicationWithMonitoring(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + public CDOServerProtocol getProtocol() + { + return (CDOServerProtocol)super.getProtocol(); + } + + protected ExtendedDataInputStream getIndicationStream() + { + return indicationStream; + } + + protected ExtendedDataOutputStream getResponseStream() + { + return responseStream; + } + + protected InternalSession getSession() + { + return getProtocol().getSession(); + } + + protected InternalCDOPackageRegistry getPackageRegistry() + { + return getRepository().getPackageRegistry(false); + } + + protected InternalRepository getRepository() + { + InternalRepository repository = getSession().getManager().getRepository(); + if (!LifecycleUtil.isActive(repository)) + { + throw new IllegalStateException("CDORepositoryInfo has been deactivated"); //$NON-NLS-1$ + } + + return repository; + } + + protected IStore getStore() + { + IStore store = getRepository().getStore(); + if (!LifecycleUtil.isActive(store)) + { + throw new IllegalStateException("Store has been deactivated"); //$NON-NLS-1$ + } + + return store; + } + + @Override + protected final void indicating(ExtendedDataInputStream in, OMMonitor monitor) throws Exception + { + indicationStream = in; + + try + { + indicating(new CDODataInputImpl(in) + { + @Override + protected CDOPackageRegistry getPackageRegistry() + { + return CDOServerIndicationWithMonitoring.this.getPackageRegistry(); + } + + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + + @Override + protected CDOBranchManager getBranchManager() + { + return CDOServerIndicationWithMonitoring.this.getRepository().getBranchManager(); + } + + @Override + protected CDOCommitInfoManager getCommitInfoManager() + { + return CDOServerIndicationWithMonitoring.this.getRepository().getCommitInfoManager(); + } + + @Override + protected CDORevisionFactory getRevisionFactory() + { + return CDOServerIndicationWithMonitoring.this.getRepository().getRevisionManager().getFactory(); + } + + @Override + protected CDOLobStore getLobStore() + { + return null; // Not used on server + } + + @Override + protected CDOListFactory getListFactory() + { + return CDOListImpl.FACTORY; + } + }, monitor); + } + catch (Exception ex) + { + indicatingFailed(); + throw ex; + } + catch (Error ex) + { + indicatingFailed(); + throw ex; + } + } + + @Override + protected final void responding(ExtendedDataOutputStream out, OMMonitor monitor) throws Exception + { + responseStream = out; + responding(new CDODataOutputImpl(out) + { + @Override + public CDOPackageRegistry getPackageRegistry() + { + return CDOServerIndicationWithMonitoring.this.getPackageRegistry(); + } + + @Override + public CDOIDProvider getIDProvider() + { + return CDOServerIndicationWithMonitoring.this.getSession(); + } + + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + }, monitor); + } + + protected void indicatingFailed() + { + } + + protected abstract void indicating(CDODataInput in, OMMonitor monitor) throws Exception; + + protected abstract void responding(CDODataOutput out, OMMonitor monitor) throws Exception; +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java index 4120bf5680..93472dfad4 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocol.java @@ -1,330 +1,330 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 233273
- * Simon McDuff - bug 230832
- * Simon McDuff - bug 233490
- * Simon McDuff - bug 213402
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IRepositoryProvider;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.server.ISessionProtocol;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.io.StringCompressor;
-import org.eclipse.net4j.util.io.StringIO;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-/**
- * @author Eike Stepper
- */
-public class CDOServerProtocol extends SignalProtocol<InternalSession> implements ISessionProtocol
-{
- public static final long DEFAULT_NEGOTIATION_TIMEOUT = 15 * 1000;
-
- private long negotiationTimeout = DEFAULT_NEGOTIATION_TIMEOUT;
-
- private IRepositoryProvider repositoryProvider;
-
- private StringIO packageURICompressor = StringCompressor.BYPASS ? StringIO.DIRECT : new StringCompressor(false);
-
- public CDOServerProtocol(IRepositoryProvider repositoryProvider)
- {
- super(CDOProtocolConstants.PROTOCOL_NAME);
- this.repositoryProvider = repositoryProvider;
- }
-
- public InternalSession getSession()
- {
- return getInfraStructure();
- }
-
- public IRepositoryProvider getRepositoryProvider()
- {
- return repositoryProvider;
- }
-
- public StringIO getPackageURICompressor()
- {
- return packageURICompressor;
- }
-
- public long getNegotiationTimeout()
- {
- return negotiationTimeout;
- }
-
- public void setNegotiationTimeout(long negotiationTimeout)
- {
- this.negotiationTimeout = negotiationTimeout;
- }
-
- public CDOAuthenticationResult sendAuthenticationChallenge(byte[] randomToken) throws Exception
- {
- return new AuthenticationRequest(this, randomToken).send(negotiationTimeout);
- }
-
- public void sendRepositoryTypeNotification(CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType)
- throws Exception
- {
- if (LifecycleUtil.isActive(getChannel()))
- {
- new RepositoryTypeNotificationRequest(this, oldType, newType).sendAsync();
- }
- else
- {
- handleInactiveSession();
- }
- }
-
- @Deprecated
- public void sendRepositoryStateNotification(CDOCommonRepository.State oldState, CDOCommonRepository.State newState)
- throws Exception
- {
- sendRepositoryStateNotification(oldState, newState, null);
- }
-
- public void sendRepositoryStateNotification(CDOCommonRepository.State oldState, CDOCommonRepository.State newState,
- CDOID rootResourceID) throws Exception
- {
- if (LifecycleUtil.isActive(getChannel()))
- {
- new RepositoryStateNotificationRequest(this, oldState, newState, rootResourceID).sendAsync();
- }
- else
- {
- handleInactiveSession();
- }
- }
-
- public void sendBranchNotification(InternalCDOBranch branch) throws Exception
- {
- if (LifecycleUtil.isActive(getChannel()))
- {
- new BranchNotificationRequest(this, branch).sendAsync();
- }
- else
- {
- handleInactiveSession();
- }
- }
-
- public void sendCommitNotification(CDOCommitInfo commitInfo) throws Exception
- {
- if (LifecycleUtil.isActive(getChannel()))
- {
- new CommitNotificationRequest(this, commitInfo).sendAsync();
- }
- else
- {
- handleInactiveSession();
- }
- }
-
- public void sendRemoteSessionNotification(InternalSession sender, byte opcode) throws Exception
- {
- if (LifecycleUtil.isActive(getChannel()))
- {
- new RemoteSessionNotificationRequest(this, sender, opcode).sendAsync();
- }
- else
- {
- handleInactiveSession();
- }
- }
-
- public void sendRemoteMessageNotification(InternalSession sender, CDORemoteSessionMessage message) throws Exception
- {
- if (LifecycleUtil.isActive(getChannel()))
- {
- new RemoteMessageNotificationRequest(this, sender, message).sendAsync();
- }
- else
- {
- handleInactiveSession();
- }
- }
-
- public void sendLockNotification(CDOLockChangeInfo lockChangeInfo) throws Exception
- {
- if (LifecycleUtil.isActive(getChannel()))
- {
- new LockNotificationRequest(this, lockChangeInfo).sendAsync();
- }
- else
- {
- handleInactiveSession();
- }
- }
-
- protected void handleInactiveSession()
- {
- OM.LOG.warn("Session channel is inactive: " + this); //$NON-NLS-1$
- }
-
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case CDOProtocolConstants.SIGNAL_OPEN_SESSION:
- return new OpenSessionIndication(this);
-
- case CDOProtocolConstants.SIGNAL_OPEN_VIEW:
- return new OpenViewIndication(this);
-
- case CDOProtocolConstants.SIGNAL_SWITCH_TARGET:
- return new SwitchTargetIndication(this);
-
- case CDOProtocolConstants.SIGNAL_CLOSE_VIEW:
- return new CloseViewIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_PACKAGES:
- return new LoadPackagesIndication(this);
-
- case CDOProtocolConstants.SIGNAL_CREATE_BRANCH:
- return new CreateBranchIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_BRANCH:
- return new LoadBranchIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_SUB_BRANCHES:
- return new LoadSubBranchesIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_BRANCHES:
- return new LoadBranchesIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_REVISIONS:
- return new LoadRevisionsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_VERSION:
- return new LoadRevisionByVersionIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_CHUNK:
- return new LoadChunkIndication(this);
-
- case CDOProtocolConstants.SIGNAL_QUERY_LOBS:
- return new QueryLobsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_LOB:
- return new LoadLobIndication(this);
-
- case CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION:
- return new CommitTransactionIndication(this);
-
- case CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION:
- return new CommitDelegationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE1:
- return new CommitXATransactionPhase1Indication(this);
-
- case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE2:
- return new CommitXATransactionPhase2Indication(this);
-
- case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE3:
- return new CommitXATransactionPhase3Indication(this);
-
- case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_CANCEL:
- return new CommitXATransactionCancelIndication(this);
-
- case CDOProtocolConstants.SIGNAL_QUERY:
- return new QueryIndication(this);
-
- case CDOProtocolConstants.SIGNAL_QUERY_CANCEL:
- return new QueryCancelIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REFRESH_SESSION:
- return new RefreshSessionIndication(this);
-
- case CDOProtocolConstants.SIGNAL_DISABLE_PASSIVE_UPDATE:
- return new DisablePassiveUpdateIndication(this);
-
- case CDOProtocolConstants.SIGNAL_SET_PASSIVE_UPDATE_MODE:
- return new SetPassiveUpdateModeIndication(this);
-
- case CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION:
- return new ChangeSubscriptionIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REPOSITORY_TIME:
- return new RepositoryTimeIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOCK_OBJECTS:
- return new LockObjectsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS:
- return new UnlockObjectsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOCK_DELEGATION:
- return new LockDelegationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_UNLOCK_DELEGATION:
- return new UnlockDelegationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_OBJECT_LOCKED:
- return new ObjectLockedIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOCK_AREA:
- return new LockAreaIndication(this);
-
- case CDOProtocolConstants.SIGNAL_GET_REMOTE_SESSIONS:
- return new GetRemoteSessionsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS:
- return new UnsubscribeRemoteSessionsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE:
- return new RemoteMessageIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_COMMIT_INFOS:
- return new LoadCommitInfosIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_COMMIT_DATA:
- return new LoadCommitDataIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY:
- return new ReplicateRepositoryIndication(this);
-
- case CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY_RAW:
- return new ReplicateRepositoryRawIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_CHANGE_SETS:
- return new LoadChangeSetsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOAD_MERGE_DATA:
- return new LoadMergeDataIndication(this);
-
- case CDOProtocolConstants.SIGNAL_HANDLE_REVISIONS:
- return new HandleRevisionsIndication(this);
-
- case CDOProtocolConstants.SIGNAL_LOCK_STATE:
- return new LockStateIndication(this);
-
- case CDOProtocolConstants.SIGNAL_ENABLE_LOCK_NOTIFICATION:
- return new EnableLockNotificationIndication(this);
-
- case CDOProtocolConstants.SIGNAL_SET_LOCK_NOTIFICATION_MODE:
- return new SetLockNotificationModeIndication(this);
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 233273 + * Simon McDuff - bug 230832 + * Simon McDuff - bug 233490 + * Simon McDuff - bug 213402 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonRepository; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IRepositoryProvider; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; +import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.server.ISessionProtocol; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.signal.SignalReactor; +import org.eclipse.net4j.util.io.StringCompressor; +import org.eclipse.net4j.util.io.StringIO; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; + +/** + * @author Eike Stepper + */ +public class CDOServerProtocol extends SignalProtocol<InternalSession> implements ISessionProtocol +{ + public static final long DEFAULT_NEGOTIATION_TIMEOUT = 15 * 1000; + + private long negotiationTimeout = DEFAULT_NEGOTIATION_TIMEOUT; + + private IRepositoryProvider repositoryProvider; + + private StringIO packageURICompressor = StringCompressor.BYPASS ? StringIO.DIRECT : new StringCompressor(false); + + public CDOServerProtocol(IRepositoryProvider repositoryProvider) + { + super(CDOProtocolConstants.PROTOCOL_NAME); + this.repositoryProvider = repositoryProvider; + } + + public InternalSession getSession() + { + return getInfraStructure(); + } + + public IRepositoryProvider getRepositoryProvider() + { + return repositoryProvider; + } + + public StringIO getPackageURICompressor() + { + return packageURICompressor; + } + + public long getNegotiationTimeout() + { + return negotiationTimeout; + } + + public void setNegotiationTimeout(long negotiationTimeout) + { + this.negotiationTimeout = negotiationTimeout; + } + + public CDOAuthenticationResult sendAuthenticationChallenge(byte[] randomToken) throws Exception + { + return new AuthenticationRequest(this, randomToken).send(negotiationTimeout); + } + + public void sendRepositoryTypeNotification(CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType) + throws Exception + { + if (LifecycleUtil.isActive(getChannel())) + { + new RepositoryTypeNotificationRequest(this, oldType, newType).sendAsync(); + } + else + { + handleInactiveSession(); + } + } + + @Deprecated + public void sendRepositoryStateNotification(CDOCommonRepository.State oldState, CDOCommonRepository.State newState) + throws Exception + { + sendRepositoryStateNotification(oldState, newState, null); + } + + public void sendRepositoryStateNotification(CDOCommonRepository.State oldState, CDOCommonRepository.State newState, + CDOID rootResourceID) throws Exception + { + if (LifecycleUtil.isActive(getChannel())) + { + new RepositoryStateNotificationRequest(this, oldState, newState, rootResourceID).sendAsync(); + } + else + { + handleInactiveSession(); + } + } + + public void sendBranchNotification(InternalCDOBranch branch) throws Exception + { + if (LifecycleUtil.isActive(getChannel())) + { + new BranchNotificationRequest(this, branch).sendAsync(); + } + else + { + handleInactiveSession(); + } + } + + public void sendCommitNotification(CDOCommitInfo commitInfo) throws Exception + { + if (LifecycleUtil.isActive(getChannel())) + { + new CommitNotificationRequest(this, commitInfo).sendAsync(); + } + else + { + handleInactiveSession(); + } + } + + public void sendRemoteSessionNotification(InternalSession sender, byte opcode) throws Exception + { + if (LifecycleUtil.isActive(getChannel())) + { + new RemoteSessionNotificationRequest(this, sender, opcode).sendAsync(); + } + else + { + handleInactiveSession(); + } + } + + public void sendRemoteMessageNotification(InternalSession sender, CDORemoteSessionMessage message) throws Exception + { + if (LifecycleUtil.isActive(getChannel())) + { + new RemoteMessageNotificationRequest(this, sender, message).sendAsync(); + } + else + { + handleInactiveSession(); + } + } + + public void sendLockNotification(CDOLockChangeInfo lockChangeInfo) throws Exception + { + if (LifecycleUtil.isActive(getChannel())) + { + new LockNotificationRequest(this, lockChangeInfo).sendAsync(); + } + else + { + handleInactiveSession(); + } + } + + protected void handleInactiveSession() + { + OM.LOG.warn("Session channel is inactive: " + this); //$NON-NLS-1$ + } + + @Override + protected SignalReactor createSignalReactor(short signalID) + { + switch (signalID) + { + case CDOProtocolConstants.SIGNAL_OPEN_SESSION: + return new OpenSessionIndication(this); + + case CDOProtocolConstants.SIGNAL_OPEN_VIEW: + return new OpenViewIndication(this); + + case CDOProtocolConstants.SIGNAL_SWITCH_TARGET: + return new SwitchTargetIndication(this); + + case CDOProtocolConstants.SIGNAL_CLOSE_VIEW: + return new CloseViewIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_PACKAGES: + return new LoadPackagesIndication(this); + + case CDOProtocolConstants.SIGNAL_CREATE_BRANCH: + return new CreateBranchIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_BRANCH: + return new LoadBranchIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_SUB_BRANCHES: + return new LoadSubBranchesIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_BRANCHES: + return new LoadBranchesIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_REVISIONS: + return new LoadRevisionsIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_REVISION_BY_VERSION: + return new LoadRevisionByVersionIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_CHUNK: + return new LoadChunkIndication(this); + + case CDOProtocolConstants.SIGNAL_QUERY_LOBS: + return new QueryLobsIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_LOB: + return new LoadLobIndication(this); + + case CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION: + return new CommitTransactionIndication(this); + + case CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION: + return new CommitDelegationIndication(this); + + case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE1: + return new CommitXATransactionPhase1Indication(this); + + case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE2: + return new CommitXATransactionPhase2Indication(this); + + case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE3: + return new CommitXATransactionPhase3Indication(this); + + case CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_CANCEL: + return new CommitXATransactionCancelIndication(this); + + case CDOProtocolConstants.SIGNAL_QUERY: + return new QueryIndication(this); + + case CDOProtocolConstants.SIGNAL_QUERY_CANCEL: + return new QueryCancelIndication(this); + + case CDOProtocolConstants.SIGNAL_REFRESH_SESSION: + return new RefreshSessionIndication(this); + + case CDOProtocolConstants.SIGNAL_DISABLE_PASSIVE_UPDATE: + return new DisablePassiveUpdateIndication(this); + + case CDOProtocolConstants.SIGNAL_SET_PASSIVE_UPDATE_MODE: + return new SetPassiveUpdateModeIndication(this); + + case CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION: + return new ChangeSubscriptionIndication(this); + + case CDOProtocolConstants.SIGNAL_REPOSITORY_TIME: + return new RepositoryTimeIndication(this); + + case CDOProtocolConstants.SIGNAL_LOCK_OBJECTS: + return new LockObjectsIndication(this); + + case CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS: + return new UnlockObjectsIndication(this); + + case CDOProtocolConstants.SIGNAL_LOCK_DELEGATION: + return new LockDelegationIndication(this); + + case CDOProtocolConstants.SIGNAL_UNLOCK_DELEGATION: + return new UnlockDelegationIndication(this); + + case CDOProtocolConstants.SIGNAL_OBJECT_LOCKED: + return new ObjectLockedIndication(this); + + case CDOProtocolConstants.SIGNAL_LOCK_AREA: + return new LockAreaIndication(this); + + case CDOProtocolConstants.SIGNAL_GET_REMOTE_SESSIONS: + return new GetRemoteSessionsIndication(this); + + case CDOProtocolConstants.SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS: + return new UnsubscribeRemoteSessionsIndication(this); + + case CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE: + return new RemoteMessageIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_COMMIT_INFOS: + return new LoadCommitInfosIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_COMMIT_DATA: + return new LoadCommitDataIndication(this); + + case CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY: + return new ReplicateRepositoryIndication(this); + + case CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY_RAW: + return new ReplicateRepositoryRawIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_CHANGE_SETS: + return new LoadChangeSetsIndication(this); + + case CDOProtocolConstants.SIGNAL_LOAD_MERGE_DATA: + return new LoadMergeDataIndication(this); + + case CDOProtocolConstants.SIGNAL_HANDLE_REVISIONS: + return new HandleRevisionsIndication(this); + + case CDOProtocolConstants.SIGNAL_LOCK_STATE: + return new LockStateIndication(this); + + case CDOProtocolConstants.SIGNAL_ENABLE_LOCK_NOTIFICATION: + return new EnableLockNotificationIndication(this); + + case CDOProtocolConstants.SIGNAL_SET_LOCK_NOTIFICATION_MODE: + return new SetLockNotificationModeIndication(this); + + default: + return super.createSignalReactor(signalID); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocolFactory.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocolFactory.java index 9d69a94d56..87c3538efa 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocolFactory.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerProtocolFactory.java @@ -1,49 +1,49 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IRepositoryProvider;
-
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-import org.eclipse.spi.net4j.ServerProtocolFactory;
-
-/**
- * @author Eike Stepper
- */
-public class CDOServerProtocolFactory extends ServerProtocolFactory
-{
- public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME;
-
- private IRepositoryProvider repositoryProvider;
-
- public CDOServerProtocolFactory(IRepositoryProvider repositoryProvider)
- {
- super(TYPE);
- this.repositoryProvider = repositoryProvider;
- }
-
- public IRepositoryProvider getRepositoryProvider()
- {
- return repositoryProvider;
- }
-
- public CDOServerProtocol create(String description)
- {
- return new CDOServerProtocol(repositoryProvider);
- }
-
- public static CDOServerProtocol get(IManagedContainer container, String description)
- {
- return (CDOServerProtocol)container.getElement(PRODUCT_GROUP, TYPE, description);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IRepositoryProvider; + +import org.eclipse.net4j.util.container.IManagedContainer; + +import org.eclipse.spi.net4j.ServerProtocolFactory; + +/** + * @author Eike Stepper + */ +public class CDOServerProtocolFactory extends ServerProtocolFactory +{ + public static final String TYPE = CDOProtocolConstants.PROTOCOL_NAME; + + private IRepositoryProvider repositoryProvider; + + public CDOServerProtocolFactory(IRepositoryProvider repositoryProvider) + { + super(TYPE); + this.repositoryProvider = repositoryProvider; + } + + public IRepositoryProvider getRepositoryProvider() + { + return repositoryProvider; + } + + public CDOServerProtocol create(String description) + { + return new CDOServerProtocol(repositoryProvider); + } + + public static CDOServerProtocol get(IManagedContainer container, String description) + { + return (CDOServerProtocol)container.getElement(PRODUCT_GROUP, TYPE, description); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndication.java index c50bd31a24..ea97c76596 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndication.java @@ -1,43 +1,43 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.server.StoreThreadLocal;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.buffer.BufferInputStream;
-import org.eclipse.net4j.buffer.BufferOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOServerReadIndication extends CDOServerIndication
-{
- public CDOServerReadIndication(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
- {
- try
- {
- InternalSession session = getSession();
- StoreThreadLocal.setSession(session);
- super.execute(in, out);
- }
- finally
- {
- StoreThreadLocal.release();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.server.StoreThreadLocal; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.buffer.BufferInputStream; +import org.eclipse.net4j.buffer.BufferOutputStream; + +/** + * @author Eike Stepper + */ +public abstract class CDOServerReadIndication extends CDOServerIndication +{ + public CDOServerReadIndication(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception + { + try + { + InternalSession session = getSession(); + StoreThreadLocal.setSession(session); + super.execute(in, out); + } + finally + { + StoreThreadLocal.release(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndicationWithMonitoring.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndicationWithMonitoring.java index 5b436e71e2..3e67053fcd 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndicationWithMonitoring.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerReadIndicationWithMonitoring.java @@ -1,43 +1,43 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.server.StoreThreadLocal;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.buffer.BufferInputStream;
-import org.eclipse.net4j.buffer.BufferOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOServerReadIndicationWithMonitoring extends CDOServerIndicationWithMonitoring
-{
- protected CDOServerReadIndicationWithMonitoring(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
- {
- try
- {
- InternalSession session = getSession();
- StoreThreadLocal.setSession(session);
- super.execute(in, out);
- }
- finally
- {
- StoreThreadLocal.release();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.server.StoreThreadLocal; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.buffer.BufferInputStream; +import org.eclipse.net4j.buffer.BufferOutputStream; + +/** + * @author Eike Stepper + */ +public abstract class CDOServerReadIndicationWithMonitoring extends CDOServerIndicationWithMonitoring +{ + protected CDOServerReadIndicationWithMonitoring(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception + { + try + { + InternalSession session = getSession(); + StoreThreadLocal.setSession(session); + super.execute(in, out); + } + finally + { + StoreThreadLocal.release(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerRequest.java index eb1a0c9216..25b11a97a5 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerRequest.java @@ -1,72 +1,72 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.signal.Request;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.io.StringIO;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOServerRequest extends Request
-{
- public CDOServerRequest(CDOServerProtocol serverProtocol, short signalID)
- {
- super(serverProtocol, signalID);
- }
-
- @Override
- public CDOServerProtocol getProtocol()
- {
- return (CDOServerProtocol)super.getProtocol();
- }
-
- protected InternalSession getSession()
- {
- return getProtocol().getSession();
- }
-
- @Override
- protected final void requesting(ExtendedDataOutputStream out) throws Exception
- {
- requesting(new CDODataOutputImpl(out)
- {
- @Override
- public CDOPackageRegistry getPackageRegistry()
- {
- return getSession().getManager().getRepository().getPackageRegistry();
- }
-
- @Override
- protected StringIO getPackageURICompressor()
- {
- return getProtocol().getPackageURICompressor();
- }
-
- @Override
- public CDOIDProvider getIDProvider()
- {
- return getSession();
- }
- });
- }
-
- protected abstract void requesting(CDODataOutput out) throws IOException;
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.signal.Request; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; +import org.eclipse.net4j.util.io.StringIO; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public abstract class CDOServerRequest extends Request +{ + public CDOServerRequest(CDOServerProtocol serverProtocol, short signalID) + { + super(serverProtocol, signalID); + } + + @Override + public CDOServerProtocol getProtocol() + { + return (CDOServerProtocol)super.getProtocol(); + } + + protected InternalSession getSession() + { + return getProtocol().getSession(); + } + + @Override + protected final void requesting(ExtendedDataOutputStream out) throws Exception + { + requesting(new CDODataOutputImpl(out) + { + @Override + public CDOPackageRegistry getPackageRegistry() + { + return getSession().getManager().getRepository().getPackageRegistry(); + } + + @Override + protected StringIO getPackageURICompressor() + { + return getProtocol().getPackageURICompressor(); + } + + @Override + public CDOIDProvider getIDProvider() + { + return getSession(); + } + }); + } + + protected abstract void requesting(CDODataOutput out) throws IOException; +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerWriteIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerWriteIndication.java index a1e00e2f2e..7c315f7088 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerWriteIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CDOServerWriteIndication.java @@ -1,46 +1,46 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.server.IStoreAccessor;
-import org.eclipse.emf.cdo.server.StoreThreadLocal;
-
-import org.eclipse.net4j.buffer.BufferInputStream;
-import org.eclipse.net4j.buffer.BufferOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOServerWriteIndication extends CDOServerIndication
-{
- public CDOServerWriteIndication(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception
- {
- try
- {
- // Allocate a store writer
- IStoreAccessor accessor = getStore().getWriter(null);
-
- // Make the store writer available in a ThreadLocal variable
- StoreThreadLocal.setAccessor(accessor);
- super.execute(in, out);
- }
- finally
- {
- StoreThreadLocal.release();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.server.IStoreAccessor; +import org.eclipse.emf.cdo.server.StoreThreadLocal; + +import org.eclipse.net4j.buffer.BufferInputStream; +import org.eclipse.net4j.buffer.BufferOutputStream; + +/** + * @author Eike Stepper + */ +public abstract class CDOServerWriteIndication extends CDOServerIndication +{ + public CDOServerWriteIndication(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + protected void execute(BufferInputStream in, BufferOutputStream out) throws Exception + { + try + { + // Allocate a store writer + IStoreAccessor accessor = getStore().getWriter(null); + + // Make the store writer available in a ThreadLocal variable + StoreThreadLocal.setAccessor(accessor); + super.execute(in, out); + } + finally + { + StoreThreadLocal.release(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ChangeSubscriptionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ChangeSubscriptionIndication.java index 40bf3e2f0d..077a0b330c 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ChangeSubscriptionIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ChangeSubscriptionIndication.java @@ -1,81 +1,81 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class ChangeSubscriptionIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, ChangeSubscriptionIndication.class);
-
- public ChangeSubscriptionIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- boolean subscribeMode = true;
-
- int viewID = in.readInt();
- boolean clear = in.readBoolean();
- int size = in.readInt();
- if (size <= 0)
- {
- subscribeMode = false;
- size = -size;
- }
-
- InternalView view = getSession().getView(viewID);
- if (clear)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Clear subscription"); //$NON-NLS-1$
- }
-
- view.clearChangeSubscription();
- }
-
- for (int i = 0; i < size; i++)
- {
- CDOID id = in.readCDOID();
- if (subscribeMode)
- {
- view.subscribe(id);
- }
- else
- {
- view.unsubscribe(id);
- }
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(true);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class ChangeSubscriptionIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, ChangeSubscriptionIndication.class); + + public ChangeSubscriptionIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_CHANGE_SUBSCRIPTION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + boolean subscribeMode = true; + + int viewID = in.readInt(); + boolean clear = in.readBoolean(); + int size = in.readInt(); + if (size <= 0) + { + subscribeMode = false; + size = -size; + } + + InternalView view = getSession().getView(viewID); + if (clear) + { + if (TRACER.isEnabled()) + { + TRACER.trace("Clear subscription"); //$NON-NLS-1$ + } + + view.clearChangeSubscription(); + } + + for (int i = 0; i < size; i++) + { + CDOID id = in.readCDOID(); + if (subscribeMode) + { + view.subscribe(id); + } + else + { + view.unsubscribe(id); + } + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CloseViewIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CloseViewIndication.java index 433930aa8c..579ad64a2f 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CloseViewIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CloseViewIndication.java @@ -1,48 +1,48 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class CloseViewIndication extends CDOServerReadIndication
-{
- public CloseViewIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_CLOSE_VIEW);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int viewID = in.readInt();
- InternalSession session = getSession();
- IView view = session.getView(viewID);
- if (view != null)
- {
- view.close();
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(true);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class CloseViewIndication extends CDOServerReadIndication +{ + public CloseViewIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_CLOSE_VIEW); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int viewID = in.readInt(); + InternalSession session = getSession(); + IView view = session.getView(viewID); + if (view != null) + { + view.close(); + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitDelegationIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitDelegationIndication.java index 823b808430..6ec7c47511 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitDelegationIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitDelegationIndication.java @@ -1,73 +1,73 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 213402
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.server.TransactionCommitContext;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-import org.eclipse.emf.cdo.spi.server.InternalTransaction;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-/**
- * @author Eike Stepper
- */
-public class CommitDelegationIndication extends CommitTransactionIndication
-{
- private InternalTransaction transaction;
-
- public CommitDelegationIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION);
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
- {
- super.indicating(in, monitor);
- }
-
- @Override
- protected void initializeCommitContext(CDODataInput in) throws Exception
- {
- CDOBranch branch = in.readCDOBranch();
- transaction = getSession().openTransaction(InternalSession.TEMP_VIEW_ID, branch.getHead());
-
- final String userID = in.readString();
- commitContext = new TransactionCommitContext(transaction)
- {
- @Override
- public String getUserID()
- {
- return userID;
- }
- };
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- try
- {
- super.responding(out, monitor);
- }
- finally
- {
- transaction.close();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 213402 + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.server.TransactionCommitContext; +import org.eclipse.emf.cdo.spi.server.InternalSession; +import org.eclipse.emf.cdo.spi.server.InternalTransaction; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +/** + * @author Eike Stepper + */ +public class CommitDelegationIndication extends CommitTransactionIndication +{ + private InternalTransaction transaction; + + public CommitDelegationIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION); + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception + { + super.indicating(in, monitor); + } + + @Override + protected void initializeCommitContext(CDODataInput in) throws Exception + { + CDOBranch branch = in.readCDOBranch(); + transaction = getSession().openTransaction(InternalSession.TEMP_VIEW_ID, branch.getHead()); + + final String userID = in.readString(); + commitContext = new TransactionCommitContext(transaction) + { + @Override + public String getUserID() + { + return userID; + } + }; + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception + { + try + { + super.responding(out, monitor); + } + finally + { + transaction.close(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java index edf38a639a..2cbe2f1e48 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java @@ -1,362 +1,362 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 213402
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDReference;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
-import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
-import org.eclipse.emf.cdo.spi.server.InternalTransaction;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.ProgressDistributor;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author Eike Stepper
- */
-public class CommitTransactionIndication extends CDOServerIndicationWithMonitoring
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionIndication.class);
-
- protected InternalCommitContext commitContext;
-
- public CommitTransactionIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION);
- }
-
- protected CommitTransactionIndication(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- protected InternalCDOPackageRegistry getPackageRegistry()
- {
- return commitContext.getPackageRegistry();
- }
-
- @Override
- protected void indicatingFailed()
- {
- if (commitContext != null)
- {
- commitContext.postCommit(false);
- commitContext = null;
- }
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
- {
- try
- {
- monitor.begin(OMMonitor.TEN);
- indicatingCommit(in, monitor.fork(OMMonitor.ONE));
- indicatingCommit(monitor.fork(OMMonitor.TEN - OMMonitor.ONE));
- }
- catch (IOException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- throw WrappedException.wrap(ex);
- }
- finally
- {
- monitor.done();
- }
- }
-
- protected void indicatingCommit(CDODataInput in, OMMonitor monitor) throws Exception
- {
- // Create commit context
- initializeCommitContext(in);
- commitContext.preWrite();
-
- boolean autoReleaseLocksEnabled = in.readBoolean();
- commitContext.setAutoReleaseLocksEnabled(autoReleaseLocksEnabled);
- String commitComment = in.readString();
-
- InternalCDOPackageUnit[] newPackageUnits = new InternalCDOPackageUnit[in.readInt()];
- CDOLockState[] locksOnNewObjects = new CDOLockState[in.readInt()];
- InternalCDORevision[] newObjects = new InternalCDORevision[in.readInt()];
- InternalCDORevisionDelta[] dirtyObjectDeltas = new InternalCDORevisionDelta[in.readInt()];
- CDOID[] detachedObjects = new CDOID[in.readInt()];
- monitor.begin(newPackageUnits.length + newObjects.length + dirtyObjectDeltas.length + detachedObjects.length);
-
- try
- {
- // New package units
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} new package units", newPackageUnits.length); //$NON-NLS-1$
- }
-
- InternalCDOPackageRegistry packageRegistry = commitContext.getPackageRegistry();
- ResourceSet resourceSet = createResourceSet(packageRegistry);
- for (int i = 0; i < newPackageUnits.length; i++)
- {
- newPackageUnits[i] = (InternalCDOPackageUnit)in.readCDOPackageUnit(resourceSet);
- packageRegistry.putPackageUnit(newPackageUnits[i]); // Must happen before readCDORevision!!!
- monitor.worked();
- }
-
- // When all packages are deserialized and registered, resolve them
- // Note: EcoreUtil.resolveAll(resourceSet) does *not* do the trick
- EMFUtil.safeResolveAll(resourceSet);
-
- // Locks on new objects
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} locks on new objects", locksOnNewObjects.length); //$NON-NLS-1$
- }
-
- for (int i = 0; i < locksOnNewObjects.length; i++)
- {
- locksOnNewObjects[i] = in.readCDOLockState();
- monitor.worked();
- }
-
- // New objects
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} new objects", newObjects.length); //$NON-NLS-1$
- }
-
- for (int i = 0; i < newObjects.length; i++)
- {
- newObjects[i] = (InternalCDORevision)in.readCDORevision();
- monitor.worked();
- }
-
- // Make the assignment of permanent IDs predictable
- Arrays.sort(newObjects, new Comparator<InternalCDORevision>()
- {
- public int compare(InternalCDORevision r1, InternalCDORevision r2)
- {
- return r1.getID().compareTo(r2.getID());
- }
- });
-
- // Dirty objects
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} dirty object deltas", dirtyObjectDeltas.length); //$NON-NLS-1$
- }
-
- for (int i = 0; i < dirtyObjectDeltas.length; i++)
- {
- dirtyObjectDeltas[i] = (InternalCDORevisionDelta)in.readCDORevisionDelta();
- monitor.worked();
- }
-
- Map<CDOID, EClass> detachedObjectTypes = null;
- if (getRepository().isEnsuringReferentialIntegrity())
- {
- detachedObjectTypes = new HashMap<CDOID, EClass>();
- }
-
- for (int i = 0; i < detachedObjects.length; i++)
- {
- CDOID id = in.readCDOID();
- detachedObjects[i] = id;
-
- if (detachedObjectTypes != null)
- {
- EClass eClass = (EClass)in.readCDOClassifierRefAndResolve();
- detachedObjectTypes.put(id, eClass);
- }
-
- monitor.worked();
- }
-
- if (detachedObjectTypes != null && detachedObjectTypes.isEmpty())
- {
- detachedObjectTypes = null;
- }
-
- commitContext.setNewPackageUnits(newPackageUnits);
- commitContext.setLocksOnNewObjects(locksOnNewObjects);
- commitContext.setNewObjects(newObjects);
- commitContext.setDirtyObjectDeltas(dirtyObjectDeltas);
- commitContext.setDetachedObjects(detachedObjects);
- commitContext.setDetachedObjectTypes(detachedObjectTypes);
- commitContext.setCommitComment(commitComment);
- commitContext.setLobs(getIndicationStream());
- }
- finally
- {
- monitor.done();
- }
- }
-
- private ResourceSet createResourceSet(InternalCDOPackageRegistry packageRegistry)
- {
- ResourceSet resourceSet = new ResourceSetImpl()
- {
- @Override
- protected void demandLoad(Resource resource) throws IOException
- {
- // Do nothing: we don't want this ResourceSet to attempt demandloads.
- }
- };
-
- Resource.Factory resourceFactory = new EcoreResourceFactoryImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$
- resourceSet.setPackageRegistry(packageRegistry);
- return resourceSet;
- }
-
- protected void initializeCommitContext(CDODataInput in) throws Exception
- {
- int viewID = in.readInt();
- commitContext = getTransaction(viewID).createCommitContext();
- }
-
- protected void indicatingCommit(OMMonitor monitor)
- {
- ProgressDistributor distributor = getStore().getIndicatingCommitDistributor();
- distributor.run(InternalCommitContext.OPS, commitContext, monitor);
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- boolean success = false;
-
- try
- {
- success = respondingException(out, commitContext.getRollbackMessage(), commitContext.getXRefs());
- if (success)
- {
- respondingResult(out);
- respondingMappingNewObjects(out);
- respondingNewLockStates(out);
- }
- }
- finally
- {
- commitContext.postCommit(success);
- }
- }
-
- protected boolean respondingException(CDODataOutput out, String rollbackMessage, List<CDOIDReference> xRefs)
- throws Exception
- {
- boolean success = rollbackMessage == null;
- out.writeBoolean(success);
- if (!success)
- {
- out.writeString(rollbackMessage);
- out.writeCDOBranchPoint(commitContext.getBranchPoint());
- out.writeLong(commitContext.getPreviousTimeStamp());
-
- if (xRefs != null)
- {
- out.writeInt(xRefs.size());
- for (CDOIDReference xRef : xRefs)
- {
- out.writeCDOIDReference(xRef);
- }
- }
- else
- {
- out.writeInt(0);
- }
- }
-
- return success;
- }
-
- protected void respondingResult(CDODataOutput out) throws Exception
- {
- out.writeCDOBranchPoint(commitContext.getBranchPoint());
- out.writeLong(commitContext.getPreviousTimeStamp());
- }
-
- protected void respondingMappingNewObjects(CDODataOutput out) throws Exception
- {
- Map<CDOID, CDOID> idMappings = commitContext.getIDMappings();
- for (Entry<CDOID, CDOID> entry : idMappings.entrySet())
- {
- CDOID oldID = entry.getKey();
- CDOID newID = entry.getValue();
- out.writeCDOID(oldID);
- out.writeCDOID(newID);
- }
-
- out.writeCDOID(CDOID.NULL);
- }
-
- protected void respondingNewLockStates(CDODataOutput out) throws Exception
- {
- List<LockState<Object, IView>> newLockStates = commitContext.getPostCommmitLockStates();
- if (newLockStates != null)
- {
- out.writeInt(newLockStates.size());
- for (LockState<Object, IView> lockState : newLockStates)
- {
- CDOLockState cdoLockState = CDOLockUtil.createLockState(lockState);
- out.writeCDOLockState(cdoLockState);
- }
- }
- else
- {
- out.writeInt(0);
- }
- }
-
- protected InternalTransaction getTransaction(int viewID)
- {
- InternalView view = getSession().getView(viewID);
- if (view instanceof InternalTransaction)
- {
- return (InternalTransaction)view;
- }
-
- throw new IllegalStateException("Illegal transaction: " + view); //$NON-NLS-1$
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 213402 + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDReference; +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.lock.CDOLockUtil; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta; +import org.eclipse.emf.cdo.spi.server.InternalCommitContext; +import org.eclipse.emf.cdo.spi.server.InternalTransaction; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState; +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.monitor.ProgressDistributor; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * @author Eike Stepper + */ +public class CommitTransactionIndication extends CDOServerIndicationWithMonitoring +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, CommitTransactionIndication.class); + + protected InternalCommitContext commitContext; + + public CommitTransactionIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION); + } + + protected CommitTransactionIndication(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + protected InternalCDOPackageRegistry getPackageRegistry() + { + return commitContext.getPackageRegistry(); + } + + @Override + protected void indicatingFailed() + { + if (commitContext != null) + { + commitContext.postCommit(false); + commitContext = null; + } + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception + { + try + { + monitor.begin(OMMonitor.TEN); + indicatingCommit(in, monitor.fork(OMMonitor.ONE)); + indicatingCommit(monitor.fork(OMMonitor.TEN - OMMonitor.ONE)); + } + catch (IOException ex) + { + throw ex; + } + catch (Exception ex) + { + OM.LOG.error(ex); + throw WrappedException.wrap(ex); + } + finally + { + monitor.done(); + } + } + + protected void indicatingCommit(CDODataInput in, OMMonitor monitor) throws Exception + { + // Create commit context + initializeCommitContext(in); + commitContext.preWrite(); + + boolean autoReleaseLocksEnabled = in.readBoolean(); + commitContext.setAutoReleaseLocksEnabled(autoReleaseLocksEnabled); + String commitComment = in.readString(); + + InternalCDOPackageUnit[] newPackageUnits = new InternalCDOPackageUnit[in.readInt()]; + CDOLockState[] locksOnNewObjects = new CDOLockState[in.readInt()]; + InternalCDORevision[] newObjects = new InternalCDORevision[in.readInt()]; + InternalCDORevisionDelta[] dirtyObjectDeltas = new InternalCDORevisionDelta[in.readInt()]; + CDOID[] detachedObjects = new CDOID[in.readInt()]; + monitor.begin(newPackageUnits.length + newObjects.length + dirtyObjectDeltas.length + detachedObjects.length); + + try + { + // New package units + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} new package units", newPackageUnits.length); //$NON-NLS-1$ + } + + InternalCDOPackageRegistry packageRegistry = commitContext.getPackageRegistry(); + ResourceSet resourceSet = createResourceSet(packageRegistry); + for (int i = 0; i < newPackageUnits.length; i++) + { + newPackageUnits[i] = (InternalCDOPackageUnit)in.readCDOPackageUnit(resourceSet); + packageRegistry.putPackageUnit(newPackageUnits[i]); // Must happen before readCDORevision!!! + monitor.worked(); + } + + // When all packages are deserialized and registered, resolve them + // Note: EcoreUtil.resolveAll(resourceSet) does *not* do the trick + EMFUtil.safeResolveAll(resourceSet); + + // Locks on new objects + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} locks on new objects", locksOnNewObjects.length); //$NON-NLS-1$ + } + + for (int i = 0; i < locksOnNewObjects.length; i++) + { + locksOnNewObjects[i] = in.readCDOLockState(); + monitor.worked(); + } + + // New objects + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} new objects", newObjects.length); //$NON-NLS-1$ + } + + for (int i = 0; i < newObjects.length; i++) + { + newObjects[i] = (InternalCDORevision)in.readCDORevision(); + monitor.worked(); + } + + // Make the assignment of permanent IDs predictable + Arrays.sort(newObjects, new Comparator<InternalCDORevision>() + { + public int compare(InternalCDORevision r1, InternalCDORevision r2) + { + return r1.getID().compareTo(r2.getID()); + } + }); + + // Dirty objects + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} dirty object deltas", dirtyObjectDeltas.length); //$NON-NLS-1$ + } + + for (int i = 0; i < dirtyObjectDeltas.length; i++) + { + dirtyObjectDeltas[i] = (InternalCDORevisionDelta)in.readCDORevisionDelta(); + monitor.worked(); + } + + Map<CDOID, EClass> detachedObjectTypes = null; + if (getRepository().isEnsuringReferentialIntegrity()) + { + detachedObjectTypes = new HashMap<CDOID, EClass>(); + } + + for (int i = 0; i < detachedObjects.length; i++) + { + CDOID id = in.readCDOID(); + detachedObjects[i] = id; + + if (detachedObjectTypes != null) + { + EClass eClass = (EClass)in.readCDOClassifierRefAndResolve(); + detachedObjectTypes.put(id, eClass); + } + + monitor.worked(); + } + + if (detachedObjectTypes != null && detachedObjectTypes.isEmpty()) + { + detachedObjectTypes = null; + } + + commitContext.setNewPackageUnits(newPackageUnits); + commitContext.setLocksOnNewObjects(locksOnNewObjects); + commitContext.setNewObjects(newObjects); + commitContext.setDirtyObjectDeltas(dirtyObjectDeltas); + commitContext.setDetachedObjects(detachedObjects); + commitContext.setDetachedObjectTypes(detachedObjectTypes); + commitContext.setCommitComment(commitComment); + commitContext.setLobs(getIndicationStream()); + } + finally + { + monitor.done(); + } + } + + private ResourceSet createResourceSet(InternalCDOPackageRegistry packageRegistry) + { + ResourceSet resourceSet = new ResourceSetImpl() + { + @Override + protected void demandLoad(Resource resource) throws IOException + { + // Do nothing: we don't want this ResourceSet to attempt demandloads. + } + }; + + Resource.Factory resourceFactory = new EcoreResourceFactoryImpl(); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$ + resourceSet.setPackageRegistry(packageRegistry); + return resourceSet; + } + + protected void initializeCommitContext(CDODataInput in) throws Exception + { + int viewID = in.readInt(); + commitContext = getTransaction(viewID).createCommitContext(); + } + + protected void indicatingCommit(OMMonitor monitor) + { + ProgressDistributor distributor = getStore().getIndicatingCommitDistributor(); + distributor.run(InternalCommitContext.OPS, commitContext, monitor); + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception + { + boolean success = false; + + try + { + success = respondingException(out, commitContext.getRollbackMessage(), commitContext.getXRefs()); + if (success) + { + respondingResult(out); + respondingMappingNewObjects(out); + respondingNewLockStates(out); + } + } + finally + { + commitContext.postCommit(success); + } + } + + protected boolean respondingException(CDODataOutput out, String rollbackMessage, List<CDOIDReference> xRefs) + throws Exception + { + boolean success = rollbackMessage == null; + out.writeBoolean(success); + if (!success) + { + out.writeString(rollbackMessage); + out.writeCDOBranchPoint(commitContext.getBranchPoint()); + out.writeLong(commitContext.getPreviousTimeStamp()); + + if (xRefs != null) + { + out.writeInt(xRefs.size()); + for (CDOIDReference xRef : xRefs) + { + out.writeCDOIDReference(xRef); + } + } + else + { + out.writeInt(0); + } + } + + return success; + } + + protected void respondingResult(CDODataOutput out) throws Exception + { + out.writeCDOBranchPoint(commitContext.getBranchPoint()); + out.writeLong(commitContext.getPreviousTimeStamp()); + } + + protected void respondingMappingNewObjects(CDODataOutput out) throws Exception + { + Map<CDOID, CDOID> idMappings = commitContext.getIDMappings(); + for (Entry<CDOID, CDOID> entry : idMappings.entrySet()) + { + CDOID oldID = entry.getKey(); + CDOID newID = entry.getValue(); + out.writeCDOID(oldID); + out.writeCDOID(newID); + } + + out.writeCDOID(CDOID.NULL); + } + + protected void respondingNewLockStates(CDODataOutput out) throws Exception + { + List<LockState<Object, IView>> newLockStates = commitContext.getPostCommmitLockStates(); + if (newLockStates != null) + { + out.writeInt(newLockStates.size()); + for (LockState<Object, IView> lockState : newLockStates) + { + CDOLockState cdoLockState = CDOLockUtil.createLockState(lockState); + out.writeCDOLockState(cdoLockState); + } + } + else + { + out.writeInt(0); + } + } + + protected InternalTransaction getTransaction(int viewID) + { + InternalView view = getSession().getView(viewID); + if (view instanceof InternalTransaction) + { + return (InternalTransaction)view; + } + + throw new IllegalStateException("Illegal transaction: " + view); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionCancelIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionCancelIndication.java index 783eecdca9..0e6702756b 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionCancelIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionCancelIndication.java @@ -1,66 +1,66 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-/**
- * @author Simon McDuff
- */
-public class CommitXATransactionCancelIndication extends CommitTransactionIndication
-{
- public CommitXATransactionCancelIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_CANCEL);
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
- {
- initializeCommitContext(in);
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- String exceptionMessage = null;
- try
- {
- if (commitContext != null)
- {
- getRepository().getCommitManager().rollback(commitContext);
- }
- }
- catch (Exception exception)
- {
- exceptionMessage = exception.getMessage();
- }
-
- if (commitContext != null && exceptionMessage == null)
- {
- exceptionMessage = commitContext.getRollbackMessage();
- }
-
- respondingException(out, exceptionMessage, null);
- }
-
- @Override
- protected void initializeCommitContext(CDODataInput in) throws Exception
- {
- int viewID = in.readInt();
- commitContext = getRepository().getCommitManager().get(getTransaction(viewID));
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +/** + * @author Simon McDuff + */ +public class CommitXATransactionCancelIndication extends CommitTransactionIndication +{ + public CommitXATransactionCancelIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_CANCEL); + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception + { + initializeCommitContext(in); + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception + { + String exceptionMessage = null; + try + { + if (commitContext != null) + { + getRepository().getCommitManager().rollback(commitContext); + } + } + catch (Exception exception) + { + exceptionMessage = exception.getMessage(); + } + + if (commitContext != null && exceptionMessage == null) + { + exceptionMessage = commitContext.getRollbackMessage(); + } + + respondingException(out, exceptionMessage, null); + } + + @Override + protected void initializeCommitContext(CDODataInput in) throws Exception + { + int viewID = in.readInt(); + commitContext = getRepository().getCommitManager().get(getTransaction(viewID)); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java index 88c7e597b9..165c60cedc 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase1Indication.java @@ -1,71 +1,71 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-/**
- * @author Simon McDuff
- */
-public class CommitXATransactionPhase1Indication extends CommitTransactionIndication
-{
- public CommitXATransactionPhase1Indication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE1);
- }
-
- @Override
- protected void indicatingCommit(OMMonitor monitor)
- {
- // Register transactionContext
- getRepository().getCommitManager().preCommit(commitContext, monitor);
- }
-
- @Override
- protected void initializeCommitContext(CDODataInput in) throws Exception
- {
- int viewID = in.readInt();
- commitContext = new XATransactionCommitContext(getTransaction(viewID));
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- String exceptionMessage = null;
-
- try
- {
- ((XATransactionCommitContext)commitContext).getState().acquire(XATransactionCommitContext.PHASEAPPLYMAPPING);
- }
- catch (Throwable ex)
- {
- exceptionMessage = ex.getMessage();
- }
-
- if (exceptionMessage == null)
- {
- exceptionMessage = commitContext.getRollbackMessage();
- }
-
- boolean success = respondingException(out, exceptionMessage, null);
- if (success)
- {
- respondingResult(out);
- respondingMappingNewObjects(out);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +/** + * @author Simon McDuff + */ +public class CommitXATransactionPhase1Indication extends CommitTransactionIndication +{ + public CommitXATransactionPhase1Indication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE1); + } + + @Override + protected void indicatingCommit(OMMonitor monitor) + { + // Register transactionContext + getRepository().getCommitManager().preCommit(commitContext, monitor); + } + + @Override + protected void initializeCommitContext(CDODataInput in) throws Exception + { + int viewID = in.readInt(); + commitContext = new XATransactionCommitContext(getTransaction(viewID)); + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception + { + String exceptionMessage = null; + + try + { + ((XATransactionCommitContext)commitContext).getState().acquire(XATransactionCommitContext.PHASEAPPLYMAPPING); + } + catch (Throwable ex) + { + exceptionMessage = ex.getMessage(); + } + + if (exceptionMessage == null) + { + exceptionMessage = commitContext.getRollbackMessage(); + } + + boolean success = respondingException(out, exceptionMessage, null); + if (success) + { + respondingResult(out); + respondingMappingNewObjects(out); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase2Indication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase2Indication.java index 9aaa42f2d4..85afc4631b 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase2Indication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase2Indication.java @@ -1,98 +1,98 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext;
-import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext.CommitState;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.util.concurrent.ExecutionException;
-
-/**
- * @author Simon McDuff
- */
-public class CommitXATransactionPhase2Indication extends CommitTransactionIndication
-{
- private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL,
- CommitXATransactionPhase2Indication.class);
-
- public CommitXATransactionPhase2Indication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE2);
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
- {
- initializeCommitContext(in);
- XATransactionCommitContext xaContextContext = (XATransactionCommitContext)commitContext;
-
- int size = in.readInt();
- if (PROTOCOL.isEnabled())
- {
- PROTOCOL.format("Receiving {0} mapping informations", size); //$NON-NLS-1$
- }
-
- for (int i = 0; i < size; i++)
- {
- CDOIDTemp oldID = (CDOIDTemp)in.readCDOID();
- CDOID newID = in.readCDOID();
- xaContextContext.addIDMapping(oldID, newID);
- }
-
- // Mapping information from others CDOTransactions was added. Notify the commit process to continue.
- xaContextContext.getState().set(CommitState.APPLY_ID_MAPPING_DONE);
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- String exceptionMessage = null;
-
- try
- {
- // Return to the client only when the process is ready to commit
- getRepository().getCommitManager().waitForTermination(commitContext.getTransaction());
- }
- catch (InterruptedException ex)
- {
- throw WrappedException.wrap(ex);
- }
- catch (ExecutionException ex)
- {
- exceptionMessage = ex.getMessage();
- }
-
- if (exceptionMessage == null)
- {
- exceptionMessage = commitContext.getRollbackMessage();
- }
-
- respondingException(out, exceptionMessage, null);
- }
-
- @Override
- protected void initializeCommitContext(CDODataInput in) throws Exception
- {
- int viewID = in.readInt();
- commitContext = getRepository().getCommitManager().get(getTransaction(viewID));
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext; +import org.eclipse.emf.cdo.internal.server.XATransactionCommitContext.CommitState; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.util.concurrent.ExecutionException; + +/** + * @author Simon McDuff + */ +public class CommitXATransactionPhase2Indication extends CommitTransactionIndication +{ + private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, + CommitXATransactionPhase2Indication.class); + + public CommitXATransactionPhase2Indication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE2); + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception + { + initializeCommitContext(in); + XATransactionCommitContext xaContextContext = (XATransactionCommitContext)commitContext; + + int size = in.readInt(); + if (PROTOCOL.isEnabled()) + { + PROTOCOL.format("Receiving {0} mapping informations", size); //$NON-NLS-1$ + } + + for (int i = 0; i < size; i++) + { + CDOIDTemp oldID = (CDOIDTemp)in.readCDOID(); + CDOID newID = in.readCDOID(); + xaContextContext.addIDMapping(oldID, newID); + } + + // Mapping information from others CDOTransactions was added. Notify the commit process to continue. + xaContextContext.getState().set(CommitState.APPLY_ID_MAPPING_DONE); + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception + { + String exceptionMessage = null; + + try + { + // Return to the client only when the process is ready to commit + getRepository().getCommitManager().waitForTermination(commitContext.getTransaction()); + } + catch (InterruptedException ex) + { + throw WrappedException.wrap(ex); + } + catch (ExecutionException ex) + { + exceptionMessage = ex.getMessage(); + } + + if (exceptionMessage == null) + { + exceptionMessage = commitContext.getRollbackMessage(); + } + + respondingException(out, exceptionMessage, null); + } + + @Override + protected void initializeCommitContext(CDODataInput in) throws Exception + { + int viewID = in.readInt(); + commitContext = getRepository().getCommitManager().get(getTransaction(viewID)); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase3Indication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase3Indication.java index 8bd1b14812..cec29a2240 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase3Indication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitXATransactionPhase3Indication.java @@ -1,50 +1,50 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-/**
- * @author Simon McDuff
- */
-public class CommitXATransactionPhase3Indication extends CommitTransactionIndication
-{
- public CommitXATransactionPhase3Indication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE3);
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception
- {
- initializeCommitContext(in);
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception
- {
- commitContext.commit(monitor);
- boolean success = respondingException(out, commitContext.getRollbackMessage(), null);
- commitContext.postCommit(success);
- }
-
- @Override
- protected void initializeCommitContext(CDODataInput in) throws Exception
- {
- int viewID = in.readInt();
- commitContext = getRepository().getCommitManager().get(getTransaction(viewID));
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +/** + * @author Simon McDuff + */ +public class CommitXATransactionPhase3Indication extends CommitTransactionIndication +{ + public CommitXATransactionPhase3Indication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_XA_COMMIT_TRANSACTION_PHASE3); + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws Exception + { + initializeCommitContext(in); + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws Exception + { + commitContext.commit(monitor); + boolean success = respondingException(out, commitContext.getRollbackMessage(), null); + commitContext.postCommit(success); + } + + @Override + protected void initializeCommitContext(CDODataInput in) throws Exception + { + int viewID = in.readInt(); + commitContext = getRepository().getCommitManager().get(getTransaction(viewID)); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CreateBranchIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CreateBranchIndication.java index 1e4331b5e6..402ae9d987 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CreateBranchIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CreateBranchIndication.java @@ -1,58 +1,58 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class CreateBranchIndication extends CDOServerWriteIndication
-{
- private int branchID;
-
- private BranchInfo branchInfo;
-
- public CreateBranchIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_CREATE_BRANCH);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- branchID = in.readInt();
- branchInfo = new BranchInfo(in);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- InternalCDOBranchManager branchManager = getRepository().getBranchManager();
- InternalCDOBranch baseBranch = branchManager.getBranch(branchInfo.getBaseBranchID());
- InternalCDOBranch branch = branchManager.createBranch(branchID, branchInfo.getName(), baseBranch,
- branchInfo.getBaseTimeStamp());
-
- InternalSessionManager sessionManager = getRepository().getSessionManager();
- sessionManager.sendBranchNotification(getSession(), branch);
-
- out.writeInt(branch.getID());
- out.writeLong(branch.getBase().getTimeStamp());
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; +import org.eclipse.emf.cdo.spi.server.InternalSessionManager; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class CreateBranchIndication extends CDOServerWriteIndication +{ + private int branchID; + + private BranchInfo branchInfo; + + public CreateBranchIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_CREATE_BRANCH); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + branchID = in.readInt(); + branchInfo = new BranchInfo(in); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + InternalCDOBranchManager branchManager = getRepository().getBranchManager(); + InternalCDOBranch baseBranch = branchManager.getBranch(branchInfo.getBaseBranchID()); + InternalCDOBranch branch = branchManager.createBranch(branchID, branchInfo.getName(), baseBranch, + branchInfo.getBaseTimeStamp()); + + InternalSessionManager sessionManager = getRepository().getSessionManager(); + sessionManager.sendBranchNotification(getSession(), branch); + + out.writeInt(branch.getID()); + out.writeLong(branch.getBase().getTimeStamp()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/DisablePassiveUpdateIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/DisablePassiveUpdateIndication.java index ba32dc7bd6..ebac752045 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/DisablePassiveUpdateIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/DisablePassiveUpdateIndication.java @@ -1,41 +1,41 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class DisablePassiveUpdateIndication extends CDOServerReadIndication
-{
- public DisablePassiveUpdateIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_DISABLE_PASSIVE_UPDATE);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- getSession().setPassiveUpdateEnabled(false);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(true);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class DisablePassiveUpdateIndication extends CDOServerReadIndication +{ + public DisablePassiveUpdateIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_DISABLE_PASSIVE_UPDATE); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + getSession().setPassiveUpdateEnabled(false); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/EnableLockNotificationIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/EnableLockNotificationIndication.java index 1b55d42ac7..004fc0fa33 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/EnableLockNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/EnableLockNotificationIndication.java @@ -1,45 +1,45 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class EnableLockNotificationIndication extends CDOServerIndication
-{
- public EnableLockNotificationIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_ENABLE_LOCK_NOTIFICATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int viewID = in.readInt();
- boolean enable = in.readBoolean();
-
- InternalView view = getSession().getView(viewID);
- view.options().setLockNotificationEnabled(enable);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(true);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class EnableLockNotificationIndication extends CDOServerIndication +{ + public EnableLockNotificationIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_ENABLE_LOCK_NOTIFICATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int viewID = in.readInt(); + boolean enable = in.readBoolean(); + + InternalView view = getSession().getView(viewID); + view.options().setLockNotificationEnabled(enable); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/GetRemoteSessionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/GetRemoteSessionsIndication.java index 4713bb7fec..bc987cc3db 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/GetRemoteSessionsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/GetRemoteSessionsIndication.java @@ -1,65 +1,65 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class GetRemoteSessionsIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, GetRemoteSessionsIndication.class);
-
- private boolean subscribe;
-
- public GetRemoteSessionsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_GET_REMOTE_SESSIONS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- subscribe = in.readBoolean();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read subscribe: {0}", subscribe); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- InternalSession localSession = getSession();
- InternalSession[] sessions = getSession().getManager().getSessions();
- for (InternalSession session : sessions)
- {
- if (session != localSession)
- {
- out.writeInt(session.getSessionID());
- out.writeString(session.getUserID());
- out.writeBoolean(session.isSubscribed());
- }
- }
-
- out.writeInt(CDOProtocolConstants.NO_MORE_REMOTE_SESSIONS);
- localSession.setSubscribed(subscribe);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class GetRemoteSessionsIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, GetRemoteSessionsIndication.class); + + private boolean subscribe; + + public GetRemoteSessionsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_GET_REMOTE_SESSIONS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + subscribe = in.readBoolean(); + if (TRACER.isEnabled()) + { + TRACER.format("Read subscribe: {0}", subscribe); //$NON-NLS-1$ + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + InternalSession localSession = getSession(); + InternalSession[] sessions = getSession().getManager().getSessions(); + for (InternalSession session : sessions) + { + if (session != localSession) + { + out.writeInt(session.getSessionID()); + out.writeString(session.getUserID()); + out.writeBoolean(session.isSubscribed()); + } + } + + out.writeInt(CDOProtocolConstants.NO_MORE_REMOTE_SESSIONS); + localSession.setSubscribed(subscribe); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchIndication.java index cbe5a2ea45..639ce83cb6 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchIndication.java @@ -1,48 +1,48 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadBranchIndication extends CDOServerReadIndication
-{
- private int branchID;
-
- public LoadBranchIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCH);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- branchID = in.readInt();
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- InternalCDOBranchManager branchManager = getRepository().getBranchManager();
- InternalCDOBranch branch = branchManager.getBranch(branchID);
- BranchInfo branchInfo = branch.getBranchInfo();
- branchInfo.write(out);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadBranchIndication extends CDOServerReadIndication +{ + private int branchID; + + public LoadBranchIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCH); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + branchID = in.readInt(); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + InternalCDOBranchManager branchManager = getRepository().getBranchManager(); + InternalCDOBranch branch = branchManager.getBranch(branchID); + BranchInfo branchInfo = branch.getBranchInfo(); + branchInfo.write(out); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchesIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchesIndication.java index 38324263fe..5ab8666a1e 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchesIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadBranchesIndication.java @@ -1,67 +1,67 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadBranchesIndication extends CDOServerReadIndication
-{
- private int startID;
-
- private int endID;
-
- public LoadBranchesIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCHES);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- startID = in.readInt();
- endID = in.readInt();
- }
-
- @Override
- protected void responding(final CDODataOutput out) throws IOException
- {
- InternalCDOBranchManager branchManager = getRepository().getBranchManager();
- branchManager.getBranches(startID, endID, new CDOBranchHandler()
- {
- public void handleBranch(CDOBranch branch)
- {
- try
- {
- out.writeByte(CDOProtocolConstants.REPLICATE_BRANCH);
- out.writeCDOBranch(branch);
- }
- catch (IOException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- });
-
- out.writeByte(CDOProtocolConstants.REPLICATE_FINISHED);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchHandler; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; + +import org.eclipse.net4j.util.WrappedException; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadBranchesIndication extends CDOServerReadIndication +{ + private int startID; + + private int endID; + + public LoadBranchesIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_BRANCHES); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + startID = in.readInt(); + endID = in.readInt(); + } + + @Override + protected void responding(final CDODataOutput out) throws IOException + { + InternalCDOBranchManager branchManager = getRepository().getBranchManager(); + branchManager.getBranches(startID, endID, new CDOBranchHandler() + { + public void handleBranch(CDOBranch branch) + { + try + { + out.writeByte(CDOProtocolConstants.REPLICATE_BRANCH); + out.writeCDOBranch(branch); + } + catch (IOException ex) + { + throw WrappedException.wrap(ex); + } + } + }); + + out.writeByte(CDOProtocolConstants.REPLICATE_FINISHED); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java index 2834f42228..c989c5f4a5 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadChunkIndication.java @@ -1,108 +1,108 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 210868
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-
-import org.eclipse.net4j.util.collection.MoveableList;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadChunkIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkIndication.class);
-
- private CDOID id;
-
- private CDOBranchVersion branchVersion;
-
- private EStructuralFeature feature;
-
- private int fromIndex;
-
- private int toIndex;
-
- public LoadChunkIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHUNK);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- id = in.readCDOID();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read revision ID: {0}", id); //$NON-NLS-1$
- }
-
- branchVersion = in.readCDOBranchVersion();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read branchVersion: {0}", branchVersion); //$NON-NLS-1$
- }
-
- EClass eClass = (EClass)in.readCDOClassifierRefAndResolve();
- int featureID = in.readInt();
- feature = eClass.getEStructuralFeature(featureID);
- if (TRACER.isEnabled())
- {
- TRACER.format("Read feature: {0}", feature); //$NON-NLS-1$
- }
-
- fromIndex = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read fromIndex: {0}", fromIndex); //$NON-NLS-1$
- }
-
- toIndex = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read toIndex: {0}", toIndex); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- InternalRepository repository = getRepository();
- InternalCDORevisionManager revisionManager = repository.getRevisionManager();
-
- InternalCDORevision revision = revisionManager.getRevisionByVersion(id, branchVersion, 0, true);
- repository.ensureChunk(revision, feature, fromIndex, toIndex + 1);
-
- CDOType type = CDOModelUtil.getType(feature);
- MoveableList<Object> list = revision.getList(feature);
- for (int i = fromIndex; i <= toIndex; i++)
- {
- type.writeValue(out, list.get(i));
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 210868 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOType; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import org.eclipse.net4j.util.collection.MoveableList; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadChunkIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadChunkIndication.class); + + private CDOID id; + + private CDOBranchVersion branchVersion; + + private EStructuralFeature feature; + + private int fromIndex; + + private int toIndex; + + public LoadChunkIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_CHUNK); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + id = in.readCDOID(); + if (TRACER.isEnabled()) + { + TRACER.format("Read revision ID: {0}", id); //$NON-NLS-1$ + } + + branchVersion = in.readCDOBranchVersion(); + if (TRACER.isEnabled()) + { + TRACER.format("Read branchVersion: {0}", branchVersion); //$NON-NLS-1$ + } + + EClass eClass = (EClass)in.readCDOClassifierRefAndResolve(); + int featureID = in.readInt(); + feature = eClass.getEStructuralFeature(featureID); + if (TRACER.isEnabled()) + { + TRACER.format("Read feature: {0}", feature); //$NON-NLS-1$ + } + + fromIndex = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.format("Read fromIndex: {0}", fromIndex); //$NON-NLS-1$ + } + + toIndex = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.format("Read toIndex: {0}", toIndex); //$NON-NLS-1$ + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + InternalRepository repository = getRepository(); + InternalCDORevisionManager revisionManager = repository.getRevisionManager(); + + InternalCDORevision revision = revisionManager.getRevisionByVersion(id, branchVersion, 0, true); + repository.ensureChunk(revision, feature, fromIndex, toIndex + 1); + + CDOType type = CDOModelUtil.getType(feature); + MoveableList<Object> list = revision.getList(feature); + for (int i = fromIndex; i <= toIndex; i++) + { + type.writeValue(out, list.get(i)); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitInfosIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitInfosIndication.java index ae4aef613f..23c07c6608 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitInfosIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadCommitInfosIndication.java @@ -1,93 +1,93 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-
-import org.eclipse.net4j.util.WrappedException;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadCommitInfosIndication extends CDOServerReadIndication
-{
- private CDOBranch branch;
-
- private long startTime;
-
- private long endTime;
-
- public LoadCommitInfosIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_INFOS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- branch = in.readBoolean() ? in.readCDOBranch() : null;
- startTime = in.readLong();
- endTime = in.readLong();
- }
-
- @Override
- protected void responding(final CDODataOutput out) throws IOException
- {
- try
- {
- InternalCDOCommitInfoManager manager = getRepository().getCommitInfoManager();
- manager.getCommitInfos(branch, startTime, endTime, new CDOCommitInfoHandler()
- {
- public void handleCommitInfo(CDOCommitInfo commitInfo)
- {
- try
- {
- out.writeBoolean(true);
- out.writeLong(commitInfo.getPreviousTimeStamp());
- if (branch == null)
- {
- out.writeCDOBranch(commitInfo.getBranch());
- }
-
- out.writeLong(commitInfo.getTimeStamp());
- out.writeString(commitInfo.getUserID());
- out.writeString(commitInfo.getComment());
- }
- catch (IOException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- });
- }
- catch (RuntimeException ex)
- {
- Exception unwrapped = WrappedException.unwrap(ex);
- if (unwrapped instanceof IOException)
- {
- throw (IOException)unwrapped;
-
- }
-
- throw ex;
- }
-
- out.writeBoolean(false);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; + +import org.eclipse.net4j.util.WrappedException; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadCommitInfosIndication extends CDOServerReadIndication +{ + private CDOBranch branch; + + private long startTime; + + private long endTime; + + public LoadCommitInfosIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_COMMIT_INFOS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + branch = in.readBoolean() ? in.readCDOBranch() : null; + startTime = in.readLong(); + endTime = in.readLong(); + } + + @Override + protected void responding(final CDODataOutput out) throws IOException + { + try + { + InternalCDOCommitInfoManager manager = getRepository().getCommitInfoManager(); + manager.getCommitInfos(branch, startTime, endTime, new CDOCommitInfoHandler() + { + public void handleCommitInfo(CDOCommitInfo commitInfo) + { + try + { + out.writeBoolean(true); + out.writeLong(commitInfo.getPreviousTimeStamp()); + if (branch == null) + { + out.writeCDOBranch(commitInfo.getBranch()); + } + + out.writeLong(commitInfo.getTimeStamp()); + out.writeString(commitInfo.getUserID()); + out.writeString(commitInfo.getComment()); + } + catch (IOException ex) + { + throw WrappedException.wrap(ex); + } + } + }); + } + catch (RuntimeException ex) + { + Exception unwrapped = WrappedException.unwrap(ex); + if (unwrapped instanceof IOException) + { + throw (IOException)unwrapped; + + } + + throw ex; + } + + out.writeBoolean(false); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadLobIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadLobIndication.java index c13a6e7779..b4c94eb273 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadLobIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadLobIndication.java @@ -1,50 +1,50 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadLobIndication extends CDOServerReadIndication
-{
- private byte[] id;
-
- public LoadLobIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_LOB);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- id = in.readByteArray();
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- getRepository().loadLob(id, out);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- throw new UnsupportedOperationException();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadLobIndication extends CDOServerReadIndication +{ + private byte[] id; + + public LoadLobIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_LOB); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + id = in.readByteArray(); + } + + @Override + protected void responding(ExtendedDataOutputStream out) throws Exception + { + getRepository().loadLob(id, out); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + throw new UnsupportedOperationException(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadPackagesIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadPackagesIndication.java index 67140f6f6b..d5c94bcc40 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadPackagesIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadPackagesIndication.java @@ -1,62 +1,62 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EPackage;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadPackagesIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadPackagesIndication.class);
-
- private String packageUnitID;
-
- public LoadPackagesIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_PACKAGES);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- packageUnitID = in.readCDOPackageURI();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read packageUnitID: {0}", packageUnitID); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- InternalCDOPackageRegistry packageRegistry = getRepository().getPackageRegistry();
- EPackage ePackage = packageRegistry.getEPackage(packageUnitID);
- if (ePackage == null)
- {
- throw new IllegalStateException("Package unit not found: " + packageUnitID); //$NON-NLS-1$
- }
-
- CDOModelUtil.writePackage(out, ePackage, true, packageRegistry);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EPackage; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadPackagesIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, LoadPackagesIndication.class); + + private String packageUnitID; + + public LoadPackagesIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_PACKAGES); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + packageUnitID = in.readCDOPackageURI(); + if (TRACER.isEnabled()) + { + TRACER.format("Read packageUnitID: {0}", packageUnitID); //$NON-NLS-1$ + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + InternalCDOPackageRegistry packageRegistry = getRepository().getPackageRegistry(); + EPackage ePackage = packageRegistry.getEPackage(packageUnitID); + if (ePackage == null) + { + throw new IllegalStateException("Package unit not found: " + packageUnitID); //$NON-NLS-1$ + } + + CDOModelUtil.writePackage(out, ePackage, true, packageRegistry); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadSubBranchesIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadSubBranchesIndication.java index 846b82face..cef946bec6 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadSubBranchesIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadSubBranchesIndication.java @@ -1,53 +1,53 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LoadSubBranchesIndication extends CDOServerReadIndication
-{
- private int branchID;
-
- public LoadSubBranchesIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOAD_SUB_BRANCHES);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- branchID = in.readInt();
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- InternalCDOBranchManager branchManager = getRepository().getBranchManager();
- InternalCDOBranch branch = branchManager.getBranch(branchID);
- InternalCDOBranch[] branches = branch.getBranches();
- out.writeInt(branches.length);
- for (InternalCDOBranch subBranch : branches)
- {
- SubBranchInfo info = new SubBranchInfo(subBranch.getID(), subBranch.getName(), subBranch.getBase().getTimeStamp());
- info.write(out);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LoadSubBranchesIndication extends CDOServerReadIndication +{ + private int branchID; + + public LoadSubBranchesIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOAD_SUB_BRANCHES); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + branchID = in.readInt(); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + InternalCDOBranchManager branchManager = getRepository().getBranchManager(); + InternalCDOBranch branch = branchManager.getBranch(branchID); + InternalCDOBranch[] branches = branch.getBranches(); + out.writeInt(branches.length); + for (InternalCDOBranch subBranch : branches) + { + SubBranchInfo info = new SubBranchInfo(subBranch.getID(), subBranch.getName(), subBranch.getBase().getTimeStamp()); + info.write(out); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockAreaIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockAreaIndication.java index 9aa811ce0d..b0bf711c47 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockAreaIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockAreaIndication.java @@ -1,62 +1,62 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.server.InternalLockManager;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class LockAreaIndication extends CDOServerWriteIndication
-{
- private String result;
-
- public LockAreaIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_AREA);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- InternalLockManager lockManager = getRepository().getLockingManager();
-
- int viewID = in.readInt();
- InternalView view = getSession().getView(viewID);
-
- boolean create = in.readBoolean();
- if (create)
- {
- LockArea area = lockManager.createLockArea(view);
-
- result = area.getDurableLockingID();
- view.setDurableLockingID(result);
- }
- else
- {
- String durableLockingID = view.getDurableLockingID();
- lockManager.deleteLockArea(durableLockingID);
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeString(result);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.server.InternalLockManager; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class LockAreaIndication extends CDOServerWriteIndication +{ + private String result; + + public LockAreaIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_AREA); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + InternalLockManager lockManager = getRepository().getLockingManager(); + + int viewID = in.readInt(); + InternalView view = getSession().getView(viewID); + + boolean create = in.readBoolean(); + if (create) + { + LockArea area = lockManager.createLockArea(view); + + result = area.getDurableLockingID(); + view.setDurableLockingID(result); + } + else + { + String durableLockingID = view.getDurableLockingID(); + lockManager.deleteLockArea(durableLockingID); + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeString(result); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockDelegationIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockDelegationIndication.java index cfbd6193cd..23c8a00a0c 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockDelegationIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockDelegationIndication.java @@ -1,73 +1,73 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.spi.server.InternalLockManager;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-import org.eclipse.emf.cdo.spi.server.SyncingUtil;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class LockDelegationIndication extends LockObjectsIndication
-{
- private InternalView view;
-
- private String lockAreaID;
-
- private CDOBranch viewedBranch;
-
- public LockDelegationIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_DELEGATION);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- lockAreaID = in.readString();
- viewedBranch = in.readCDOBranch();
- super.indicating(in);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- try
- {
- super.responding(out);
- }
- finally
- {
- view.close();
- }
- }
-
- @Override
- protected IView getView(int viewID)
- {
- // The viewID received as an argument, is the ID of the client's view, which
- // does not exist on the master. So we ignore this argument and open a new
- // view instead.
- InternalLockManager lockManager = getRepository().getLockingManager();
- InternalSession session = getSession();
- view = SyncingUtil.openViewWithLockArea(session, lockManager, viewedBranch, lockAreaID);
- return view;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.spi.server.InternalLockManager; +import org.eclipse.emf.cdo.spi.server.InternalSession; +import org.eclipse.emf.cdo.spi.server.InternalView; +import org.eclipse.emf.cdo.spi.server.SyncingUtil; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class LockDelegationIndication extends LockObjectsIndication +{ + private InternalView view; + + private String lockAreaID; + + private CDOBranch viewedBranch; + + public LockDelegationIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_DELEGATION); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + lockAreaID = in.readString(); + viewedBranch = in.readCDOBranch(); + super.indicating(in); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + try + { + super.responding(out); + } + finally + { + view.close(); + } + } + + @Override + protected IView getView(int viewID) + { + // The viewID received as an argument, is the ID of the client's view, which + // does not exist on the master. So we ignore this argument and open a new + // view instead. + InternalLockManager lockManager = getRepository().getLockingManager(); + InternalSession session = getSession(); + view = SyncingUtil.openViewWithLockArea(session, lockManager, viewedBranch, lockAreaID); + return view; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockNotificationRequest.java index 05efa6aea0..5771c86679 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockNotificationRequest.java @@ -1,37 +1,37 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class LockNotificationRequest extends CDOServerRequest
-{
- private CDOLockChangeInfo lockChangeInfo;
-
- public LockNotificationRequest(CDOServerProtocol serverProtocol, CDOLockChangeInfo lockChangeInfo)
- {
- super(serverProtocol, CDOProtocolConstants.SIGNAL_LOCK_NOTIFICATION);
- this.lockChangeInfo = lockChangeInfo;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeCDOLockChangeInfo(lockChangeInfo);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class LockNotificationRequest extends CDOServerRequest +{ + private CDOLockChangeInfo lockChangeInfo; + + public LockNotificationRequest(CDOServerProtocol serverProtocol, CDOLockChangeInfo lockChangeInfo) + { + super(serverProtocol, CDOProtocolConstants.SIGNAL_LOCK_NOTIFICATION); + this.lockChangeInfo = lockChangeInfo; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeCDOLockChangeInfo(lockChangeInfo); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java index 49eba75985..a807828435 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockObjectsIndication.java @@ -1,98 +1,98 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.LockObjectsResult;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public class LockObjectsIndication extends CDOServerWriteIndication
-{
- private LockObjectsResult result;
-
- public LockObjectsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS);
- }
-
- protected LockObjectsIndication(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int viewID = in.readInt();
- LockType lockType = in.readCDOLockType();
- boolean recursive = in.readBoolean();
- long timeout = in.readLong();
-
- int nRevisions = in.readInt();
- List<CDORevisionKey> revisionKeys = new LinkedList<CDORevisionKey>();
- for (int i = 0; i < nRevisions; i++)
- {
- revisionKeys.add(in.readCDORevisionKey());
- }
-
- InternalRepository repository = getRepository();
- IView view = getView(viewID);
- result = repository.lock((InternalView)view, lockType, revisionKeys, recursive, timeout);
- }
-
- protected IView getView(int viewID)
- {
- return getSession().getView(viewID);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(result.isSuccessful());
- out.writeBoolean(result.isTimedOut());
- out.writeBoolean(result.isWaitForUpdate());
- out.writeLong(result.getRequiredTimestamp());
-
- CDORevisionKey[] staleRevisions = result.getStaleRevisions();
- out.writeInt(staleRevisions.length);
- for (CDORevisionKey revKey : staleRevisions)
- {
- out.writeCDORevisionKey(revKey);
- }
-
- out.writeLong(result.getTimestamp());
-
- CDOLockState[] newLockStates = result.getNewLockStates();
- out.writeInt(newLockStates.length);
- for (CDOLockState lockState : newLockStates)
- {
- out.writeCDOLockState(lockState);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + * Caspar De Groot - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.spi.server.InternalRepository; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.LockObjectsResult; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +/** + * @author Simon McDuff + */ +public class LockObjectsIndication extends CDOServerWriteIndication +{ + private LockObjectsResult result; + + public LockObjectsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_OBJECTS); + } + + protected LockObjectsIndication(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int viewID = in.readInt(); + LockType lockType = in.readCDOLockType(); + boolean recursive = in.readBoolean(); + long timeout = in.readLong(); + + int nRevisions = in.readInt(); + List<CDORevisionKey> revisionKeys = new LinkedList<CDORevisionKey>(); + for (int i = 0; i < nRevisions; i++) + { + revisionKeys.add(in.readCDORevisionKey()); + } + + InternalRepository repository = getRepository(); + IView view = getView(viewID); + result = repository.lock((InternalView)view, lockType, revisionKeys, recursive, timeout); + } + + protected IView getView(int viewID) + { + return getSession().getView(viewID); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(result.isSuccessful()); + out.writeBoolean(result.isTimedOut()); + out.writeBoolean(result.isWaitForUpdate()); + out.writeLong(result.getRequiredTimestamp()); + + CDORevisionKey[] staleRevisions = result.getStaleRevisions(); + out.writeInt(staleRevisions.length); + for (CDORevisionKey revKey : staleRevisions) + { + out.writeCDORevisionKey(revKey); + } + + out.writeLong(result.getTimestamp()); + + CDOLockState[] newLockStates = result.getNewLockStates(); + out.writeInt(newLockStates.length); + for (CDOLockState lockState : newLockStates) + { + out.writeCDOLockState(lockState); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockStateIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockStateIndication.java index 38792d19f3..fc4c635ea9 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockStateIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LockStateIndication.java @@ -1,90 +1,90 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.spi.server.InternalLockManager;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class LockStateIndication extends CDOServerReadIndication
-{
- private CDOLockState[] cdoLockStates;
-
- public LockStateIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_LOCK_STATE);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int viewID = in.readInt();
- InternalView view = getSession().getView(viewID);
- if (view == null)
- {
- throw new IllegalStateException("View not found");
- }
-
- InternalLockManager lockMgr = getRepository().getLockingManager();
-
- int n = in.readInt();
- cdoLockStates = new CDOLockState[n];
- for (int i = 0; i < n; i++)
- {
- Object key = indicatingCDOID(in, view.getBranch());
- LockState<Object, IView> lockState = lockMgr.getLockState(key);
- if (lockState != null)
- {
- cdoLockStates[i] = CDOLockUtil.createLockState(lockState);
- }
- else
- {
- cdoLockStates[i] = CDOLockUtil.createLockState(key);
- }
- }
- }
-
- private Object indicatingCDOID(CDODataInput in, CDOBranch viewedBranch) throws IOException
- {
- CDOID id = in.readCDOID();
- if (getRepository().isSupportingBranches())
- {
- return CDOIDUtil.createIDAndBranch(id, viewedBranch);
- }
-
- return id;
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeInt(cdoLockStates.length);
- for (CDOLockState lockState : cdoLockStates)
- {
- out.writeCDOLockState(lockState);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.lock.CDOLockUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.spi.server.InternalLockManager; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class LockStateIndication extends CDOServerReadIndication +{ + private CDOLockState[] cdoLockStates; + + public LockStateIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_LOCK_STATE); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int viewID = in.readInt(); + InternalView view = getSession().getView(viewID); + if (view == null) + { + throw new IllegalStateException("View not found"); + } + + InternalLockManager lockMgr = getRepository().getLockingManager(); + + int n = in.readInt(); + cdoLockStates = new CDOLockState[n]; + for (int i = 0; i < n; i++) + { + Object key = indicatingCDOID(in, view.getBranch()); + LockState<Object, IView> lockState = lockMgr.getLockState(key); + if (lockState != null) + { + cdoLockStates[i] = CDOLockUtil.createLockState(lockState); + } + else + { + cdoLockStates[i] = CDOLockUtil.createLockState(key); + } + } + } + + private Object indicatingCDOID(CDODataInput in, CDOBranch viewedBranch) throws IOException + { + CDOID id = in.readCDOID(); + if (getRepository().isSupportingBranches()) + { + return CDOIDUtil.createIDAndBranch(id, viewedBranch); + } + + return id; + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeInt(cdoLockStates.length); + for (CDOLockState lockState : cdoLockStates) + { + out.writeCDOLockState(lockState); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ObjectLockedIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ObjectLockedIndication.java index 8e0f60cd38..e4bd99fa50 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ObjectLockedIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ObjectLockedIndication.java @@ -1,65 +1,65 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.spi.server.InternalLockManager;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class ObjectLockedIndication extends CDOServerReadIndication
-{
- private boolean isLocked;
-
- public ObjectLockedIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_OBJECT_LOCKED);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int viewID = in.readInt();
- IView view = getSession().getView(viewID);
- InternalLockManager lockManager = getRepository().getLockingManager();
-
- LockType lockType = in.readCDOLockType();
- CDOID id = in.readCDOID();
- Object key = getRepository().isSupportingBranches() ? CDOIDUtil.createIDAndBranch(id, view.getBranch()) : id;
-
- boolean byOthers = in.readBoolean();
- if (byOthers)
- {
- isLocked = lockManager.hasLockByOthers(lockType, view, key);
- }
- else
- {
- isLocked = lockManager.hasLock(lockType, view, key);
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(isLocked);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.spi.server.InternalLockManager; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class ObjectLockedIndication extends CDOServerReadIndication +{ + private boolean isLocked; + + public ObjectLockedIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_OBJECT_LOCKED); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int viewID = in.readInt(); + IView view = getSession().getView(viewID); + InternalLockManager lockManager = getRepository().getLockingManager(); + + LockType lockType = in.readCDOLockType(); + CDOID id = in.readCDOID(); + Object key = getRepository().isSupportingBranches() ? CDOIDUtil.createIDAndBranch(id, view.getBranch()) : id; + + boolean byOthers = in.readBoolean(); + if (byOthers) + { + isLocked = lockManager.hasLockByOthers(lockType, view, key); + } + else + { + isLocked = lockManager.hasLock(lockType, view, key); + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(isLocked); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenViewIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenViewIndication.java index 2e20ec6dd6..9952b5a29f 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenViewIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/OpenViewIndication.java @@ -1,92 +1,92 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockAreaNotFoundException;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.server.InternalLockManager;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class OpenViewIndication extends CDOServerReadIndication
-{
- private InternalView newView;
-
- private String message;
-
- public OpenViewIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_OPEN_VIEW);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- InternalSession session = getSession();
-
- int viewID = in.readInt();
- boolean readOnly = in.readBoolean();
-
- if (in.readBoolean())
- {
- CDOBranchPoint branchPoint = in.readCDOBranchPoint();
- if (readOnly)
- {
- newView = session.openView(viewID, branchPoint);
- }
- else
- {
- newView = session.openTransaction(viewID, branchPoint);
- }
- }
- else
- {
- InternalLockManager lockManager = getRepository().getLockingManager();
-
- try
- {
- String durableLockingID = in.readString();
- newView = (InternalView)lockManager.openView(session, viewID, readOnly, durableLockingID);
- }
- catch (LockAreaNotFoundException ex)
- {
- // Client uses durableLockingID!=null && result==null to detect exceptional case
- }
- catch (IllegalStateException ex)
- {
- message = ex.getMessage();
- }
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- if (newView != null)
- {
- out.writeBoolean(true);
- out.writeCDOBranchPoint(newView);
- }
- else
- {
- out.writeBoolean(false);
- out.writeString(message);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockAreaNotFoundException; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.server.InternalLockManager; +import org.eclipse.emf.cdo.spi.server.InternalSession; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class OpenViewIndication extends CDOServerReadIndication +{ + private InternalView newView; + + private String message; + + public OpenViewIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_OPEN_VIEW); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + InternalSession session = getSession(); + + int viewID = in.readInt(); + boolean readOnly = in.readBoolean(); + + if (in.readBoolean()) + { + CDOBranchPoint branchPoint = in.readCDOBranchPoint(); + if (readOnly) + { + newView = session.openView(viewID, branchPoint); + } + else + { + newView = session.openTransaction(viewID, branchPoint); + } + } + else + { + InternalLockManager lockManager = getRepository().getLockingManager(); + + try + { + String durableLockingID = in.readString(); + newView = (InternalView)lockManager.openView(session, viewID, readOnly, durableLockingID); + } + catch (LockAreaNotFoundException ex) + { + // Client uses durableLockingID!=null && result==null to detect exceptional case + } + catch (IllegalStateException ex) + { + message = ex.getMessage(); + } + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + if (newView != null) + { + out.writeBoolean(true); + out.writeCDOBranchPoint(newView); + } + else + { + out.writeBoolean(false); + out.writeString(message); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryCancelIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryCancelIndication.java index a5d6d2b1e1..4084ac7ab9 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryCancelIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryCancelIndication.java @@ -1,61 +1,61 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class QueryCancelIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryCancelIndication.class);
-
- private int queryID;
-
- public QueryCancelIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_QUERY_CANCEL);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- queryID = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.trace("Query " + queryID + " will be cancelled"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- try
- {
- getRepository().getQueryManager().cancel(queryID);
- out.writeBoolean(false);
- }
- catch (Exception exception)
- {
- out.writeBoolean(true);
- out.writeString(exception.getMessage());
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class QueryCancelIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryCancelIndication.class); + + private int queryID; + + public QueryCancelIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_QUERY_CANCEL); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + queryID = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.trace("Query " + queryID + " will be cancelled"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + try + { + getRepository().getQueryManager().cancel(queryID); + out.writeBoolean(false); + } + catch (Exception exception) + { + out.writeBoolean(true); + out.writeString(exception.getMessage()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java index 7322ca6f56..f72aed1aab 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryIndication.java @@ -1,98 +1,98 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOIDReference;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
-import org.eclipse.emf.cdo.internal.common.CDOQueryInfoImpl;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.server.InternalQueryManager;
-import org.eclipse.emf.cdo.spi.server.InternalQueryResult;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class QueryIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryIndication.class);
-
- private boolean xrefs;
-
- private InternalQueryResult queryResult;
-
- public QueryIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_QUERY);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int viewID = in.readInt();
- InternalView view = getSession().getView(viewID);
-
- CDOQueryInfo queryInfo = new CDOQueryInfoImpl(in);
- xrefs = queryInfo.getQueryLanguage().equals(CDOProtocolConstants.QUERY_LANGUAGE_XREFS);
-
- InternalQueryManager queryManager = getRepository().getQueryManager();
- queryResult = queryManager.execute(view, queryInfo);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- // Return queryID immediately.
- out.writeInt(queryResult.getQueryID());
- flush();
-
- int numberOfResults = 0;
- while (queryResult.hasNext())
- {
- Object object = queryResult.next();
-
- // Object to return
- numberOfResults++;
- out.writeBoolean(true);
-
- if (xrefs)
- {
- CDOIDReference idReference = (CDOIDReference)object;
- out.writeCDOIDReference(idReference);
- }
- else
- {
- out.writeCDORevisionOrPrimitive(object);
- }
-
- if (queryResult.peek() == null)
- {
- flush();
- }
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Query returned " + numberOfResults + " results"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Query is done successfully
- out.writeBoolean(false);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOIDReference; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.util.CDOQueryInfo; +import org.eclipse.emf.cdo.internal.common.CDOQueryInfoImpl; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.server.InternalQueryManager; +import org.eclipse.emf.cdo.spi.server.InternalQueryResult; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class QueryIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, QueryIndication.class); + + private boolean xrefs; + + private InternalQueryResult queryResult; + + public QueryIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_QUERY); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int viewID = in.readInt(); + InternalView view = getSession().getView(viewID); + + CDOQueryInfo queryInfo = new CDOQueryInfoImpl(in); + xrefs = queryInfo.getQueryLanguage().equals(CDOProtocolConstants.QUERY_LANGUAGE_XREFS); + + InternalQueryManager queryManager = getRepository().getQueryManager(); + queryResult = queryManager.execute(view, queryInfo); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + // Return queryID immediately. + out.writeInt(queryResult.getQueryID()); + flush(); + + int numberOfResults = 0; + while (queryResult.hasNext()) + { + Object object = queryResult.next(); + + // Object to return + numberOfResults++; + out.writeBoolean(true); + + if (xrefs) + { + CDOIDReference idReference = (CDOIDReference)object; + out.writeCDOIDReference(idReference); + } + else + { + out.writeCDORevisionOrPrimitive(object); + } + + if (queryResult.peek() == null) + { + flush(); + } + } + + if (TRACER.isEnabled()) + { + TRACER.trace("Query returned " + numberOfResults + " results"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + // Query is done successfully + out.writeBoolean(false); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryLobsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryLobsIndication.java index 24a15bb6f9..77ebbec6f6 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryLobsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/QueryLobsIndication.java @@ -1,53 +1,53 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class QueryLobsIndication extends CDOServerReadIndication
-{
- private List<byte[]> ids = new ArrayList<byte[]>();
-
- public QueryLobsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_QUERY_LOBS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- ids.add(in.readByteArray());
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- getRepository().queryLobs(ids);
- out.writeInt(ids.size());
- for (byte[] id : ids)
- {
- out.writeByteArray(id);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class QueryLobsIndication extends CDOServerReadIndication +{ + private List<byte[]> ids = new ArrayList<byte[]>(); + + public QueryLobsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_QUERY_LOBS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int size = in.readInt(); + for (int i = 0; i < size; i++) + { + ids.add(in.readByteArray()); + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + getRepository().queryLobs(ids); + out.writeInt(ids.size()); + for (byte[] id : ids) + { + out.writeByteArray(id); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageIndication.java index 2fa7378fb8..44d91fb9df 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageIndication.java @@ -1,73 +1,73 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class RemoteMessageIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, RemoteMessageIndication.class);
-
- private List<Integer> result;
-
- public RemoteMessageIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- CDORemoteSessionMessage message = new CDORemoteSessionMessage(in);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Read message: " + message); //$NON-NLS-1$
- }
-
- int count = in.readInt();
- if (TRACER.isEnabled())
- {
- TRACER.format("Reading {0} recipients", count); //$NON-NLS-1$
- }
-
- int[] recipients = new int[count];
- for (int i = 0; i < recipients.length; i++)
- {
- recipients[i] = in.readInt();
- }
-
- InternalSessionManager sessionManager = getRepository().getSessionManager();
- result = sessionManager.sendRemoteMessageNotification(getSession(), message, recipients);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeInt(result.size());
- for (Integer recipient : result)
- {
- out.writeInt(recipient);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; +import org.eclipse.emf.cdo.spi.server.InternalSessionManager; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class RemoteMessageIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, RemoteMessageIndication.class); + + private List<Integer> result; + + public RemoteMessageIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + CDORemoteSessionMessage message = new CDORemoteSessionMessage(in); + if (TRACER.isEnabled()) + { + TRACER.trace("Read message: " + message); //$NON-NLS-1$ + } + + int count = in.readInt(); + if (TRACER.isEnabled()) + { + TRACER.format("Reading {0} recipients", count); //$NON-NLS-1$ + } + + int[] recipients = new int[count]; + for (int i = 0; i < recipients.length; i++) + { + recipients[i] = in.readInt(); + } + + InternalSessionManager sessionManager = getRepository().getSessionManager(); + result = sessionManager.sendRemoteMessageNotification(getSession(), message, recipients); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeInt(result.size()); + for (Integer recipient : result) + { + out.writeInt(recipient); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageNotificationRequest.java index bdb591725b..65e93c8973 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteMessageNotificationRequest.java @@ -1,61 +1,61 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RemoteMessageNotificationRequest extends CDOServerRequest
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL,
- RemoteMessageNotificationRequest.class);
-
- private int senderID;
-
- private CDORemoteSessionMessage message;
-
- public RemoteMessageNotificationRequest(CDOServerProtocol serverProtocol, InternalSession sender,
- CDORemoteSessionMessage message)
- {
- super(serverProtocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE_NOTIFICATION);
- senderID = sender.getSessionID();
- this.message = message;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Writing senderID: " + senderID); //$NON-NLS-1$
- }
-
- out.writeInt(senderID);
- if (TRACER.isEnabled())
- {
- TRACER.trace("Writing message: " + message); //$NON-NLS-1$
- }
-
- message.write(out);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RemoteMessageNotificationRequest extends CDOServerRequest +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, + RemoteMessageNotificationRequest.class); + + private int senderID; + + private CDORemoteSessionMessage message; + + public RemoteMessageNotificationRequest(CDOServerProtocol serverProtocol, InternalSession sender, + CDORemoteSessionMessage message) + { + super(serverProtocol, CDOProtocolConstants.SIGNAL_REMOTE_MESSAGE_NOTIFICATION); + senderID = sender.getSessionID(); + this.message = message; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.trace("Writing senderID: " + senderID); //$NON-NLS-1$ + } + + out.writeInt(senderID); + if (TRACER.isEnabled()) + { + TRACER.trace("Writing message: " + message); //$NON-NLS-1$ + } + + message.write(out); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteSessionNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteSessionNotificationRequest.java index a8d4e3c1a0..dc1dc1a6f7 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteSessionNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RemoteSessionNotificationRequest.java @@ -1,47 +1,47 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RemoteSessionNotificationRequest extends CDOServerRequest
-{
- private InternalSession sender;
-
- private byte opcode;
-
- public RemoteSessionNotificationRequest(CDOServerProtocol serverProtocol, InternalSession sender, byte opcode)
- {
- super(serverProtocol, CDOProtocolConstants.SIGNAL_REMOTE_SESSION_NOTIFICATION);
- this.sender = sender;
- this.opcode = opcode;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeInt(sender.getSessionID());
- out.writeByte(opcode);
- if (opcode == CDOProtocolConstants.REMOTE_SESSION_OPENED)
- {
- out.writeString(sender.getUserID());
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RemoteSessionNotificationRequest extends CDOServerRequest +{ + private InternalSession sender; + + private byte opcode; + + public RemoteSessionNotificationRequest(CDOServerProtocol serverProtocol, InternalSession sender, byte opcode) + { + super(serverProtocol, CDOProtocolConstants.SIGNAL_REMOTE_SESSION_NOTIFICATION); + this.sender = sender; + this.opcode = opcode; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeInt(sender.getSessionID()); + out.writeByte(opcode); + if (opcode == CDOProtocolConstants.REMOTE_SESSION_OPENED) + { + out.writeString(sender.getUserID()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryRawIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryRawIndication.java index ed08be58f8..3c709b5e31 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryRawIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/ReplicateRepositoryRawIndication.java @@ -1,74 +1,74 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class ReplicateRepositoryRawIndication extends CDOServerReadIndicationWithMonitoring
-{
- private int lastReplicatedBranchID;
-
- private long lastReplicatedCommitTime;
-
- public ReplicateRepositoryRawIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY_RAW);
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws IOException
- {
- try
- {
- monitor.begin();
-
- lastReplicatedBranchID = in.readInt();
- lastReplicatedCommitTime = in.readLong();
- }
- finally
- {
- monitor.done();
- }
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- try
- {
- monitor.begin();
- Async async = monitor.forkAsync();
-
- try
- {
- getRepository().replicateRaw(out, lastReplicatedBranchID, lastReplicatedCommitTime);
- }
- finally
- {
- async.stop();
- }
- }
- finally
- {
- monitor.done();
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.monitor.OMMonitor.Async; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class ReplicateRepositoryRawIndication extends CDOServerReadIndicationWithMonitoring +{ + private int lastReplicatedBranchID; + + private long lastReplicatedCommitTime; + + public ReplicateRepositoryRawIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPLICATE_REPOSITORY_RAW); + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws IOException + { + try + { + monitor.begin(); + + lastReplicatedBranchID = in.readInt(); + lastReplicatedCommitTime = in.readLong(); + } + finally + { + monitor.done(); + } + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws IOException + { + try + { + monitor.begin(); + Async async = monitor.forkAsync(); + + try + { + getRepository().replicateRaw(out, lastReplicatedBranchID, lastReplicatedCommitTime); + } + finally + { + async.stop(); + } + } + finally + { + monitor.done(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryStateNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryStateNotificationRequest.java index 934de9b6da..42cc8e0aee 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryStateNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryStateNotificationRequest.java @@ -1,49 +1,49 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RepositoryStateNotificationRequest extends CDOServerRequest
-{
- private final CDOCommonRepository.State oldState;
-
- private final CDOCommonRepository.State newState;
-
- private final CDOID rootResourceID;
-
- public RepositoryStateNotificationRequest(CDOServerProtocol serverProtocol, CDOCommonRepository.State oldState,
- CDOCommonRepository.State newState, CDOID rootResourceID)
- {
- super(serverProtocol, CDOProtocolConstants.SIGNAL_REPOSITORY_STATE_NOTIFICATION);
- this.oldState = oldState;
- this.newState = newState;
- this.rootResourceID = rootResourceID;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeEnum(oldState);
- out.writeEnum(newState);
- out.writeCDOID(rootResourceID);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonRepository; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RepositoryStateNotificationRequest extends CDOServerRequest +{ + private final CDOCommonRepository.State oldState; + + private final CDOCommonRepository.State newState; + + private final CDOID rootResourceID; + + public RepositoryStateNotificationRequest(CDOServerProtocol serverProtocol, CDOCommonRepository.State oldState, + CDOCommonRepository.State newState, CDOID rootResourceID) + { + super(serverProtocol, CDOProtocolConstants.SIGNAL_REPOSITORY_STATE_NOTIFICATION); + this.oldState = oldState; + this.newState = newState; + this.rootResourceID = rootResourceID; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeEnum(oldState); + out.writeEnum(newState); + out.writeCDOID(rootResourceID); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTimeIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTimeIndication.java index 85860d48f5..2d7358b0d2 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTimeIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTimeIndication.java @@ -1,65 +1,65 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RepositoryTimeIndication extends CDOServerIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, RepositoryTimeIndication.class);
-
- private long indicated;
-
- public RepositoryTimeIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TIME);
- }
-
- public RepositoryTimeIndication(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- indicated = System.currentTimeMillis();
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- long responded = System.currentTimeMillis();
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing indicated: {0}", CDOCommonUtil.formatTimeStamp(indicated)); //$NON-NLS-1$
- }
-
- out.writeLong(indicated);
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing responded: {0}", CDOCommonUtil.formatTimeStamp(responded)); //$NON-NLS-1$
- }
-
- out.writeLong(responded);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RepositoryTimeIndication extends CDOServerIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, RepositoryTimeIndication.class); + + private long indicated; + + public RepositoryTimeIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TIME); + } + + public RepositoryTimeIndication(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + indicated = System.currentTimeMillis(); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + long responded = System.currentTimeMillis(); + if (TRACER.isEnabled()) + { + TRACER.format("Writing indicated: {0}", CDOCommonUtil.formatTimeStamp(indicated)); //$NON-NLS-1$ + } + + out.writeLong(indicated); + if (TRACER.isEnabled()) + { + TRACER.format("Writing responded: {0}", CDOCommonUtil.formatTimeStamp(responded)); //$NON-NLS-1$ + } + + out.writeLong(responded); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTypeNotificationRequest.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTypeNotificationRequest.java index 906250722f..32ccc9d55d 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTypeNotificationRequest.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/RepositoryTypeNotificationRequest.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 201266
- * Simon McDuff - bug 233490
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class RepositoryTypeNotificationRequest extends CDOServerRequest
-{
- private CDOCommonRepository.Type oldType;
-
- private CDOCommonRepository.Type newType;
-
- public RepositoryTypeNotificationRequest(CDOServerProtocol serverProtocol, CDOCommonRepository.Type oldType,
- CDOCommonRepository.Type newType)
- {
- super(serverProtocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TYPE_NOTIFICATION);
- this.oldType = oldType;
- this.newType = newType;
- }
-
- @Override
- protected void requesting(CDODataOutput out) throws IOException
- {
- out.writeEnum(oldType);
- out.writeEnum(newType);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 201266 + * Simon McDuff - bug 233490 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonRepository; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class RepositoryTypeNotificationRequest extends CDOServerRequest +{ + private CDOCommonRepository.Type oldType; + + private CDOCommonRepository.Type newType; + + public RepositoryTypeNotificationRequest(CDOServerProtocol serverProtocol, CDOCommonRepository.Type oldType, + CDOCommonRepository.Type newType) + { + super(serverProtocol, CDOProtocolConstants.SIGNAL_REPOSITORY_TYPE_NOTIFICATION); + this.oldType = oldType; + this.newType = newType; + } + + @Override + protected void requesting(CDODataOutput out) throws IOException + { + out.writeEnum(oldType); + out.writeEnum(newType); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetLockNotificationModeIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetLockNotificationModeIndication.java index b93f88828c..b20ee0a45d 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetLockNotificationModeIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetLockNotificationModeIndication.java @@ -1,42 +1,42 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class SetLockNotificationModeIndication extends CDOServerReadIndication
-{
- public SetLockNotificationModeIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_SET_LOCK_NOTIFICATION_MODE);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- LockNotificationMode mode = in.readEnum(LockNotificationMode.class);
- getSession().setLockNotificationMode(mode);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(true);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class SetLockNotificationModeIndication extends CDOServerReadIndication +{ + public SetLockNotificationModeIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_SET_LOCK_NOTIFICATION_MODE); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + LockNotificationMode mode = in.readEnum(LockNotificationMode.class); + getSession().setLockNotificationMode(mode); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetPassiveUpdateModeIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetPassiveUpdateModeIndication.java index 7e8f5829ad..ed376db519 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetPassiveUpdateModeIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SetPassiveUpdateModeIndication.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class SetPassiveUpdateModeIndication extends CDOServerReadIndication
-{
- public SetPassiveUpdateModeIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_SET_PASSIVE_UPDATE_MODE);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- byte ordinal = in.readByte();
- PassiveUpdateMode mode = PassiveUpdateMode.values()[ordinal];
- getSession().setPassiveUpdateMode(mode);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(true);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class SetPassiveUpdateModeIndication extends CDOServerReadIndication +{ + public SetPassiveUpdateModeIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_SET_PASSIVE_UPDATE_MODE); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + byte ordinal = in.readByte(); + PassiveUpdateMode mode = PassiveUpdateMode.values()[ordinal]; + getSession().setPassiveUpdateMode(mode); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SwitchTargetIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SwitchTargetIndication.java index e68c04a155..59c09e48d6 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SwitchTargetIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/SwitchTargetIndication.java @@ -1,93 +1,93 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class SwitchTargetIndication extends CDOServerReadIndicationWithMonitoring
-{
- private List<CDORevisionDelta> allChangedObjects = new ArrayList<CDORevisionDelta>();
-
- private List<CDOID> allDetachedObjects = new ArrayList<CDOID>();
-
- public SwitchTargetIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_SWITCH_TARGET);
- }
-
- @Override
- protected void indicating(CDODataInput in, OMMonitor monitor) throws IOException
- {
- try
- {
- monitor.begin();
- Async async = monitor.forkAsync();
-
- try
- {
- int viewID = in.readInt();
- CDOBranchPoint branchPoint = in.readCDOBranchPoint();
-
- int size = in.readInt();
- List<CDOID> invalidObjects = new ArrayList<CDOID>(size);
- for (int i = 0; i < size; i++)
- {
- CDOID id = in.readCDOID();
- invalidObjects.add(id);
- }
-
- InternalView view = getSession().getView(viewID);
- view.changeTarget(branchPoint, invalidObjects, allChangedObjects, allDetachedObjects);
- }
- finally
- {
- async.stop();
- }
-
- }
- finally
- {
- monitor.done();
- }
- }
-
- @Override
- protected void responding(CDODataOutput out, OMMonitor monitor) throws IOException
- {
- out.writeInt(allChangedObjects.size());
- for (CDORevisionDelta delta : allChangedObjects)
- {
- out.writeCDORevisionDelta(delta);
- }
-
- out.writeInt(allDetachedObjects.size());
- for (CDOID id : allDetachedObjects)
- {
- out.writeCDOID(id);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; +import org.eclipse.net4j.util.om.monitor.OMMonitor.Async; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class SwitchTargetIndication extends CDOServerReadIndicationWithMonitoring +{ + private List<CDORevisionDelta> allChangedObjects = new ArrayList<CDORevisionDelta>(); + + private List<CDOID> allDetachedObjects = new ArrayList<CDOID>(); + + public SwitchTargetIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_SWITCH_TARGET); + } + + @Override + protected void indicating(CDODataInput in, OMMonitor monitor) throws IOException + { + try + { + monitor.begin(); + Async async = monitor.forkAsync(); + + try + { + int viewID = in.readInt(); + CDOBranchPoint branchPoint = in.readCDOBranchPoint(); + + int size = in.readInt(); + List<CDOID> invalidObjects = new ArrayList<CDOID>(size); + for (int i = 0; i < size; i++) + { + CDOID id = in.readCDOID(); + invalidObjects.add(id); + } + + InternalView view = getSession().getView(viewID); + view.changeTarget(branchPoint, invalidObjects, allChangedObjects, allDetachedObjects); + } + finally + { + async.stop(); + } + + } + finally + { + monitor.done(); + } + } + + @Override + protected void responding(CDODataOutput out, OMMonitor monitor) throws IOException + { + out.writeInt(allChangedObjects.size()); + for (CDORevisionDelta delta : allChangedObjects) + { + out.writeCDORevisionDelta(delta); + } + + out.writeInt(allDetachedObjects.size()); + for (CDOID id : allDetachedObjects) + { + out.writeCDOID(id); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockDelegationIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockDelegationIndication.java index 0edf78ac0b..b6ad88b4df 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockDelegationIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockDelegationIndication.java @@ -1,65 +1,65 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.spi.server.InternalLockManager;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import java.io.IOException;
-
-/**
- * @author Caspar De Groot
- */
-public class UnlockDelegationIndication extends UnlockObjectsIndication
-{
- private InternalView view;
-
- private String lockAreaID;
-
- public UnlockDelegationIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- lockAreaID = in.readString();
- super.indicating(in);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- try
- {
- super.responding(out);
- }
- finally
- {
- view.close();
- }
- }
-
- @Override
- protected IView getView(int viewID)
- {
- InternalLockManager lockManager = getRepository().getLockingManager();
- InternalSession session = getSession();
- view = (InternalView)lockManager.openView(session, InternalSession.TEMP_VIEW_ID, true, lockAreaID);
- return view;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.spi.server.InternalLockManager; +import org.eclipse.emf.cdo.spi.server.InternalSession; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import java.io.IOException; + +/** + * @author Caspar De Groot + */ +public class UnlockDelegationIndication extends UnlockObjectsIndication +{ + private InternalView view; + + private String lockAreaID; + + public UnlockDelegationIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + lockAreaID = in.readString(); + super.indicating(in); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + try + { + super.responding(out); + } + finally + { + view.close(); + } + } + + @Override + protected IView getView(int viewID) + { + InternalLockManager lockManager = getRepository().getLockingManager(); + InternalSession session = getSession(); + view = (InternalView)lockManager.openView(session, InternalSession.TEMP_VIEW_ID, true, lockAreaID); + return view; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockObjectsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockObjectsIndication.java index 20cb6a3419..17aefb1ea5 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockObjectsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnlockObjectsIndication.java @@ -1,91 +1,91 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalView;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import org.eclipse.emf.spi.cdo.CDOSessionProtocol.UnlockObjectsResult;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- */
-public class UnlockObjectsIndication extends CDOServerWriteIndication
-{
- private UnlockObjectsResult result;
-
- public UnlockObjectsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS);
- }
-
- protected UnlockObjectsIndication(CDOServerProtocol protocol, short signalID)
- {
- super(protocol, signalID);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- int viewID = in.readInt();
- LockType lockType = in.readCDOLockType();
- boolean recursive = in.readBoolean();
- int size = in.readInt();
-
- InternalRepository repository = getRepository();
- IView view = getView(viewID);
-
- if (size == CDOProtocolConstants.RELEASE_ALL_LOCKS)
- {
- result = repository.unlock((InternalView)view, null, null, false);
- }
- else
- {
- List<CDOID> objectIDs = new LinkedList<CDOID>();
- for (int i = 0; i < size; i++)
- {
- objectIDs.add(in.readCDOID());
- }
-
- result = repository.unlock((InternalView)view, lockType, objectIDs, recursive);
- }
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeLong(result.getTimestamp());
- CDOLockState[] newLockStates = result.getNewLockStates();
- out.writeInt(newLockStates.length);
- for (CDOLockState state : newLockStates)
- {
- out.writeCDOLockState(state);
- }
- }
-
- protected IView getView(int viewID)
- {
- return getSession().getView(viewID);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.lock.CDOLockState; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.IView; +import org.eclipse.emf.cdo.spi.server.InternalRepository; +import org.eclipse.emf.cdo.spi.server.InternalView; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import org.eclipse.emf.spi.cdo.CDOSessionProtocol.UnlockObjectsResult; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +/** + * @author Simon McDuff + */ +public class UnlockObjectsIndication extends CDOServerWriteIndication +{ + private UnlockObjectsResult result; + + public UnlockObjectsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_UNLOCK_OBJECTS); + } + + protected UnlockObjectsIndication(CDOServerProtocol protocol, short signalID) + { + super(protocol, signalID); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + int viewID = in.readInt(); + LockType lockType = in.readCDOLockType(); + boolean recursive = in.readBoolean(); + int size = in.readInt(); + + InternalRepository repository = getRepository(); + IView view = getView(viewID); + + if (size == CDOProtocolConstants.RELEASE_ALL_LOCKS) + { + result = repository.unlock((InternalView)view, null, null, false); + } + else + { + List<CDOID> objectIDs = new LinkedList<CDOID>(); + for (int i = 0; i < size; i++) + { + objectIDs.add(in.readCDOID()); + } + + result = repository.unlock((InternalView)view, lockType, objectIDs, recursive); + } + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeLong(result.getTimestamp()); + CDOLockState[] newLockStates = result.getNewLockStates(); + out.writeInt(newLockStates.length); + for (CDOLockState state : newLockStates) + { + out.writeCDOLockState(state); + } + } + + protected IView getView(int viewID) + { + return getSession().getView(viewID); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnsubscribeRemoteSessionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnsubscribeRemoteSessionsIndication.java index 1a1927e27d..4ea298248e 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnsubscribeRemoteSessionsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/UnsubscribeRemoteSessionsIndication.java @@ -1,53 +1,53 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.net4j.protocol;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM;
-import org.eclipse.emf.cdo.spi.server.InternalSession;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public class UnsubscribeRemoteSessionsIndication extends CDOServerReadIndication
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL,
- UnsubscribeRemoteSessionsIndication.class);
-
- public UnsubscribeRemoteSessionsIndication(CDOServerProtocol protocol)
- {
- super(protocol, CDOProtocolConstants.SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS);
- }
-
- @Override
- protected void indicating(CDODataInput in) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Unsubscribing"); //$NON-NLS-1$
- }
-
- InternalSession localSession = getSession();
- localSession.setSubscribed(false);
- }
-
- @Override
- protected void responding(CDODataOutput out) throws IOException
- {
- out.writeBoolean(true);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.net4j.protocol; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.server.internal.net4j.bundle.OM; +import org.eclipse.emf.cdo.spi.server.InternalSession; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class UnsubscribeRemoteSessionsIndication extends CDOServerReadIndication +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_PROTOCOL, + UnsubscribeRemoteSessionsIndication.class); + + public UnsubscribeRemoteSessionsIndication(CDOServerProtocol protocol) + { + super(protocol, CDOProtocolConstants.SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS); + } + + @Override + protected void indicating(CDODataInput in) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.trace("Unsubscribing"); //$NON-NLS-1$ + } + + InternalSession localSession = getSession(); + localSession.setSubscribed(false); + } + + @Override + protected void responding(CDODataOutput out) throws IOException + { + out.writeBoolean(true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/package-info.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/package-info.java index bfac7c2195..d7e803cf12 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/package-info.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/net4j/package-info.java @@ -1,15 +1,15 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-
-/**
- * Server concepts for dealing with Net4j-based repositories and fail-over infrastructure.
- */
-package org.eclipse.emf.cdo.server.net4j;
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ + +/** + * Server concepts for dealing with Net4j-based repositories and fail-over infrastructure. + */ +package org.eclipse.emf.cdo.server.net4j; |