Example usage for java.lang.reflect Constructor newInstance

List of usage examples for java.lang.reflect Constructor newInstance

Introduction

In this page you can find the example usage for java.lang.reflect Constructor newInstance.

Prototype

@CallerSensitive
@ForceInline 
public T newInstance(Object... initargs) throws InstantiationException, IllegalAccessException,
        IllegalArgumentException, InvocationTargetException 

Source Link

Document

Uses the constructor represented by this Constructor object to create and initialize a new instance of the constructor's declaring class, with the specified initialization parameters.

Usage

From source file:com.greenpepper.maven.plugin.Repository.java

/**
 * <p>newInstance.</p>//from   w  w w  .j  av a 2s .  c  om
 *
 * @return a {@link com.greenpepper.repository.DocumentRepository} object.
 * @throws java.lang.Exception if any.
 */
public DocumentRepository newInstance() throws Exception {
    Class<?> klass = Class.forName(type);
    if (!DocumentRepository.class.isAssignableFrom(klass))
        throw new IllegalArgumentException("Not a " + DocumentRepository.class.getName() + ": " + type);

    Constructor<?> constructor = klass.getConstructor(String[].class);
    return (DocumentRepository) constructor.newInstance(new Object[] { StringUtils.split(root, ';') });
}