private Properties loadPropertiesFile(ClassLoader classLoader, PooledConnectionFactoryConfiguration poolConfig) { if (classLoader == null) return new Properties(); FileLookup fileLookup = FileLookupFactory.newInstance(); String propertyPath = poolConfig.propertyFile(); InputStream is = null; try { if (propertyPath != null) { is = fileLookup.lookupFileStrict(propertyPath, classLoader); } else if (classLoader.getResource(HIKARI_PROPERTIES) != null) { is = fileLookup.lookupFileStrict(HIKARI_PROPERTIES, classLoader); } if (is != null) { Properties properties = new Properties(); properties.load(is); return properties; } } catch (IOException e) { log.errorLoadingHikariCPProperties(PooledConnectionFactoryConfiguration.class.getName()); } return new Properties(); }
private static InputStream lookupFile(String configFile, ClassLoader classLoader, ClassLoader strictClassLoader) throws FileNotFoundException { FileLookup fileLookup = FileLookupFactory.newInstance(); InputStream input = fileLookup.lookupFile(configFile, classLoader); // when it's not a user-provided configuration file, it might be a default configuration file, // and if that's included in [this] module might not be visible to the ClassLoaderService: if (input == null) { // This time use lookupFile*Strict* so to provide an exception if we can't find it yet: input = fileLookup.lookupFileStrict(configFile, strictClassLoader); } return input; }
public static EmbeddedCacheManager fromXml(String xmlFile, boolean keepJmxDomainName, boolean defaultParserOnly) throws IOException { InputStream is = FileLookupFactory.newInstance().lookupFileStrict( xmlFile, Thread.currentThread().getContextClassLoader()); return fromStream(is, keepJmxDomainName, defaultParserOnly, true); }
public static EmbeddedCacheManager fromXml(String xmlFile, boolean keepJmxDomainName) throws IOException { InputStream is = FileLookupFactory.newInstance().lookupFileStrict( xmlFile, Thread.currentThread().getContextClassLoader()); return fromStream(is, keepJmxDomainName); }
public static EmbeddedCacheManager fromXml(String xmlFile, boolean keepJmxDomainName, boolean defaultParserOnly, boolean start) throws IOException { InputStream is = FileLookupFactory.newInstance().lookupFileStrict( xmlFile, Thread.currentThread().getContextClassLoader()); return fromStream(is, keepJmxDomainName, defaultParserOnly, start); }
@Test(dataProvider = "configurationFiles") public void testParseAndConstructUnifiedXmlFile(Path config) throws IOException { String[] parts = config.getFileName().toString().split("\\."); int major = Integer.parseInt(parts[0]); int minor = Integer.parseInt(parts[1]); ParserRegistry parserRegistry = new ParserRegistry(Thread.currentThread().getContextClassLoader(), false); try (InputStream is = FileLookupFactory.newInstance().lookupFileStrict(config.toString(), Thread.currentThread().getContextClassLoader())) { ConfigurationBuilderHolder holder = parserRegistry.parse(is); for(ParserVersionCheck check : ParserVersionCheck.values()) { if (check.isIncludedBy(major, minor)) { check.check(holder); } } } }
private EmbeddedCacheManager createCacheManager(int nodeIndex) throws Exception { InputStream is = FileLookupFactory.newInstance().lookupFileStrict("async-jdbc-store-config.xml", Thread.currentThread().getContextClassLoader()); ParserRegistry parserRegistry = new ParserRegistry(Thread.currentThread().getContextClassLoader()); ConfigurationBuilderHolder holder = parserRegistry.parse(is); is.close(); for (ConfigurationBuilder builder : holder.getNamedConfigurationBuilders().values()) { for (StoreConfigurationBuilder storeBuilder : builder.persistence().stores()) { if (storeBuilder instanceof AbstractJdbcStoreConfigurationBuilder) { AbstractJdbcStoreConfigurationBuilder jdbcStoreBuilder = (AbstractJdbcStoreConfigurationBuilder) storeBuilder; jdbcStoreBuilder.simpleConnection() .driverClass("org.h2.Driver") .connectionUrl("jdbc:h2:mem:infinispan_string_based_" + nodeIndex + ";DB_CLOSE_DELAY=-1") .username("sa"); } } } return TestCacheManagerFactory.createClusteredCacheManager(holder); }
@Override protected void createCacheManagers() throws Throwable { server = PerThreadMBeanServerLookup.getThreadMBeanServer(); for (int i = 0; i < NUM_NODES; i++) { InputStream is = FileLookupFactory.newInstance().lookupFileStrict( "dynamic-indexing-distribution.xml", Thread.currentThread().getContextClassLoader()); ParserRegistry parserRegistry = new ParserRegistry( Thread.currentThread().getContextClassLoader()); ConfigurationBuilderHolder holder = parserRegistry.parse(is); // Each cache manager should use a different jmx domain and // a parallel-testsuite friendly mbean server holder.getGlobalConfigurationBuilder().globalJmxStatistics() .jmxDomain(BASE_JMX_DOMAIN + i) .mBeanServerLookup(new PerThreadMBeanServerLookup()); EmbeddedCacheManager cm = TestCacheManagerFactory .createClusteredCacheManager(holder, true); registerCacheManager(cm); Cache cache = cm.getCache(); caches.add(cache); } waitForClusterToForm(neededCacheNames); }
@Test(dataProvider="configurationFiles") public void configurationSerializationTest(Path config) throws Exception { ParserRegistry registry = new ParserRegistry(); InputStream is = FileLookupFactory.newInstance().lookupFileStrict(config.toString(), Thread.currentThread().getContextClassLoader()); ConfigurationBuilderHolder holderBefore = registry.parse(is); Map<String, Configuration> configurations = new HashMap<>();