public ClasspathConfigurationSource(String propertiesFileName) { try (InputStream is = ClassUtils.getDefaultClassLoader().getResourceAsStream(propertiesFileName)) { properties.load(is); } catch (IOException e) { throw new RuntimeException("Could not load properties file: " + propertiesFileName, e); } }
private static URL getClasspathResourceUrl(String path) throws FileNotFoundException { ClassLoader cl = ClassUtils.getDefaultClassLoader(); URL url = (cl != null ? cl.getResource(path) : ClassLoader.getSystemResource(path)); if (url == null) { String description = "class path resource [" + path + "]"; throw new FileNotFoundException(description + " cannot be resolved to URL because it does not exist"); } return url; }
public static StringBuilder readCQLFile(String cqlFileName) { StringBuilder cypher = new StringBuilder(); try (Scanner scanner = new Scanner( ClassUtils.getDefaultClassLoader().getResourceAsStream(cqlFileName))) { scanner.useDelimiter(System.getProperty("line.separator")); while (scanner.hasNext()) { cypher.append(scanner.next()).append(' '); } } return cypher; }
public static AttributeConverter<?, ?> getBigDecimalCollectionConverter(String collectionType) { try { Class collectionClazz = Class .forName(collectionType, false, ClassUtils.getDefaultClassLoader()); return new NumberCollectionStringConverter(BigDecimal.class, collectionClazz); } catch (Exception e) { throw new RuntimeException(e); } }
public static AttributeConverter<?, ?> getBigIntegerCollectionConverter(String collectionType) { try { Class collectionClazz = Class .forName(collectionType, false, ClassUtils.getDefaultClassLoader()); return new NumberCollectionStringConverter(BigInteger.class, collectionClazz); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Utility method to load the dedicated driver version of native types. * * @param nativeTypesImplementation the fully qualified name of the class implementing this drivers' natives types. * @return A fully loaded and initialized instance of the class qualified by <code>nativeTypesImplementation</code> * @throws ClassNotFoundException If the required implementation is not on the classpath. Initialization should terminate then. * @since 3.2 */ private static TypeSystem loadNativeTypes(String nativeTypesImplementation) throws ClassNotFoundException { try { Class<TypeSystem> nativeTypesClass = (Class<TypeSystem>) Class .forName(nativeTypesImplementation, true, ClassUtils.getDefaultClassLoader()); Constructor<TypeSystem> ctor = nativeTypesClass.getDeclaredConstructor(); ctor.setAccessible(true); return ctor.newInstance(); } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { throw new RuntimeException("Could not load native types implementation " + nativeTypesImplementation); } }
public static AttributeConverter<?, ?> getDateCollectionConverter(String collectionType) { try { Class collectionClazz = Class .forName(collectionType, false, ClassUtils.getDefaultClassLoader()); return new DateCollectionStringConverter(DateString.ISO_8601, collectionClazz); } catch (Exception e) { throw new RuntimeException(e); } }
public static AttributeConverter<?, ?> getEnumCollectionConverter(Class enumClass, String collectionType) { try { Class collectionClazz = Class .forName(collectionType, false, ClassUtils.getDefaultClassLoader()); return new EnumCollectionStringConverter(enumClass, collectionClazz); } catch (Exception e) { throw new RuntimeException(e); } }
public static AttributeConverter<?, ?> getConverterBasedCollectionConverter(AttributeConverter<?, ?> converter, String collectionType) { try { Class collectionClazz = Class .forName(collectionType, false, ClassUtils.getDefaultClassLoader()); return new ConverterBasedCollectionConverter<>(collectionClazz, converter); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
static boolean canRunHATests() { try { Class.forName("org.neo4j.graphdb.factory.HighlyAvailableGraphDatabaseFactory", false, ClassUtils.getDefaultClassLoader()); return true; } catch (ClassNotFoundException e) { return false; } } }
Class<?> clazz = Class.forName(classDescriptor, false, ClassUtils.getDefaultClassLoader()); return clazz.newInstance(); } catch (Exception e) { String classDescriptor = enumStringConverterInfo.get(EnumString.TYPE, null); try { Class clazz = Class.forName(classDescriptor, false, ClassUtils.getDefaultClassLoader()); return new EnumStringConverter(clazz, isLenientConversion(enumStringConverterInfo)); } catch (Exception e) { String classDescriptor = numberStringConverterInfo.get(NumberString.TYPE, null); try { Class clazz = Class.forName(classDescriptor, false, ClassUtils.getDefaultClassLoader()); return new NumberStringConverter(clazz, isLenientConversion(numberStringConverterInfo)); } catch (Exception e) {