diff options
author | khussey | 2006-02-21 14:52:23 +0000 |
---|---|---|
committer | khussey | 2006-02-21 14:52:23 +0000 |
commit | 3489808431869a5281d2c5bed62d550545f34919 (patch) | |
tree | 625c1a9cb34ddbd088bdf708a456459e629a4cec /deprecated | |
parent | 84c38ec5abaff15ce650d3bb961cedcdff6093bc (diff) | |
download | org.eclipse.uml2-3489808431869a5281d2c5bed62d550545f34919.tar.gz org.eclipse.uml2-3489808431869a5281d2c5bed62d550545f34919.tar.xz org.eclipse.uml2-3489808431869a5281d2c5bed62d550545f34919.zip |
[85176] Optimizing use of cache adapter w.r.t. notifications, resource loading.
Diffstat (limited to 'deprecated')
3 files changed, 103 insertions, 24 deletions
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ElementImpl.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ElementImpl.java index 524ccc6fa..febf17ea5 100644 --- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ElementImpl.java +++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/impl/ElementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005 IBM Corporation and others. + * Copyright (c) 2003, 2006 IBM Corporation 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 @@ -8,7 +8,7 @@ * Contributors: * IBM - initial API and implementation * - * $Id: ElementImpl.java,v 1.40 2005/12/06 23:18:02 khussey Exp $ + * $Id: ElementImpl.java,v 1.41 2006/02/21 14:52:24 khussey Exp $ */ package org.eclipse.uml2.impl; @@ -22,8 +22,11 @@ import java.util.Map; import java.util.Set; //import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.DiagnosticChain; import org.eclipse.emf.common.util.EList; @@ -151,12 +154,10 @@ public abstract class ElementImpl extends EObjectImpl implements Element { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> - * @generated NOT + * @generated */ protected ElementImpl() { super(); - - CacheAdapter.INSTANCE.adapt(this); } /** @@ -530,6 +531,80 @@ public abstract class ElementImpl extends EObjectImpl implements Element { /* * (non-Javadoc) * + * @see org.eclipse.emf.ecore.impl.EObjectImpl#eAdapters() + */ + public EList eAdapters() { + EList eAdapters = super.eAdapters(); + + if (eAdapters.isEmpty()) { + CacheAdapter cacheAdapter = getCacheAdapter(); + + if (cacheAdapter != null) { + eAdapters.add(cacheAdapter); + } + } + + return eAdapters; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.emf.ecore.impl.EObjectImpl#eSetDeliver(boolean) + */ + public void eSetDeliver(boolean deliver) { + + if (deliver) { + CacheAdapter cacheAdapter = getCacheAdapter(); + + if (cacheAdapter != null) { + getCacheAdapter().handleCrossReference(this); + } + } + + super.eSetDeliver(deliver); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.emf.common.notify.impl.BasicNotifierImpl#eNotificationRequired() + */ + public boolean eNotificationRequired() { + return getCacheAdapter() == null + ? super.eNotificationRequired() + : eDeliver(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.emf.common.notify.impl.BasicNotifierImpl#eNotify(org.eclipse.emf.common.notify.Notification) + */ + public void eNotify(Notification notification) { + + if (eDeliver()) { + BasicEList eBasicAdapters = eBasicAdapters(); + + if (eBasicAdapters == null || eBasicAdapters.isEmpty()) { + CacheAdapter cacheAdapter = getCacheAdapter(); + + if (cacheAdapter != null) { + cacheAdapter.notifyChanged(notification); + } + } else { + Adapter[] adapters = (Adapter[]) eBasicAdapters.data(); + + for (int i = 0, size = eBasicAdapters.size(); i < size; i++) { + adapters[i].notifyChanged(notification); + } + } + } + } + + /* + * (non-Javadoc) + * * @see org.eclipse.uml2.Element#createEAnnotation(String) */ public EAnnotation createEAnnotation(String source) { diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java index 74144cbfe..83e28573b 100644 --- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java +++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ClassOperations.java @@ -8,7 +8,7 @@ * Contributors: * IBM - initial API and implementation * - * $Id: ClassOperations.java,v 1.13 2006/01/31 20:35:03 khussey Exp $ + * $Id: ClassOperations.java,v 1.14 2006/02/21 14:52:24 khussey Exp $ */ package org.eclipse.uml2.internal.operation; @@ -28,7 +28,6 @@ import org.eclipse.uml2.NamedElement; import org.eclipse.uml2.Property; import org.eclipse.uml2.RedefinableElement; import org.eclipse.uml2.UML2Package; -import org.eclipse.uml2.common.util.CacheAdapter; /** * <!-- begin-user-doc --> @@ -118,9 +117,8 @@ public class ClassOperations extends ClassifierOperations { if (null != class_ && class_.isMetaclass()) { - for (Iterator nonNavigableInverseReferences = CacheAdapter.INSTANCE - .getNonNavigableInverseReferences(class_).iterator(); nonNavigableInverseReferences - .hasNext();) { + for (Iterator nonNavigableInverseReferences = getNonNavigableInverseReferences( + class_).iterator(); nonNavigableInverseReferences.hasNext();) { EStructuralFeature.Setting setting = (EStructuralFeature.Setting) nonNavigableInverseReferences .next(); diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/util/UML2ResourceFactoryImpl.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/util/UML2ResourceFactoryImpl.java index 7899ef893..42d25ebe7 100644 --- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/util/UML2ResourceFactoryImpl.java +++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/util/UML2ResourceFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2005 IBM Corporation and others. + * Copyright (c) 2003, 2006 IBM Corporation 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 @@ -8,10 +8,12 @@ * Contributors: * IBM - initial API and implementation * - * $Id: UML2ResourceFactoryImpl.java,v 1.6 2005/05/18 16:38:32 khussey Exp $ + * $Id: UML2ResourceFactoryImpl.java,v 1.7 2006/02/21 14:52:24 khussey Exp $ */ package org.eclipse.uml2.internal.util; +import java.util.Map; + import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; @@ -60,21 +62,25 @@ public class UML2ResourceFactoryImpl extends ResourceFactoryImpl implements UML2 public Resource createResource(URI uri) { UML2Resource resource = (UML2Resource) createResourceGen(uri); - resource.getDefaultLoadOptions().put( - XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - resource.getDefaultLoadOptions().put( - XMIResource.OPTION_LAX_FEATURE_PROCESSING, Boolean.TRUE); + Map defaultLoadOptions = resource.getDefaultLoadOptions(); + + defaultLoadOptions.put(XMLResource.OPTION_DISABLE_NOTIFY, Boolean.TRUE); + defaultLoadOptions.put(XMIResource.OPTION_EXTENDED_META_DATA, + Boolean.TRUE); + defaultLoadOptions.put(XMIResource.OPTION_LAX_FEATURE_PROCESSING, + Boolean.TRUE); + + Map defaultSaveOptions = resource.getDefaultSaveOptions(); - resource.getDefaultSaveOptions().put( - XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); - resource.getDefaultSaveOptions().put(XMIResource.OPTION_USE_XMI_TYPE, + defaultSaveOptions + .put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); + defaultSaveOptions.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE); + defaultSaveOptions.put(XMIResource.OPTION_SAVE_TYPE_INFORMATION, + Boolean.TRUE); + defaultSaveOptions.put(XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - resource.getDefaultSaveOptions().put( - XMIResource.OPTION_SAVE_TYPE_INFORMATION, Boolean.TRUE); - resource.getDefaultSaveOptions().put( - XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); return resource; } -} //UML2ResourceFactoryImpl +} // UML2ResourceFactoryImpl |