List of usage examples for org.apache.commons.lang3 ExtendedClassUtils getDefaultClassLoader
public static final ClassLoader getDefaultClassLoader(Class<?> anchor)
From source file:net.community.chest.gitcloud.facade.AbstractEnvironmentInitializer.java
protected void extractConfigFiles(File confDir, String resPrefix, Collection<String> names) { if (ConfigUtils.verifyFolderProperty(ConfigUtils.CONF_DIR_NAME, confDir)) { logger.info("extractConfigFiles(" + resPrefix + ") - created " + ExtendedFileUtils.toString(confDir)); }/*from w w w . j ava 2s. c o m*/ ClassLoader cl = ExtendedClassUtils.getDefaultClassLoader(getClass()); for (String fileName : names) { File targetFile = new File(confDir, fileName); if (targetFile.exists()) { logger.info("extractConfigFiles(" + fileName + ")[" + resPrefix + "] skip - already exists: " + ExtendedFileUtils.toString(targetFile)); continue; } try { long copyLength = extractConfigFile(cl.getResourceAsStream(resPrefix + "/" + fileName), targetFile, getWorkBuf(ExtendedIOUtils.DEFAULT_BUFFER_SIZE_VALUE)); if (copyLength <= 0L) { throw new StreamCorruptedException("Bad copy count: " + copyLength); } logger.info("extractConfigFiles(" + resPrefix + ")[" + fileName + "] " + copyLength + " bytes: " + ExtendedFileUtils.toString(targetFile)); } catch (IOException e) { RuntimeException thrown = new RuntimeException( "extractConfigFiles(" + resPrefix + ")[" + fileName + "]" + " failed (" + e.getClass().getSimpleName() + ")" + " to extract contents: " + e.getMessage(), e); logger.warn(thrown.getMessage(), e); throw thrown; } } }
From source file:net.community.chest.gitcloud.facade.AbstractContextInitializer.java
protected void scanArtifactsManifests(Predicate<Pair<URL, Manifest>> manifestHandler) { ClassLoader loader = ExtendedClassUtils.getDefaultClassLoader(getClass()); try {//from ww w . j a v a2 s .c om for (Enumeration<URL> manifests = loader.getResources(JarFile.MANIFEST_NAME); (manifests != null) && manifests.hasMoreElements();) { URL url = manifests.nextElement(); try { Manifest manifest = ManifestUtils.loadManifest(url); if (manifestHandler.evaluate(Pair.of(url, manifest))) { logger.info("Scanning stopped by handler at URL=" + url.toExternalForm()); break; } } catch (Exception e) { logger.warn(e.getClass().getSimpleName() + " while handle URL=" + url.toExternalForm() + ": " + e.getMessage()); } } } catch (IOException e) { logger.warn("Failed (" + e.getClass().getSimpleName() + ") to get manifests URLs: " + e.getMessage()); } }
From source file:org.springframework.jdbc.repo.impl.AbstractRawPropertiesRepoImpl.java
protected AbstractRawPropertiesRepoImpl(Class<E> eClass, ConversionService converter, IdentifiedEntityIdGenerator<E> idGen) { super(eClass); entityClass = Validate.notNull(eClass, "No entity class", ArrayUtils.EMPTY_OBJECT_ARRAY); idGenerator = Validate.notNull(idGen, "No ID(s) generator", ArrayUtils.EMPTY_OBJECT_ARRAY); conversionService = Validate.notNull(converter, "No conversion service", ArrayUtils.EMPTY_OBJECT_ARRAY); loader = ExtendedClassUtils.getDefaultClassLoader(getClass()); }
From source file:org.springframework.validation.ExtendedValidationUtils.java
/** * @param validator The {@link TypedValidator} * @return A proxy {@link Validator} that delegates the calls to the typed one * @see #toValidator(TypedValidator, ClassLoader) *///from w w w . j av a 2 s .c om public static final Validator toValidator(TypedValidator<?> validator) { Assert.notNull(validator, "No validator instance"); return toValidator(validator, ExtendedClassUtils.getDefaultClassLoader(validator.getClass())); }