#649 - ENH: Add ebean.disableL2Cache=true option ... to globally disable l2 cache

This commit is contained in:
Robin Bygrave committed 2016-04-13 17:44:37 +12:00
1 parent e8a979bc9d
commit 707dda636d
6 files changed
+45 -4

No files matched your search

@@ -201,7 +201,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
this.asOfViewSuffix = getAsOfViewSuffix(databasePlatform, serverConfig);
String versionsBetweenSuffix = getVersionsBetweenSuffix(databasePlatform, serverConfig);
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix, versionsBetweenSuffix);
this.readAnnotations = new ReadAnnotations(config.getGeneratedPropertyFactory(), asOfViewSuffix, versionsBetweenSuffix, serverConfig.isDisableL2Cache());
this.bootupClasses = config.getBootupClasses();
this.createProperties = config.getDeployCreateProperties();
this.namingConvention = serverConfig.getNamingConvention();
@@ -43,13 +43,16 @@ public class AnnotationClass extends AnnotationParser {
private final String versionsBetweenSuffix;
private final boolean disableL2Cache;
/**
* Create for normal early parse of class level annotations.
*/
public AnnotationClass(DeployBeanInfo<?> info, boolean validationAnnotations, String asOfViewSuffix, String versionsBetweenSuffix) {
public AnnotationClass(DeployBeanInfo<?> info, boolean validationAnnotations, String asOfViewSuffix, String versionsBetweenSuffix, boolean disableL2Cache) {
super(info, validationAnnotations);
this.asOfViewSuffix = asOfViewSuffix;
this.versionsBetweenSuffix = versionsBetweenSuffix;
this.disableL2Cache = disableL2Cache;
}
/**
@@ -60,6 +63,7 @@ public class AnnotationClass extends AnnotationParser {
super(info, false);
this.asOfViewSuffix = null;
this.versionsBetweenSuffix = null;
this.disableL2Cache = false;
}
/**
@@ -210,6 +214,9 @@ public class AnnotationClass extends AnnotationParser {
private void readCacheStrategy(CacheStrategy cacheStrategy, CacheTuning cacheTuning) {
if (disableL2Cache) {
return;
}
CacheOptions cacheOptions = descriptor.getCacheOptions();
if (cacheTuning != null) {
cacheOptions.setMaxSecsToLive(cacheTuning.maxSecsToLive());
@@ -32,12 +32,15 @@ public class ReadAnnotations {
*/
private final boolean jacksonAnnotations;
public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix) {
private final boolean disableL2Cache;
public ReadAnnotations(GeneratedPropertyFactory generatedPropFactory, String asOfViewSuffix, String versionsBetweenSuffix, boolean disableL2Cache) {
this.generatedPropFactory = generatedPropFactory;
this.asOfViewSuffix = asOfViewSuffix;
this.versionsBetweenSuffix = versionsBetweenSuffix;
this.javaxValidationAnnotations = generatedPropFactory.getClassLoadConfig().isJavaxValidationAnnotationsPresent();
this.jacksonAnnotations = generatedPropFactory.getClassLoadConfig().isJacksonAnnotationsPresent();
this.disableL2Cache = disableL2Cache;
}
/**
@@ -50,7 +53,7 @@ public class ReadAnnotations {
public void readInitial(DeployBeanInfo<?> info, boolean eagerFetchLobs) {
try {
new AnnotationClass(info, javaxValidationAnnotations, asOfViewSuffix, versionsBetweenSuffix).parse();
new AnnotationClass(info, javaxValidationAnnotations, asOfViewSuffix, versionsBetweenSuffix, disableL2Cache).parse();
new AnnotationFields(generatedPropFactory, info, javaxValidationAnnotations, jacksonAnnotations, eagerFetchLobs).parse();
} catch (RuntimeException e) {