Ejemplo n.º 1
0
 /**
  * Tries to load a BootstrapCacheLoader from the class specified.
  *
  * @return If there is none returns null.
  */
 public final BootstrapCacheLoader createBootstrapCacheLoader(
     CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration factoryConfiguration)
     throws CacheException {
   String className = null;
   BootstrapCacheLoader bootstrapCacheLoader = null;
   if (factoryConfiguration != null) {
     className = factoryConfiguration.getFullyQualifiedClassPath();
   }
   if (className == null || className.length() == 0) {
     LOG.fine("No BootstrapCacheLoaderFactory class specified. Skipping...");
   } else {
     BootstrapCacheLoaderFactory factory =
         (BootstrapCacheLoaderFactory) ClassLoaderUtil.createNewInstance(className);
     Properties properties =
         PropertyUtil.parseProperties(
             factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator());
     return factory.createBootstrapCacheLoader(properties);
   }
   return bootstrapCacheLoader;
 }
  @Override
  public PortalCacheBootstrapLoader create(Properties properties) {
    String className =
        properties.getProperty(EhcacheConstants.BOOTSTRAP_CACHE_LOADER_FACTORY_CLASS_NAME);

    if (Validator.isNull(className)) {
      return null;
    }

    try {
      BootstrapCacheLoaderFactory<?> bootstrapCacheLoaderFactory =
          (BootstrapCacheLoaderFactory<?>) InstanceFactory.newInstance(getClassLoader(), className);

      return new EhcachePortalCacheBootstrapLoaderAdapter(
          bootstrapCacheLoaderFactory.createBootstrapCacheLoader(properties));
    } catch (Exception e) {
      throw new SystemException(
          "Unable to instantiate bootstrap cache loader factory " + className, e);
    }
  }