summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-17 14:46:53 (EDT)
committerEike Stepper2007-07-17 14:46:53 (EDT)
commitca5c83aa15abe52e0a2ff24a00d06fe50d7563f0 (patch)
tree6b10ebac7b40b8622d542a9f6dd427840e2abb2e
parent69678ef3e6ae619fcfa28726c52eff44407f5c70 (diff)
downloadcdo-ca5c83aa15abe52e0a2ff24a00d06fe50d7563f0.zip
cdo-ca5c83aa15abe52e0a2ff24a00d06fe50d7563f0.tar.gz
cdo-ca5c83aa15abe52e0a2ff24a00d06fe50d7563f0.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java (renamed from plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/RegisterPackagesIndication.java)25
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java27
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java31
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java28
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java130
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/RegisterPackagesRequest.java)26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java2
23 files changed, 237 insertions, 145 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
index dfae613..1167783 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RepositoryPackageManager.java
@@ -31,8 +31,9 @@ public class RepositoryPackageManager extends CDOPackageManagerImpl
}
@Override
- protected CDOPackageImpl resolve(String packageURI)
+ protected void resolve(CDOPackageImpl cdoPackage)
{
- return null;
+ // TODO Implement method RepositoryPackageManager.resolve()
+ throw new UnsupportedOperationException("Not yet implemented");
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
index 60e3c9b..9a84dd2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java
@@ -47,22 +47,22 @@ public class CDOServerProtocol extends SignalProtocol
{
switch (signalID)
{
- case CDOProtocolConstants.OPEN_SESSION_SIGNAL:
+ case CDOProtocolConstants.SIGNAL_OPEN_SESSION:
return new OpenSessionIndication();
- case CDOProtocolConstants.RESOURCE_ID_SIGNAL:
+ case CDOProtocolConstants.SIGNAL_RESOURCE_ID:
return new ResourceIDIndication();
- case CDOProtocolConstants.RESOURCE_PATH_SIGNAL:
+ case CDOProtocolConstants.SIGNAL_RESOURCE_PATH:
return new ResourcePathIndication();
- case CDOProtocolConstants.LOAD_OBJECT_SIGNAL:
- return new LoadObjectIndication();
+ case CDOProtocolConstants.SIGNAL_LOAD_PACKAGE:
+ return new LoadPackageIndication();
- case CDOProtocolConstants.REGISTER_PACKAGES_SIGNAL:
- return new RegisterPackagesIndication();
+ case CDOProtocolConstants.SIGNAL_LOAD_OBJECT:
+ return new LoadObjectIndication();
- case CDOProtocolConstants.COMMIT_TRANSACTION_SIGNAL:
+ case CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION:
return new CommitTransactionIndication();
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
index d334058..56532b4 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
@@ -11,8 +11,10 @@
package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.server.RepositoryPackageManager;
import org.eclipse.emf.cdo.internal.server.RevisionManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
@@ -37,6 +39,8 @@ public class CommitTransactionIndication extends CDOServerIndication
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CommitTransactionIndication.class);
+ private CDOPackageImpl[] newPackages;
+
private CDORevisionImpl[] newResources;
private CDORevisionImpl[] newObjects;
@@ -49,17 +53,37 @@ public class CommitTransactionIndication extends CDOServerIndication
public CommitTransactionIndication()
{
- super(CDOProtocolConstants.COMMIT_TRANSACTION_SIGNAL);
+ super(CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION);
}
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
+ newPackages = readNewPackages(in);
newResources = readNewResources(in);
newObjects = readNewObjects(in);
dirtyObjects = readDirtyObjects(in);
}
+ private CDOPackageImpl[] readNewPackages(ExtendedDataInputStream in) throws IOException
+ {
+ int size = in.readInt();
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Reading {0} new packages", size);
+ }
+
+ RepositoryPackageManager packageManager = getPackageManager();
+ CDOPackageImpl[] packages = new CDOPackageImpl[size];
+ for (int i = 0; i < size; i++)
+ {
+ packages[i] = new CDOPackageImpl(packageManager, in);
+ packageManager.addPackage(packages[i]);
+ }
+
+ return packages;
+ }
+
private CDORevisionImpl[] readNewResources(ExtendedDataInputStream in) throws IOException
{
int size = in.readInt();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java
index 7a60fae..bf6aeb0 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/InvalidationRequest.java
@@ -43,7 +43,7 @@ public class InvalidationRequest extends Request
@Override
protected short getSignalID()
{
- return CDOProtocolConstants.INVALIDATION_SIGNAL;
+ return CDOProtocolConstants.SIGNAL_INVALIDATION;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java
index e5ba5d5..a0dffe0 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadObjectIndication.java
@@ -36,7 +36,7 @@ public class LoadObjectIndication extends CDOServerIndication
public LoadObjectIndication()
{
- super(CDOProtocolConstants.LOAD_OBJECT_SIGNAL);
+ super(CDOProtocolConstants.SIGNAL_LOAD_OBJECT);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/RegisterPackagesIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
index 795d2d1..8ace90b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/RegisterPackagesIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.server.RepositoryPackageManager;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.util.ImplementationError;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
@@ -23,34 +24,30 @@ import java.io.IOException;
* @author Eike Stepper
*/
@SuppressWarnings("unused")
-public class RegisterPackagesIndication extends CDOServerIndication
+public class LoadPackageIndication extends CDOServerIndication
{
- public RegisterPackagesIndication()
+ private CDOPackageImpl cdoPackage;
+
+ public LoadPackageIndication()
{
- super(CDOProtocolConstants.REGISTER_PACKAGES_SIGNAL);
+ super(CDOProtocolConstants.SIGNAL_LOAD_PACKAGE);
}
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
+ String packageURI = in.readString();
RepositoryPackageManager packageManager = getPackageManager();
- int size = in.readInt();
- CDOPackageImpl[] newPackages = new CDOPackageImpl[size];
- for (int i = 0; i < size; i++)
- {
- newPackages[i] = new CDOPackageImpl(packageManager, in);
- packageManager.addPackage(newPackages[i]);
- }
-
- for (int i = 0; i < size; i++)
+ cdoPackage = packageManager.lookupPackage(packageURI);
+ if (cdoPackage == null)
{
- newPackages[i].initialize();
+ throw new ImplementationError("CDO package not found: " + packageURI);
}
}
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
- out.writeBoolean(true);
+ cdoPackage.write(out);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
index 3722492..6e3b6ef 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
@@ -10,14 +10,14 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server.protocol;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.server.Repository;
import org.eclipse.emf.cdo.internal.server.RepositoryManager;
+import org.eclipse.emf.cdo.internal.server.RepositoryPackageManager;
import org.eclipse.emf.cdo.internal.server.Session;
import org.eclipse.emf.cdo.internal.server.SessionManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.protocol.model.CDOPackage;
-import org.eclipse.emf.cdo.protocol.model.CDOPackageManager;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.RepositoryNotFoundException;
@@ -46,7 +46,7 @@ public class OpenSessionIndication extends IndicationWithResponse
@Override
protected short getSignalID()
{
- return CDOProtocolConstants.OPEN_SESSION_SIGNAL;
+ return CDOProtocolConstants.SIGNAL_OPEN_SESSION;
}
@Override
@@ -116,18 +116,23 @@ public class OpenSessionIndication extends IndicationWithResponse
out.writeString(repository.getUUID());
}
- private void writePackageURIs(ExtendedDataOutputStream out, CDOPackageManager packageManager) throws IOException
+ private void writePackageURIs(ExtendedDataOutputStream out, RepositoryPackageManager packageManager)
+ throws IOException
{
- CDOPackage[] packages = packageManager.getPackages();
- out.writeInt(packages.length);
- for (CDOPackage p : packages)
+ CDOPackageImpl[] packages = packageManager.getPackages();
+ for (CDOPackageImpl p : packages)
{
- if (PROTOCOL.isEnabled())
+ if (!p.isSystem())
{
- PROTOCOL.format("Writing package URI: {0}", p.getPackageURI());
- }
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Writing package URI: {0}", p.getPackageURI());
+ }
- out.writeString(p.getPackageURI());
+ out.writeString(p.getPackageURI());
+ }
}
+
+ out.writeString(null);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java
index 85911d2..1fcd39b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourceIDIndication.java
@@ -32,7 +32,7 @@ public class ResourceIDIndication extends CDOServerIndication
public ResourceIDIndication()
{
- super(CDOProtocolConstants.RESOURCE_ID_SIGNAL);
+ super(CDOProtocolConstants.SIGNAL_RESOURCE_ID);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
index d6344c8..b537044 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/ResourcePathIndication.java
@@ -32,7 +32,7 @@ public class ResourcePathIndication extends CDOServerIndication
public ResourcePathIndication()
{
- super(CDOProtocolConstants.RESOURCE_PATH_SIGNAL);
+ super(CDOProtocolConstants.SIGNAL_RESOURCE_PATH);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index dd358d6..4557bf6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -48,7 +48,6 @@ public final class CDOUtil
{
}
- @Deprecated
public static CDOSession openSession(IConnector connector, String repositoryName, EPackage.Registry delegate)
throws ConnectorException
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
index 461c9f5..da79d10 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.net4j.util.ReflectUtil;
@@ -20,6 +21,7 @@ import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import org.eclipse.emf.internal.cdo.util.EMFUtil;
import java.lang.reflect.Method;
import java.util.Map;
@@ -31,18 +33,29 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
{
private static final long serialVersionUID = 1L;
- public CDOPackageRegistryImpl()
+ private CDOSessionImpl session;
+
+ public CDOPackageRegistryImpl(CDOSessionImpl session)
{
+ this.session = session;
}
- public CDOPackageRegistryImpl(Registry delegateRegistry)
+ public CDOPackageRegistryImpl(CDOSessionImpl session, Registry delegateRegistry)
{
super(delegateRegistry);
+ this.session = session;
+ }
+
+ public CDOSessionImpl getSession()
+ {
+ return session;
}
public EPackage putEPackage(EPackage ePackage)
{
- return (EPackage)put(ePackage.getNsURI(), ePackage);
+ String uri = ePackage.getNsURI();
+ put(uri, ePackage);
+ return getEPackage(uri);
}
@Override
@@ -54,11 +67,19 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
EPackageImpl copy = (EPackageImpl)EcoreUtil.copy(ePackage);
copy.setEFactoryInstance(createCDOFactory(copy));
fixEClassifiers(copy);
+
+ CDOPackageImpl cdoPackage = EMFUtil.getCDOPackage(copy, session.getPackageManager());
+ cdoPackage.setPersistent(false);
+
ePackage = copy;
}
- super.put(key, ePackage);
- return ePackage;
+ return internalPut(key, ePackage);
+ }
+
+ public Object internalPut(String key, Object value)
+ {
+ return super.put(key, value);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
index 4136fe0..1c43cb8 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.net4j.internal.util.factory.Factory;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.core.runtime.IPath;
@@ -35,7 +36,7 @@ public class CDOSessionFactory extends Factory<CDOSession>
public CDOSession create(String description)
{
- CDOSessionImpl session = new CDOSessionImpl(null);
+ CDOSessionImpl session = new CDOSessionImpl(EPackage.Registry.INSTANCE);
session.setRepositoryName(getRepositoryName(description));
return session;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index a1ea58c..9c6fea5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -63,8 +63,6 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
private String repositoryUUID;
- private Set<String> packageURIs;
-
private CDOPackageRegistryImpl packageRegistry;
private CDOSessionPackageManager packageManager;
@@ -86,12 +84,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
public CDOSessionImpl(EPackage.Registry delegate)
{
- if (delegate == null)
- {
- delegate = EPackage.Registry.INSTANCE;
- }
-
- this.packageRegistry = new CDOPackageRegistryImpl(delegate);
+ this.packageRegistry = new CDOPackageRegistryImpl(this, delegate);
packageManager = new CDOSessionPackageManager(this);
revisionManager = new CDORevisionManagerImpl(this);
}
@@ -144,11 +137,6 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
return repositoryUUID;
}
- public Set<String> getPackageURIs()
- {
- return packageURIs;
- }
-
public boolean isOpen()
{
return channel != null;
@@ -287,7 +275,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
OpenSessionResult result = request.send();
sessionID = result.getSessionID();
repositoryUUID = result.getRepositoryUUID();
- packageURIs = result.getPackageURIs();
+ packageManager.addPackageProxies(result.getPackageURIs());
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java
index 2682e1e..17e916e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java
@@ -12,9 +12,13 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
+import org.eclipse.emf.cdo.protocol.util.TransportException;
+import org.eclipse.emf.internal.cdo.protocol.LoadPackageRequest;
import org.eclipse.emf.internal.cdo.util.EMFUtil;
+import java.util.Collection;
+
/**
* @author Eike Stepper
*/
@@ -33,9 +37,29 @@ public class CDOSessionPackageManager extends CDOPackageManagerImpl
return session;
}
+ public void addPackageProxies(Collection<String> packageURIs)
+ {
+ for (String packageURI : packageURIs)
+ {
+ CDOPackageImpl proxy = new CDOPackageImpl(this, packageURI);
+ addPackage(proxy);
+ }
+ }
+
@Override
- protected CDOPackageImpl resolve(String packageURI)
+ protected void resolve(CDOPackageImpl cdoPackage)
{
- return null;
+ try
+ {
+ new LoadPackageRequest(session.getChannel(), cdoPackage).send();
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new TransportException(ex);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index 483fe64..6e761fb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -13,26 +13,20 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.core.CDOCorePackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.resource.CDOResourcePackageImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.util.ImplementationError;
+import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.net4j.IChannel;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
-import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionRequest;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
-import org.eclipse.emf.internal.cdo.protocol.RegisterPackagesRequest;
-import org.eclipse.emf.internal.cdo.util.EMFUtil;
-import org.eclipse.emf.internal.cdo.util.PackageClosure;
-import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* @author Eike Stepper
@@ -47,6 +41,8 @@ public class CDOTransactionImpl
private CDOViewImpl view;
+ private List<CDOPackageImpl> newPackages;
+
private Map<CDOID, CDOResourceImpl> newResources = new HashMap();
private Map<CDOID, CDOObjectImpl> newObjects = new HashMap();
@@ -70,6 +66,11 @@ public class CDOTransactionImpl
return dirty;
}
+ public List<CDOPackageImpl> getNewPackages()
+ {
+ return newPackages;
+ }
+
public Map<CDOID, CDOResourceImpl> getNewResources()
{
return newResources;
@@ -111,11 +112,12 @@ public class CDOTransactionImpl
try
{
CDOSessionImpl session = view.getSession();
- IChannel channel = session.getChannel();
-
- new RegisterPackagesRequest(channel, calculateNewPackages()).send();
+ CDOPackageManagerImpl packageManager = session.getPackageManager();
+ newPackages = packageManager.getTransientPackages();
+ IChannel channel = session.getChannel();
CommitTransactionResult result = new CommitTransactionRequest(channel, this).send();
+
postCommit(newResources, result);
postCommit(newObjects, result);
postCommit(dirtyObjects, result);
@@ -125,6 +127,12 @@ public class CDOTransactionImpl
session.notifyInvalidation(result.getTimeStamp(), dirtyObjects.keySet(), view);
}
+ for (CDOPackageImpl newPackage : newPackages)
+ {
+ newPackage.setPersistent(true);
+ }
+
+ newPackages = null;
newResources.clear();
newObjects.clear();
dirtyObjects.clear();
@@ -138,8 +146,7 @@ public class CDOTransactionImpl
}
catch (Exception ex)
{
- // TODO Better exception handling
- throw new RuntimeException(ex);
+ throw new TransportException(ex);
}
}
@@ -148,8 +155,19 @@ public class CDOTransactionImpl
public void rollback()
{
- // TODO Implement method CDOTransactionImpl.rollback()
- throw new UnsupportedOperationException("Not yet implemented");
+ try
+ {
+ // TODO Implement method CDOTransactionImpl.rollback()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new TransportException(ex);
+ }
}
public void registerNew(CDOObjectImpl object)
@@ -210,43 +228,47 @@ public class CDOTransactionImpl
}
}
- private Collection<CDOPackageImpl> calculateNewPackages()
- {
- CDOSessionImpl session = view.getSession();
- CDOPackageManagerImpl packageManager = session.getPackageManager();
- CDOCorePackageImpl corePackage = packageManager.getCDOCorePackage();
- CDOResourcePackageImpl resourcePackage = packageManager.getCDOResourcePackage();
-
- Set<String> knownPackages = session.getPackageURIs();
- Map<String, CDOPackageImpl> newPackages = new HashMap();
- for (CDOObjectImpl cdoObject : newObjects.values())
- {
- CDOPackageImpl cdoPackage = cdoObject.cdoClass().getContainingPackage();
- String uri = cdoPackage.getPackageURI();
- if (!newPackages.containsKey(uri) && !knownPackages.contains(uri))
- {
- EPackage ePackage = EMFUtil.getEPackage(cdoPackage);
- Set<EPackage> ePackages = PackageClosure.calculate(ePackage);
- for (EPackage eP : ePackages)
- {
- CDOPackageImpl cdoP = eP == ePackage ? cdoPackage : EMFUtil.getCDOPackage(eP, packageManager);
- if (cdoP == null)
- {
- throw new IllegalStateException("Not a CDO package: " + eP);
- }
-
- if (cdoP != corePackage && cdoP != resourcePackage)
- {
- uri = cdoP.getPackageURI();
- if (!newPackages.containsKey(uri) && !knownPackages.contains(uri))
- {
- newPackages.put(uri, cdoP);
- }
- }
- }
- }
- }
-
- return newPackages.values();
- }
+ // private Collection<CDOPackageImpl> calculateNewPackages()
+ // {
+ // CDOSessionImpl session = view.getSession();
+ // CDOPackageManagerImpl packageManager = session.getPackageManager();
+ // return packageManager.getTransientPackages();
+ //
+ // CDOCorePackageImpl corePackage = packageManager.getCDOCorePackage();
+ // CDOResourcePackageImpl resourcePackage =
+ // packageManager.getCDOResourcePackage();
+ //
+ // Set<String> knownPackages = session.getPackageURIs();
+ // Map<String, CDOPackageImpl> newPackages = new HashMap();
+ // for (CDOObjectImpl cdoObject : newObjects.values())
+ // {
+ // CDOPackageImpl cdoPackage = cdoObject.cdoClass().getContainingPackage();
+ // String uri = cdoPackage.getPackageURI();
+ // if (!newPackages.containsKey(uri) && !knownPackages.contains(uri))
+ // {
+ // EPackage ePackage = EMFUtil.getEPackage(cdoPackage);
+ // Set<EPackage> ePackages = PackageClosure.calculate(ePackage);
+ // for (EPackage eP : ePackages)
+ // {
+ // CDOPackageImpl cdoP = eP == ePackage ? cdoPackage :
+ // EMFUtil.getCDOPackage(eP, packageManager);
+ // if (cdoP == null)
+ // {
+ // throw new IllegalStateException("Not a CDO package: " + eP);
+ // }
+ //
+ // if (cdoP != corePackage && cdoP != resourcePackage)
+ // {
+ // uri = cdoP.getPackageURI();
+ // if (!newPackages.containsKey(uri) && !knownPackages.contains(uri))
+ // {
+ // newPackages.put(uri, cdoP);
+ // }
+ // }
+ // }
+ // }
+ // }
+ //
+ // return newPackages.values();
+ // }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
index f7e026a..e316d72 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientProtocol.java
@@ -48,7 +48,7 @@ public class CDOClientProtocol extends SignalProtocol
{
switch (signalID)
{
- case CDOProtocolConstants.INVALIDATION_SIGNAL:
+ case CDOProtocolConstants.SIGNAL_INVALIDATION:
return new InvalidationIndication();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index 7cf3e60..5bff6e2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDOReferenceConverter;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
@@ -30,6 +31,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
/**
@@ -45,7 +47,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
public CommitTransactionRequest(IChannel channel, final CDOTransactionImpl transaction)
{
- super(channel, CDOProtocolConstants.COMMIT_TRANSACTION_SIGNAL);
+ super(channel, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION);
this.transaction = transaction;
converter = new CDOReferenceConverter()
{
@@ -72,11 +74,27 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
+ writeNewPackages(out);
writeNewResources(out);
writeNewObjects(out);
writeDirtyObjects(out);
}
+ private void writeNewPackages(ExtendedDataOutputStream out) throws IOException
+ {
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Writing {0} new packages", transaction.getNewResources().size());
+ }
+
+ List<CDOPackageImpl> newPackages = transaction.getNewPackages();
+ out.writeInt(newPackages.size());
+ for (CDOPackageImpl newPackage : newPackages)
+ {
+ newPackage.write(out);
+ }
+ }
+
private void writeNewResources(ExtendedDataOutputStream out) throws IOException
{
if (PROTOCOL.isEnabled())
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
index bf1c374..98ad34a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/InvalidationIndication.java
@@ -39,7 +39,7 @@ public class InvalidationIndication extends Indication
@Override
protected short getSignalID()
{
- return CDOProtocolConstants.INVALIDATION_SIGNAL;
+ return CDOProtocolConstants.SIGNAL_INVALIDATION;
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java
index e6c80dc..ad665b0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadObjectRequest.java
@@ -37,7 +37,7 @@ public class LoadObjectRequest extends CDOClientRequest<CDORevisionImpl>
public LoadObjectRequest(IChannel channel, CDOID id)
{
- super(channel, CDOProtocolConstants.LOAD_OBJECT_SIGNAL);
+ super(channel, CDOProtocolConstants.SIGNAL_LOAD_OBJECT);
this.id = id;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/RegisterPackagesRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java
index 10db974..c67fab3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/RegisterPackagesRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java
@@ -18,42 +18,30 @@ import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
import java.io.IOException;
-import java.util.Collection;
-import java.util.Set;
/**
* @author Eike Stepper
*/
-public class RegisterPackagesRequest extends CDOClientRequest
+public class LoadPackageRequest extends CDOClientRequest
{
- private Collection<CDOPackageImpl> newPackages;
+ private CDOPackageImpl cdoPackage;
- public RegisterPackagesRequest(IChannel channel, Collection<CDOPackageImpl> newPackages)
+ public LoadPackageRequest(IChannel channel, CDOPackageImpl cdoPackage)
{
- super(channel, CDOProtocolConstants.REGISTER_PACKAGES_SIGNAL);
- this.newPackages = newPackages;
+ super(channel, CDOProtocolConstants.SIGNAL_LOAD_PACKAGE);
+ this.cdoPackage = cdoPackage;
}
@Override
protected void requesting(ExtendedDataOutputStream out) throws IOException
{
- out.writeInt(newPackages.size());
- for (CDOPackageImpl newPackage : newPackages)
- {
- newPackage.write(out);
- }
+ out.writeString(cdoPackage.getPackageURI());
}
@Override
protected Object confirming(ExtendedDataInputStream in) throws IOException
{
- in.readBoolean();
- Set<String> knownPackages = getSession().getPackageURIs();
- for (CDOPackageImpl newPackage : newPackages)
- {
- knownPackages.add(newPackage.getPackageURI());
- }
-
+ cdoPackage.read(in);
return null;
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
index 78c497f..162618c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
@@ -44,7 +44,7 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
@Override
protected short getSignalID()
{
- return CDOProtocolConstants.OPEN_SESSION_SIGNAL;
+ return CDOProtocolConstants.SIGNAL_OPEN_SESSION;
}
@Override
@@ -86,10 +86,14 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
}
Set<String> packageURIs = new HashSet();
- int size = in.readInt();
- for (int i = 0; i < size; i++)
+ for (;;)
{
String packageURI = in.readString();
+ if (packageURI == null)
+ {
+ break;
+ }
+
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Read package URI: {0}", packageURI);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java
index bab7655..a4fdf10 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourceIDRequest.java
@@ -34,7 +34,7 @@ public class ResourceIDRequest extends CDOClientRequest<CDOID>
public ResourceIDRequest(IChannel channel, String path)
{
- super(channel, CDOProtocolConstants.RESOURCE_ID_SIGNAL);
+ super(channel, CDOProtocolConstants.SIGNAL_RESOURCE_ID);
this.path = path;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java
index b85d8a1..f413ee2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/ResourcePathRequest.java
@@ -34,7 +34,7 @@ public class ResourcePathRequest extends CDOClientRequest<String>
public ResourcePathRequest(IChannel channel, CDOID id)
{
- super(channel, CDOProtocolConstants.RESOURCE_PATH_SIGNAL);
+ super(channel, CDOProtocolConstants.SIGNAL_RESOURCE_PATH);
this.id = id;
}