예제 #1
0
  /** Tries to load the class specified otherwise defaults to null */
  public Map<String, CacheManagerPeerListener> createCachePeerListeners() {
    String className = null;
    Map<String, CacheManagerPeerListener> cacheManagerPeerListeners =
        new HashMap<String, CacheManagerPeerListener>();
    List<FactoryConfiguration> cacheManagerPeerListenerFactoryConfigurations =
        configuration.getCacheManagerPeerListenerFactoryConfigurations();
    boolean first = true;
    for (FactoryConfiguration factoryConfiguration :
        cacheManagerPeerListenerFactoryConfigurations) {

      if (factoryConfiguration != null) {
        className = factoryConfiguration.getFullyQualifiedClassPath();
      }
      if (className == null) {
        LOG.fine(
            "No CachePeerListenerFactoryConfiguration specified. Not configuring a CacheManagerPeerListener.");
        return null;
      } else {
        CacheManagerPeerListenerFactory cacheManagerPeerListenerFactory =
            (CacheManagerPeerListenerFactory) ClassLoaderUtil.createNewInstance(className);
        Properties properties =
            PropertyUtil.parseProperties(
                factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator());
        CacheManagerPeerListener cacheManagerPeerListener =
            cacheManagerPeerListenerFactory.createCachePeerListener(cacheManager, properties);
        cacheManagerPeerListeners.put(
            cacheManagerPeerListener.getScheme(), cacheManagerPeerListener);
      }
    }
    return cacheManagerPeerListeners;
  }
예제 #2
0
 /**
  * Tries to load the class specified otherwise defaults to null.
  *
  * @param factoryConfiguration
  */
 private static CacheLoader createCacheLoader(
     CacheConfiguration.CacheLoaderFactoryConfiguration factoryConfiguration, Ehcache cache) {
   String className = null;
   CacheLoader cacheLoader = null;
   if (factoryConfiguration != null) {
     className = factoryConfiguration.getFullyQualifiedClassPath();
   }
   if (className == null) {
     LOG.fine("CacheLoader factory not configured. Skipping...");
   } else {
     CacheLoaderFactory factory =
         (CacheLoaderFactory) ClassLoaderUtil.createNewInstance(className);
     Properties properties =
         PropertyUtil.parseProperties(
             factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator());
     cacheLoader = factory.createCacheLoader(cache, properties);
   }
   return cacheLoader;
 }
예제 #3
0
 /**
  * Tries to load the class specified.
  *
  * @return If there is none returns null.
  */
 public final CacheManagerEventListener createCacheManagerEventListener() throws CacheException {
   String className = null;
   FactoryConfiguration cacheManagerEventListenerFactoryConfiguration =
       configuration.getCacheManagerEventListenerFactoryConfiguration();
   if (cacheManagerEventListenerFactoryConfiguration != null) {
     className = cacheManagerEventListenerFactoryConfiguration.getFullyQualifiedClassPath();
   }
   if (className == null || className.length() == 0) {
     LOG.fine("No CacheManagerEventListenerFactory class specified. Skipping...");
     return null;
   } else {
     CacheManagerEventListenerFactory factory =
         (CacheManagerEventListenerFactory) ClassLoaderUtil.createNewInstance(className);
     Properties properties =
         PropertyUtil.parseProperties(
             cacheManagerEventListenerFactoryConfiguration.properties,
             cacheManagerEventListenerFactoryConfiguration.getPropertySeparator());
     return factory.createCacheManagerEventListener(properties);
   }
 }
예제 #4
0
 /**
  * Tries to create a CacheLoader from the configuration using the factory specified.
  *
  * @return The CacheExceptionHandler, or null if it could not be found.
  */
 public final CacheExceptionHandler createCacheExceptionHandler(
     CacheConfiguration.CacheExceptionHandlerFactoryConfiguration factoryConfiguration)
     throws CacheException {
   String className = null;
   CacheExceptionHandler cacheExceptionHandler = null;
   if (factoryConfiguration != null) {
     className = factoryConfiguration.getFullyQualifiedClassPath();
   }
   if (className == null || className.length() == 0) {
     LOG.fine("No CacheExceptionHandlerFactory class specified. Skipping...");
   } else {
     CacheExceptionHandlerFactory factory =
         (CacheExceptionHandlerFactory) ClassLoaderUtil.createNewInstance(className);
     Properties properties =
         PropertyUtil.parseProperties(
             factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator());
     return factory.createExceptionHandler(properties);
   }
   return cacheExceptionHandler;
 }