summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-04-01 13:21:55 (EST)
committerEike Stepper2006-04-01 13:21:55 (EST)
commitf9510c478315515d4d7b507e4c4f6e42ad9187f3 (patch)
tree5abe0edf997aaff059a2d7354347ea6243964529
parent0a20df97c9f1ead9e4111af0fb35d03ab96b8c65 (diff)
downloadcdo-f9510c478315515d4d7b507e4c4f6e42ad9187f3.zip
cdo-f9510c478315515d4d7b507e4c4f6e42ad9187f3.tar.gz
cdo-f9510c478315515d4d7b507e4c4f6e42ad9187f3.tar.bz2
Multiple changeInfos in a ResourcesChangedIndication.
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java44
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourcesChangedRequest.java45
7 files changed, 108 insertions, 10 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml
index 98ff13f..2808d76 100644
--- a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml
+++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.xml
@@ -64,6 +64,9 @@
<property name="mapper">
<ref local="mapper"/>
</property>
+ <property name="cdoResServerProtocol">
+ <ref local="cdoResServerProtocol"/>
+ </property>
</bean>
<!-- ######################################################## -->
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java
index cf1a9a6..344837b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoResServerProtocol.java
@@ -11,12 +11,12 @@
package org.eclipse.emf.cdo.server;
-import org.eclipse.net4j.spring.Service;
+import org.eclipse.emf.cdo.core.CdoResProtocol;
import org.springframework.transaction.support.TransactionTemplate;
-public interface CdoResServerProtocol extends Service
+public interface CdoResServerProtocol extends CdoResProtocol
{
public Mapper getMapper();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java
index 1441b7d..76633a7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CdoServerProtocol.java
@@ -13,12 +13,16 @@ package org.eclipse.emf.cdo.server;
import org.eclipse.net4j.spring.Service;
+import org.eclipse.emf.cdo.core.CdoProtocol;
+
import org.springframework.transaction.support.TransactionTemplate;
-public interface CdoServerProtocol extends Service
+public interface CdoServerProtocol extends CdoProtocol
{
public Mapper getMapper();
public TransactionTemplate getTransactionTemplate();
+
+ public CdoResServerProtocol getCdoResServerProtocol();
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java
index 60dae9c..7f8e01a 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java
@@ -14,11 +14,10 @@ package org.eclipse.emf.cdo.server;
import org.eclipse.net4j.core.Channel;
import org.eclipse.net4j.spring.Service;
-import org.eclipse.emf.cdo.core.CdoProtocol;
import org.eclipse.emf.cdo.core.OidEncoder;
-public interface Mapper extends Service, CdoProtocol
+public interface Mapper extends Service
{
public int getNextPid();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java
index e526095..dd91f63 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CdoServerProtocolImpl.java
@@ -17,6 +17,7 @@ import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.emf.cdo.core.CdoProtocol;
import org.eclipse.emf.cdo.core.protocol.AbstractCdoProtocol;
+import org.eclipse.emf.cdo.server.CdoResServerProtocol;
import org.eclipse.emf.cdo.server.CdoServerProtocol;
import org.eclipse.emf.cdo.server.Mapper;
@@ -29,6 +30,8 @@ public class CdoServerProtocolImpl extends AbstractCdoProtocol implements CdoSer
protected TransactionTemplate transactionTemplate;
+ protected CdoResServerProtocol cdoResServerProtocol;
+
public CdoServerProtocolImpl()
{
}
@@ -89,6 +92,16 @@ public class CdoServerProtocolImpl extends AbstractCdoProtocol implements CdoSer
doSet("transactionTemplate", transactionTemplate);
}
+ public CdoResServerProtocol getCdoResServerProtocol()
+ {
+ return cdoResServerProtocol;
+ }
+
+ public void setCdoResServerProtocol(CdoResServerProtocol cdoResServerProtocol)
+ {
+ doSet("cdoResServerProtocol", cdoResServerProtocol);
+ }
+
protected void validate() throws ValidationException
{
super.validate();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java
index 3531ff9..9143972 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java
@@ -18,7 +18,9 @@ import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.emf.cdo.core.CdoProtocol;
import org.eclipse.emf.cdo.core.OidEncoder;
+import org.eclipse.emf.cdo.core.protocol.ResourceChangeInfo;
import org.eclipse.emf.cdo.server.AttributeInfo;
+import org.eclipse.emf.cdo.server.CdoResServerProtocol;
import org.eclipse.emf.cdo.server.CdoServerProtocol;
import org.eclipse.emf.cdo.server.ClassInfo;
import org.eclipse.emf.cdo.server.ColumnConverter;
@@ -54,6 +56,8 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
private Mapper mapper;
+ private List<ResourceChangeInfo> newResources = new ArrayList();
+
public short getSignalId()
{
return CdoProtocol.COMMIT_TRANSACTION;
@@ -73,7 +77,7 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
receiveObjectsToAttach();
receiveObjectChanges();
- announcedNewResources();
+ receiveNewResources();
}
});
}
@@ -83,6 +87,7 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
}
transmitInvalidations();
+ transmitRescourceChanges();
}
public void respond()
@@ -117,13 +122,14 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
}
}
- private void announcedNewResources()
+ private void receiveNewResources()
{
int rid;
while ((rid = receiveInt()) != 0)
{
String path = receiveString();
getMapper().insertResource(rid, path);
+ newResources.add(new ResourceChangeInfo(ResourceChangeInfo.ADDED, rid, path));
}
}
@@ -572,9 +578,6 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
}
}
- /**
- *
- */
private void transmitInvalidations()
{
if (!changedObjectIds.isEmpty())
@@ -608,6 +611,37 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
}
}
+ private void transmitRescourceChanges()
+ {
+ if (!newResources.isEmpty())
+ {
+ Channel me = getChannel();
+ int myType = me.getConnector().getType();
+ CdoServerProtocol cdo = (CdoServerProtocol) me.getProtocol();
+ CdoResServerProtocol cdores = cdo.getCdoResServerProtocol();
+
+ Channel[] channels = cdores.getChannels();
+ for (int i = 0; i < channels.length; i++)
+ {
+ Channel channel = channels[i];
+ int type = channel.getConnector().getType();
+ if (type == myType) // Important to exclude embedded peers (clients)
+ {
+ ResourcesChangedRequest signal = new ResourcesChangedRequest(newResources);
+
+ try
+ {
+ channel.transmit(signal);
+ }
+ catch (Exception ex)
+ {
+ error("Error while requesting signal " + signal, ex);
+ }
+ }
+ }
+ }
+ }
+
private Mapper getMapper()
{
if (mapper == null)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourcesChangedRequest.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourcesChangedRequest.java
new file mode 100644
index 0000000..a5e1317
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/ResourcesChangedRequest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2006 Eike Stepper, Sympedia Methods and Tools.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms 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.protocol;
+
+
+import org.eclipse.net4j.core.impl.AbstractRequest;
+
+import org.eclipse.emf.cdo.core.CdoResSignals;
+import org.eclipse.emf.cdo.core.protocol.ResourceChangeInfo;
+
+import java.util.List;
+
+
+public class ResourcesChangedRequest extends AbstractRequest
+{
+ private List<ResourceChangeInfo> infos;
+
+ public ResourcesChangedRequest(List<ResourceChangeInfo> infos)
+ {
+ this.infos = infos;
+ }
+
+ public short getSignalId()
+ {
+ return CdoResSignals.RESOURCES_CHANGED;
+ }
+
+ public void request()
+ {
+ for (ResourceChangeInfo info : infos)
+ {
+ info.transmit(getChannel());
+ }
+
+ transmitByte(ResourceChangeInfo.NONE);
+ }
+}