/** * Tries to load the class specified. * * @return If there is none returns null. * @param cacheManager */ public final CacheManagerEventListener createCacheManagerEventListener(CacheManager cacheManager) throws CacheException { String className = null; FactoryConfiguration cacheManagerEventListenerFactoryConfiguration = configuration.getCacheManagerEventListenerFactoryConfiguration(); if (cacheManagerEventListenerFactoryConfiguration != null) { className = cacheManagerEventListenerFactoryConfiguration.getFullyQualifiedClassPath(); } if (className == null || className.length() == 0) { LOG.debug("No CacheManagerEventListenerFactory class specified. Skipping..."); return null; } else { CacheManagerEventListenerFactory factory = (CacheManagerEventListenerFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(cacheManagerEventListenerFactoryConfiguration.properties, cacheManagerEventListenerFactoryConfiguration.getPropertySeparator()); return factory.createCacheManagerEventListener(cacheManager, properties); } }
/** * Tries to create a CacheLoader from the configuration using the factory * specified. * * @return The CacheExceptionHandler, or null if it could not be found. */ public static CacheExceptionHandler createCacheExceptionHandler( CacheConfiguration.CacheExceptionHandlerFactoryConfiguration factoryConfiguration, ClassLoader loader) throws CacheException { String className = null; CacheExceptionHandler cacheExceptionHandler = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null || className.length() == 0) { LOG.debug("No CacheExceptionHandlerFactory class specified. Skipping..."); } else { CacheExceptionHandlerFactory factory = (CacheExceptionHandlerFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); return factory.createExceptionHandler(properties); } return cacheExceptionHandler; }
/** * Tries to load a BootstrapCacheLoader from the class specified. * @param loader * * @return If there is none returns null. */ private static final BootstrapCacheLoader createBootstrapCacheLoader( CacheConfiguration.BootstrapCacheLoaderFactoryConfiguration factoryConfiguration, ClassLoader loader) throws CacheException { String className = null; BootstrapCacheLoader bootstrapCacheLoader = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null || className.length() == 0) { LOG.debug("No BootstrapCacheLoaderFactory class specified. Skipping..."); } else { BootstrapCacheLoaderFactory factory = (BootstrapCacheLoaderFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); return factory.createBootstrapCacheLoader(properties); } return bootstrapCacheLoader; }
/** * Tries to load the class specified otherwise defaults to null. * * @param factoryConfiguration * @param loader */ private static CacheLoader createCacheLoader( CacheConfiguration.CacheLoaderFactoryConfiguration factoryConfiguration, Ehcache cache, ClassLoader loader) { String className = null; CacheLoader cacheLoader = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null) { LOG.debug("CacheLoader factory not configured. Skipping..."); } else { CacheLoaderFactory factory = (CacheLoaderFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); cacheLoader = factory.createCacheLoader(cache, properties); } return cacheLoader; }
/** * Tries to load the class specified otherwise defaults to null. * * @param factoryConfiguration * @param loader */ private static CacheExtension createCacheExtension( CacheConfiguration.CacheExtensionFactoryConfiguration factoryConfiguration, Ehcache cache, ClassLoader loader) { String className = null; CacheExtension cacheExtension = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null) { LOG.debug("CacheExtension factory not configured. Skipping..."); } else { CacheExtensionFactory factory = (CacheExtensionFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); cacheExtension = factory.createCacheExtension(cache, properties); } return cacheExtension; }
/** * 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.debug("No CachePeerListenerFactoryConfiguration specified. Not configuring a CacheManagerPeerListener."); return null; } else { CacheManagerPeerListenerFactory cacheManagerPeerListenerFactory = (CacheManagerPeerListenerFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); CacheManagerPeerListener cacheManagerPeerListener = cacheManagerPeerListenerFactory.createCachePeerListener(cacheManager, properties); cacheManagerPeerListeners.put(cacheManagerPeerListener.getScheme(), cacheManagerPeerListener); } } return cacheManagerPeerListeners; }
/** * Tries to load the class specified otherwise defaults to null. * * @param config * @param loader */ private static CacheWriter createCacheWriter(CacheWriterConfiguration config, Ehcache cache, ClassLoader loader) { String className = null; CacheWriter cacheWriter = null; CacheWriterConfiguration.CacheWriterFactoryConfiguration factoryConfiguration = config.getCacheWriterFactoryConfiguration(); if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (null == className) { LOG.debug("CacheWriter factory not configured. Skipping..."); } else { CacheWriterFactory factory = (CacheWriterFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); if (null == properties) { properties = new Properties(); } cacheWriter = factory.createCacheWriter(cache, properties); } return cacheWriter; }
/** * Tries to load the class specified otherwise defaults to null * * @return a map of CacheManagerPeerProviders */ public Map<String, CacheManagerPeerProvider> createCachePeerProviders() { String className = null; Map<String, CacheManagerPeerProvider> cacheManagerPeerProviders = new HashMap<String, CacheManagerPeerProvider>(); List<FactoryConfiguration> cachePeerProviderFactoryConfiguration = configuration.getCacheManagerPeerProviderFactoryConfiguration(); for (FactoryConfiguration factoryConfiguration : cachePeerProviderFactoryConfiguration) { if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null) { LOG.debug("No CachePeerProviderFactoryConfiguration specified. Not configuring a CacheManagerPeerProvider."); return null; } else { CacheManagerPeerProviderFactory cacheManagerPeerProviderFactory = (CacheManagerPeerProviderFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); CacheManagerPeerProvider cacheManagerPeerProvider = cacheManagerPeerProviderFactory.createCachePeerProvider(cacheManager, properties); cacheManagerPeerProviders.put(cacheManagerPeerProvider.getScheme(), cacheManagerPeerProvider); } } return cacheManagerPeerProviders; }
/** * Tries to load the class specified otherwise defaults to null. * * @param factoryConfiguration * @param loader */ private static CacheEventListener createCacheEventListener( CacheConfiguration.CacheEventListenerFactoryConfiguration factoryConfiguration, ClassLoader loader) { String className = null; CacheEventListener cacheEventListener = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null) { LOG.debug("CacheEventListener factory not configured. Skipping..."); } else { CacheEventListenerFactory factory = (CacheEventListenerFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); cacheEventListener = factory.createCacheEventListener(properties); } return cacheEventListener; }
Properties properties = PropertyUtil.parseProperties(lookupConfiguration.getProperties(), lookupConfiguration.getPropertySeparator());
/** * Creates the decorated cache from the decorator config specified. Returns null if the name of the factory class is not specified */ private static Ehcache createDecoratedCache(Ehcache cache, CacheConfiguration.CacheDecoratorFactoryConfiguration factoryConfiguration, boolean forDefaultCache, ClassLoader loader) { if (factoryConfiguration == null) { return null; } String className = factoryConfiguration.getFullyQualifiedClassPath(); if (className == null) { LOG.debug("CacheDecoratorFactory was specified without the name of the factory. Skipping..."); return null; } else { CacheDecoratorFactory factory = (CacheDecoratorFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); if (forDefaultCache) { return factory.createDefaultDecoratedEhcache(cache, properties); } else { return factory.createDecoratedEhcache(cache, properties); } } }
/** * Construct the extractor for this attribute configuration */ public AttributeExtractor constructExtractor(ClassLoader loader) { if (name == null) { throw new InvalidConfigurationException("search attribute has no name"); } if (expression != null) { return new ReflectionAttributeExtractor(expression); } else if (className != null) { if (properties != null) { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className, new Class[] {Properties.class}, new Object[] {PropertyUtil.parseProperties(properties, propertySeparator)}); } else { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className); } } else { return new JavaBeanAttributeExtractor(name); } }
/** * Tries to load the class specified. * * @return If there is none returns null. * @param cacheManager */ public final CacheManagerEventListener createCacheManagerEventListener(CacheManager cacheManager) throws CacheException { String className = null; FactoryConfiguration cacheManagerEventListenerFactoryConfiguration = configuration.getCacheManagerEventListenerFactoryConfiguration(); if (cacheManagerEventListenerFactoryConfiguration != null) { className = cacheManagerEventListenerFactoryConfiguration.getFullyQualifiedClassPath(); } if (className == null || className.length() == 0) { LOG.debug("No CacheManagerEventListenerFactory class specified. Skipping..."); return null; } else { CacheManagerEventListenerFactory factory = (CacheManagerEventListenerFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(cacheManagerEventListenerFactoryConfiguration.properties, cacheManagerEventListenerFactoryConfiguration.getPropertySeparator()); return factory.createCacheManagerEventListener(cacheManager, properties); } }
/** * Tries to load the class specified otherwise defaults to null. * * @param factoryConfiguration * @param loader */ private static CacheEventListener createCacheEventListener( CacheConfiguration.CacheEventListenerFactoryConfiguration factoryConfiguration, ClassLoader loader) { String className = null; CacheEventListener cacheEventListener = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null) { LOG.debug("CacheEventListener factory not configured. Skipping..."); } else { CacheEventListenerFactory factory = (CacheEventListenerFactory) ClassLoaderUtil.createNewInstance(loader, className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); cacheEventListener = factory.createCacheEventListener(properties); } return cacheEventListener; }
/** * Tries to load the class specified otherwise defaults to null. * * @param factoryConfiguration */ private static CacheExtension createCacheExtension( CacheConfiguration.CacheExtensionFactoryConfiguration factoryConfiguration, Ehcache cache) { String className = null; CacheExtension cacheExtension = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null) { LOG.debug("CacheExtension factory not configured. Skipping..."); } else { CacheExtensionFactory factory = (CacheExtensionFactory) ClassLoaderUtil.createNewInstance(className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); cacheExtension = factory.createCacheExtension(cache, properties); } return cacheExtension; }
/** * Tries to load the class specified otherwise defaults to null. * * @param factoryConfiguration */ private static CacheEventListener createCacheEventListener( CacheConfiguration.CacheEventListenerFactoryConfiguration factoryConfiguration) { String className = null; CacheEventListener cacheEventListener = null; if (factoryConfiguration != null) { className = factoryConfiguration.getFullyQualifiedClassPath(); } if (className == null) { LOG.debug("CacheEventListener factory not configured. Skipping..."); } else { CacheEventListenerFactory factory = (CacheEventListenerFactory) ClassLoaderUtil.createNewInstance(className); Properties properties = PropertyUtil.parseProperties(factoryConfiguration.getProperties(), factoryConfiguration.getPropertySeparator()); cacheEventListener = factory.createCacheEventListener(properties); } return cacheEventListener; }
/** * 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.debug("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; }
/** * Construct the extractor for this attribute configuration */ public AttributeExtractor constructExtractor() { if (name == null) { throw new InvalidConfigurationException("search attribute has no name"); } if (expression != null) { return new ReflectionAttributeExtractor(expression); } else if (className != null) { if (properties != null) { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(className, new Class[] {Properties.class}, new Object[] {PropertyUtil.parseProperties(properties, propertySeparator)}); } else { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(className); } } else { return new JavaBeanAttributeExtractor(name); } }
/** * Construct the extractor for this attribute configuration */ public AttributeExtractor constructExtractor(ClassLoader loader) { if (name == null) { throw new InvalidConfigurationException("search attribute has no name"); } if (expression != null) { return new ReflectionAttributeExtractor(expression); } else if (className != null) { if (properties != null) { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className, new Class[] {Properties.class}, new Object[] {PropertyUtil.parseProperties(properties, propertySeparator)}); } else { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className); } } else { return new JavaBeanAttributeExtractor(name); } }
/** * Construct the extractor for this attribute configuration */ public AttributeExtractor constructExtractor(ClassLoader loader) { if (name == null) { throw new InvalidConfigurationException("search attribute has no name"); } if (expression != null) { return new ReflectionAttributeExtractor(expression); } else if (className != null) { if (properties != null) { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className, new Class[] {Properties.class}, new Object[] {PropertyUtil.parseProperties(properties, propertySeparator)}); } else { return (AttributeExtractor) ClassLoaderUtil.createNewInstance(loader, className); } } else { return new JavaBeanAttributeExtractor(name); } }