From c89333fb30a55b0f43f5a7a71e7d1db1365c1998 Mon Sep 17 00:00:00 2001 From: tle Date: Thu, 4 Mar 2010 02:54:15 +0000 Subject: 294077 [JPA 2.0] Add validation for usage of EclipseLink entity caching properties --- .../persistence/AbstractPersistenceUnit.java | 12 +++++++--- .../eclipselink_jpa_validation.properties | 5 ++-- .../internal/EclipseLinkJpaValidationMessages.java | 6 +++-- .../persistence/EclipseLinkPersistenceUnit.java | 27 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java index f804ee701f..9c1e269a1a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java @@ -1443,9 +1443,10 @@ public abstract class AbstractPersistenceUnit @Override public void validate(List messages, IReporter reporter) { super.validate(messages, reporter); - validateMappingFiles(messages, reporter); - validateClassRefs(messages, reporter); - validateJarFileRefs(messages, reporter); + this.validateMappingFiles(messages, reporter); + this.validateClassRefs(messages, reporter); + this.validateJarFileRefs(messages, reporter); + this.validateProperties(messages, reporter); } protected void validateMappingFiles(List messages, IReporter reporter) { @@ -1574,6 +1575,11 @@ public abstract class AbstractPersistenceUnit } }; } + + @SuppressWarnings("unused") + protected void validateProperties(List messages, IReporter reporter) { + // do nothing by default + } // ********** misc ********** diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties index 12df2233e2..ad0d3d7f02 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (c) 2008 Oracle. All rights reserved. +# Copyright (c) 2008, 2010 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. @@ -11,4 +11,5 @@ CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED=The @Cache annotation on entity \"{0}\" has both expiry() and expiryTimeOfDay() specified. Only one of the two may be specified CONVERTER_CLASS_IMPLEMENTS_CONVERTER=The converter class \"{0}\" does not implement the org.eclipse.persistence.mappings.converters.Converter interface CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER=The customizer class \"{0}\" does not implement the org.eclipse.persistence.config.DescriptorCustomizer interface -MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE=Multiple object values are specified for the data value \"{0}\" \ No newline at end of file +MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE=Multiple object values are specified for the data value \"{0}\" +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 diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java index 352eaa4aae..460c2485b1 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 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. @@ -21,5 +21,7 @@ public interface EclipseLinkJpaValidationMessages { public static final String CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER = "CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER"; public static final String MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE = "MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE"; - + + public static final String PERSISTENCE_UNIT_LEGACY_ENTITY_CACHING = "PERSISTENCE_UNIT_LEGACY_ENTITY_CACHING"; + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/EclipseLinkPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/EclipseLinkPersistenceUnit.java index 74a5b68cb9..b0d81f3a04 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/EclipseLinkPersistenceUnit.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/persistence/EclipseLinkPersistenceUnit.java @@ -15,6 +15,7 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Set; + import org.eclipse.jpt.core.context.persistence.MappingFileRef; import org.eclipse.jpt.core.context.persistence.Persistence; import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnit; @@ -31,6 +32,8 @@ import org.eclipse.jpt.eclipselink.core.context.persistence.general.GeneralPrope import org.eclipse.jpt.eclipselink.core.context.persistence.logging.Logging; import org.eclipse.jpt.eclipselink.core.context.persistence.options.Options; import org.eclipse.jpt.eclipselink.core.context.persistence.schema.generation.SchemaGeneration; +import org.eclipse.jpt.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages; +import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaValidationMessages; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.caching.EclipseLinkCaching; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.customization.EclipseLinkCustomization; @@ -42,6 +45,8 @@ import org.eclipse.jpt.utility.internal.iterables.ListIterable; import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; +import org.eclipse.wst.validation.internal.provisional.core.IReporter; /** * EclipseLink persistence unit @@ -392,5 +397,27 @@ public class EclipseLinkPersistenceUnit protected void convertersUpdated() { fireListChanged(CONVERTERS_LIST, this.converters); } + + // ********** validation ********** + + @Override + protected void validateProperties(List messages, IReporter reporter) { + + if(this.isJpa2_0Compatible()) { + Iterator properties = this.propertiesWithNamePrefix("eclipselink.cache.type."); //$NON-NLS-1$ + + if(properties.hasNext()) { + Property property = properties.next(); + messages.add( + DefaultEclipseLinkJpaValidationMessages.buildMessage( + IMessage.NORMAL_SEVERITY, + EclipseLinkJpaValidationMessages.PERSISTENCE_UNIT_LEGACY_ENTITY_CACHING, + new String[] {property.getName()}, + this.getPersistenceUnit() + ) + ); + } + } + } } -- cgit v1.2.3