17
17
18
18
import org .springframework .beans .factory .annotation .Autowired ;
19
19
import org .springframework .stereotype .Service ;
20
+ import static org .terracotta .tinypounder .CacheConfiguration .ClusterTierType .DEDICATED ;
21
+ import static org .terracotta .tinypounder .CacheConfiguration .ClusterTierType .SHARED ;
20
22
21
23
import java .io .File ;
22
24
import java .io .IOException ;
41
43
import java .util .concurrent .TimeUnit ;
42
44
import java .util .stream .IntStream ;
43
45
44
- import static org .terracotta .tinypounder .CacheConfiguration .ClusterTierType .DEDICATED ;
45
- import static org .terracotta .tinypounder .CacheConfiguration .ClusterTierType .SHARED ;
46
-
47
46
@ Service
48
47
public class CacheManagerBusinessReflectionImpl implements CacheManagerBusiness {
49
48
@@ -238,13 +237,13 @@ public String retrieveHumanReadableConfiguration() {
238
237
}
239
238
240
239
@ Override
241
- public void initializeCacheManager (String terracottaServerUrl , String cmName , String diskPersistenceLocation , String defaultOffheapResource , String serverDiskResource ) {
240
+ public void initializeCacheManager (String terracottaServerUrl , String cmName , String diskPersistenceLocation , String defaultOffheapResource , String serverDiskResource , String securityPath ) {
242
241
try {
243
242
Thread .currentThread ().setContextClassLoader (kitAwareClassLoaderDelegator .getUrlClassLoader ());
244
243
Object clusteringServiceConfigurationBuilder ;
245
244
if (terracottaServerUrl != null ) {
246
245
URI clusterUri = URI .create ("terracotta://" + terracottaServerUrl + "/" + cmName );
247
- clusteringServiceConfigurationBuilder = constructClusteringServiceConfigurationBuilder (cmName , clusterUri , kitAwareClassLoaderDelegator .isEEKit (), defaultOffheapResource , serverDiskResource );
246
+ clusteringServiceConfigurationBuilder = constructClusteringServiceConfigurationBuilder (cmName , clusterUri , kitAwareClassLoaderDelegator .isEEKit (), defaultOffheapResource , serverDiskResource , securityPath );
248
247
} else {
249
248
clusteringServiceConfigurationBuilder = null ;
250
249
}
@@ -329,7 +328,7 @@ private Object constructCacheManagerBuilder(Object enterpriseClusteringServiceCo
329
328
return buildMethod .invoke (cacheManagerBuilder );
330
329
}
331
330
332
- private Object constructClusteringServiceConfigurationBuilder (String clusterTierManagerName , URI clusterUri , boolean eeKit , String defaultOffheapResource , String serverDiskResource ) throws IllegalAccessException , InvocationTargetException , ClassNotFoundException , NoSuchMethodException {
331
+ private Object constructClusteringServiceConfigurationBuilder (String clusterTierManagerName , URI clusterUri , boolean eeKit , String defaultOffheapResource , String serverDiskResource , String securityPath ) throws IllegalAccessException , InvocationTargetException , ClassNotFoundException , NoSuchMethodException {
333
332
334
333
Class <?> memoryUnitClass = loadClass ("org.ehcache.config.units.MemoryUnit" );
335
334
Method valueOfMethod = memoryUnitClass .getMethod ("valueOf" , String .class );
@@ -351,16 +350,23 @@ private Object constructClusteringServiceConfigurationBuilder(String clusterTier
351
350
352
351
353
352
Class <?> enterpriseClusteringServiceConfigurationBuilderClass = loadClass ("com.terracottatech.ehcache.clustered.client.config.builders.EnterpriseClusteringServiceConfigurationBuilder" );
354
- Method enterpriseClusterMethod = enterpriseClusteringServiceConfigurationBuilderClass . getMethod ( "enterpriseCluster" , URI . class );
353
+
355
354
356
355
Method autoCreateMethod = enterpriseClusteringServiceConfigurationBuilderClass .getMethod ("autoCreate" );
357
356
Method defaultServerResourceMethod = enterpriseServerSideConfigurationBuilderClass .getMethod ("defaultServerResource" , String .class );
358
357
Method resourcePoolMethod4 = enterpriseServerSideConfigurationBuilderClass .getMethod ("resourcePool" , String .class , long .class , memoryUnitClass , String .class );
359
358
Method resourcePoolMethod3 = enterpriseServerSideConfigurationBuilderClass .getMethod ("resourcePool" , String .class , long .class , memoryUnitClass );
360
359
Method restartableMethod = enterpriseServerSideConfigurationBuilderClass .getMethod ("restartable" , String .class );
361
360
361
+ Object enterpriseClusteringServiceConfigurationBuilder ;
362
+ if (securityPath != null ) {
363
+ Method enterpriseClusterMethod = enterpriseClusteringServiceConfigurationBuilderClass .getMethod ("enterpriseSecureCluster" , URI .class , Path .class );
364
+ enterpriseClusteringServiceConfigurationBuilder = enterpriseClusterMethod .invoke (null , clusterUri .resolve (clusterTierManagerName ), Paths .get (securityPath ));
365
+ } else {
366
+ Method enterpriseClusterMethod = enterpriseClusteringServiceConfigurationBuilderClass .getMethod ("enterpriseCluster" , URI .class );
367
+ enterpriseClusteringServiceConfigurationBuilder = enterpriseClusterMethod .invoke (null , clusterUri .resolve (clusterTierManagerName ));
368
+ }
362
369
363
- Object enterpriseClusteringServiceConfigurationBuilder = enterpriseClusterMethod .invoke (null , clusterUri .resolve (clusterTierManagerName ));
364
370
if (timeoutsClass != null && timeoutsInstance != null ) {
365
371
Method timeoutsMethod = enterpriseClusteringServiceConfigurationBuilderClass .getMethod ("timeouts" , timeoutsClass );
366
372
enterpriseClusteringServiceConfigurationBuilder = timeoutsMethod .invoke (enterpriseClusteringServiceConfigurationBuilder , timeoutsInstance );
0 commit comments