private static FactoryConfiguration getDefaultTransactionManagerLookupConfiguration() { FactoryConfiguration configuration = new FactoryConfiguration(); configuration.setClass(DefaultTransactionManagerLookup.class.getName()); return configuration; }
/** * 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; }
protected <T extends FactoryConfiguration<?>> T newFactory( final String path, final Config config, final Supplier<T> supplier) { T factory = supplier.get(); sstr(path, config, "class", factory::setClass); String sep = ";"; factory.setProperties(toPropertiesLine(config.withoutPath("class"), sep)); factory.setPropertySeparator(";"); requireNonNull(factory.getFullyQualifiedClassPath(), "No .class found in: " + path); return factory; }
/** * 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); } }
/** * Overrided equals */ @Override public boolean equals(Object obj) { return super.equals(obj); } }
private FactoryConfiguration buildPeerListenerFactory(final ClusterNodeProperties clusterNodeProperties) { final String hostname = clusterNodeProperties.getProperty(EHCACHE_LISTENER_HOSTNAME); final String port = clusterNodeProperties.getProperty(EHCACHE_LISTENER_PORT); final String socketTimeoutMillis = clusterNodeProperties.getProperty(EHCACHE_LISTENER_SOCKET_TIMEOUT_MILLIS); final Properties properties = new Properties(); // We add the JiraUtils to maintain consistency between Java 7 and 8. // EhCache uses the default Java 7 approach, and it will fail in the future. properties.put("hostName", hostname != null ? hostname : JiraUtils.getHostname()); properties.put("port", port != null ? port : DEFAULT_LISTENER_PORT); if (socketTimeoutMillis != null) { properties.put("socketTimeoutMillis", socketTimeoutMillis); } return new FactoryConfiguration() .className(RMICacheManagerPeerListenerFactory.class.getName()) .properties(propertiesToString(properties)); }
/** * @return this configuration instance * @see #setClass(String) */ public T className(String fullyQualifiedClassPath) { setClass(fullyQualifiedClassPath); return (T) this; }
/** * @return this configuration instance * @see #setPropertySeparator(String) */ public T propertySeparator(String propertySeparator) { setPropertySeparator(propertySeparator); return (T) this; }
/** * @return this configuration instance * @see #setProperties(String) */ public T properties(String properties) { setProperties(properties); return (T) this; }
/** * Overrided hashCode() */ @Override public int hashCode() { return super.hashCode(); }
/** * 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); } }
private void testAddTransactionManagerLookupElement() { FactoryConfiguration transactionManagerLookupConfiguration = configuration.getTransactionManagerLookupConfiguration(); if (transactionManagerLookupConfiguration != null && !transactionManagerLookupConfiguration.equals(Configuration.DEFAULT_TRANSACTION_MANAGER_LOOKUP_CONFIG)) { addChildElement(new FactoryConfigurationElement(this, "transactionManagerLookup", transactionManagerLookupConfiguration)); } }
private FactoryConfiguration buildPeerProviderFactory(final ClusterNodeProperties clusterNodeProperties) { final String address = clusterNodeProperties.getProperty(EHCACHE_MULTICAST_ADDRESS); final String port = clusterNodeProperties.getProperty(EHCACHE_MULTICAST_PORT); final String timeToLive = clusterNodeProperties.getProperty(EHCACHE_MULTICAST_TTL); final String hostName = clusterNodeProperties.getProperty(EHCACHE_MULTICAST_HOSTNAME); final String peerDiscovery = clusterNodeProperties.getProperty(EHCACHE_PEER_DISCOVERY); final Properties properties = new Properties(); if (timeToLive != null) { properties.put("timeToLive", timeToLive); } if (hostName != null) { properties.put("hostName", hostName); } properties.put(PEER_DISCOVERY, peerDiscovery != null ? peerDiscovery : "default"); properties.put("multicastGroupAddress", address != null ? address : DEFAULT_MULTICAST_ADDRESS); properties.put("multicastGroupPort", port != null ? port : DEFAULT_MULTICAST_PORT); return new FactoryConfiguration() .className(JiraRMICacheManagerPeerProviderFactory.class.getName()) .properties(propertiesToString(properties)); }
/** * @return this configuration instance * @see #setClass(String) */ public T className(String fullyQualifiedClassPath) { setClass(fullyQualifiedClassPath); return (T) this; }
/** * @return this configuration instance * @see #setPropertySeparator(String) */ public T propertySeparator(String propertySeparator) { setPropertySeparator(propertySeparator); return (T) this; }
/** * @return this configuration instance * @see #setProperties(String) */ public T properties(String properties) { setProperties(properties); return (T) this; }
/** * Overrided hashCode() */ @Override public int hashCode() { return super.hashCode(); }
Properties properties = PropertyUtil.parseProperties(lookupConfiguration.getProperties(), lookupConfiguration.getPropertySeparator()); if (DEFAULT_TRANSACTION_MANAGER_LOOKUP_CONFIG.getFullyQualifiedClassPath().equals(lookupConfiguration.getFullyQualifiedClassPath())) { loader = getClass().getClassLoader(); .loadClass(lookupConfiguration.getFullyQualifiedClassPath()); this.transactionManagerLookup = transactionManagerLookupClass.newInstance(); this.transactionManagerLookup.setProperties(properties); } catch (Exception e) { LOG.error("could not instantiate transaction manager lookup class: {}", lookupConfiguration.getFullyQualifiedClassPath(), e);
private static FactoryConfiguration getDefaultTransactionManagerLookupConfiguration() { FactoryConfiguration configuration = new FactoryConfiguration(); configuration.setClass(DefaultTransactionManagerLookup.class.getName()); return configuration; }
protected <T extends FactoryConfiguration<?>> T newFactory( final String path, final Config config, final Supplier<T> supplier) { T factory = supplier.get(); sstr(path, config, "class", factory::setClass); String sep = ";"; factory.setProperties(toPropertiesLine(config.withoutPath("class"), sep)); factory.setPropertySeparator(";"); requireNonNull(factory.getFullyQualifiedClassPath(), "No .class found in: " + path); return factory; }