Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortle2009-04-28 18:01:08 +0000
committertle2009-04-28 18:01:08 +0000
commitd37ed9344f3708b7d7fc321c403e2824901371d2 (patch)
tree48f1f17cbe61b204a36094ba05ebb258e3b1a8e7
parentca1dab4e6dd1f93a6f5b65a42dcff49122d9a50c (diff)
downloadwebtools.dali-d37ed9344f3708b7d7fc321c403e2824901371d2.tar.gz
webtools.dali-d37ed9344f3708b7d7fc321c403e2824901371d2.tar.xz
webtools.dali-d37ed9344f3708b7d7fc321c403e2824901371d2.zip
272982 - Memory leak in EntityCacheProperties bug
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java26
4 files changed, 57 insertions, 35 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java
index 4bba3f02ba..edc16800f8 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityCacheProperties.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2009 Oracle. 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.
@@ -35,12 +35,12 @@ public class EntityCacheProperties extends AbstractModel {
private PropertyValueModel<Boolean> sharedCacheHolder;
private PropertyChangeListener sharedCacheListener;
- private static final long serialVersionUID = 1L;
-
public static final String CACHE_TYPE_PROPERTY = Caching.CACHE_TYPE_PROPERTY;
public static final String CACHE_SIZE_PROPERTY = Caching.CACHE_SIZE_PROPERTY;
public static final String SHARED_CACHE_PROPERTY = Caching.SHARED_CACHE_PROPERTY;
+ private static final long serialVersionUID = 1L;
+
// ********** constructors **********
public EntityCacheProperties(Caching caching, String entityName) {
super();
@@ -49,20 +49,19 @@ public class EntityCacheProperties extends AbstractModel {
PropertyValueModel<Caching> cachingHolder = new SimplePropertyValueModel<Caching>(this.caching);
this.initialize(cachingHolder);
+
+ this.engageListeners();
}
protected void initialize(PropertyValueModel<Caching> cachingHolder) {
this.cacheTypeHolder = this.buildCacheTypeAA(cachingHolder);
this.cacheTypeListener = this.buildCacheTypeChangeListener();
- this.cacheTypeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener);
this.cacheSizeHolder = this.buildCacheSizeAA(cachingHolder);
this.cacheSizeListener = this.buildCacheSizeChangeListener();
- this.cacheSizeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheSizeListener);
this.sharedCacheHolder = this.buildSharedCacheAA(cachingHolder);
this.sharedCacheListener = this.buildSharedCacheChangeListener();
- this.sharedCacheHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener);
}
// ********** behavior **********
@@ -182,6 +181,18 @@ public class EntityCacheProperties extends AbstractModel {
};
}
+ public void engageListeners() {
+ this.cacheTypeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener);
+ this.cacheSizeHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.cacheSizeListener);
+ this.sharedCacheHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener);
+ }
+
+ public void disengageListeners() {
+ this.cacheTypeHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheTypeListener);
+ this.cacheSizeHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.cacheSizeListener);
+ this.sharedCacheHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.sharedCacheListener);
+ }
+
@Override
public void toString(StringBuilder sb) {
sb.append("name: ");
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java
index ee16bcf329..77ae10d207 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/caching/EntityListComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2008 Oracle. All rights reserved.
+* Copyright (c) 2007, 2009 Oracle. 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.
@@ -61,7 +61,6 @@ public class EntityListComposite extends Pane<Caching>
container,
EclipseLinkUiMessages.CachingEntityListComposite_groupTitle
);
-
WritablePropertyValueModel<EntityCacheProperties> entityHolder = this.buildEntityHolder();
// Entities add/remove list pane
@@ -87,13 +86,14 @@ public class EntityListComposite extends Pane<Caching>
private AddRemoveListPane.Adapter buildEntitiesAdapter() {
return new AddRemoveListPane.AbstractAdapter() {
public void addNewItem(ObjectListSelectionModel listSelectionModel) {
- addEntities(listSelectionModel);
+ EntityListComposite.this.addEntities(listSelectionModel);
}
public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
Caching caching = getSubject();
for (Object item : listSelectionModel.selectedValues()) {
EntityCacheProperties entityCaching = (EntityCacheProperties) item;
+ entityCaching.disengageListeners();
caching.removeEntity(entityCaching.getEntityName());
}
}
@@ -117,7 +117,7 @@ public class EntityListComposite extends Pane<Caching>
}
}
}
-
+
private String getEntityName(String fullyQualifiedTypeName) {
Entity entity = getSubject().getPersistenceUnit().getEntity(fullyQualifiedTypeName);
@@ -186,10 +186,10 @@ public class EntityListComposite extends Pane<Caching>
}
private ListValueModel<EntityCacheProperties> buildEntityCachingListHolder() {
- return new TransformationListValueModelAdapter<String, EntityCacheProperties>(buildEntitiesListHolder()) {
+ return new TransformationListValueModelAdapter<String, EntityCacheProperties>(this.buildEntitiesListHolder()) {
@Override
- protected EntityCacheProperties transformItem(String item) {
- return new EntityCacheProperties(getSubject(), item);
+ protected EntityCacheProperties transformItem(String entityName) {
+ return new EntityCacheProperties(getSubject(), entityName);
}
};
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java
index f8ffd09300..d2d29ac1ef 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityCustomizerProperties.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2009 Oracle. 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.
@@ -25,14 +25,12 @@ import org.eclipse.jpt.utility.model.value.PropertyValueModel;
public class EntityCustomizerProperties extends AbstractModel {
private Customization customization;
-
private String entityName;
- public static final String DESCRIPTOR_CUSTOMIZER_PROPERTY = Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY;
-
- SimplePropertyValueModel<Customization> customizationHolder;
PropertyValueModel<String> descriptorCustomizerHolder;
PropertyChangeListener descriptorCustomizerListener;
+
+ public static final String DESCRIPTOR_CUSTOMIZER_PROPERTY = Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY;
private static final long serialVersionUID = 1L;
@@ -41,11 +39,16 @@ public class EntityCustomizerProperties extends AbstractModel {
super();
this.customization = customization;
this.entityName = entityName;
- this.customizationHolder = new SimplePropertyValueModel<Customization>(this.customization);
-
- this.descriptorCustomizerHolder = this.buildDescriptorCustomizerAA(this.customizationHolder);
+
+ PropertyValueModel<Customization> customizationHolder = new SimplePropertyValueModel<Customization>(this.customization);
+ this.initialize(customizationHolder);
+
+ this.engageListeners();
+ }
+
+ protected void initialize(PropertyValueModel<Customization> customizationHolder) {
+ this.descriptorCustomizerHolder = this.buildDescriptorCustomizerAA(customizationHolder);
this.descriptorCustomizerListener = this.buildDescriptorCustomizerChangeListener();
- this.descriptorCustomizerHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.descriptorCustomizerListener);
}
// ********** behavior **********
@@ -104,6 +107,14 @@ public class EntityCustomizerProperties extends AbstractModel {
return;
}
+ public void engageListeners() {
+ this.descriptorCustomizerHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.descriptorCustomizerListener);
+ }
+
+ public void disengageListeners() {
+ this.descriptorCustomizerHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.descriptorCustomizerListener);
+ }
+
@Override
public void toString(StringBuilder sb) {
sb.append("name: ");
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java
index 5d8c7077f1..169e26fcf9 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/EntityListComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2007, 2008 Oracle. All rights reserved.
+* Copyright (c) 2007, 2009 Oracle. 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.
@@ -60,7 +60,7 @@ public class EntityListComposite extends Pane<Customization>
@Override
protected void initialize() {
super.initialize();
- entityHolder = this.buildEntityHolder();
+ this.entityHolder = this.buildEntityHolder();
}
@Override
@@ -77,7 +77,7 @@ public class EntityListComposite extends Pane<Customization>
container,
this.buildEntitiesAdapter(),
this.buildEntityCustomizationListHolder(),
- entityHolder,
+ this.entityHolder,
this.buildEntityLabelProvider(),
null // EclipseLinkHelpContextIds.CUSTOMIZATION_ENTITIES
);
@@ -85,22 +85,23 @@ public class EntityListComposite extends Pane<Customization>
// Entity Customization property pane
EntityCustomizationPropertyComposite pane = new EntityCustomizationPropertyComposite(
this,
- entityHolder,
+ this.entityHolder,
container
);
- this.installPaneEnabler(entityHolder, pane);
+ this.installPaneEnabler(this.entityHolder, pane);
}
private AddRemoveListPane.Adapter buildEntitiesAdapter() {
return new AddRemoveListPane.AbstractAdapter() {
public void addNewItem(ObjectListSelectionModel listSelectionModel) {
- addEntities(listSelectionModel);
+ EntityListComposite.this.addEntities(listSelectionModel);
}
public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
Customization customization = getSubject();
for (Object item : listSelectionModel.selectedValues()) {
EntityCustomizerProperties entityCustomization = (EntityCustomizerProperties) item;
+ entityCustomization.disengageListeners();
customization.removeEntity(entityCustomization.getEntityName());
}
}
@@ -118,11 +119,10 @@ public class EntityListComposite extends Pane<Customization>
}
if( ! this.getSubject().entityExists(entityName)) {
- String entity = this.getSubject().addEntity(entityName);
-
+ this.getSubject().addEntity(entityName);
int index = CollectionTools.indexOf(this.getSubject().entities(), entityName);
- EntityCustomizerProperties item = (EntityCustomizerProperties) listSelectionModel.getListModel().getElementAt(index);
- entityHolder.setValue(item);
+ EntityCustomizerProperties entity = (EntityCustomizerProperties) listSelectionModel.getListModel().getElementAt(index);
+ this.entityHolder.setValue(entity);
}
}
}
@@ -195,10 +195,10 @@ public class EntityListComposite extends Pane<Customization>
}
private ListValueModel<EntityCustomizerProperties> buildEntityCustomizationListHolder() {
- return new TransformationListValueModelAdapter<String, EntityCustomizerProperties>(buildEntitiesListHolder()) {
+ return new TransformationListValueModelAdapter<String, EntityCustomizerProperties>(this.buildEntitiesListHolder()) {
@Override
- protected EntityCustomizerProperties transformItem(String item) {
- return new EntityCustomizerProperties(getSubject(), item);
+ protected EntityCustomizerProperties transformItem(String entityName) {
+ return new EntityCustomizerProperties(getSubject(), entityName);
}
};
}

Back to the top