Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornhauge2011-04-19 15:00:35 +0000
committernhauge2011-04-19 15:00:35 +0000
commitaa67fe676fa07b715d55bbcf2eb8a268b4e0cd4b (patch)
treeb3ab5b897215de634b750f86b68c165e62a37ed6
parent721b28a9fca6909fddc48f35ee4217e527b7b12a (diff)
downloadwebtools.dali-aa67fe676fa07b715d55bbcf2eb8a268b4e0cd4b.tar.gz
webtools.dali-aa67fe676fa07b715d55bbcf2eb8a268b4e0cd4b.tar.xz
webtools.dali-aa67fe676fa07b715d55bbcf2eb8a268b4e0cd4b.zip
[330619] [277138] [330619] - Class validation for various EclipseLink Customizers. Patch from Nan.
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/eclipselink_jpa_validation.properties20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java232
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/customization/Customization.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/logging/Logging.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkCustomizer.java61
8 files changed, 397 insertions, 15 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java
index 4052d252da..242cf34075 100644
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java
@@ -13,6 +13,7 @@ import java.io.FileNotFoundException;
import java.util.ArrayList;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IParent;
import org.eclipse.jdt.core.IType;
@@ -273,4 +274,21 @@ public final class JDTTools {
java.sql.Time.class.getName(),
java.sql.Timestamp.class.getName(),
};
+
+ public static boolean classHasPublicZeroArgConstructor(IJavaProject javaProject, String className) {
+ if (javaProject != null && className != null) {
+ IType type = findType(javaProject, className);
+ try {
+ for (IMethod method : type.getMethods()) {
+ if ((method.isConstructor()) && (method.getNumberOfParameters() == 0)
+ && (method.getFlags() == 1)) {
+ return true;
+ }
+ }
+ } catch (JavaModelException ex) {
+ JptCommonCorePlugin.log(ex);
+ }
+ }
+ return false;
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/eclipselink_jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/eclipselink_jpa_validation.properties
index f69280624c..0423a9e310 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/eclipselink_jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/eclipselink_jpa_validation.properties
@@ -14,13 +14,31 @@ CONVERTER_CLASS_DEFINED=The converter class must be defined.
CONVERTER_CLASS_IMPLEMENTS_CONVERTER=The converter class \"{0}\" does not implement the org.eclipse.persistence.mappings.converters.Converter interface
CONVERTER_DUPLICATE_NAME=Duplicate converter \"{0}\" defined in this persistence unit
CONVERTER_NAME_UNDEFINED=Converter is unnamed. All converters require a name.
-CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER=The customizer class \"{0}\" does not implement the org.eclipse.persistence.config.DescriptorCustomizer interface
+DESCRIPTOR_CUSTOMIZER_CLASS_NOT_SPECIFIED=An entity customizer class should be specified
+DESCRIPTOR_CUSTOMIZER_CLASS_NOT_EXIST=The entity customizer class \"{0}\" does not exist on the project classpath
+DESCRIPTOR_CUSTOMIZER_CLASS_NOT_VALID=The entity customizer class \"{0}\" must have a public, zero-argument constructor
+DESCRIPTOR_CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER=The entity customizer class \"{0}\" does not implement the org.eclipse.persistence.config.DescriptorCustomizer interface
+EXCEPTION_HANDLER_CLASS_NOT_SPECIFIED=An exception handler class should be specified
+EXCEPTION_HANDLER_CLASS_NOT_EXIST=The exception handler class \"{0}\" does not exist on the project classpath
+EXCEPTION_HANDLER_CLASS_NOT_VALID=The exception handler class \"{0}\" must have a public, zero-argument constructor
+EXCEPTION_HANDLER_CLASS_IMPLEMENTS_EXCEPTION_HANDLER=The exception handler class \"{0}\" does not implement the org.eclipse.persistence.exceptions.ExceptionHandler interface
ID_MAPPING_UNRESOLVED_CONVERTER_NAME=The specified converter \"{0}\" for mapping \"{1}\" cannot be resolved
MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE=Multiple object values are specified for the data value \"{0}\"
PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE=The persistent field or property for a Version mapping must be of type int, Integer, short, Short, long, Long, or Timestamp
PERSISTENCE_UNIT_LEGACY_DESCRIPTOR_CUSTOMIZER=\"{0}\" is a legacy descriptor customizer property. Consider migration to the EclipseLink customizer settings via annotation or XML mapping file
PERSISTENCE_UNIT_LEGACY_ENTITY_CACHING=\"{0}\" is a legacy entity caching property. Consider migration to JPA 2.0 and EclipseLink cache settings via annotation or XML mapping file
PERSISTENCE_UNIT_CACHING_PROPERTY_IGNORED=Property \"{0}\" will be ignored as shared-cache-mode is set to NONE
+SESSION_CUSTOMIZER_CLASS_NOT_SPECIFIED=A session customizer class should be specified
+SESSION_CUSTOMIZER_CLASS_NOT_EXIST=The session customizer class \"{0}\" does not exist on the project classpath
+SESSION_CUSTOMIZER_CLASS_NOT_VALID=The session customizer class \"{0}\" must have a public, zero-argument constructor
+SESSION_CUSTOMIZER_CLASS_IMPLEMENTS_SESSION_CUSTOMIZER=The session customizer class \"{0}\" does not implement the org.eclipse.persistence.config.SessionCustomizer interface
+SESSION_LOGGER_CLASS_NOT_SPECIFIED=A session logger class should be specified
+SESSION_LOGGER_CLASS_NOT_EXIST=The session logger class \"{0}\" does not exist on the project classpath
+SESSION_LOGGER_CLASS_IMPLEMENTS_SESSION_LOG=The session logger class \"{0}\" does not implement the org.eclipse.persistence.logging.SessionLog interface
+SESSION_PROFILER_CLASS_NOT_SPECIFIED=A session profiler class should be specified
+SESSION_PROFILER_CLASS_NOT_EXIST=The session profiler class \"{0}\" does not exist on the project classpath
+SESSION_PROFILER_CLASS_NOT_VALID=The session profiler class \"{0}\" must have a public, zero-argument constructor
+SESSION_PROFILER_CLASS_IMPLEMENTS_SESSION_PROFILER=The session profiler class \"{0}\" does not implement the org.eclipse.persistence.sessions.SessionProfiler interface
BASIC_COLLECTION_MAPPING_DEPRECATED=The type basic-collection is deprecated
BASIC_MAP_MAPPING_DEPRECATED=The type basic-map is deprecated
TYPE_MAPPING_MEMBER_CLASS_NOT_STATIC=The java class for mapped type \"{0}\" is a non-static member class
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
index 1a48663bba..9f564eba2a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
@@ -15,10 +15,14 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.Vector;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.common.core.internal.utility.JDTTools;
+import org.eclipse.jpt.common.utility.internal.ArrayTools;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.NotNullFilter;
+import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.common.utility.internal.iterables.CompositeListIterable;
import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
@@ -424,6 +428,10 @@ public class EclipseLinkPersistenceUnit
this.validateDefaultCachingProperty(this.getCacheTypeDefaultProperty(), messages);
this.validateDefaultCachingProperty(this.getCacheSizeDefaultProperty(), messages);
this.validateDefaultCachingProperty(this.getFlushClearCacheProperty(), messages);
+ this.validateLoggerProperty(this.getLoggerProperty(), messages);
+ this.validateExceptionHandlerProperty(this.getExceptionHandlerProperty(), messages);
+ this.validatePerformanceProfilerProperty(this.getPerformanceProfilerProperty(), messages);
+ this.validateSessionCustomizerProperty(this.getSessionCustomizerProperties(), messages);
}
}
@@ -443,6 +451,212 @@ public class EclipseLinkPersistenceUnit
}
}
}
+
+ protected void validateLoggerProperty(Property loggerProperty, List<IMessage> messages) {
+ if ((loggerProperty == null) || (loggerProperty.getValue() == null) ) {
+ return;
+ }
+
+ if (ArrayTools.contains(Logging.RESERVED_LOGGER_NAMES, loggerProperty.getValue())) {
+ return;
+ }
+
+ IJavaProject javaProject = getJpaProject().getJavaProject();
+ if (StringTools.stringIsEmpty(loggerProperty.getValue())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_LOGGER_CLASS_NOT_SPECIFIED,
+ new String[] {},
+ this.getPersistenceUnit(),
+ loggerProperty.getValidationTextRange()
+ )
+ );
+ } else if (JDTTools.findType(javaProject, loggerProperty.getValue()) == null) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_LOGGER_CLASS_NOT_EXIST,
+ new String[] {loggerProperty.getValue()},
+ this.getPersistenceUnit(),
+ loggerProperty.getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.typeNamedImplementsInterfaceNamed(
+ javaProject, loggerProperty.getValue(), Logging.ECLIPSELINK_LOGGER_CLASS_NAME)
+ ) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_LOGGER_CLASS_IMPLEMENTS_SESSION_LOG,
+ new String[] {loggerProperty.getValue()},
+ this.getPersistenceUnit(),
+ loggerProperty.getValidationTextRange()
+ )
+ );
+ }
+ }
+
+ private void validateExceptionHandlerProperty(Property handlerProperty, List<IMessage> messages) {
+ if ((handlerProperty == null) || (handlerProperty.getValue() == null) ) {
+ return;
+ }
+
+ IJavaProject javaProject = getJpaProject().getJavaProject();
+ if (StringTools.stringIsEmpty(handlerProperty.getValue())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.EXCEPTION_HANDLER_CLASS_NOT_SPECIFIED,
+ new String[] {},
+ this.getPersistenceUnit(),
+ handlerProperty.getValidationTextRange()
+ )
+ );
+ } else if (JDTTools.findType(javaProject, handlerProperty.getValue()) == null) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.EXCEPTION_HANDLER_CLASS_NOT_EXIST,
+ new String[] {handlerProperty.getValue()},
+ this.getPersistenceUnit(),
+ handlerProperty.getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, handlerProperty.getValue())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.EXCEPTION_HANDLER_CLASS_NOT_VALID,
+ new String[] {handlerProperty.getValue()},
+ this.getPersistenceUnit(),
+ handlerProperty.getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.typeNamedImplementsInterfaceNamed(
+ javaProject, handlerProperty.getValue(), Customization.ECLIPSELINK_EXCEPTION_HANDLER_CLASS_NAME)
+ ) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.EXCEPTION_HANDLER_CLASS_IMPLEMENTS_EXCEPTION_HANDLER,
+ new String[] {handlerProperty.getValue()},
+ this.getPersistenceUnit(),
+ handlerProperty.getValidationTextRange()
+ )
+ );
+ }
+ }
+
+ private void validatePerformanceProfilerProperty(Property profilerProperty, List<IMessage> messages) {
+
+ if ((profilerProperty == null) || (profilerProperty.getValue() == null) ) {
+ return;
+ }
+
+ if (ArrayTools.contains(Customization.RESERVED_PROFILER_NAMES, profilerProperty.getValue())) {
+ return;
+ }
+
+ IJavaProject javaProject = getJpaProject().getJavaProject();
+ if (StringTools.stringIsEmpty(profilerProperty.getValue())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_PROFILER_CLASS_NOT_SPECIFIED,
+ new String[] {},
+ this.getPersistenceUnit(),
+ profilerProperty.getValidationTextRange()
+ )
+ );
+ } else if (JDTTools.findType(javaProject, profilerProperty.getValue()) == null) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_PROFILER_CLASS_NOT_EXIST,
+ new String[] {profilerProperty.getValue()},
+ this.getPersistenceUnit(),
+ profilerProperty.getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, profilerProperty.getValue())){
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_PROFILER_CLASS_NOT_VALID,
+ new String[] {profilerProperty.getValue()},
+ this.getPersistenceUnit(),
+ profilerProperty.getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.typeNamedImplementsInterfaceNamed(
+ javaProject, profilerProperty.getValue(), Customization.ECLIPSELINK_SESSION_PROFILER_CLASS_NAME)
+ ) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_PROFILER_CLASS_IMPLEMENTS_SESSIONP_ROFILER,
+ new String[] {profilerProperty.getValue()},
+ this.getPersistenceUnit(),
+ profilerProperty.getValidationTextRange()
+ )
+ );
+ }
+ }
+
+ private void validateSessionCustomizerProperty( Iterable<Property> properties, List<IMessage> messages) {
+ for (Property property : properties) {
+ if (property.getValue() == null) {
+ return;
+ }
+
+ IJavaProject javaProject = getJpaProject().getJavaProject();
+ if (StringTools.stringIsEmpty(property.getValue())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_CUSTOMIZER_CLASS_NOT_SPECIFIED,
+ new String[] {},
+ this.getPersistenceUnit(),
+ property.getValidationTextRange()
+ )
+ );
+ } else if (JDTTools.findType(javaProject, property.getValue()) == null) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_CUSTOMIZER_CLASS_NOT_EXIST,
+ new String[] {property.getValue()},
+ this.getPersistenceUnit(),
+ property.getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, property.getValue())){
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_CUSTOMIZER_CLASS_NOT_VALID,
+ new String[] {property.getValue()},
+ this.getPersistenceUnit(),
+ property.getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.typeNamedImplementsInterfaceNamed(
+ javaProject, property.getValue(), Customization.ECLIPSELINK_SESSION_CUSTOMIZER_CLASS_NAME)
+ ) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.SESSION_CUSTOMIZER_CLASS_IMPLEMENTS_SESSION_CUSTOMIZER,
+ new String[] {property.getValue()},
+ this.getPersistenceUnit(),
+ property.getValidationTextRange()
+ )
+ );
+ }
+ }
+ }
+
protected ArrayList<Property> getLegacyDescriptorCustomizerProperties() {
ArrayList<Property> result = new ArrayList<Property>();
@@ -512,6 +726,24 @@ public class EclipseLinkPersistenceUnit
};
}
+ private Property getLoggerProperty() {
+ return this.getProperty(Logging.ECLIPSELINK_LOGGER);
+ }
+
+ private Property getExceptionHandlerProperty() {
+ return this.getProperty(Customization.ECLIPSELINK_EXCEPTION_HANDLER);
+ }
+
+ private Property getPerformanceProfilerProperty() {
+ return this.getProperty(Customization.ECLIPSELINK_PROFILER);
+ }
+
+ /**
+ * Returns all Session Customizer Properties.
+ */
+ private Iterable<Property> getSessionCustomizerProperties() {
+ return CollectionTools.iterable(this.propertiesWithNamePrefix(Customization.ECLIPSELINK_SESSION_CUSTOMIZER));
+ }
// ********** refactoring **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/customization/Customization.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/customization/Customization.java
index 621404b996..642df24ec6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/customization/Customization.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/customization/Customization.java
@@ -93,6 +93,7 @@ public interface Customization extends PersistenceUnitProperties
static final String SESSION_CUSTOMIZER_PROPERTY = "sessionCustomizer"; //$NON-NLS-1$
// EclipseLink key string
static final String ECLIPSELINK_SESSION_CUSTOMIZER = "eclipselink.session.customizer"; //$NON-NLS-1$
+ String ECLIPSELINK_SESSION_CUSTOMIZER_CLASS_NAME = "org.eclipse.persistence.config.SessionCustomizer"; //$NON-NLS-1$
ListIterator<Entity> entities();
Iterator<String> entityNames();
@@ -111,6 +112,7 @@ public interface Customization extends PersistenceUnitProperties
static final String ECLIPSELINK_PROFILER = "eclipselink.profiler"; //$NON-NLS-1$
static final String DEFAULT_PROFILER =
AbstractPersistenceUnitProperties.getPropertyStringValueOf(Profiler.no_profiler);
+ static final String[] RESERVED_PROFILER_NAMES = {Profiler.NO_PROFILER, Profiler.PERFORMANCE_PROFILER, Profiler.QUERY_MONITOR};
String ECLIPSELINK_SESSION_PROFILER_CLASS_NAME = "org.eclipse.persistence.sessions.SessionProfiler"; //$NON-NLS-1$
Boolean getDefaultValidationOnly();
@@ -128,7 +130,6 @@ public interface Customization extends PersistenceUnitProperties
// EclipseLink key string
static final String ECLIPSELINK_EXCEPTION_HANDLER = "eclipselink.exception-handler"; //$NON-NLS-1$
static final String DEFAULT_EXCEPTION_HANDLER = null; // no default
-
String ECLIPSELINK_EXCEPTION_HANDLER_CLASS_NAME = "org.eclipse.persistence.exceptions.ExceptionHandler"; //$NON-NLS-1$
Boolean getDefaultValidateSchema();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/logging/Logging.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/logging/Logging.java
index 3ac4b38a78..a74c3cd581 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/logging/Logging.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/logging/Logging.java
@@ -74,5 +74,6 @@ public interface Logging extends PersistenceUnitProperties
static final String ECLIPSELINK_LOGGER = "eclipselink.logging.logger"; //$NON-NLS-1$
static final String DEFAULT_LOGGER =
AbstractPersistenceUnitProperties.getPropertyStringValueOf(Logger.default_logger);
+ static final String[] RESERVED_LOGGER_NAMES = {Logger.DEFAULT_LOGGER, Logger.JAVA_LOGGER, Logger.SERVER_LOGGER};
String ECLIPSELINK_LOGGER_CLASS_NAME = "org.eclipse.persistence.logging.SessionLog"; //$NON-NLS-1$
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java
index 3eac43e2a0..d378e2ca4f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java
@@ -26,7 +26,21 @@ public interface EclipseLinkJpaValidationMessages {
public static final String CONVERTER_CLASS_DEFINED = "CONVERTER_CLASS_DEFINED";
- public static final String CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER = "CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER";
+ public static final String DESCRIPTOR_CUSTOMIZER_CLASS_NOT_SPECIFIED = "DESCRIPTOR_CUSTOMIZER_CLASS_NOT_SPECIFIED";
+
+ public static final String DESCRIPTOR_CUSTOMIZER_CLASS_NOT_EXIST = "DESCRIPTOR_CUSTOMIZER_CLASS_NOT_EXIST";
+
+ public static final String DESCRIPTOR_CUSTOMIZER_CLASS_NOT_VALID = "DESCRIPTOR_CUSTOMIZER_CLASS_NOT_VALID";
+
+ public static final String DESCRIPTOR_CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER = "DESCRIPTOR_CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER";
+
+ public static final String EXCEPTION_HANDLER_CLASS_NOT_SPECIFIED = "EXCEPTION_HANDLER_CLASS_NOT_SPECIFIED";
+
+ public static final String EXCEPTION_HANDLER_CLASS_NOT_EXIST = "EXCEPTION_HANDLER_CLASS_NOT_EXIST";
+
+ public static final String EXCEPTION_HANDLER_CLASS_NOT_VALID = "EXCEPTION_HANDLER_CLASS_NOT_VALID";
+
+ public static final String EXCEPTION_HANDLER_CLASS_IMPLEMENTS_EXCEPTION_HANDLER = "EXCEPTION_HANDLER_CLASS_IMPLEMENTS_EXCEPTION_HANDLER";
public static final String ID_MAPPING_UNRESOLVED_CONVERTER_NAME = "ID_MAPPING_UNRESOLVED_CONVERTER_NAME";
@@ -40,6 +54,28 @@ public interface EclipseLinkJpaValidationMessages {
public static final String PERSISTENCE_UNIT_CACHING_PROPERTY_IGNORED = "PERSISTENCE_UNIT_CACHING_PROPERTY_IGNORED";
+ public static final String SESSION_CUSTOMIZER_CLASS_NOT_SPECIFIED = "SESSION_CUSTOMIZER_CLASS_NOT_SPECIFIED";
+
+ public static final String SESSION_CUSTOMIZER_CLASS_NOT_EXIST = "SESSION_CUSTOMIZER_CLASS_NOT_EXIST";
+
+ public static final String SESSION_CUSTOMIZER_CLASS_NOT_VALID = "SESSION_CUSTOMIZER_CLASS_NOT_VALID";
+
+ public static final String SESSION_CUSTOMIZER_CLASS_IMPLEMENTS_SESSION_CUSTOMIZER = "SESSION_CUSTOMIZER_CLASS_IMPLEMENTS_SESSION_CUSTOMIZER";
+
+ public static final String SESSION_LOGGER_CLASS_NOT_SPECIFIED = "SESSION_LOGGER_CLASS_NOT_SPECIFIED";
+
+ public static final String SESSION_LOGGER_CLASS_NOT_EXIST = "SESSION_LOGGER_CLASS_NOT_EXIST";
+
+ public static final String SESSION_LOGGER_CLASS_IMPLEMENTS_SESSION_LOG = "SESSION_LOGGER_CLASS_IMPLEMENTS_SESSION_LOG";
+
+ public static final String SESSION_PROFILER_CLASS_NOT_SPECIFIED = "SESSION_PROFILER_CLASS_NOT_SPECIFIED";
+
+ public static final String SESSION_PROFILER_CLASS_NOT_EXIST = "SESSION_PROFILER_CLASS_NOT_EXIST";
+
+ public static final String SESSION_PROFILER_CLASS_NOT_VALID = "SESSION_PROFILER_CLASS_NOT_VALID";
+
+ public static final String SESSION_PROFILER_CLASS_IMPLEMENTS_SESSIONP_ROFILER = "SESSION_PROFILER_CLASS_IMPLEMENTS_SESSION_PROFILER";
+
public static final String BASIC_COLLECTION_MAPPING_DEPRECATED = "BASIC_COLLECTION_MAPPING_DEPRECATED";
public static final String BASIC_MAP_MAPPING_DEPRECATED = "BASIC_MAP_MAPPING_DEPRECATED";
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java
index 3af1df0890..06619379e5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java
@@ -10,7 +10,9 @@
package org.eclipse.jpt.jpa.eclipselink.core.internal.context.java;
import java.util.List;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
@@ -159,21 +161,34 @@ public class JavaEclipseLinkCustomizer
@Override
public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
super.validate(messages, reporter, astRoot);
- this.validateConverterClass(messages, astRoot);
+ this.validateCustomizerClass(messages, reporter, astRoot);
}
- protected void validateConverterClass(List<IMessage> messages, CompilationUnit astRoot) {
+ protected void validateCustomizerClass(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ IJavaProject javaProject = getPersistenceUnit().getJpaProject().getJavaProject();
EclipseLinkCustomizerAnnotation annotation = this.getCustomizerAnnotation();
- if ((annotation != null) && ! annotation.customizerClassImplementsInterface(ECLIPSELINK_DESCRIPTOR_CUSTOMIZER_CLASS_NAME, astRoot)) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- EclipseLinkJpaValidationMessages.CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER,
- new String[] {this.getCustomizerClass()},
- this,
- this.getCustomizerClassTextRange(astRoot)
- )
- );
+ if (annotation != null && annotation.getValue() != null) {
+ if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, this.getFullyQualifiedCustomizerClass())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.DESCRIPTOR_CUSTOMIZER_CLASS_NOT_VALID,
+ new String[] {this.getFullyQualifiedCustomizerClass()},
+ this,
+ this.getCustomizerClassTextRange(astRoot)
+ )
+ );
+ } else if (!annotation.customizerClassImplementsInterface(ECLIPSELINK_DESCRIPTOR_CUSTOMIZER_CLASS_NAME, astRoot)) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.DESCRIPTOR_CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER,
+ new String[] {this.getFullyQualifiedCustomizerClass()},
+ this,
+ this.getCustomizerClassTextRange(astRoot)
+ )
+ );
+ }
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkCustomizer.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkCustomizer.java
index d82bc2071f..6dfc70fac2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkCustomizer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkCustomizer.java
@@ -9,12 +9,18 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
+import java.util.List;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
@@ -24,6 +30,8 @@ import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomizer;
import org.eclipse.jpt.jpa.eclipselink.core.context.java.EclipseLinkJavaTypeMapping;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmTypeMapping;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaValidationMessages;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.JavaEclipseLinkCustomizer;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlCustomizerHolder;
@@ -228,6 +236,59 @@ public class OrmEclipseLinkCustomizer
// ********** validation **********
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ super.validate(messages, reporter);
+ this.validateCustomizerClass(messages, reporter);
+ }
+
+ protected void validateCustomizerClass(List<IMessage> messages, IReporter reporter) {
+ IJavaProject javaProject = getPersistenceUnit().getJpaProject().getJavaProject();
+ if (this.getCustomizerClass() != null) {
+ if (StringTools.stringIsEmpty(this.getCustomizerClass())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.DESCRIPTOR_CUSTOMIZER_CLASS_NOT_SPECIFIED,
+ new String[] {},
+ this,
+ this.getParent().getValidationTextRange()
+ )
+ );
+ } else if (JDTTools.findType(javaProject, this.getCustomizerClass()) == null) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.DESCRIPTOR_CUSTOMIZER_CLASS_NOT_EXIST,
+ new String[] { this.getCustomizerClass()},
+ this,
+ this.getParent().getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, this.getCustomizerClass())) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.DESCRIPTOR_CUSTOMIZER_CLASS_NOT_VALID,
+ new String[] {this.getCustomizerClass()},
+ this,
+ this.getParent().getValidationTextRange()
+ )
+ );
+ } else if (!JDTTools.typeNamedImplementsInterfaceNamed(javaProject, this.getCustomizerClass(), ECLIPSELINK_DESCRIPTOR_CUSTOMIZER_CLASS_NAME)) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.DESCRIPTOR_CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER,
+ new String[] {this.getCustomizerClass()},
+ this,
+ this.getParent().getValidationTextRange()
+ )
+ );
+ }
+ }
+ }
+
public TextRange getValidationTextRange() {
XmlClassReference xmlClassRef = this.getXmlCustomizerClassRef();
return (xmlClassRef == null) ? null : xmlClassRef.getClassNameTextRange();

Back to the top