Example usage for org.apache.commons.lang ClassUtils getClass

List of usage examples for org.apache.commons.lang ClassUtils getClass

Introduction

In this page you can find the example usage for org.apache.commons.lang ClassUtils getClass.

Prototype

public static Class<?> getClass(ClassLoader classLoader, String className, boolean initialize)
        throws ClassNotFoundException 

Source Link

Document

Returns the class represented by className using the classLoader.

Usage

From source file:net.datenwerke.transloader.ClassWrapper.java

/**
 * Loads the <code>Class</code> with the given name from the given <code>ClassLoader</code>.
 *
 * @param classLoader the <code>ClassLoader</code> with which to load it
 * @param className   the name of the <code>Class</code>
 * @return the <code>Class</code> with the given name loaded from the given <code>ClassLoader</code>
 * @throws net.datenwerke.transloader.except.TransloaderException
 *          if the <code>Class</code> cannot be found in the given <code>ClassLoader</code>
 *//*from  ww w .  jav a  2  s  . c  o m*/
public static Class getClassFrom(ClassLoader classLoader, String className) {
    Assert.areNotNull(classLoader, className);
    try {
        return ClassUtils.getClass(classLoader, className, false);
    } catch (ClassNotFoundException e) {
        // TODO test ClassNotFoundException
        throw new TransloaderException(
                "Unable to load Class '" + className + "' from ClassLoader '" + classLoader + "'.", e);
    }
}

From source file:com.github.dirkraft.jash.ShExecutableJarBundler.java

@Override
public List<String> validateAndInit() throws Exception {
    List<String> errors = super.validateAndInit();

    if (!jarFile.isFile()) {
        errors.add(jarFile + " is not a file.");
        return errors;
    }//from  ww w.ja v a2s  .c  o  m

    JarFile jar = new JarFile(jarFile);
    Manifest manifest = jar.getManifest();
    String mainClass = manifest.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
    ClassLoader jarClassLoader = URLClassLoader.newInstance(new URL[] { jarFile.toURI().toURL() });
    try {
        ClassUtils.getClass(jarClassLoader, mainClass, false);
    } catch (ClassNotFoundException e) {
        errors.add("Could not find Main-Class: " + mainClass + " in jar " + jarFile.getAbsolutePath());
        return errors;
    }

    _targetBinary = outputDir.toPath().resolve(commandName).toFile();
    if (_targetBinary.exists()) {
        errors.add("Target binary path " + _targetBinary.getAbsolutePath()
                + " is occupied. Will not overwrite, so aborting.");
    }

    return errors;
}

From source file:org.apache.maven.plugin.javadoc.AbstractFixJavadocMojo.java

/**
 * @param className not null//  w  w  w.j ava2 s .  c o m
 * @return the Class corresponding to the given class name using the project classloader.
 * @throws MojoExecutionException if class not found
 * @see {@link ClassUtils#getClass(ClassLoader, String, boolean)}
 * @see {@link #getProjectClassLoader()}
 */
private Class<?> getClass(String className) throws MojoExecutionException {
    try {
        return ClassUtils.getClass(getProjectClassLoader(), className, false);
    } catch (ClassNotFoundException e) {
        throw new MojoExecutionException("ClassNotFoundException: " + e.getMessage(), e);
    }
}

From source file:org.datacleaner.descriptors.RemoteDescriptorProvider.java

private Class<?> findClass(String name) throws ClassNotFoundException {
    return ClassUtils.getClass(getClass().getClassLoader(), name, false);
}