Example usage for org.apache.commons.discovery.tools ClassUtils newInstance

List of usage examples for org.apache.commons.discovery.tools ClassUtils newInstance

Introduction

In this page you can find the example usage for org.apache.commons.discovery.tools ClassUtils newInstance.

Prototype

public static Object newInstance(Class impl, Class paramClasses[], Object params[]) throws DiscoveryException,
        InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException 

Source Link

Document

Instantiate a new

Usage

From source file:org.apache.axis.AxisProperties.java

public static Object newInstance(final Class spiClass, final Class constructorParamTypes[],
        final Object constructorParams[]) {
    return AccessController.doPrivileged(new PrivilegedAction() {
        public Object run() {
            ResourceClassIterator services = getResourceClassIterator(spiClass);

            Object obj = null;//  w  w w  .  ja  v  a  2  s .c o  m
            while (obj == null && services.hasNext()) {
                Class service = services.nextResourceClass().loadClass();

                /* service == null
                 * if class resource wasn't loadable
                 */
                if (service != null) {
                    /* OK, class loaded.. attempt to instantiate it.
                     */
                    try {
                        ClassUtils.verifyAncestory(spiClass, service);
                        obj = ClassUtils.newInstance(service, constructorParamTypes, constructorParams);
                    } catch (InvocationTargetException e) {
                        if (e.getTargetException() instanceof java.lang.NoClassDefFoundError) {
                            log.debug(Messages.getMessage("exception00"), e);
                        } else {
                            log.warn(Messages.getMessage("exception00"), e);
                        }
                    } catch (Exception e) {
                        log.warn(Messages.getMessage("exception00"), e);
                    }
                }
            }

            return obj;
        }
    });
}