Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-04-19 04:48:09 -0400
committerEike Stepper2013-04-19 04:48:09 -0400
commit122b20e5a0bbad29bff306188a56357d196f94b3 (patch)
tree524f5fa8a13ddb7c4bc4c35776b81a2f7f2fb9f9
parenteeef27373d8ba469c84980f2bc56a3be2c1cbfc0 (diff)
downloadcdo-122b20e5a0bbad29bff306188a56357d196f94b3.tar.gz
cdo-122b20e5a0bbad29bff306188a56357d196f94b3.tar.xz
cdo-122b20e5a0bbad29bff306188a56357d196f94b3.zip
Map package infos in package registry
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java38
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java5
6 files changed, 37 insertions, 68 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java
index c0b649eb18..53b9814ed6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java
@@ -12,7 +12,6 @@ package org.eclipse.emf.cdo.common.model;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
-import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EPackage.Descriptor;
@@ -25,7 +24,7 @@ import org.eclipse.emf.ecore.EPackage.Descriptor;
* package unit is loaded all contained package infos/descriptors are resolved and replaced by their actual packages. At
* the same time the describing package info objects are attached as adapters to the resolved packages. This way the
* descriptive information is available before and after loading the packages.
- *
+ *
* @author Eike Stepper
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
@@ -33,7 +32,7 @@ import org.eclipse.emf.ecore.EPackage.Descriptor;
* @apiviz.has {@link org.eclipse.emf.ecore.EPackage}
* @apiviz.composedOf {@link CDOClassInfo}
*/
-public interface CDOPackageInfo extends Adapter, EPackage.Descriptor, Comparable<CDOPackageInfo>
+public interface CDOPackageInfo extends EPackage.Descriptor, Comparable<CDOPackageInfo>
{
/**
* Returns the package unit containing this package info.
@@ -53,7 +52,7 @@ public interface CDOPackageInfo extends Adapter, EPackage.Descriptor, Comparable
/**
* Returns the {@link EPackage package} described by this package info.
- *
+ *
* @param loadOnDemand
* If <code>true</code> and the containing {@link CDOPackageUnit package unit} is not {@link State#LOADED
* LOADED} the package unit is implicitely loaded. If <code>false</code> and this package unit is not
@@ -76,7 +75,7 @@ public interface CDOPackageInfo extends Adapter, EPackage.Descriptor, Comparable
/**
* Returnes <code>true</code> if the package described by this package info is the <i>Etypes</i> model,
* <code>false</code> oterwise.
- *
+ *
* @since 4.0
*/
public boolean isTypePackage();
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java
index 106b05d438..8f2dc36fc5 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.net4j.util.om.trace.ContextTracer;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EPackage;
@@ -30,7 +29,7 @@ import java.text.MessageFormat;
/**
* @author Eike Stepper
*/
-public class CDOPackageInfoImpl extends AdapterImpl implements InternalCDOPackageInfo
+public class CDOPackageInfoImpl implements InternalCDOPackageInfo
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageInfoImpl.class);
@@ -40,6 +39,8 @@ public class CDOPackageInfoImpl extends AdapterImpl implements InternalCDOPackag
private String parentURI;
+ private EPackage ePackage;
+
public CDOPackageInfoImpl()
{
}
@@ -107,24 +108,12 @@ public class CDOPackageInfoImpl extends AdapterImpl implements InternalCDOPackag
public EPackage getEPackage(boolean loadOnDemand)
{
- return doGetEPackage(loadOnDemand);
- }
-
- public EPackage doGetEPackage(boolean loadOnDemand)
- {
- EPackage ePackage = (EPackage)getTarget();
- if (ePackage != null)
- {
- return ePackage;
- }
-
- if (loadOnDemand)
+ if (ePackage == null && loadOnDemand)
{
- packageUnit.load(true); // TODO (CD) Dubious: is resolution-on-load really a good idea?
- return (EPackage)getTarget();
+ packageUnit.load(true);
}
- return null;
+ return ePackage;
}
public boolean isCorePackage()
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java
index 67ee3803e9..c8dd79a8e7 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.internal.common.bundle.OM;
import org.eclipse.emf.cdo.internal.common.messages.Messages;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
@@ -33,8 +32,6 @@ import org.eclipse.net4j.util.lifecycle.LifecycleState;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Enumerator;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
@@ -87,6 +84,8 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements Inte
private Set<CDOPackageInfo> visitedPackages = new HashSet<CDOPackageInfo>();
+ private Map<EPackage, InternalCDOPackageInfo> packageInfoMap = new HashMap<EPackage, InternalCDOPackageInfo>();
+
public CDOPackageRegistryImpl()
{
}
@@ -193,7 +192,7 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements Inte
EPackage newValue = (EPackage)value;
if (oldPackageInfo.getEPackage(false) == null)
{
- EMFUtil.addAdapter(newValue, oldPackageInfo);
+ registerPackageInfo(newValue, oldPackageInfo);
oldPackageInfo.getPackageUnit().setState(CDOPackageUnit.State.LOADED);
}
}
@@ -257,7 +256,7 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements Inte
EPackage ePackage = packageInfo.getEPackage(false);
if (ePackage != null)
{
- EMFUtil.addAdapter(ePackage, packageInfo);
+ registerPackageInfo(ePackage, packageInfo);
basicPut(ePackage.getNsURI(), ePackage);
}
else
@@ -283,11 +282,16 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements Inte
}
}
+ public synchronized void registerPackageInfo(EPackage ePackage, InternalCDOPackageInfo packageInfo)
+ {
+ packageInfoMap.put(ePackage, packageInfo);
+ }
+
public synchronized InternalCDOPackageInfo getPackageInfo(EPackage ePackage)
{
LifecycleUtil.checkActive(this);
- // Looks in the registry
+ // Looks up a package descriptor in the registry
Object object = get(ePackage.getNsURI());
if (object instanceof InternalCDOPackageInfo)
{
@@ -298,25 +302,8 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements Inte
}
}
- // Looks in the adapters
- synchronized (ePackage)
- {
- EList<Adapter> adapters = ePackage.eAdapters();
- for (int i = 0, size = adapters.size(); i < size; ++i)
- {
- Adapter adapter = adapters.get(i);
- if (adapter instanceof InternalCDOPackageInfo)
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)adapter;
- if (packageInfo.getPackageUnit().getPackageRegistry() == this)
- {
- return packageInfo;
- }
- }
- }
- }
-
- return null;
+ // Looks up a package info in the packageInfoMap
+ return packageInfoMap.get(ePackage);
}
public synchronized InternalCDOPackageInfo[] getPackageInfos()
@@ -612,6 +599,7 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements Inte
{
try
{
+ packageInfoMap.clear();
disposePackageUnits();
clear();
active = false;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java
index db20245bf3..ca23110573 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java
@@ -218,25 +218,14 @@ public class CDOPackageUnitImpl implements InternalCDOPackageUnit
public void dispose()
{
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- EPackage ePackage = packageInfo.getEPackage(false);
- if (ePackage != null)
- {
- synchronized (ePackage)
- {
- ePackage.eAdapters().remove(packageInfo);
- }
- }
- }
-
packageInfos = null;
setState(State.DISPOSED);
}
public synchronized void load(boolean resolve)
{
- load(packageRegistry.getPackageLoader(), resolve);
+ PackageLoader packageLoader = packageRegistry.getPackageLoader();
+ load(packageLoader, resolve);
}
public synchronized void load(PackageLoader packageLoader, boolean resolve)
@@ -254,10 +243,10 @@ public class CDOPackageUnitImpl implements InternalCDOPackageUnit
{
String packageURI = ePackage.getNsURI();
InternalCDOPackageInfo packageInfo = getPackageInfo(packageURI);
- synchronized (ePackage)
+ packageRegistry.registerPackageInfo(ePackage, packageInfo);
+ if (resolve)
{
- EMFUtil.addAdapter(ePackage, packageInfo);
- if (resolve)
+ synchronized (ePackage)
{
EcoreUtil.resolveAll(ePackage);
}
@@ -347,9 +336,10 @@ public class CDOPackageUnitImpl implements InternalCDOPackageUnit
packageInfo.setPackageUnit(this);
packageInfo.setPackageURI(ePackage.getNsURI());
packageInfo.setParentURI(ePackage.getESuperPackage() == null ? null : ePackage.getESuperPackage().getNsURI());
- EMFUtil.addAdapter(ePackage, packageInfo);
+ packageRegistry.registerPackageInfo(ePackage, packageInfo);
packageRegistry.basicPut(ePackage.getNsURI(), ePackage);
+
result.add(packageInfo);
for (EPackage subPackage : ePackage.getESubpackages())
{
@@ -362,7 +352,7 @@ public class CDOPackageUnitImpl implements InternalCDOPackageUnit
InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage.getNsURI());
if (packageInfo != null)
{
- EMFUtil.addAdapter(ePackage, packageInfo);
+ packageRegistry.registerPackageInfo(ePackage, packageInfo);
}
for (EPackage subPackage : ePackage.getESubpackages())
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java
index ecd25e5c86..cf2bb7417a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java
@@ -14,8 +14,6 @@ import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.common.notify.Adapter;
-
import java.io.IOException;
/**
@@ -26,7 +24,7 @@ import java.io.IOException;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface InternalCDOPackageInfo extends CDOPackageInfo, Adapter.Internal
+public interface InternalCDOPackageInfo extends CDOPackageInfo
{
public InternalCDOPackageUnit getPackageUnit();
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java
index ec45b9872c..fd5c22ab55 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java
@@ -42,6 +42,11 @@ public interface InternalCDOPackageRegistry extends CDOPackageRegistry, ILifecyc
public Object basicPut(String nsURI, Object value);
+ /**
+ * @since 4.2
+ */
+ public void registerPackageInfo(EPackage ePackage, InternalCDOPackageInfo packageInfo);
+
public void putPackageUnit(InternalCDOPackageUnit packageUnit);
/**

Back to the top