Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authortle2008-11-10 16:35:44 +0000
committertle2008-11-10 16:35:44 +0000
commit619ebd34a4a9ed50503f9ecd390fcfe88b89769b (patch)
treef54d0491d2ebddd2d58562a2c50c11abaa695c05 /jpa
parenta22db5fb4ffeca6d14e528546d60e9876ca5e5bd (diff)
downloadwebtools.dali-619ebd34a4a9ed50503f9ecd390fcfe88b89769b.tar.gz
webtools.dali-619ebd34a4a9ed50503f9ecd390fcfe88b89769b.tar.xz
webtools.dali-619ebd34a4a9ed50503f9ecd390fcfe88b89769b.zip
228083 EclipseLink persistence.xml support eclipselink.profiler property
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Customization.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/EclipseLinkCustomization.java156
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Profiler.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/ProfilerComposite.java315
-rw-r--r--jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java142
5 files changed, 677 insertions, 4 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Customization.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Customization.java
index 306d11ecbf..238f411d7f 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Customization.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Customization.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.eclipselink.core.internal.context.persistence.customizat
import java.util.ListIterator;
import org.eclipse.jpt.core.context.persistence.ClassRef;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnitProperties;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.PersistenceUnitProperties;
/**
@@ -57,7 +58,23 @@ public interface Customization extends PersistenceUnitProperties
// EclipseLink key string
static final String ECLIPSELINK_WEAVING_FETCH_GROUPS = "eclipselink.weaving.fetchgroups";
static final Boolean DEFAULT_WEAVING_FETCH_GROUPS = Boolean.TRUE;
-
+
+ Boolean getDefaultWeavingInternal();
+ Boolean getWeavingInternal();
+ void setWeavingInternal(Boolean newWeavingInternal);
+ static final String WEAVING_INTERNAL_PROPERTY = "weavingInternalProperty";
+ // EclipseLink key string
+ static final String ECLIPSELINK_WEAVING_INTERNAL = "eclipselink.weaving.internal";
+ static final Boolean DEFAULT_WEAVING_INTERNAL = Boolean.TRUE;
+
+ Boolean getDefaultWeavingEager();
+ Boolean getWeavingEager();
+ void setWeavingEager(Boolean newWeavingEager);
+ static final String WEAVING_EAGER_PROPERTY = "weavingEagerProperty";
+ // EclipseLink key string
+ static final String ECLIPSELINK_WEAVING_EAGER = "eclipselink.weaving.eager";
+ static final Boolean DEFAULT_WEAVING_EAGER = Boolean.FALSE;
+
String getDefaultDescriptorCustomizer();
String getDescriptorCustomizer(String entityName);
void setDescriptorCustomizer(String newDescriptorCustomizer, String entityName);
@@ -82,5 +99,15 @@ public interface Customization extends PersistenceUnitProperties
String addEntity(String entity);
void removeEntity(String entity);
static final String ENTITIES_LIST_PROPERTY = "entitiesListProperty";
+
+ String getDefaultProfiler();
+ String getProfiler();
+ void setProfiler(String newProfiler);
+ void setProfiler(Profiler newProfiler);
+ static final String PROFILER_PROPERTY = "profilerProperty";
+ // EclipseLink key string
+ static final String ECLIPSELINK_PROFILER = "eclipselink.profiler";
+ static final String DEFAULT_PROFILER =
+ EclipseLinkPersistenceUnitProperties.getEclipseLinkStringValueOf(Profiler.no_profiler);
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/EclipseLinkCustomization.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/EclipseLinkCustomization.java
index f8a755ba19..f96ccabd5c 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/EclipseLinkCustomization.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/EclipseLinkCustomization.java
@@ -37,7 +37,10 @@ public class EclipseLinkCustomization extends EclipseLinkPersistenceUnitProperti
private Boolean weavingLazy;
private Boolean weavingChangeTracking;
private Boolean weavingFetchGroups;
+ private Boolean weavingInternal;
+ private Boolean weavingEager;
private ArrayList<ClassRef> sessionCustomizers;
+ private String profiler; // storing EclipseLinkStringValue since value can be Profiler or custom class
// key = Entity name ; value = Customizer properties
private Map<String, CustomizerProperties> entitiesCustomizerProperties;
@@ -69,11 +72,17 @@ public class EclipseLinkCustomization extends EclipseLinkPersistenceUnitProperti
this.getBooleanValue(ECLIPSELINK_WEAVING_CHANGE_TRACKING);
this.weavingFetchGroups =
this.getBooleanValue(ECLIPSELINK_WEAVING_FETCH_GROUPS);
+ this.weavingInternal =
+ this.getBooleanValue(ECLIPSELINK_WEAVING_INTERNAL);
+ this.weavingEager =
+ this.getBooleanValue(ECLIPSELINK_WEAVING_EAGER);
this.initializeSessionCustomizersFromPersistenceUnit();
Set<Property> properties =
this.getPropertiesSetWithPrefix(ECLIPSELINK_DESCRIPTOR_CUSTOMIZER);
this.initializeEntitiesCustomizerClass(properties);
+
+ this.profiler = this.getProfilerProtertyValue();
}
private void initializeSessionCustomizersFromPersistenceUnit() {
@@ -110,6 +119,23 @@ public class EclipseLinkCustomization extends EclipseLinkPersistenceUnitProperti
}
}
+ /**
+ * Gets the Profiler property from the persistence unit.
+ */
+ private String getProfilerProtertyValue() {
+
+ Profiler standardProfiler = this.getEnumValue(ECLIPSELINK_PROFILER, Profiler.values());
+ if( ! this.persistenceUnit().containsProperty(ECLIPSELINK_PROFILER)) {
+ return null; // no property found
+ }
+ else if(standardProfiler == null) {
+ return this.getStringValue(ECLIPSELINK_PROFILER); // custom profiler
+ }
+ else {
+ return getEclipseLinkStringValueOf(standardProfiler); // a Profiler
+ }
+ }
+
// ********** behavior **********
/**
* Adds property names key/value pairs, where:
@@ -134,8 +160,17 @@ public class EclipseLinkCustomization extends EclipseLinkPersistenceUnitProperti
ECLIPSELINK_WEAVING_FETCH_GROUPS,
WEAVING_FETCH_GROUPS_PROPERTY);
propertyNames.put(
+ ECLIPSELINK_WEAVING_INTERNAL,
+ WEAVING_INTERNAL_PROPERTY);
+ propertyNames.put(
+ ECLIPSELINK_WEAVING_EAGER,
+ WEAVING_EAGER_PROPERTY);
+ propertyNames.put(
ECLIPSELINK_SESSION_CUSTOMIZER,
SESSION_CUSTOMIZER_PROPERTY);
+ propertyNames.put(
+ ECLIPSELINK_PROFILER,
+ PROFILER_PROPERTY);
// Don't need to initialize propertyNames for:
// descriptorCustomizerProperty
@@ -190,12 +225,21 @@ public class EclipseLinkCustomization extends EclipseLinkPersistenceUnitProperti
else if (aspectName.equals(WEAVING_FETCH_GROUPS_PROPERTY)) {
this.weavingFetchGroupsChanged(event);
}
+ else if (aspectName.equals(WEAVING_INTERNAL_PROPERTY)) {
+ this.weavingInternalChanged(event);
+ }
+ else if (aspectName.equals(WEAVING_EAGER_PROPERTY)) {
+ this.weavingEagerChanged(event);
+ }
else if (aspectName.equals(SESSION_CUSTOMIZER_PROPERTY)) {
this.sessionCustomizersChanged(event);
}
else if (aspectName.equals(DESCRIPTOR_CUSTOMIZER_PROPERTY)) {
this.descriptorCustomizerChanged(event);
}
+ else if (aspectName.equals(PROFILER_PROPERTY)) {
+ this.profilerChanged(event);
+ }
else {
throw new IllegalArgumentException("Illegal event received - property not applicable: " + aspectName);
}
@@ -303,6 +347,56 @@ public class EclipseLinkCustomization extends EclipseLinkPersistenceUnitProperti
return DEFAULT_WEAVING_FETCH_GROUPS;
}
+ // ********** WeavingInternal **********
+ public Boolean getWeavingInternal() {
+ return this.weavingInternal;
+ }
+
+ public void setWeavingInternal(Boolean newWeavingInternal) {
+ Boolean old = this.weavingInternal;
+ this.weavingInternal = newWeavingInternal;
+ this.putProperty(WEAVING_INTERNAL_PROPERTY, newWeavingInternal);
+ this.firePropertyChanged(WEAVING_INTERNAL_PROPERTY, old, newWeavingInternal);
+ }
+
+ private void weavingInternalChanged(PropertyChangeEvent event) {
+ String stringValue = (event.getNewValue() == null) ? null : ((Property) event.getNewValue()).getValue();
+ Boolean newValue = getBooleanValueOf(stringValue);
+
+ Boolean old = this.weavingInternal;
+ this.weavingInternal = newValue;
+ this.firePropertyChanged(event.getAspectName(), old, newValue);
+ }
+
+ public Boolean getDefaultWeavingInternal() {
+ return DEFAULT_WEAVING_INTERNAL;
+ }
+
+ // ********** WeavingEager **********
+ public Boolean getWeavingEager() {
+ return this.weavingEager;
+ }
+
+ public void setWeavingEager(Boolean newWeavingEager) {
+ Boolean old = this.weavingEager;
+ this.weavingEager = newWeavingEager;
+ this.putProperty(WEAVING_EAGER_PROPERTY, newWeavingEager);
+ this.firePropertyChanged(WEAVING_EAGER_PROPERTY, old, newWeavingEager);
+ }
+
+ private void weavingEagerChanged(PropertyChangeEvent event) {
+ String stringValue = (event.getNewValue() == null) ? null : ((Property) event.getNewValue()).getValue();
+ Boolean newValue = getBooleanValueOf(stringValue);
+
+ Boolean old = this.weavingEager;
+ this.weavingEager = newValue;
+ this.firePropertyChanged(event.getAspectName(), old, newValue);
+ }
+
+ public Boolean getDefaultWeavingEager() {
+ return DEFAULT_WEAVING_EAGER;
+ }
+
// ********** SessionCustomizers **********
public ListIterator<ClassRef> sessionCustomizers(){
return new CloneListIterator<ClassRef>(this.sessionCustomizers);
@@ -536,5 +630,67 @@ public class EclipseLinkCustomization extends EclipseLinkPersistenceUnitProperti
this.entitiesCustomizerProperties.remove(entity);
this.fireListChanged(ENTITIES_LIST_PROPERTY);
}
+
+ // ********** Profiler **********
+ /**
+ * Returns Profiler or custom profiler class.
+ *
+ * @return EclipseLink string value for Profiler enum or custom profiler class
+ */
+ public String getProfiler() {
+ return this.profiler;
+ }
+
+ /**
+ * Sets EclipseLink profiler.
+ *
+ * @param newProfiler - Profiler
+ */
+ public void setProfiler(Profiler newProfiler) {
+ if( newProfiler == null) {
+ this.setProfiler_((String) null);
+ return;
+ }
+ this.setProfiler_(getEclipseLinkStringValueOf(newProfiler));
+ }
+
+ /**
+ * Sets EclipseLink profiler or custom profiler.
+ *
+ * @param newProfiler -
+ * Can be a EclipseLink profiler literal or
+ * a fully qualified class name of a custom profiler.
+ */
+ public void setProfiler(String newProfiler) {
+ if( newProfiler == null) {
+ this.setProfiler_((String) null);
+ return;
+ }
+ Profiler profiler = Profiler.getProfilerFor(newProfiler);
+ if(profiler == null) { // custom profiler class
+ this.setProfiler_(newProfiler);
+ }
+ else {
+ this.setProfiler(profiler);
+ }
+ }
+ private void setProfiler_(String newProfiler) {
+ String old = this.profiler;
+ this.profiler = newProfiler;
+ this.putProperty(PROFILER_PROPERTY, newProfiler);
+ this.firePropertyChanged(PROFILER_PROPERTY, old, newProfiler);
+ }
+
+ private void profilerChanged(PropertyChangeEvent event) {
+ String newValue = (event.getNewValue() == null) ? null : ((Property) event.getNewValue()).getValue();
+ String old = this.profiler;
+ this.profiler = newValue;
+ this.firePropertyChanged(event.getAspectName(), old, newValue);
+ }
+
+ public String getDefaultProfiler() {
+ return DEFAULT_PROFILER;
+ }
+
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Profiler.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Profiler.java
new file mode 100644
index 0000000000..123c2345bb
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/customization/Profiler.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization;
+
+/**
+ * Profiler
+ */
+public enum Profiler {
+ dms_performance_profiler,
+ performance_profiler,
+ query_monitor,
+ no_profiler;
+
+ // EclipseLink value string
+ public static final String DMS_PERFORMANCE_PROFILER = "DMSPerformanceProfiler";
+ public static final String PERFORMANCE_PROFILER = "PerformanceProfiler";
+ public static final String QUERY_MONITOR = "QueryMonitor";
+ public static final String NO_PROFILER = "NoProfiler";
+
+ /**
+ * Return the Profiler value corresponding to the given literal.
+ */
+ public static Profiler getProfilerFor(String literal) {
+
+ for( Profiler profiler : Profiler.values()) {
+ if(profiler.toString().equals(literal)) {
+ return profiler;
+ }
+ }
+ return null;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/ProfilerComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/ProfilerComposite.java
new file mode 100644
index 0000000000..aabeeba012
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/persistence/customization/ProfilerComposite.java
@@ -0,0 +1,315 @@
+/*******************************************************************************
+* Copyright (c) 2008 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.
+*
+* Contributors:
+* Oracle - initial API and implementation
+*******************************************************************************/
+package org.eclipse.jpt.eclipselink.ui.internal.persistence.customization;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.core.search.SearchEngine;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Profiler;
+import org.eclipse.jpt.eclipselink.ui.JptEclipseLinkUiPlugin;
+import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.JptUiPlugin;
+import org.eclipse.jpt.ui.internal.JptUiMessages;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.ClassTools;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringConverter;
+import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.SimpleCollectionValueModel;
+import org.eclipse.jpt.utility.internal.model.value.SortedListValueModelAdapter;
+import org.eclipse.jpt.utility.model.value.CollectionValueModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.eclipse.ui.progress.IProgressService;
+
+/**
+ * ProfilerComposite
+ */
+public class ProfilerComposite extends Pane<Customization>
+{
+ /**
+ * Creates a new <code>ProfilerComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public ProfilerComposite(
+ Pane<? extends Customization> parentPane,
+ Composite parent) {
+
+ super(parentPane, parent);
+ }
+
+ private PropertyValueModel<String> buildDefaultProfilerHolder() {
+ return new PropertyAspectAdapter<Customization, String>(this.getSubjectHolder(), Customization.DEFAULT_PROFILER) {
+ @Override
+ protected String buildValue_() {
+ return ProfilerComposite.this.getDefaultValue(subject);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildDefaultProfilerListHolder() {
+ return new PropertyListValueModelAdapter<String>(
+ this.buildDefaultProfilerHolder()
+ );
+ }
+
+ private String buildDisplayString(String profilerName) {
+
+ switch (Profiler.valueOf(profilerName)) {
+ case no_profiler: {
+ return EclipseLinkUiMessages.ProfilerComposite_no_profiler;
+ }
+ case dms_performance_profiler: {
+ return EclipseLinkUiMessages.ProfilerComposite_dms_performance_profiler;
+ }
+ case performance_profiler: {
+ return EclipseLinkUiMessages.ProfilerComposite_performance_profiler;
+ }
+ case query_monitor: {
+ return EclipseLinkUiMessages.ProfilerComposite_query_monitor;
+ }
+ default: {
+ return null;
+ }
+ }
+ }
+
+ private Comparator<String> buildProfilerComparator() {
+ return new Comparator<String>() {
+ public int compare(String profiler1, String profiler2) {
+ profiler1 = buildDisplayString(profiler1);
+ profiler2 = buildDisplayString(profiler2);
+ return Collator.getInstance().compare(profiler1, profiler2);
+ }
+ };
+ }
+
+ private StringConverter<String> buildProfilerConverter() {
+ return new StringConverter<String>() {
+ public String convertToString(String value) {
+ try {
+ Profiler.valueOf(value);
+ value = buildDisplayString(value);
+ }
+ catch (Exception e) {
+ // Ignore since the value is not a Profiler
+ }
+ return value;
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildProfilerHolder() {
+ return new PropertyAspectAdapter<Customization, String>(this.getSubjectHolder(), Customization.PROFILER_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+
+ String name = subject.getProfiler();
+ if (name == null) {
+ name = ProfilerComposite.this.getDefaultValue(subject);
+ }
+ return name;
+ }
+
+ @Override
+ protected void setValue_(String value) {
+
+ if (getDefaultValue(subject).equals(value)) {
+ value = null;
+ }
+ subject.setProfiler(value);
+ }
+ };
+ }
+
+ private ListValueModel<String> buildProfilerListHolder() {
+ ArrayList<ListValueModel<String>> holders = new ArrayList<ListValueModel<String>>(2);
+ holders.add(this.buildDefaultProfilerListHolder());
+ holders.add(this.buildProfilersListHolder());
+ return new CompositeListValueModel<ListValueModel<String>, String>(holders);
+ }
+
+ private Iterator<String> buildProfilers() {
+ return new TransformationIterator<Profiler, String>(CollectionTools.iterator(Profiler.values())) {
+ @Override
+ protected String transform(Profiler next) {
+ return next.name();
+ }
+ };
+ }
+
+ private CollectionValueModel<String> buildProfilersCollectionHolder() {
+ return new SimpleCollectionValueModel<String>(
+ CollectionTools.collection(this.buildProfilers())
+ );
+ }
+
+ private ListValueModel<String> buildProfilersListHolder() {
+ return new SortedListValueModelAdapter<String>(
+ this.buildProfilersCollectionHolder(),
+ this.buildProfilerComparator()
+ );
+ }
+
+ private String getDefaultValue(Customization subject) {
+ String defaultValue = subject.getDefaultProfiler();
+
+ if (defaultValue != null) {
+ return NLS.bind(
+ EclipseLinkUiMessages.PersistenceXmlCustomizationTab_defaultWithOneParam,
+ defaultValue
+ );
+ }
+ else {
+ return EclipseLinkUiMessages.PersistenceXmlCustomizationTab_defaultEmpty;
+ }
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ CCombo combo = this.addProfilerCCombo(container);
+
+ this.addLabeledComposite(
+ container,
+ this.addLeftControl(container),
+ combo.getParent(),
+ this.addBrowseButton(container),
+ null
+ );
+ }
+
+ protected CCombo addProfilerCCombo(Composite container) {
+
+ return this.addEditableCCombo(
+ container,
+ this.buildProfilerListHolder(),
+ this.buildProfilerHolder(),
+ this.buildProfilerConverter()
+ );
+ }
+
+ protected Control addLeftControl(Composite container) {
+ return this.addLabel(container, EclipseLinkUiMessages.PersistenceXmlCustomizationTab_profilerLabel);
+ }
+
+ protected Button addBrowseButton(Composite parent) {
+ return this.addPushButton(
+ parent,
+ EclipseLinkUiMessages.PersistenceXmlCustomizationTab_browse,
+ this.buildBrowseAction()
+ );
+ }
+
+ private Runnable buildBrowseAction() {
+ return new Runnable() {
+ public void run() {
+ promptType();
+ }
+ };
+ }
+
+ protected void promptType() {
+ IType type = this.chooseType();
+
+ if (type != null) {
+ String className = type.getFullyQualifiedName('.');
+ this.getSubject().setProfiler(className);
+ }
+ }
+
+ /**
+ * Prompts the user the Open Type dialog.
+ *
+ * @return Either the selected type or <code>null</code> if the user
+ * cancelled the dialog
+ */
+ protected IType chooseType() {
+
+ IPackageFragmentRoot root = this.getPackageFragmentRoot();
+
+ if (root == null) {
+ return null;
+ }
+
+ IJavaElement[] elements = new IJavaElement[] { root.getJavaProject() };
+ IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ SelectionDialog typeSelectionDialog;
+
+ try {
+ typeSelectionDialog = JavaUI.createTypeDialog(
+ getShell(),
+ service,
+ scope,
+ IJavaElementSearchConstants.CONSIDER_CLASSES,
+ false,
+ this.getClassName() != null ? ClassTools.shortNameForClassNamed(this.getClassName()) : ""
+ );
+ }
+ catch (JavaModelException e) {
+ JptUiPlugin.log(e);
+ return null;
+ }
+
+ typeSelectionDialog.setTitle(JptUiMessages.ClassChooserPane_dialogTitle);
+ typeSelectionDialog.setMessage(JptUiMessages.ClassChooserPane_dialogMessage);
+
+ if (typeSelectionDialog.open() == Window.OK) {
+ return (IType) typeSelectionDialog.getResult()[0];
+ }
+ return null;
+ }
+
+ protected String getClassName() {
+ return this.getSubject().getProfiler();
+ }
+
+ protected IPackageFragmentRoot getPackageFragmentRoot() {
+ IProject project = this.getSubject().getJpaProject().getProject();
+ IJavaProject root = JavaCore.create(project);
+
+ try {
+ return root.getAllPackageFragmentRoots()[0];
+ }
+ catch (JavaModelException e) {
+ JptEclipseLinkUiPlugin.log(e);
+ }
+ return null;
+ }
+} \ No newline at end of file
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java
index ebab933a0d..2d54035539 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/persistence/customization/CustomizationAdapterTests.java
@@ -19,6 +19,7 @@ import org.eclipse.jpt.eclipselink.core.internal.context.persistence.Persistence
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Customization;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.CustomizerProperties;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.EclipseLinkCustomization;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Profiler;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.Weaving;
import org.eclipse.jpt.eclipselink.core.tests.internal.context.persistence.PersistenceUnitTestCase;
import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
@@ -57,6 +58,14 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
public static final Boolean WEAVING_FETCH_GROUPS_TEST_VALUE = false;
public static final Boolean WEAVING_FETCH_GROUPS_TEST_VALUE_2 = ! WEAVING_FETCH_GROUPS_TEST_VALUE;
+ public static final String WEAVING_INTERNAL_KEY = Customization.ECLIPSELINK_WEAVING_INTERNAL;
+ public static final Boolean WEAVING_INTERNAL_TEST_VALUE = false;
+ public static final Boolean WEAVING_INTERNAL_TEST_VALUE_2 = ! WEAVING_INTERNAL_TEST_VALUE;
+
+ public static final String WEAVING_EAGER_KEY = Customization.ECLIPSELINK_WEAVING_EAGER;
+ public static final Boolean WEAVING_EAGER_TEST_VALUE = true;
+ public static final Boolean WEAVING_EAGER_TEST_VALUE_2 = ! WEAVING_EAGER_TEST_VALUE;
+
private static final String SESSION_CUSTOMIZER_KEY = Customization.ECLIPSELINK_SESSION_CUSTOMIZER;
private static final String SESSION_CUSTOMIZER_TEST_VALUE = "java.lang.String";
private static final String SESSION_CUSTOMIZER_TEST_VALUE_2 = "java.lang.Boolean";
@@ -69,6 +78,10 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
public static final String CUSTOMIZER_TEST_VALUE = "acme.sessions.DescriptorCustomizer";
public static final String CUSTOMIZER_TEST_VALUE_2 = "acme.sessions.Customizer";
+ private static final String PROFILER_KEY = Customization.ECLIPSELINK_PROFILER;
+ private static final Profiler PROFILER_TEST_VALUE = Profiler.query_monitor;
+ private static final String PROFILER_TEST_VALUE_2 = "custom.profiler.test";
+
public CustomizationAdapterTests(String name) {
super(name);
}
@@ -83,11 +96,12 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
this.customization.addPropertyChangeListener(Customization.WEAVING_LAZY_PROPERTY, propertyChangeListener);
this.customization.addPropertyChangeListener(Customization.WEAVING_CHANGE_TRACKING_PROPERTY, propertyChangeListener);
this.customization.addPropertyChangeListener(Customization.WEAVING_FETCH_GROUPS_PROPERTY, propertyChangeListener);
+ this.customization.addPropertyChangeListener(Customization.WEAVING_INTERNAL_PROPERTY, propertyChangeListener);
+ this.customization.addPropertyChangeListener(Customization.WEAVING_EAGER_PROPERTY, propertyChangeListener);
this.customization.addPropertyChangeListener(Customization.WEAVING_PROPERTY, propertyChangeListener);
-
this.customization.addPropertyChangeListener(Customization.DESCRIPTOR_CUSTOMIZER_PROPERTY, propertyChangeListener);
-
this.customization.addPropertyChangeListener(Customization.SESSION_CUSTOMIZER_PROPERTY, propertyChangeListener);
+ this.customization.addPropertyChangeListener(Customization.PROFILER_PROPERTY, propertyChangeListener);
ListChangeListener sessionCustomizersChangeListener = this.buildSessionCustomizersChangeListener();
this.customization.addListChangeListener(Customization.SESSION_CUSTOMIZER_LIST_PROPERTY, sessionCustomizersChangeListener);
@@ -102,7 +116,7 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
*/
@Override
protected void populatePu() {
- this.modelPropertiesSizeOriginal = 7;
+ this.modelPropertiesSizeOriginal = 10;
this.propertiesTotal = this.modelPropertiesSizeOriginal + 4; // 4 misc properties
this.modelPropertiesSize = this.modelPropertiesSizeOriginal;
@@ -111,12 +125,15 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
this.persistenceUnitPut(WEAVING_LAZY_KEY, WEAVING_LAZY_TEST_VALUE.toString());
this.persistenceUnitPut(WEAVING_CHANGE_TRACKING_KEY, WEAVING_CHANGE_TRACKING_TEST_VALUE.toString());
this.persistenceUnitPut(WEAVING_FETCH_GROUPS_KEY, WEAVING_FETCH_GROUPS_TEST_VALUE.toString());
+ this.persistenceUnitPut(WEAVING_INTERNAL_KEY, WEAVING_INTERNAL_TEST_VALUE.toString());
+ this.persistenceUnitPut(WEAVING_EAGER_KEY, WEAVING_EAGER_TEST_VALUE.toString());
this.persistenceUnitPut("misc.property.2", "value.2");
this.persistenceUnitPut(SESSION_CUSTOMIZER_KEY, SESSION_CUSTOMIZER_TEST_VALUE.toString());
this.persistenceUnitPut(WEAVING_KEY, WEAVING_TEST_VALUE);
this.persistenceUnitPut("misc.property.3", "value.3");
this.persistenceUnitPut("misc.property.4", "value.4");
this.persistenceUnitPut(CUSTOMIZER_KEY, CUSTOMIZER_TEST_VALUE);
+ this.persistenceUnitPut(PROFILER_KEY, PROFILER_TEST_VALUE);
return;
}
@@ -333,6 +350,42 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
WEAVING_FETCH_GROUPS_TEST_VALUE_2);
}
+ // ********** WeavingInternal tests **********
+ public void testSetWeavingInternal() throws Exception {
+ this.verifyModelInitialized(
+ WEAVING_INTERNAL_KEY,
+ WEAVING_INTERNAL_TEST_VALUE);
+ this.verifySetProperty(
+ WEAVING_INTERNAL_KEY,
+ WEAVING_INTERNAL_TEST_VALUE,
+ WEAVING_INTERNAL_TEST_VALUE_2);
+ }
+
+ public void testAddRemoveWeavingInternal() throws Exception {
+ this.verifyAddRemoveProperty(
+ WEAVING_INTERNAL_KEY,
+ WEAVING_INTERNAL_TEST_VALUE,
+ WEAVING_INTERNAL_TEST_VALUE_2);
+ }
+
+ // ********** WeavingEager tests **********
+ public void testSetWeavingEager() throws Exception {
+ this.verifyModelInitialized(
+ WEAVING_EAGER_KEY,
+ WEAVING_EAGER_TEST_VALUE);
+ this.verifySetProperty(
+ WEAVING_EAGER_KEY,
+ WEAVING_EAGER_TEST_VALUE,
+ WEAVING_EAGER_TEST_VALUE_2);
+ }
+
+ public void testAddRemoveWeavingEager() throws Exception {
+ this.verifyAddRemoveProperty(
+ WEAVING_EAGER_KEY,
+ WEAVING_EAGER_TEST_VALUE,
+ WEAVING_EAGER_TEST_VALUE_2);
+ }
+
// ********** SessionCustomizer tests **********
public void testSetSessionCustomizer() throws Exception {
this.verifyModelInitialized(
@@ -398,6 +451,61 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
CUSTOMIZER_TEST_VALUE,
CUSTOMIZER_TEST_VALUE_2);
}
+
+ // ********** Profiler tests **********
+ public void testSetProfiler() throws Exception {
+ this.verifyModelInitialized(
+ PROFILER_KEY,
+ this.getEclipseLinkStringValueOf(PROFILER_TEST_VALUE)); // model is storing EclipseLinkStringValue
+ // verify set enum value
+ this.verifySetProperty(
+ PROFILER_KEY,
+ PROFILER_TEST_VALUE,
+ PROFILER_TEST_VALUE_2);
+ // verify set custom and literal value
+ this.verifySetProfiler(
+ PROFILER_KEY,
+ PROFILER_TEST_VALUE,
+ PROFILER_TEST_VALUE_2);
+ }
+
+ public void testAddRemoveProfiler() throws Exception {
+ this.verifyAddRemoveProperty(
+ PROFILER_KEY,
+ PROFILER_TEST_VALUE,
+ PROFILER_TEST_VALUE_2);
+ }
+
+ /**
+ * Verifies setting custom profiler and literals.
+ */
+ protected void verifySetProfiler(String elKey, Object testValue1, Object testValue2) throws Exception {
+ Property property = this.persistenceUnit().getProperty(elKey);
+ String propertyName = this.model().propertyIdFor(property);
+ // test set custom profiler.
+ this.clearEvent();
+ this.setProperty(propertyName, testValue2);
+ this.verifyPutProperty(propertyName, testValue2);
+
+ // test set (Profiler) null
+ this.clearEvent();
+ this.customization.setProfiler((Profiler) null);
+ assertFalse(this.persistenceUnit().containsProperty(elKey));
+ this.verifyPutProperty(propertyName, null);
+
+ // test set enum literal
+ this.clearEvent();
+ this.setProperty(propertyName, testValue1.toString());
+ assertTrue(this.persistenceUnit().containsProperty(elKey));
+ this.verifyPutProperty(propertyName, this.getEclipseLinkStringValueOf(testValue1));
+
+ // test set (String) null
+ this.clearEvent();
+ this.customization.setProfiler((String) null);
+ assertFalse(this.persistenceUnit().containsProperty(elKey));
+ this.verifyPutProperty(propertyName, null);
+ }
+
// ****** convenience methods *******
@@ -524,10 +632,20 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
this.customization.setWeavingChangeTracking((Boolean) newValue);
else if (propertyName.equals(Customization.WEAVING_FETCH_GROUPS_PROPERTY))
this.customization.setWeavingFetchGroups((Boolean) newValue);
+ else if (propertyName.equals(Customization.WEAVING_INTERNAL_PROPERTY))
+ this.customization.setWeavingInternal((Boolean) newValue);
+ else if (propertyName.equals(Customization.WEAVING_EAGER_PROPERTY))
+ this.customization.setWeavingEager((Boolean) newValue);
else if (propertyName.equals(Customization.SESSION_CUSTOMIZER_PROPERTY))
this.customization.addSessionCustomizer((String) newValue);
else if (propertyName.equals(Customization.WEAVING_PROPERTY))
this.customization.setWeaving((Weaving) newValue);
+ else if (propertyName.equals(Customization.PROFILER_PROPERTY)) {
+ if (newValue.getClass().isEnum())
+ this.customization.setProfiler((Profiler) newValue);
+ else
+ this.customization.setProfiler((String) newValue);
+ }
else
this.throwMissingDefinition("setProperty", propertyName);
}
@@ -545,6 +663,12 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
modelValue = this.customization.getWeavingChangeTracking();
else if (propertyName.equals(Customization.WEAVING_FETCH_GROUPS_PROPERTY))
modelValue = this.customization.getWeavingFetchGroups();
+ else if (propertyName.equals(Customization.WEAVING_INTERNAL_PROPERTY))
+ modelValue = this.customization.getWeavingInternal();
+ else if (propertyName.equals(Customization.WEAVING_EAGER_PROPERTY))
+ modelValue = this.customization.getWeavingEager();
+ else if (propertyName.equals(Customization.PROFILER_PROPERTY))
+ modelValue = this.customization.getProfiler();
else if (propertyName.equals(Customization.SESSION_CUSTOMIZER_PROPERTY)) {
ListIterator<ClassRef> iterator = this.customization.sessionCustomizers();
if(iterator.hasNext()) {
@@ -557,6 +681,18 @@ public class CustomizationAdapterTests extends PersistenceUnitTestCase
this.throwMissingDefinition("getProperty", propertyName);
return modelValue;
}
+
+ @Override
+ protected void verifyPutProperty(String propertyName, Object expectedValue) throws Exception {
+ Object expectedValue_ = expectedValue;
+ if (propertyName.equals(Customization.PROFILER_PROPERTY)) {
+
+ expectedValue_ = (expectedValue != null && expectedValue.getClass().isEnum()) ?
+ this.getEclipseLinkStringValueOf(PROFILER_TEST_VALUE) : // model is storing EclipseLinkStringValue
+ expectedValue;
+ }
+ super.verifyPutProperty(propertyName, expectedValue_);
+ }
@Override
protected PersistenceUnitProperties model() {

Back to the top