diff options
author | kmoore | 2008-08-27 18:13:58 +0000 |
---|---|---|
committer | kmoore | 2008-08-27 18:13:58 +0000 |
commit | 5786ce147ab2096243f26c878d5ac95b242a9bcb (patch) | |
tree | 739752b2c73f2e98bdf7ee047f1083233782e3de | |
parent | 50dd99d3f0db35689d9c05ab9e869c16c949a44a (diff) | |
download | webtools.dali-5786ce147ab2096243f26c878d5ac95b242a9bcb.tar.gz webtools.dali-5786ce147ab2096243f26c878d5ac95b242a9bcb.tar.xz webtools.dali-5786ce147ab2096243f26c878d5ac95b242a9bcb.zip |
EclipseLink Java cache expiry support
25 files changed, 1255 insertions, 85 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/.classpath b/jpa/plugins/org.eclipse.jpt.eclipselink.core/.classpath index fb05e003fc..94ec88c86e 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/.classpath +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="property_files"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> <accessrules> diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/build.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.core/build.properties index 81a1ab6b4f..44e34e4b1f 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/build.properties +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/build.properties @@ -10,7 +10,8 @@ ############################################################################### javacSource=1.5 javacTarget=1.5 -source.. = src/ +source.. = src/,\ + property_files/ output.. = bin/ bin.includes = .,\ META-INF/,\ 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 new file mode 100644 index 0000000000..e3473e7197 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties @@ -0,0 +1,11 @@ +################################################################################ +# 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 +################################################################################ + +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."}, diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkCaching.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkCaching.java index c859249ac3..5cd4808469 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkCaching.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkCaching.java @@ -27,6 +27,10 @@ public interface EclipseLinkCaching extends JpaContextNode { //***************** shared ************************ + /** + * This is the combination of defaultShared and specifiedShared. + * If getSpecifiedShared() returns null, then return getDefaultShared() + */ Boolean getShared(); Boolean getDefaultShared(); @@ -47,6 +51,10 @@ public interface EclipseLinkCaching extends JpaContextNode //***************** cache type ************************ + /** + * This is the combination of defaultType and specifiedType. + * If getSpecifiedType() returns null, then return getDefaultType() + */ CacheType getType(); CacheType getDefaultType(); @@ -59,19 +67,27 @@ public interface EclipseLinkCaching extends JpaContextNode //***************** size ************************ - + + /** + * This is the combination of defaultSize and specifiedSize. + * If getSpecifiedSize() returns null, then return getDefaultSize() + */ Integer getSize(); Integer getDefaultSize(); - Integer DEFAULT_SIZE = Integer.valueOf(100); + Integer DEFAULT_SIZE = Integer.valueOf(100); String DEFAULT_SIZE_PROPERTY = "defaultSizeProperty"; Integer getSpecifiedSize(); void setSpecifiedSize(Integer newSpecifiedSize); String SPECIFIED_SIZE_PROPERTY = "spcifiedSizeProperty"; - //***************** always refresh ************************ + //***************** always refresh ************************ + /** + * This is the combination of defaultAlwaysRefresh and specifiedAlwaysRefresh. + * If getSpecifiedAlwaysRefresh() returns null, then return getDefaultAlwaysRefresh() + */ Boolean getAlwaysRefresh(); Boolean getDefaultAlwaysRefresh(); @@ -85,6 +101,10 @@ public interface EclipseLinkCaching extends JpaContextNode //***************** refresh only if newer ************************ + /** + * This is the combination of defaultRefreshOnlyIfNewer and specifiedRefreshOnlyIfNewer. + * If getSpecifiedRefreshOnlyIfNewer() returns null, then return getDefaultRefreshOnlyIfNewer() + */ Boolean getRefreshOnlyIfNewer(); Boolean getDefaultRefreshOnlyIfNewer(); @@ -98,6 +118,10 @@ public interface EclipseLinkCaching extends JpaContextNode //***************** disable hits ************************ + /** + * This is the combination of defaultDisableHits and specifiedDisableHits. + * If getSpecifiedDisableHits() returns null, then return getDefaultDisableHits() + */ Boolean getDisableHits(); Boolean getDefaultDisableHits(); @@ -111,6 +135,10 @@ public interface EclipseLinkCaching extends JpaContextNode //***************** coordination type ************************ + /** + * This is the combination of defaultCoordinationType and specifiedCoordinationType. + * If getSpecifiedCoordinationType() returns null, then return getDefaultCoordinationType() + */ CacheCoordinationType getCoordinationType(); CacheCoordinationType getDefaultCoordinationType(); @@ -124,11 +152,20 @@ public interface EclipseLinkCaching extends JpaContextNode //***************** existence checking ************************ - + /** + * Return true if the existence-checking model object exists. + * Have to have a separate flag for this since the default existence + * type is different depending on whether hasExistenceChecking() returns + * true or false. + */ boolean hasExistenceChecking(); void setExistenceChecking(boolean existenceChecking); String EXISTENCE_CHECKING_PROPERTY = "existenceCheckingProperty"; + /** + * This is the combination of defaultExistenceType and specifiedExistenceType. + * If getSpecifiedExistenceType() returns null, then return getDefaultExistenceType() + */ ExistenceType getExistenceType(); ExistenceType getDefaultExistenceType(); @@ -140,4 +177,40 @@ public interface EclipseLinkCaching extends JpaContextNode void setSpecifiedExistenceType(ExistenceType newSpecifiedExistenceType); String SPECIFIED_EXISTENCE_TYPE_PROPERTY = "specifiedExistenceTypeProperty"; + + //***************** expiry ************************ + + /** + * corresponds to the Cache expiry element. If this returns + * a non-null value then getExpiryTimeOfDay will return null. + * It is not valid to specify both + */ + Integer getExpiry(); + + /** + * Setting this to a non-null value will set timeOfDayExpiry to null + * @param expiry + */ + void setExpiry(Integer expiry); + String EXPIRY_PROPERTY = "expiryProperty"; + + + /** + * corresponds to the Cache expiryTimeOfDay annotation or xml element. + * If this returns a non-null value then getExpiry will return null. + * It is not valid to specify both. + */ + EclipseLinkExpiryTimeOfDay getExpiryTimeOfDay(); + + /** + * Add Cache expiryTimeOfDay annotation or xml element, this will set + * Expiry to null as it is not valid to set both expiry and timeOfDayExpiry + */ + EclipseLinkExpiryTimeOfDay addExpiryTimeOfDay(); + + /** + * Removes the Cache expiryTimeOfDay annotation/xml element + */ + void removeExpiryTimeOfDay(); + String EXPIRY_TIME_OF_DAY_PROPERTY = "expiryTimeOfDayProperty"; } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkExpiryTimeOfDay.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkExpiryTimeOfDay.java new file mode 100644 index 0000000000..2b76403ce6 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkExpiryTimeOfDay.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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.context; + +import org.eclipse.jpt.core.context.JpaContextNode; + +/** + * Corresponds to a TimeOfDay resource model object + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkExpiryTimeOfDay extends JpaContextNode +{ + + Integer getHour(); + void setHour(Integer hour); + String HOUR_PROPERTY = "hourProperty"; + + Integer getMinute(); + void setMinute(Integer minute); + String MINUTE_PROPERTY = "minuteProperty"; + + Integer getSecond(); + void setSecond(Integer second); + String SECOND_PROPERTY = "secondProperty"; + + Integer getMillisecond(); + void setMillisecond(Integer millisecond); + String MILLISECOND_PROPERTY = "millisecondProperty"; + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaCaching.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaCaching.java index ab0a69bccf..22f04ce27d 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaCaching.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaCaching.java @@ -27,7 +27,24 @@ import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; */ public interface EclipseLinkJavaCaching extends EclipseLinkCaching, JavaJpaContextNode { + + /** + * Initialize the EclipseLinkJavaCaching context model object to match the CacheAnnotation + * resource model object. This should be called immediately after object creation. + */ void initialize(JavaResourcePersistentType resourcePersistentType); - void update(JavaResourcePersistentType resourcePersistentType); + /** + * Update the EclipseLinkJavaCaching context model object to match the CacheAnnotation + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ + void update(JavaResourcePersistentType resourcePersistentType); + + + //********* covariant overrides ************ + + EclipseLinkJavaExpiryTimeOfDay getExpiryTimeOfDay(); + + EclipseLinkJavaExpiryTimeOfDay addExpiryTimeOfDay(); + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaEntity.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaEntity.java index 2fafe90cc2..59cbf7df53 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaEntity.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaEntity.java @@ -9,7 +9,14 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.context.java; +import java.util.ListIterator; +import org.eclipse.jpt.core.context.java.JavaAssociationOverride; +import org.eclipse.jpt.core.context.java.JavaAttributeOverride; import org.eclipse.jpt.core.context.java.JavaEntity; +import org.eclipse.jpt.core.context.java.JavaNamedNativeQuery; +import org.eclipse.jpt.core.context.java.JavaNamedQuery; +import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn; +import org.eclipse.jpt.core.context.java.JavaSecondaryTable; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkEntity; /** @@ -28,4 +35,19 @@ public interface EclipseLinkJavaEntity extends EclipseLinkEntity, JavaEntity { EclipseLinkJavaCaching getCaching(); + + // included these to prevent warnings on the implementation + ListIterator<JavaSecondaryTable> secondaryTables(); + ListIterator<JavaSecondaryTable> specifiedSecondaryTables(); + ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns(); + ListIterator<JavaPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns(); + ListIterator<JavaAttributeOverride> attributeOverrides(); + ListIterator<JavaAttributeOverride> specifiedAttributeOverrides(); + ListIterator<JavaAttributeOverride> virtualAttributeOverrides(); + ListIterator<JavaAssociationOverride> associationOverrides(); + ListIterator<JavaAssociationOverride> specifiedAssociationOverrides(); + ListIterator<JavaAssociationOverride> virtualAssociationOverrides(); + ListIterator<JavaNamedQuery> namedQueries(); + ListIterator<JavaNamedNativeQuery> namedNativeQueries(); + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaExpiryTimeOfDay.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaExpiryTimeOfDay.java new file mode 100644 index 0000000000..c181005f93 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/EclipseLinkJavaExpiryTimeOfDay.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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.context.java; + +import org.eclipse.jpt.core.context.java.JavaJpaContextNode; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkExpiryTimeOfDay; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; + +/** + * Corresponds to the TimeOfDay annotation + * + * Provisional API: This interface is part of an interim API that is still + * under development and expected to change significantly before reaching + * stability. It is available at this early stage to solicit feedback from + * pioneering adopters on the understanding that any code that uses this API + * will almost certainly be broken (repeatedly) as the API evolves. + * + * @version 2.1 + * @since 2.1 + */ +public interface EclipseLinkJavaExpiryTimeOfDay extends EclipseLinkExpiryTimeOfDay, JavaJpaContextNode +{ + /** + * Initialize the EclipseLinkJavaExpiryTimeOfDay context model object to match the TimeOfDayAnnotation + * resource model object. This should be called immediately after object creation. + */ + void initialize(TimeOfDayAnnotation timeOfDay); + + /** + * Update the EclipseLinkJavaExpiryTimeOfDay context model object to match the TimeOfDayAnnotation + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ + void update(TimeOfDayAnnotation timeOfDay); + + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java new file mode 100644 index 0000000000..a8198e009f --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2005, 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; + +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import org.eclipse.jpt.core.JptCorePlugin; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.wst.validation.internal.core.Message; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; + +public class DefaultEclipseLinkJpaValidationMessages { + + private static String[] DEFAULT_PARMS = new String[0]; + private static TextRange DEFAULT_TEXT_RANGE = TextRange.Empty.instance(); + + public static IMessage buildMessage( + int severity, String messageId, Object targetObject) { + return buildMessage(severity, messageId, DEFAULT_PARMS, targetObject); + } + + public static IMessage buildMessage( + int severity, String messageId, String[] parms, Object targetObject) { + return buildMessage(severity, messageId, parms, targetObject, DEFAULT_TEXT_RANGE); + } + + public static IMessage buildMessage( + int severity, String messageId, Object targetObject, TextRange textRange) { + return buildMessage(severity, messageId, DEFAULT_PARMS, targetObject, textRange); + } + + public static IMessage buildMessage( + int severity, String messageId, String[] parms, Object targetObject, TextRange textRange) { + IMessage message = new EclipseLinkMessage(EclipseLinkJpaValidationMessages.BUNDLE_NAME, severity, messageId, parms, targetObject); + if (textRange == null) { + //log an exception and then continue without setting location information + //At least the user will still get the validation message and will + //be able to see other validation messages with valid textRanges + JptCorePlugin.log(new IllegalArgumentException("Null text range for message ID: " + messageId)); //$NON-NLS-1$ + } + else { + message.setLineNo(textRange.getLineNumber()); + message.setOffset(textRange.getOffset()); + message.setLength(textRange.getLength()); + } + return message; + } + + + private DefaultEclipseLinkJpaValidationMessages() { + super(); + throw new UnsupportedOperationException(); + } + + /** + * Used so that we can find the resource bundle using this classLoader. + * Otherwise the wst validation message attempts to use the ClassLoader + * of JpaValidator which is in the org.eclipse.jpt.core plugin. + * + * Another way we could potentially solve this is to have a separate + * EclispeLinkJpaValidator and set up the extension points so that + * it only runs against jpaProjects with the EclispeLinkPlatform + * while JpaValidator runs against jpaProjects with the GenericPlatform. + * I am unsure if this is possible + */ + private static class EclipseLinkMessage extends Message { + public EclipseLinkMessage(String aBundleName, int aSeverity, String anId, String[] aParams, Object aTargetObject) { + super(aBundleName, aSeverity, anId, aParams, aTargetObject); + } + + @Override + public ResourceBundle getBundle(Locale locale, ClassLoader classLoader) { + ResourceBundle bundle = null; + try { + bundle = ResourceBundle.getBundle(getBundleName(), locale, getClass().getClassLoader()); + } catch (MissingResourceException e) { + return super.getBundle(locale, classLoader); + } + return bundle; + } + } +} 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 new file mode 100644 index 0000000000..84a73c14e7 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * 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; + +@SuppressWarnings("nls") +public interface EclipseLinkJpaValidationMessages { + + public static final String BUNDLE_NAME = "eclipselink_jpa_validation"; + + public static final String CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED = "CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED"; + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/caching/Caching.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/caching/Caching.java index 697ab70a67..035438bf88 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/caching/Caching.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/caching/Caching.java @@ -21,18 +21,18 @@ public interface Caching extends PersistenceUnitProperties CacheType getDefaultCacheTypeDefault(); CacheType getCacheTypeDefault(); void setCacheTypeDefault(CacheType cacheTypeDefault); - static final String CACHE_TYPE_DEFAULT_PROPERTY = "cacheTypeDefaultProperty"; - // EclipseLink key string - static final String ECLIPSELINK_CACHE_TYPE_DEFAULT = "eclipselink.cache.type.default"; - static final CacheType DEFAULT_CACHE_TYPE_DEFAULT = CacheType.soft_weak; + static final String CACHE_TYPE_DEFAULT_PROPERTY = "cacheTypeDefaultProperty"; + // EclipseLink key string + static final String ECLIPSELINK_CACHE_TYPE_DEFAULT = "eclipselink.cache.type.default"; + static final CacheType DEFAULT_CACHE_TYPE_DEFAULT = CacheType.soft_weak; Integer getDefaultCacheSizeDefault(); Integer getCacheSizeDefault(); void setCacheSizeDefault(Integer cacheSizeDefault); - static final String CACHE_SIZE_DEFAULT_PROPERTY = "cacheSizeDefaultProperty"; - // EclipseLink key string - static final String ECLIPSELINK_CACHE_SIZE_DEFAULT = "eclipselink.cache.size.default"; - static final Integer DEFAULT_CACHE_SIZE_DEFAULT = new Integer(100); + static final String CACHE_SIZE_DEFAULT_PROPERTY = "cacheSizeDefaultProperty"; + // EclipseLink key string + static final String ECLIPSELINK_CACHE_SIZE_DEFAULT = "eclipselink.cache.size.default"; + static final Integer DEFAULT_CACHE_SIZE_DEFAULT = Integer.valueOf(100); Boolean getDefaultSharedCacheDefault(); Boolean getSharedCacheDefault(); @@ -46,26 +46,26 @@ public interface Caching extends PersistenceUnitProperties CacheType getDefaultCacheType(); CacheType getCacheType(String entityName); void setCacheType(CacheType cacheType, String entityName); - static final String CACHE_TYPE_PROPERTY = "cacheTypeProperty"; - // EclipseLink key string - static final String ECLIPSELINK_CACHE_TYPE = "eclipselink.cache.type."; - static final CacheType DEFAULT_CACHE_TYPE = CacheType.soft_weak; + static final String CACHE_TYPE_PROPERTY = "cacheTypeProperty"; + // EclipseLink key string + static final String ECLIPSELINK_CACHE_TYPE = "eclipselink.cache.type."; + static final CacheType DEFAULT_CACHE_TYPE = CacheType.soft_weak; Integer getDefaultCacheSize(); Integer getCacheSize(String entityName); void setCacheSize(Integer cacheSize, String entityName); - static final String CACHE_SIZE_PROPERTY = "cacheSizeProperty"; - // EclipseLink key string - static final String ECLIPSELINK_CACHE_SIZE = "eclipselink.cache.size."; - static final Integer DEFAULT_CACHE_SIZE = new Integer(100); + static final String CACHE_SIZE_PROPERTY = "cacheSizeProperty"; + // EclipseLink key string + static final String ECLIPSELINK_CACHE_SIZE = "eclipselink.cache.size."; + static final Integer DEFAULT_CACHE_SIZE = Integer.valueOf(100); Boolean getDefaultSharedCache(); Boolean getSharedCache(String entityName); void setSharedCache(Boolean sharedCache, String entityName); - static final String SHARED_CACHE_PROPERTY = "sharedCacheProperty"; - // EclipseLink key string - static final String ECLIPSELINK_SHARED_CACHE = "eclipselink.cache.shared."; - static final Boolean DEFAULT_SHARED_CACHE = Boolean.TRUE; + static final String SHARED_CACHE_PROPERTY = "sharedCacheProperty"; + // EclipseLink key string + static final String ECLIPSELINK_SHARED_CACHE = "eclipselink.cache.shared."; + static final Boolean DEFAULT_SHARED_CACHE = Boolean.TRUE; ListIterator<String> entities(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaCachingImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaCachingImpl.java index 00489c5ab2..7deeba51a1 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaCachingImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaCachingImpl.java @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.internal.context.java; +import java.util.List; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.java.JavaTypeMapping; import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; @@ -17,10 +18,16 @@ import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.eclipselink.core.context.CacheCoordinationType; import org.eclipse.jpt.eclipselink.core.context.CacheType; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkExpiryTimeOfDay; import org.eclipse.jpt.eclipselink.core.context.ExistenceType; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaExpiryTimeOfDay; +import org.eclipse.jpt.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages; +import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaValidationMessages; import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceCheckingAnnotation; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode implements EclipseLinkJavaCaching { @@ -38,6 +45,10 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple protected CacheCoordinationType specifiedCoordinationType; + protected Integer expiry; + protected EclipseLinkJavaExpiryTimeOfDay expiryTimeOfDay; + + protected JavaResourcePersistentType resourcePersistentType; public EclipseLinkJavaCachingImpl(JavaTypeMapping parent) { @@ -151,7 +162,10 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple setSpecifiedRefreshOnlyIfNewer(null); setSpecifiedDisableHits(null); setSpecifiedCoordinationType(null); - //TODO expiry set to null as well, when it is supported + setExpiry(null); + if (getExpiryTimeOfDay() != null) { + removeExpiryTimeOfDay(); + } } } @@ -341,6 +355,62 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple firePropertyChanged(SPECIFIED_EXISTENCE_TYPE_PROPERTY, oldSpecifiedExistenceType, newSpecifiedExistenceType); } + public Integer getExpiry() { + return this.expiry; + } + + public void setExpiry(Integer newExpiry) { + Integer oldExpiry = this.expiry; + this.expiry = newExpiry; + getCacheAnnotation().setExpiry(newExpiry); + firePropertyChanged(EXPIRY_PROPERTY, oldExpiry, newExpiry); + if (newExpiry != null && getExpiryTimeOfDay() != null) { + removeExpiryTimeOfDay(); + } + } + + protected void setExpiry_(Integer newExpiry) { + Integer oldExpiry = this.expiry; + this.expiry = newExpiry; + firePropertyChanged(EXPIRY_PROPERTY, oldExpiry, newExpiry); + } + + public EclipseLinkJavaExpiryTimeOfDay getExpiryTimeOfDay() { + return this.expiryTimeOfDay; + } + + public EclipseLinkJavaExpiryTimeOfDay addExpiryTimeOfDay() { + if (this.expiryTimeOfDay != null) { + throw new IllegalStateException("expiryTimeOfDay already exists, use getExpiryTimeOfDay()"); + } + if (this.resourcePersistentType.getAnnotation(getCacheAnnotationName()) == null) { + this.resourcePersistentType.addAnnotation(getCacheAnnotationName()); + } + EclipseLinkJavaExpiryTimeOfDay newExpiryTimeOfDay = new EclipseLinkJavaExpiryTimeOfDayImpl(this); + this.expiryTimeOfDay = newExpiryTimeOfDay; + TimeOfDayAnnotation timeOfDayAnnotation = getCacheAnnotation().addExpiryTimeOfDay(); + newExpiryTimeOfDay.initialize(timeOfDayAnnotation); + firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, null, newExpiryTimeOfDay); + setExpiry(null); + return newExpiryTimeOfDay; + } + + public void removeExpiryTimeOfDay() { + if (this.expiryTimeOfDay == null) { + throw new IllegalStateException("timeOfDayExpiry does not exist"); + } + EclipseLinkExpiryTimeOfDay oldExpiryTimeOfDay = this.expiryTimeOfDay; + this.expiryTimeOfDay = null; + getCacheAnnotation().removeExpiryTimeOfDay(); + firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, oldExpiryTimeOfDay, null); + } + + protected void setExpiryTimeOfDay(EclipseLinkJavaExpiryTimeOfDay newExpiryTimeOfDay) { + EclipseLinkJavaExpiryTimeOfDay oldExpiryTimeOfDay = this.expiryTimeOfDay; + this.expiryTimeOfDay = newExpiryTimeOfDay; + firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, oldExpiryTimeOfDay, newExpiryTimeOfDay); + } + public void initialize(JavaResourcePersistentType resourcePersistentType) { this.resourcePersistentType = resourcePersistentType; initialize(getCacheAnnotation()); @@ -355,6 +425,7 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple this.specifiedRefreshOnlyIfNewer = this.specifiedRefreshOnlyIfNewer(cache); this.specifiedDisableHits = this.specifiedDisableHits(cache); this.specifiedCoordinationType = this.specifiedCoordinationType(cache); + this.initializeExpiry(cache); } protected void initialize(ExistenceCheckingAnnotation existenceChecking) { @@ -363,10 +434,23 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple this.defaultExistenceType = this.caclulateDefaultExistenceType(); } + protected void initializeExpiry(CacheAnnotation cache) { + if (cache.getExpiryTimeOfDay() == null) { + this.expiry = cache.getExpiry(); + } + else { + if (cache.getExpiry() == null) { //handle with validation if both expiry and expiryTimeOfDay are set + this.expiryTimeOfDay = new EclipseLinkJavaExpiryTimeOfDayImpl(this); + this.expiryTimeOfDay.initialize(cache.getExpiryTimeOfDay()); + } + } + } + public void update(JavaResourcePersistentType resourcePersistentType) { this.resourcePersistentType = resourcePersistentType; update(getCacheAnnotation()); update(getExistenceCheckingAnnotation()); + updateExpiry(getCacheAnnotation()); } protected void update(CacheAnnotation cache) { @@ -385,6 +469,25 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple setDefaultExistenceType(caclulateDefaultExistenceType()); } + protected void updateExpiry(CacheAnnotation cache) { + if (cache.getExpiryTimeOfDay() == null) { + setExpiryTimeOfDay(null); + setExpiry_(cache.getExpiry()); + } + else { + if (getExpiryTimeOfDay() != null) { + getExpiryTimeOfDay().update(cache.getExpiryTimeOfDay()); + } + else if (cache.getExpiry() == null){ + setExpiryTimeOfDay(new EclipseLinkJavaExpiryTimeOfDayImpl(this)); + getExpiryTimeOfDay().initialize(cache.getExpiryTimeOfDay()); + } + else { //handle with validation if both expiry and expiryTimeOfDay are set + setExpiryTimeOfDay(null); + } + } + } + protected CacheType specifiedType(CacheAnnotation cache) { return CacheType.fromJavaResourceModel(cache.getType()); } @@ -413,6 +516,10 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple return CacheCoordinationType.fromJavaResourceModel(cache.getCoordinationType()); } + protected Integer expiry(CacheAnnotation cache) { + return cache.getExpiry(); + } + protected ExistenceType specifiedExistenceType(ExistenceCheckingAnnotation existenceChecking) { if (existenceChecking == null) { return null; @@ -426,4 +533,23 @@ public class EclipseLinkJavaCachingImpl extends AbstractJavaJpaContextNode imple return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); } + @Override + public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) { + super.addToMessages(messages, astRoot); + addExpiryMessages(messages, astRoot); + } + + protected void addExpiryMessages(List<IMessage> messages, CompilationUnit astRoot) { + CacheAnnotation cache = getCacheAnnotation(); + if (cache.getExpiry() != null && cache.getExpiryTimeOfDay() != null) { + messages.add( + DefaultEclipseLinkJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + EclipseLinkJpaValidationMessages.CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED, + new String[] {this.getParent().getPersistentType().getName()}, + this, + getValidationTextRange(astRoot)) + ); + } + } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaEntityImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaEntityImpl.java index 3f2a6d51a7..642a292d92 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaEntityImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaEntityImpl.java @@ -9,12 +9,15 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.internal.context.java; +import java.util.List; +import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.internal.context.java.GenericJavaEntity; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.eclipselink.core.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEntity; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; public class EclipseLinkJavaEntityImpl extends GenericJavaEntity implements EclipseLinkJavaEntity { @@ -47,4 +50,12 @@ public class EclipseLinkJavaEntityImpl extends GenericJavaEntity implements Ecli super.initialize(resourcePersistentType); this.eclipseLinkCaching.initialize(resourcePersistentType); } + + //********** Validation ******************************************** + + @Override + public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) { + super.addToMessages(messages, astRoot); + getCaching().addToMessages(messages, astRoot); + } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaExpiryTimeOfDayImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaExpiryTimeOfDayImpl.java new file mode 100644 index 0000000000..759f08ffa4 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaExpiryTimeOfDayImpl.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * 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.java; + +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; +import org.eclipse.jpt.core.utility.TextRange; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaExpiryTimeOfDay; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; + +public class EclipseLinkJavaExpiryTimeOfDayImpl extends AbstractJavaJpaContextNode + implements EclipseLinkJavaExpiryTimeOfDay +{ + + protected Integer hour; + protected Integer minute; + protected Integer second; + protected Integer millisecond; + + protected TimeOfDayAnnotation timeOfDay; + + public EclipseLinkJavaExpiryTimeOfDayImpl(EclipseLinkJavaCaching parent) { + super(parent); + } + + public Integer getHour() { + return this.hour; + } + + public void setHour(Integer newHour) { + Integer oldHour = this.hour; + this.hour = newHour; + this.timeOfDay.setHour(newHour); + firePropertyChanged(HOUR_PROPERTY, oldHour, newHour); + } + + protected void setHour_(Integer newHour) { + Integer oldHour = this.hour; + this.hour = newHour; + firePropertyChanged(HOUR_PROPERTY, oldHour, newHour); + } + + public Integer getMinute() { + return this.minute; + } + + public void setMinute(Integer newMinute) { + Integer oldMinute = this.minute; + this.minute = newMinute; + this.timeOfDay.setMinute(newMinute); + firePropertyChanged(MINUTE_PROPERTY, oldMinute, newMinute); + } + + protected void setMinute_(Integer newMinute) { + Integer oldMinute = this.minute; + this.minute = newMinute; + firePropertyChanged(MINUTE_PROPERTY, oldMinute, newMinute); + } + + public Integer getSecond() { + return this.second; + } + + public void setSecond(Integer newSecond) { + Integer oldSecond = this.second; + this.second = newSecond; + this.timeOfDay.setSecond(newSecond); + firePropertyChanged(SECOND_PROPERTY, oldSecond, newSecond); + } + + protected void setSecond_(Integer newSecond) { + Integer oldSecond = this.second; + this.second = newSecond; + firePropertyChanged(SECOND_PROPERTY, oldSecond, newSecond); + } + + public Integer getMillisecond() { + return this.millisecond; + } + + public void setMillisecond(Integer newMillisecond) { + Integer oldMillisecond = this.millisecond; + this.millisecond = newMillisecond; + this.timeOfDay.setMillisecond(newMillisecond); + firePropertyChanged(MILLISECOND_PROPERTY, oldMillisecond, newMillisecond); + } + + protected void setMillisecond_(Integer newMillisecond) { + Integer oldMillisecond = this.millisecond; + this.millisecond = newMillisecond; + firePropertyChanged(MILLISECOND_PROPERTY, oldMillisecond, newMillisecond); + } + + public TextRange getValidationTextRange(CompilationUnit astRoot) { + return this.timeOfDay.getTextRange(astRoot); + } + + public void initialize(TimeOfDayAnnotation timeOfDay) { + this.timeOfDay = timeOfDay; + this.hour = getHour(timeOfDay); + this.minute = getMinute(timeOfDay); + this.second = getSecond(timeOfDay); + this.millisecond = getMillisecond(timeOfDay); + } + + public void update(TimeOfDayAnnotation timeOfDay) { + this.timeOfDay = timeOfDay; + this.setHour_(getHour(timeOfDay)); + this.setMinute_(getMinute(timeOfDay)); + this.setSecond_(getSecond(timeOfDay)); + this.setMillisecond_(getMillisecond(timeOfDay)); + } + + protected Integer getHour(TimeOfDayAnnotation timeOfDay) { + return timeOfDay.getHour(); + } + + protected Integer getMinute(TimeOfDayAnnotation timeOfDay) { + return timeOfDay.getMinute(); + } + + protected Integer getSecond(TimeOfDayAnnotation timeOfDay) { + return timeOfDay.getSecond(); + } + + protected Integer getMillisecond(TimeOfDayAnnotation timeOfDay) { + return timeOfDay.getMillisecond(); + } +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java index 6c35d46689..5f33a96413 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/CacheImpl.java @@ -150,6 +150,25 @@ public class CacheImpl extends AbstractResourceAnnotation<Type> implements Cache return this.expiryTimeOfDay; } + public TimeOfDayAnnotation addExpiryTimeOfDay() { + if (this.expiryTimeOfDay != null) { + throw new IllegalStateException("ExpiryTimeOfDay element already exists"); + } + this.expiryTimeOfDay = createTimeOfDayAnnotation(); + this.expiryTimeOfDayAdapter.newMarkerAnnotation(); + firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, null, this.expiryTimeOfDay); + return this.expiryTimeOfDay; + } + + public void removeExpiryTimeOfDay() { + if (this.expiryTimeOfDay == null) { + throw new IllegalStateException("No expiryTimeOfDay element exists"); + } + this.expiryTimeOfDay = null; + this.expiryTimeOfDayAdapter.removeAnnotation(); + firePropertyChanged(EXPIRY_TIME_OF_DAY_PROPERTY, this.expiryTimeOfDay, null); + } + protected void setExpiryTimeOfDay(TimeOfDayAnnotation newExpiryTimeOfDay) { TimeOfDayAnnotation oldExpiryTimeOfDay = this.expiryTimeOfDay; this.expiryTimeOfDay = newExpiryTimeOfDay; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java index 2650ac527b..18bf22636e 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/NullCacheAnnotation.java @@ -98,6 +98,14 @@ public class NullCacheAnnotation extends AbstractJavaResourceNode implements Cac return null; } + public TimeOfDayAnnotation addExpiryTimeOfDay() { + return createCacheResource().addExpiryTimeOfDay(); + } + + public void removeExpiryTimeOfDay() { + + } + public Boolean getAlwaysRefresh() { return null; } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java index 8be2ec8cc5..080e85d7b8 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/resource/java/TimeOfDayImpl.java @@ -12,7 +12,6 @@ package org.eclipse.jpt.eclipselink.core.internal.resource.java; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.resource.java.AbstractResourceAnnotation; import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.utility.jdt.NumberIntegerExpressionConverter; import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.resource.java.JavaResourceNode; @@ -166,19 +165,19 @@ public class TimeOfDayImpl extends AbstractResourceAnnotation<Type> implements T // ********** static methods ********** private static DeclarationAnnotationElementAdapter<Integer> buildHourAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__HOUR, NumberIntegerExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__HOUR, false, NumberIntegerExpressionConverter.instance()); } private static DeclarationAnnotationElementAdapter<Integer> buildMinuteAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__MINUTE, NumberIntegerExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__MINUTE, false, NumberIntegerExpressionConverter.instance()); } private static DeclarationAnnotationElementAdapter<Integer> buildSecondAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__SECOND, NumberIntegerExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__SECOND, false, NumberIntegerExpressionConverter.instance()); } private static DeclarationAnnotationElementAdapter<Integer> buildMillisecondAdapter(DeclarationAnnotationAdapter daa) { - return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__MILLISECOND, NumberIntegerExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, EclipseLinkJPA.TIME_OF_DAY__MILLISECOND, false, NumberIntegerExpressionConverter.instance()); } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java index 4f536a2aa7..63348a2fbd 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/java/CacheAnnotation.java @@ -84,6 +84,8 @@ public interface CacheAnnotation extends JavaResourceNode void setExpiry(Integer expiry); String EXPIRY_PROPERTY = "expiryProperty"; + TimeOfDayAnnotation addExpiryTimeOfDay(); + void removeExpiryTimeOfDay(); TimeOfDayAnnotation getExpiryTimeOfDay(); String EXPIRY_TIME_OF_DAY_PROPERTY = "expiryTimeOfDayProperty"; diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties index 53af7896b1..f3ec258dd5 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_mappings.properties @@ -20,7 +20,7 @@ CacheTypeComposite_none = None CacheSizeComposite_size = Size: -CacheCoordinationTypeComposite_label = Coordination Type: +CacheCoordinationTypeComposite_label = Coordination type: CacheCoordinationTypeComposite_send_object_changes = Send Object Changes CacheCoordinationTypeComposite_invalidate_changed_objects = Invalidate Changed Objects CacheCoordinationTypeComposite_send_new_objects_with_changes = Send New Objects with Changes @@ -30,16 +30,24 @@ CachingComposite_sharedLabelDefault = Shared ({0}) CachingComposite_sharedLabel = Shared CachingComposite_advanced = Advanced -AlwaysRefreshComposite_alwaysRefreshDefault = Always Refresh ({0}) -AlwaysRefreshComposite_alwaysRefreshLabel = Always Refresh -RefreshOnlyIfNewerComposite_refreshOnlyIfNewerDefault = Refresh Only if Newer ({0}) -RefreshOnlyIfNewerComposite_refreshOnlyIfNewerLabel = Refresh Only if Newer -DisableHitsComposite_disableHitsDefault = Disable Hits ({0}) -DisableHitsComposite_disableHitsLabel = Disable Hits +AlwaysRefreshComposite_alwaysRefreshDefault = Always refresh ({0}) +AlwaysRefreshComposite_alwaysRefreshLabel = Always refresh +RefreshOnlyIfNewerComposite_refreshOnlyIfNewerDefault = Refresh only if newer ({0}) +RefreshOnlyIfNewerComposite_refreshOnlyIfNewerLabel = Refresh only if newer +DisableHitsComposite_disableHitsDefault = Disable hits ({0}) +DisableHitsComposite_disableHitsLabel = Disable hits -ExistenceCheckingComposite_label = Existence Checking: +ExistenceCheckingComposite_label = Existence checking: ExistenceCheckingComposite_check_cache = Check Cache ExistenceCheckingComposite_check_database = Check Cache then Database ExistenceCheckingComposite_assume_existence = Assume Existence ExistenceCheckingComposite_assume_non_existence = Assume Non-Existence +ExpiryComposite_expirySection = Expiry + +ExpiryComposite_noExpiry = No expiry +ExpiryComposite_timeToLiveExpiry = Time to live expiry +ExpiryComposite_timeToLiveExpiryExpireAfter = Expire after +ExpiryComposite_timeToLiveExpiryMilliseconds = milliseconds +ExpiryComposite_dailyExpiry = Daily expiry +ExpiryComposite_timeOfDayExpiryExpireAt = Expire at
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java index 35b9c3793f..e9fbc96df5 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/EclipseLinkUiMappingsMessages.java @@ -53,7 +53,13 @@ public class EclipseLinkUiMappingsMessages extends NLS { public static String ExistenceCheckingComposite_assume_existence; public static String ExistenceCheckingComposite_assume_non_existence; - + public static String ExpiryComposite_expirySection; + public static String ExpiryComposite_noExpiry; + public static String ExpiryComposite_timeToLiveExpiry; + public static String ExpiryComposite_timeToLiveExpiryExpireAfter; + public static String ExpiryComposite_timeToLiveExpiryMilliseconds; + public static String ExpiryComposite_dailyExpiry; + public static String ExpiryComposite_timeOfDayExpiryExpireAt; static { NLS.initializeMessages("eclipselink_ui_mappings", EclipseLinkUiMappingsMessages.class); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java index 1b1aabdbea..e9624bd54f 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/CachingComposite.java @@ -34,15 +34,21 @@ import org.eclipse.swt.widgets.Composite; * ----------------------------------------------------------------------------- * | x Shared | * | CacheTypeComposite | - * | AlwaysRefreshComposite | - * | RefreshOnlyIfNewerComposite | - * | DisableHitsComposite | + * | CacheSizeComposite | + * | > Advanced | + * | ExpiryComposite | + * | AlwaysRefreshComposite | + * | RefreshOnlyIfNewerComposite | + * | DisableHitsComposite | + * | CacheCoordinationComposite | + * | ExistenceTypeComposite | * -----------------------------------------------------------------------------</pre> * * @see Entity * @see EclipseLinkCaching * @see EclipseLinkJavaEntityComposite - The parent container * @see CacheTypeComposite + * @see CacheSizeComposite * @see AlwaysRefreshComposite * @see RefreshOnlyIfNewerComposite * @see DisableHitsComposite @@ -94,6 +100,7 @@ public class CachingComposite extends FormPane<EclipseLinkCaching> } private void initializeAdvancedPane(Composite container, Collection<Pane<?>> panes) { + panes.add(new ExpiryComposite(this, container));//don't add to panes, will handle its own enablement panes.add(new AlwaysRefreshComposite(this, container)); panes.add(new RefreshOnlyIfNewerComposite(this, container)); panes.add(new DisableHitsComposite(this, container)); @@ -108,6 +115,7 @@ public class CachingComposite extends FormPane<EclipseLinkCaching> } }; } + private WritablePropertyValueModel<Boolean> buildSharedHolder() { return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.SPECIFIED_SHARED_PROPERTY) { @Override diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/ExpiryComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/ExpiryComposite.java new file mode 100644 index 0000000000..bbafb139d5 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/ExpiryComposite.java @@ -0,0 +1,302 @@ +/******************************************************************************* + * 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.mappings.details; + +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCaching; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkExpiryTimeOfDay; +import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages; +import org.eclipse.jpt.ui.internal.util.ControlEnabler; +import org.eclipse.jpt.ui.internal.widgets.FormPane; +import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter; +import org.eclipse.jpt.utility.model.value.PropertyValueModel; +import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DateTime; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Spinner; + +/** + * Here is the layout of this pane: + * <pre> + * ----------------------------------------------------------------------------- + * | - Expiry -------------------------------------------------------------- | | + * | | | | + * | | o No expiry | | + * | | ---------------- | | + * | | o Time to live expiry Expire after | I |I| milliseconds | | + * | | ---------------- | | + * | | -------------------- | | + * | | o Daily expiry Expire at | HH:MM:SS:AM/PM |I| | | + * | | -------------------- | | + * | ------------------------------------------------------------------------- | + * -----------------------------------------------------------------------------</pre> + * + * @see EclipseLinkCaching + * @see EclipseLinkExpiryTimeOfDay + * @see CachingComposite - A container of this widget + * + * @version 2.1 + * @since 2.1 + */ +public class ExpiryComposite extends FormPane<EclipseLinkCaching> { + + public ExpiryComposite(FormPane<? extends EclipseLinkCaching> parentPane, + Composite parent) { + + super(parentPane, parent); + } + + @Override + protected void initializeLayout(Composite container) { + // Expiry group pane + Group expiryGroupPane = addTitledGroup( + container, + EclipseLinkUiMappingsMessages.ExpiryComposite_expirySection, + 2, + null + ); + + // No Expiry radio button + Button button = addRadioButton( + expiryGroupPane, + EclipseLinkUiMappingsMessages.ExpiryComposite_noExpiry, + buildNoExpiryHolder(), + null + ); + GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + button.setLayoutData(gridData); + + + // Time To Live Expiry radio button + addRadioButton( + expiryGroupPane, + EclipseLinkUiMappingsMessages.ExpiryComposite_timeToLiveExpiry, + buildExpiryHolder(), + null + ); + + addTimeToLiveComposite(expiryGroupPane); + + // Daily Expiry radio button + addRadioButton( + expiryGroupPane, + EclipseLinkUiMappingsMessages.ExpiryComposite_dailyExpiry, + buildTimeOfDayExpiryBooleanHolder(), + null + ); + + addTimeOfDayComposite(expiryGroupPane); + } + + protected void addTimeToLiveComposite(Composite parent) { + Composite container = this.addSubPane(parent, 3, 0, 10, 0, 0); + + + Control expireAfterLabel = addUnmanagedLabel( + container, + EclipseLinkUiMappingsMessages.ExpiryComposite_timeToLiveExpiryExpireAfter + ); + + Spinner expirySpinner = addUnmanagedSpinner( + container, + buildTimeToLiveExpiryHolder(), + -1, + -1, + Integer.MAX_VALUE, + null + ); + //a border Container is created in FormWidgetFactory.createSpinner + if (expirySpinner.getParent() != container) { + ((GridData) expirySpinner.getParent().getLayoutData()).grabExcessHorizontalSpace = false; + } + else { + ((GridData) expirySpinner.getLayoutData()).grabExcessHorizontalSpace = false; + } + + Control millisecondsLabel = addUnmanagedLabel( + container, + EclipseLinkUiMappingsMessages.ExpiryComposite_timeToLiveExpiryMilliseconds + ); + + new ControlEnabler(buildTimeToLiveExpiryEnabler(), expireAfterLabel, expirySpinner, millisecondsLabel); + } + + protected void addTimeOfDayComposite(Composite parent) { + Composite container = this.addSubPane(parent, 2, 0, 10, 0, 0); + + + Control expireAtLabel = addUnmanagedLabel( + container, + EclipseLinkUiMappingsMessages.ExpiryComposite_timeOfDayExpiryExpireAt + ); + + PropertyValueModel<EclipseLinkExpiryTimeOfDay> timeOfDayExpiryHolder = buildTimeOfDayExpiryHolder(); + DateTime dateTime = addUnmanagedDateTime( + container, + buildTimeOfDayExpiryHourHolder(timeOfDayExpiryHolder), + buildTimeOfDayExpiryMinuteHolder(timeOfDayExpiryHolder), + buildTimeOfDayExpirySecondHolder(timeOfDayExpiryHolder), + null); + + new ControlEnabler(buildTimeOfDayExpiryEnabler(), expireAtLabel, dateTime); + } + + private WritablePropertyValueModel<Boolean> buildNoExpiryHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>( + getSubjectHolder(), + EclipseLinkCaching.EXPIRY_PROPERTY, + EclipseLinkCaching.EXPIRY_TIME_OF_DAY_PROPERTY) { + @Override + protected Boolean buildValue_() { + return Boolean.valueOf(this.subject.getExpiry() == null && this.subject.getExpiryTimeOfDay() == null); + } + + @Override + protected void setValue_(Boolean value) { + this.subject.setExpiry(null); + if (this.subject.getExpiryTimeOfDay() != null) { + this.subject.removeExpiryTimeOfDay(); + } + } + }; + } + + private WritablePropertyValueModel<Boolean> buildExpiryHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>( + getSubjectHolder(), + EclipseLinkCaching.EXPIRY_PROPERTY) { + @Override + protected Boolean buildValue_() { + return Boolean.valueOf(this.subject.getExpiry() != null); + } + + @Override + protected void setValue_(Boolean value) { + if (value == Boolean.TRUE) { + this.subject.setExpiry(0); + } + } + }; + } + + private WritablePropertyValueModel<Boolean> buildTimeOfDayExpiryBooleanHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>( + getSubjectHolder(), + EclipseLinkCaching.EXPIRY_TIME_OF_DAY_PROPERTY) { + @Override + protected Boolean buildValue_() { + return Boolean.valueOf(this.subject.getExpiryTimeOfDay() != null); + } + + @Override + protected void setValue_(Boolean value) { + if (value == Boolean.TRUE) { + this.subject.addExpiryTimeOfDay(); + } + } + }; + } + + private WritablePropertyValueModel<Integer> buildTimeToLiveExpiryHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, Integer>(getSubjectHolder(), EclipseLinkCaching.EXPIRY_PROPERTY) { + @Override + protected Integer buildValue_() { + return this.subject.getExpiry(); + } + + @Override + protected void setValue_(Integer value) { + if (value == -1) { + value = null; + } + subject.setExpiry(value); + } + }; + } + + private PropertyValueModel<Boolean> buildTimeToLiveExpiryEnabler() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.EXPIRY_PROPERTY) { + @Override + protected Boolean buildValue_() { + return Boolean.valueOf(this.subject.getExpiry() != null); + } + }; + } + + private PropertyValueModel<Boolean> buildTimeOfDayExpiryEnabler() { + return new PropertyAspectAdapter<EclipseLinkCaching, Boolean>(getSubjectHolder(), EclipseLinkCaching.EXPIRY_TIME_OF_DAY_PROPERTY) { + @Override + protected Boolean buildValue_() { + return Boolean.valueOf(this.subject.getExpiryTimeOfDay() != null); + } + }; + } + + private PropertyValueModel<EclipseLinkExpiryTimeOfDay> buildTimeOfDayExpiryHolder() { + return new PropertyAspectAdapter<EclipseLinkCaching, EclipseLinkExpiryTimeOfDay>(getSubjectHolder(), EclipseLinkCaching.EXPIRY_TIME_OF_DAY_PROPERTY) { + @Override + protected EclipseLinkExpiryTimeOfDay buildValue_() { + return this.subject.getExpiryTimeOfDay(); + } + }; + } + + private WritablePropertyValueModel<Integer> buildTimeOfDayExpiryHourHolder(PropertyValueModel<EclipseLinkExpiryTimeOfDay> timeOfDayExpiryHolder) { + return new PropertyAspectAdapter<EclipseLinkExpiryTimeOfDay, Integer>( + timeOfDayExpiryHolder, + EclipseLinkExpiryTimeOfDay.HOUR_PROPERTY) { + @Override + protected Integer buildValue_() { + return this.subject.getHour(); + } + + @Override + protected void setValue_(Integer hour) { + this.subject.setHour(hour); + } + }; + } + + private WritablePropertyValueModel<Integer> buildTimeOfDayExpiryMinuteHolder(PropertyValueModel<EclipseLinkExpiryTimeOfDay> timeOfDayExpiryHolder) { + return new PropertyAspectAdapter<EclipseLinkExpiryTimeOfDay, Integer>( + timeOfDayExpiryHolder, + EclipseLinkExpiryTimeOfDay.MINUTE_PROPERTY) { + @Override + protected Integer buildValue_() { + return this.subject.getMinute(); + } + + @Override + protected void setValue_(Integer minute) { + this.subject.setMinute(minute); + } + }; + } + + private WritablePropertyValueModel<Integer> buildTimeOfDayExpirySecondHolder(PropertyValueModel<EclipseLinkExpiryTimeOfDay> timeOfDayExpiryHolder) { + return new PropertyAspectAdapter<EclipseLinkExpiryTimeOfDay, Integer>( + timeOfDayExpiryHolder, + EclipseLinkExpiryTimeOfDay.SECOND_PROPERTY) { + @Override + protected Integer buildValue_() { + return this.subject.getSecond(); + } + + @Override + protected void setValue_(Integer second) { + this.subject.setSecond(second); + } + }; + } + +} diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java index a5147b8c5d..56dec42f8e 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaCachingTests.java @@ -15,9 +15,11 @@ import org.eclipse.jpt.core.resource.java.JPA; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.eclipselink.core.context.CacheCoordinationType; import org.eclipse.jpt.eclipselink.core.context.CacheType; +import org.eclipse.jpt.eclipselink.core.context.EclipseLinkExpiryTimeOfDay; import org.eclipse.jpt.eclipselink.core.context.ExistenceType; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaCaching; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEntity; +import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaExpiryTimeOfDay; import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; import org.eclipse.jpt.eclipselink.core.resource.java.ExistenceCheckingAnnotation; @@ -48,7 +50,7 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkJavaContextModelTest private void createCacheAnnotation() throws Exception { createCacheTypeEnum(); createCacheCoordinationTypeEnum(); - + createTimeOfDayAnnotation(); this.createAnnotationAndMembers(ECLIPSELINK_ANNOTATIONS_PACKAGE_NAME, "Cache", "CacheType type() default SOFT_WEAK; " + "int size() default 100; " + @@ -61,6 +63,14 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkJavaContextModelTest "CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;"); } + private void createTimeOfDayAnnotation() throws Exception { + this.createAnnotationAndMembers(ECLIPSELINK_ANNOTATIONS_PACKAGE_NAME, "TimeOfDay", + "int hour() default 0; " + + "int minute() default 0; " + + "int second() default 0; " + + "int millisecond() default 0;"); + } + private void createExistenceCheckingAnnotation() throws Exception { createExistenceTypeEnum(); @@ -123,14 +133,14 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkJavaContextModelTest EclipseLinkJavaCaching caching = entity.getCaching(); caching.setSpecifiedType(CacheType.HARD_WEAK); - caching.setSpecifiedSize(new Integer(500)); + caching.setSpecifiedSize(Integer.valueOf(500)); caching.setSpecifiedAlwaysRefresh(Boolean.FALSE); caching.setSpecifiedRefreshOnlyIfNewer(Boolean.FALSE); caching.setSpecifiedDisableHits(Boolean.FALSE); caching.setSpecifiedCoordinationType(CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS); caching.setExistenceChecking(true); caching.setSpecifiedExistenceType(ExistenceType.CHECK_CACHE); - + caching.setExpiry(Integer.valueOf(8000)); caching.setSpecifiedShared(Boolean.FALSE); @@ -140,10 +150,26 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkJavaContextModelTest assertEquals(null, caching.getSpecifiedRefreshOnlyIfNewer()); assertEquals(null, caching.getSpecifiedDisableHits()); assertEquals(null, caching.getSpecifiedCoordinationType()); + assertEquals(null, caching.getExpiry()); + //existence checking is the only thing that isn't unset when shared is set to false assertTrue(caching.hasExistenceChecking()); assertEquals(ExistenceType.CHECK_CACHE, caching.getSpecifiedExistenceType()); + + caching.setSpecifiedShared(null); + EclipseLinkExpiryTimeOfDay timeOfDayExpiry = caching.addExpiryTimeOfDay(); + timeOfDayExpiry.setHour(Integer.valueOf(5)); + + caching.setSpecifiedShared(Boolean.FALSE); + assertNull(caching.getExpiryTimeOfDay()); + + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + + assertEquals(Boolean.FALSE, cacheAnnotation.getShared()); + assertNull(cacheAnnotation.getExpiryTimeOfDay()); } public void testGetSpecifiedShared() throws Exception { @@ -482,4 +508,142 @@ public class EclipseLinkJavaCachingTests extends EclipseLinkJavaContextModelTest assertEquals(ExistenceType.CHECK_CACHE, caching.getExistenceType()); } + public void testGetExpiry() throws Exception { + createTestEntity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaEntity entity = (EclipseLinkJavaEntity) javaPersistentType().getMapping(); + + assertNull(entity.getCaching().getExpiry()); + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.addAnnotation(EclipseLinkJPA.CACHE); + assertNull(entity.getCaching().getExpiry()); + + cacheAnnotation.setExpiry(Integer.valueOf(57)); + + assertEquals(Integer.valueOf(57), entity.getCaching().getExpiry()); + + typeResource.removeAnnotation(EclipseLinkJPA.CACHE); + assertNull(entity.getCaching().getExpiry()); + } + + public void testSetExpiry() throws Exception { + createTestEntity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaEntity entity = (EclipseLinkJavaEntity) javaPersistentType().getMapping(); + EclipseLinkJavaCaching caching = entity.getCaching(); + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + + caching.setExpiry(Integer.valueOf(58)); + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + assertEquals(Integer.valueOf(58), cacheAnnotation.getExpiry()); + + + caching.setExpiry(null); + cacheAnnotation = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + assertNull(cacheAnnotation); + } + + public void testSetExpiryUnsetsExpiryTimeOfDay() throws Exception { + createTestEntity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaEntity entity = (EclipseLinkJavaEntity) javaPersistentType().getMapping(); + EclipseLinkJavaCaching caching = entity.getCaching(); + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + + caching.addExpiryTimeOfDay(); + caching.getExpiryTimeOfDay().setHour(Integer.valueOf(5)); + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + assertEquals(Integer.valueOf(5), cacheAnnotation.getExpiryTimeOfDay().getHour()); + + caching.setExpiry(Integer.valueOf(900)); + + assertNull(caching.getExpiryTimeOfDay()); + assertNull(cacheAnnotation.getExpiryTimeOfDay()); + assertEquals(Integer.valueOf(900), cacheAnnotation.getExpiry()); + assertEquals(Integer.valueOf(900), caching.getExpiry()); + } + + public void testGetTimeOfDayExpiry() throws Exception { + createTestEntity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaEntity entity = (EclipseLinkJavaEntity) javaPersistentType().getMapping(); + EclipseLinkJavaCaching caching = entity.getCaching(); + + assertNull(caching.getExpiryTimeOfDay()); + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.addAnnotation(EclipseLinkJPA.CACHE); + + cacheAnnotation.addExpiryTimeOfDay(); + + assertNotNull(caching.getExpiryTimeOfDay()); + } + + public void testAddTimeOfDayExpiry() throws Exception { + createTestEntity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaEntity entity = (EclipseLinkJavaEntity) javaPersistentType().getMapping(); + EclipseLinkJavaCaching caching = entity.getCaching(); + + assertNull(caching.getExpiryTimeOfDay()); + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaExpiryTimeOfDay timeOfDayExpiry = caching.addExpiryTimeOfDay(); + + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + assertNotNull(cacheAnnotation.getExpiryTimeOfDay()); + assertNotNull(caching.getExpiryTimeOfDay()); + assertEquals(timeOfDayExpiry, caching.getExpiryTimeOfDay()); + } + + public void testRemoveTimeOfDayExpiry() throws Exception { + createTestEntity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaEntity entity = (EclipseLinkJavaEntity) javaPersistentType().getMapping(); + EclipseLinkJavaCaching caching = entity.getCaching(); + + assertNull(caching.getExpiryTimeOfDay()); + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.addAnnotation(EclipseLinkJPA.CACHE); + cacheAnnotation.addExpiryTimeOfDay(); + + assertNotNull(caching.getExpiryTimeOfDay()); + + caching.removeExpiryTimeOfDay(); + assertNull(caching.getExpiryTimeOfDay()); + assertNull(typeResource.getAnnotation(EclipseLinkJPA.CACHE)); + } + + public void testAddTimeOfDayExpiryUnsetsExpiry() throws Exception { + createTestEntity(); + addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME); + + EclipseLinkJavaEntity entity = (EclipseLinkJavaEntity) javaPersistentType().getMapping(); + EclipseLinkJavaCaching caching = entity.getCaching(); + + JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME); + caching.setExpiry(Integer.valueOf(800)); + CacheAnnotation cacheAnnotation = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + assertEquals(Integer.valueOf(800), cacheAnnotation.getExpiry()); + + + caching.addExpiryTimeOfDay(); + + + assertNull(caching.getExpiry()); + assertNull(cacheAnnotation.getExpiry()); + assertNotNull(cacheAnnotation.getExpiryTimeOfDay()); + } + } diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/CacheTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/CacheTests.java index e0ec100c67..9f7240a6ba 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/CacheTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/CacheTests.java @@ -16,6 +16,7 @@ import org.eclipse.jpt.eclipselink.core.resource.java.CacheAnnotation; import org.eclipse.jpt.eclipselink.core.resource.java.CacheCoordinationType; import org.eclipse.jpt.eclipselink.core.resource.java.CacheType; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA; +import org.eclipse.jpt.eclipselink.core.resource.java.TimeOfDayAnnotation; import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; public class CacheTests extends EclipseLinkJavaResourceModelTestCase { @@ -31,11 +32,20 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { private void createCacheCoordinationTypeEnum() throws Exception { this.createEnumAndMembers("CacheCoordinationType", "SEND_OBJECT_CHANGES, INVALIDATE_CHANGED_OBJECTS, SEND_NEW_OBJECTS_WITH_CHANGES, NONE;"); } + + private void createTimeOfDayAnnotation() throws Exception { + + this.createAnnotationAndMembers("TimeOfDay", + "int hour() default 0; " + + "int minute() default 0; " + + "int second() default 0; " + + "int millisecond() default 0;"); + } private void createCacheAnnotation() throws Exception { createCacheTypeEnum(); createCacheCoordinationTypeEnum(); - + createTimeOfDayAnnotation(); this.createAnnotationAndMembers("Cache", "CacheType type() default SOFT_WEAK; " + "int size() default 100; " + @@ -62,7 +72,7 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { }); } - private ICompilationUnit createTestExistenceCheckingWithCacheType() throws Exception { + private ICompilationUnit createTestCacheWithCacheType() throws Exception { createCacheAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -76,7 +86,7 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { }); } - private ICompilationUnit createTestExistenceCheckingWithSize() throws Exception { + private ICompilationUnit createTestCacheWithSize() throws Exception { createCacheAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -90,7 +100,7 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { }); } - private ICompilationUnit createTestExistenceCheckingWithExpiry() throws Exception { + private ICompilationUnit createTestCacheWithExpiry() throws Exception { createCacheAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @Override @@ -104,6 +114,20 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { }); } + private ICompilationUnit createTestCacheWithExpiryTimeOfDay() throws Exception { + createCacheAnnotation(); + return this.createTestType(new DefaultAnnotationWriter() { + @Override + public Iterator<String> imports() { + return new ArrayIterator<String>(EclipseLinkJPA.CACHE, EclipseLinkJPA.TIME_OF_DAY); + } + @Override + public void appendTypeAnnotationTo(StringBuilder sb) { + sb.append("@Cache(expiryTimeOfDay = @TimeOfDay)"); + } + }); + } + private ICompilationUnit createTestCacheWithShared() throws Exception { this.createCacheAnnotation(); return this.createTestType(new DefaultAnnotationWriter() { @@ -183,7 +207,7 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { } public void testGetType() throws Exception { - ICompilationUnit cu = this.createTestExistenceCheckingWithCacheType(); + ICompilationUnit cu = this.createTestCacheWithCacheType(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); @@ -191,7 +215,7 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { } public void testSetType() throws Exception { - ICompilationUnit cu = this.createTestExistenceCheckingWithCacheType(); + ICompilationUnit cu = this.createTestCacheWithCacheType(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); @@ -210,22 +234,22 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { } public void testGetSize() throws Exception { - ICompilationUnit cu = this.createTestExistenceCheckingWithSize(); + ICompilationUnit cu = this.createTestCacheWithSize(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); - assertEquals(new Integer(50), cache.getSize()); + assertEquals(Integer.valueOf(50), cache.getSize()); } public void testSetSize() throws Exception { - ICompilationUnit cu = this.createTestExistenceCheckingWithSize(); + ICompilationUnit cu = this.createTestCacheWithSize(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); - assertEquals(new Integer(50), cache.getSize()); + assertEquals(Integer.valueOf(50), cache.getSize()); - cache.setSize(new Integer(80)); - assertEquals(new Integer(80), cache.getSize()); + cache.setSize(Integer.valueOf(80)); + assertEquals(Integer.valueOf(80), cache.getSize()); assertSourceContains("@Cache(size = 80)", cu); @@ -271,22 +295,22 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { } public void testGetExpiry() throws Exception { - ICompilationUnit cu = this.createTestExistenceCheckingWithExpiry(); + ICompilationUnit cu = this.createTestCacheWithExpiry(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); - assertEquals(new Integer(50), cache.getExpiry()); + assertEquals(Integer.valueOf(50), cache.getExpiry()); } public void testSetExpiry() throws Exception { - ICompilationUnit cu = this.createTestExistenceCheckingWithExpiry(); + ICompilationUnit cu = this.createTestCacheWithExpiry(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); - assertEquals(new Integer(50), cache.getExpiry()); + assertEquals(Integer.valueOf(50), cache.getExpiry()); - cache.setExpiry(new Integer(80)); - assertEquals(new Integer(80), cache.getExpiry()); + cache.setExpiry(Integer.valueOf(80)); + assertEquals(Integer.valueOf(80), cache.getExpiry()); assertSourceContains("@Cache(expiry = 80)", cu); @@ -296,7 +320,41 @@ public class CacheTests extends EclipseLinkJavaResourceModelTestCase { assertSourceDoesNotContain("(expiry = 80)", cu); assertSourceDoesNotContain("@Cache", cu); } + + public void testGetExpiryTimeOfDay() throws Exception { + ICompilationUnit cu = this.createTestCacheWithExpiryTimeOfDay(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + + CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); + assertNotNull(timeOfDay); + } + public void testAddExpiryTimeOfDay() throws Exception { + ICompilationUnit cu = this.createTestCache(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + + CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + cache.addExpiryTimeOfDay(); + + assertNotNull(cache.getExpiryTimeOfDay()); + + assertSourceContains("@Cache(expiryTimeOfDay=@TimeOfDay)", cu); + } + + public void testRemoveExpiryTimeOfDay() throws Exception { + ICompilationUnit cu = this.createTestCacheWithExpiryTimeOfDay(); + JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); + + CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); + + assertNotNull(cache.getExpiryTimeOfDay()); + + cache.removeExpiryTimeOfDay(); + assertNull(cache.getExpiryTimeOfDay()); + assertSourceDoesNotContain("@Cache(expiryTimeOfDay = @TimeOfDay)", cu); + } + public void testGetAlwaysRefresh() throws Exception { ICompilationUnit cu = this.createTestCacheWithAlwaysRefresh(); JavaResourcePersistentType typeResource = buildJavaTypeResource(cu); diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java index f8e17c9ea6..71d72d0a1e 100644 --- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java +++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/resource/java/TimeOfDayTests.java @@ -137,7 +137,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getHour()); + assertEquals(Integer.valueOf(5), timeOfDay.getHour()); } public void testSetHour() throws Exception { @@ -146,10 +146,10 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getHour()); + assertEquals(Integer.valueOf(5), timeOfDay.getHour()); - timeOfDay.setHour(new Integer(80)); - assertEquals(new Integer(80), timeOfDay.getHour()); + timeOfDay.setHour(Integer.valueOf(80)); + assertEquals(Integer.valueOf(80), timeOfDay.getHour()); assertSourceContains("@TimeOfDay(hour=80)", cu); @@ -157,7 +157,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { assertNull(timeOfDay.getHour()); assertSourceDoesNotContain("(hour=80)", cu); - assertSourceDoesNotContain("@TimeOfDay", cu); + assertSourceContains("@TimeOfDay", cu); } public void testGetMinute() throws Exception { @@ -166,7 +166,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getMinute()); + assertEquals(Integer.valueOf(5), timeOfDay.getMinute()); } public void testSetMinute() throws Exception { @@ -175,10 +175,10 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getMinute()); + assertEquals(Integer.valueOf(5), timeOfDay.getMinute()); - timeOfDay.setMinute(new Integer(80)); - assertEquals(new Integer(80), timeOfDay.getMinute()); + timeOfDay.setMinute(Integer.valueOf(80)); + assertEquals(Integer.valueOf(80), timeOfDay.getMinute()); assertSourceContains("@TimeOfDay(minute=80)", cu); @@ -186,7 +186,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { assertNull(timeOfDay.getMinute()); assertSourceDoesNotContain("(minute=80)", cu); - assertSourceDoesNotContain("@TimeOfDay", cu); + assertSourceContains("@TimeOfDay", cu); } public void testGetSecond() throws Exception { @@ -195,7 +195,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getSecond()); + assertEquals(Integer.valueOf(5), timeOfDay.getSecond()); } public void testSetSecond() throws Exception { @@ -204,10 +204,10 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getSecond()); + assertEquals(Integer.valueOf(5), timeOfDay.getSecond()); - timeOfDay.setSecond(new Integer(80)); - assertEquals(new Integer(80), timeOfDay.getSecond()); + timeOfDay.setSecond(Integer.valueOf(80)); + assertEquals(Integer.valueOf(80), timeOfDay.getSecond()); assertSourceContains("@TimeOfDay(second=80)", cu); @@ -215,7 +215,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { assertNull(timeOfDay.getSecond()); assertSourceDoesNotContain("(second=80)", cu); - assertSourceDoesNotContain("@TimeOfDay", cu); + assertSourceContains("@TimeOfDay", cu); } public void testGetMillisecond() throws Exception { @@ -224,7 +224,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getMillisecond()); + assertEquals(Integer.valueOf(5), timeOfDay.getMillisecond()); } public void testSetMillisecond() throws Exception { @@ -233,10 +233,10 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { CacheAnnotation cache = (CacheAnnotation) typeResource.getAnnotation(EclipseLinkJPA.CACHE); TimeOfDayAnnotation timeOfDay = cache.getExpiryTimeOfDay(); - assertEquals(new Integer(5), timeOfDay.getMillisecond()); + assertEquals(Integer.valueOf(5), timeOfDay.getMillisecond()); - timeOfDay.setMillisecond(new Integer(80)); - assertEquals(new Integer(80), timeOfDay.getMillisecond()); + timeOfDay.setMillisecond(Integer.valueOf(80)); + assertEquals(Integer.valueOf(80), timeOfDay.getMillisecond()); assertSourceContains("@TimeOfDay(millisecond=80)", cu); @@ -244,7 +244,7 @@ public class TimeOfDayTests extends EclipseLinkJavaResourceModelTestCase { assertNull(timeOfDay.getMillisecond()); assertSourceDoesNotContain("(millisecond=80)", cu); - assertSourceDoesNotContain("@TimeOfDay", cu); + assertSourceContains("@TimeOfDay", cu); } |