8
8
9
9
import java .net .URL ;
10
10
11
- import net .sf .ehcache .Ehcache ;
12
11
import net .sf .ehcache .config .CacheConfiguration ;
13
12
import net .sf .ehcache .config .Configuration ;
14
13
import net .sf .ehcache .config .ConfigurationFactory ;
15
14
import net .sf .ehcache .config .NonstopConfiguration ;
16
- import net .sf .ehcache .config .TerracottaConfiguration ;
17
- import net .sf .ehcache .config .TerracottaConfiguration .ValueMode ;
18
15
import net .sf .ehcache .config .TimeoutBehaviorConfiguration .TimeoutBehaviorType ;
16
+ import org .jboss .logging .Logger ;
19
17
20
- import org .hibernate .cache .CacheException ;
21
18
import org .hibernate .cache .ehcache .EhCacheMessageLogger ;
22
19
23
- import org .jboss .logging .Logger ;
24
-
25
20
26
21
/**
27
22
* Copy of Ehcache utils into Hibernate code base
@@ -56,16 +51,9 @@ public static Configuration loadAndCorrectConfiguration(URL url) {
56
51
if ( config == null ) {
57
52
return null ;
58
53
}
59
-
54
+
60
55
if ( config .getDefaultCacheConfiguration () != null
61
56
&& config .getDefaultCacheConfiguration ().isTerracottaClustered () ) {
62
- if ( ValueMode .IDENTITY
63
- .equals ( config .getDefaultCacheConfiguration ().getTerracottaConfiguration ().getValueMode () ) ) {
64
- LOG .incompatibleCacheValueMode ();
65
- config .getDefaultCacheConfiguration ()
66
- .getTerracottaConfiguration ()
67
- .setValueMode ( ValueMode .SERIALIZATION .name () );
68
- }
69
57
setupHibernateTimeoutBehavior (
70
58
config .getDefaultCacheConfiguration ()
71
59
.getTerracottaConfiguration ()
@@ -75,10 +63,6 @@ public static Configuration loadAndCorrectConfiguration(URL url) {
75
63
76
64
for ( CacheConfiguration cacheConfig : config .getCacheConfigurations ().values () ) {
77
65
if ( cacheConfig .isTerracottaClustered () ) {
78
- if ( ValueMode .IDENTITY .equals ( cacheConfig .getTerracottaConfiguration ().getValueMode () ) ) {
79
- LOG .incompatibleCacheValueModePerCache ( cacheConfig .getName () );
80
- cacheConfig .getTerracottaConfiguration ().setValueMode ( ValueMode .SERIALIZATION .name () );
81
- }
82
66
setupHibernateTimeoutBehavior ( cacheConfig .getTerracottaConfiguration ().getNonstopConfiguration () );
83
67
}
84
68
}
@@ -88,32 +72,4 @@ public static Configuration loadAndCorrectConfiguration(URL url) {
88
72
private static void setupHibernateTimeoutBehavior (NonstopConfiguration nonstopConfig ) {
89
73
nonstopConfig .getTimeoutBehavior ().setType ( TimeoutBehaviorType .EXCEPTION .getTypeName () );
90
74
}
91
-
92
- /**
93
- * Validates that the supplied Ehcache instance is valid for use as a Hibernate cache.
94
- *
95
- * @param cache The cache instance
96
- *
97
- * @throws CacheException If any explicit settings on the cache are not validate
98
- */
99
- public static void validateEhcache (Ehcache cache ) throws CacheException {
100
- final CacheConfiguration cacheConfig = cache .getCacheConfiguration ();
101
-
102
- if ( cacheConfig .isTerracottaClustered () ) {
103
- final TerracottaConfiguration tcConfig = cacheConfig .getTerracottaConfiguration ();
104
- switch ( tcConfig .getValueMode () ) {
105
- case IDENTITY : {
106
- throw new CacheException (
107
- "The clustered Hibernate cache " + cache .getName () + " is using IDENTITY value mode.\n "
108
- + "Identity value mode cannot be used with Hibernate cache regions."
109
- );
110
- }
111
- case SERIALIZATION :
112
- default : {
113
- // this is the recommended valueMode
114
- break ;
115
- }
116
- }
117
- }
118
- }
119
75
}
0 commit comments