Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-11-13 20:57:30 +0000
committerChristian W. Damus2014-11-13 21:50:17 +0000
commit14be55490adc7e7b1325fd033600ed912917aad6 (patch)
tree8d5a54fc610d9506cc085f05d5a5912bddc78dcb /plugins/infra
parent2921506e21105cbf1ac389525fd0bdfed7839bdc (diff)
downloadorg.eclipse.papyrus-14be55490adc7e7b1325fd033600ed912917aad6.tar.gz
org.eclipse.papyrus-14be55490adc7e7b1325fd033600ed912917aad6.tar.xz
org.eclipse.papyrus-14be55490adc7e7b1325fd033600ed912917aad6.zip
451338: [RSA Model Import] Performance issues when importing larger models to Papyrus
https://bugs.eclipse.org/bugs/show_bug.cgi?id=451338 Fix severe performance problems in stereotype repair, including: * expensive search for a profile matching an unknown-schema EPackage for every instance of an EClass in the package, despite that a match can never be found * expensive validation of the transaction that does stereotype repair, despite that there are no semantic changes worth validating * let SemanticUMLContentProvider refresh its roots only once at the end of a transaction that changes resource-set roots, instead of repeatedly throughout the transaction (and posting async viewer refreshes along the way) Conflicts: plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java126
1 files changed, 124 insertions, 2 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
index 4f8a718fe48..c6811ed723b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,18 +8,27 @@
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus - bug 451338
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.adapters;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.emf.transaction.NotificationFilter;
+import org.eclipse.emf.transaction.ResourceSetChangeEvent;
+import org.eclipse.emf.transaction.ResourceSetListener;
+import org.eclipse.emf.transaction.RollbackException;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
/**
- * An EMF Adapter which listens on Resource Set root elements
+ * An EMF Adapter which listens on Resource Set root elements. For resource sets managed by {@link TransactionalEditingDomain}s,
+ * consider using the {@link Transactional} subclass.
*
* @author Camille Letavernier
*
@@ -104,4 +113,117 @@ public abstract class ResourceSetRootsAdapter extends EContentAdapter {
protected abstract void doNotify(Notification msg);
+ //
+ // Nested types
+ //
+
+ /**
+ * A variant of the {@link ResourceSetRootsAdapter} that is attached to a {@link TransactionalEditingDomain} to process batched notifications.
+ */
+ public static abstract class Transactional extends ResourceSetRootsAdapter implements ResourceSetListener {
+ private final boolean isPrecommit;
+
+ private final NotificationFilter filter = NotificationFilter.NOT_TOUCH.and(createFilter());
+
+ /**
+ * Initializes me as a post-commit resource-set roots notification handler.
+ */
+ public Transactional() {
+ this(false);
+ }
+
+ /**
+ * Initializes me as a pre- or post-commit resource-set roots notification handler.
+ *
+ * @param isPrecommit
+ * {@code true} to react to pre-commit notifications; {@code false} to react to post-commit notifications
+ */
+ public Transactional(boolean isPrecommit) {
+ this.isPrecommit = isPrecommit;
+ }
+
+ public boolean isAggregatePrecommitListener() {
+ return false;
+ }
+
+ public boolean isPrecommitOnly() {
+ return isPrecommit;
+ }
+
+ public boolean isPostcommitOnly() {
+ return !isPrecommit;
+ }
+
+ /**
+ * Subclasses may override/extend this method to create custom filters, perhaps based on the default filter create by the superclass.
+ * <b>Note</b> that this method is invoked by the superclass constructor, so subclasses must not attempt to access their own state.
+ *
+ * @return my notification filter
+ */
+ protected NotificationFilter createFilter() {
+ return NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES).or(
+ NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__CONTENTS));
+ }
+
+ public NotificationFilter getFilter() {
+ return filter;
+ }
+
+ public void resourceSetChanged(ResourceSetChangeEvent event) {
+ handleResourceSetChangeEvent(event);
+ }
+
+ public Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
+ handleResourceSetChangeEvent(event);
+ return null;
+ }
+
+ /**
+ * Subclasses may override this to handle notifications as a group.
+ *
+ * @param event
+ * the resource-set changed event carrying notifications to process
+ *
+ * @see #doNotify(Notification)
+ */
+ protected void handleResourceSetChangeEvent(ResourceSetChangeEvent event) {
+ for (Notification next : event.getNotifications()) {
+ doNotify(next);
+ }
+ }
+
+ /**
+ * Subclasses may override this to handle notifications individually.
+ *
+ * @param msg
+ * a notification from the group sent by the commit of a transaction
+ *
+ * @see #handleResourceSetChangeEvent(ResourceSetChangeEvent)
+ */
+ @Override
+ protected void doNotify(Notification msg) {
+ // Pass
+ }
+
+ @Override
+ public final void setTarget(Notifier newTarget) {
+ // Don't attach me to anything. I am fed directly by the editing domain
+ }
+
+ @Override
+ public final void unsetTarget(Notifier oldTarget) {
+ // Pass
+ }
+
+ @Override
+ protected final void addAdapter(Notifier notifier) {
+ // Don't attach me to anything. I am fed directly by the editing domain
+ }
+
+ @Override
+ protected final void removeAdapter(Notifier notifier) {
+ // Pass
+ }
+ }
+
}

Back to the top