当前位置: 首页>>代码示例>>Java>>正文


Java InvocationTargetException.getTargetException方法代码示例

本文整理汇总了Java中java.lang.reflect.InvocationTargetException.getTargetException方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationTargetException.getTargetException方法的具体用法?Java InvocationTargetException.getTargetException怎么用?Java InvocationTargetException.getTargetException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.InvocationTargetException的用法示例。


在下文中一共展示了InvocationTargetException.getTargetException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
/**
 * Return the value of an indexed property with the specified name.
 *
 * @param name Name of the property whose value is to be retrieved
 * @param index Index of the value to be retrieved
 * @return The indexed property's value
 *
 * @throws IllegalArgumentException if there is no property
 *  of the specified name
 * @throws IllegalArgumentException if the specified property
 *  exists, but is not indexed
 * @throws IndexOutOfBoundsException if the specified index
 *  is outside the range of the underlying property
 * @throws NullPointerException if no array or List has been
 *  initialized for this property
 */
public Object get(final String name, final int index) {

    Object value = null;
    try {
        value = getPropertyUtils().getIndexedProperty(instance, name, index);
    } catch (final IndexOutOfBoundsException e) {
        throw e;
    } catch (final InvocationTargetException ite) {
        final Throwable cause = ite.getTargetException();
        throw new IllegalArgumentException
                ("Error reading indexed property '" + name +
                          "' nested exception - " + cause);
    } catch (final Throwable t) {
        throw new IllegalArgumentException
                ("Error reading indexed property '" + name +
                          "', exception - " + t);
    }
    return (value);

}
 
开发者ID:yippeesoft,项目名称:NotifyTools,代码行数:37,代码来源:WrapDynaBean.java

示例2: testGetAnonymousLogger

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
public boolean testGetAnonymousLogger() throws Throwable {
    // Test getAnonymousLogger()
    URLClassLoader loadItUpCL = new URLClassLoader(getURLs(), null);
    Class<?> loadItUpClazz = Class.forName("LoadItUp1", true, loadItUpCL);
    ClassLoader actual = loadItUpClazz.getClassLoader();
    if (actual != loadItUpCL) {
        throw new Exception("LoadItUp1 was loaded by an unexpected CL: "
                             + actual);
    }
    Object loadItUpAnon = loadItUpClazz.newInstance();
    Method testAnonMethod = loadItUpClazz.getMethod("getAnonymousLogger",
                                                    String.class);
    try {
        return (Logger)testAnonMethod.invoke(loadItUpAnon, rbName) != null;
    } catch (InvocationTargetException ex) {
        throw ex.getTargetException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:IndirectlyLoadABundle.java

示例3: invoke

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    Hook hook = getHook(method.getName());
    try {
        if (hook != null && hook.isEnable()) {
            if (hook.beforeCall(mBaseInterface, method, args)) {
                Object res = hook.call(mBaseInterface, method, args);
                res = hook.afterCall(mBaseInterface, method, args, res);
                return res;
            }
        }
        return method.invoke(mBaseInterface, args);
    } catch (InvocationTargetException e) {
        Throwable cause = e.getTargetException();
        if (cause != null) {
            throw cause;
        }
        throw e;
    }
}
 
开发者ID:codehz,项目名称:container,代码行数:21,代码来源:HookDelegate.java

示例4: invoke

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
    try {
        if (method.getName().equals("getDeligate"))
            return impl;

        Object res = invoker.invoke(method.getName(), args);

        return res;
    } catch (InvocationTargetException e) {
        throw e.getTargetException();
    } finally {
        if ("close".equals(method.getName())) {
            invoker = null;
        }
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:19,代码来源:SuperEngineFactory.java

示例5: newFactory

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
/**
 * Retrieves a new HsqlSocketFactory whose class
 * is determined by the implClass argument. The basic contract here
 * is that implementations constructed by this method should return
 * true upon calling isSecure() iff they actually create secure sockets.
 * There is no way to guarantee this directly here, so it is simply
 * trusted that an  implementation is secure if it returns true
 * for calls to isSecure();
 *
 * @return a new secure socket factory
 * @param implClass the fully qaulified name of the desired
 *      class to construct
 * @throws Exception if a new secure socket factory cannot
 *      be constructed
 */
private static HsqlSocketFactory newFactory(String implClass)
throws Exception {

    Class       clazz;
    Constructor ctor;
    Class[]     ctorParm;
    Object[]    ctorArg;
    Object      factory;

    clazz    = Class.forName(implClass);
    ctorParm = new Class[0];

    // protected constructor
    ctor    = clazz.getDeclaredConstructor(ctorParm);
    ctorArg = new Object[0];

    try {
        factory = ctor.newInstance(ctorArg);
    } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();

        throw (t instanceof Exception) ? ((Exception) t)
                                       : new RuntimeException(
                                           t.toString());
    }

    return (HsqlSocketFactory) factory;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:44,代码来源:HsqlSocketFactory.java

示例6: invoke

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
@Override
protected Object invoke(final RemoteInvocation invocation, final Object targetObject)
	throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
	Throwable unwrapped = null;
	try
	{
		Object rval = super.invoke(invocation, targetObject);
		rval = initialiser.unwrapHibernate(rval);
		rval = initialiser.initialise(rval, new RemoteSimplifier());
		return rval;
	}
	catch( InvocationTargetException e )
	{
		unwrapped = e.getTargetException();
		Throwable t2 = unwrapped;
		// We want to determine if hibernate exception is thrown at any
		// point
		while( t2 != null )
		{
			if( t2 instanceof NestedRuntimeException )
			{
				logger.error(unwrapped.getMessage(), unwrapped);
				throw new RuntimeApplicationException(unwrapped.getMessage());
			}
			t2 = t2.getCause();
		}
		logger.error("Error invoking " + invocation.getMethodName(), unwrapped);
		throw e;
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:RemoteInterceptor.java

示例7: dealWithInvocationException

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
/**
 * Deals with InvocationException from proxied objects.
 * 
 * @param e
 *            The Exception instance to check.
 */
void dealWithInvocationException(InvocationTargetException e) throws SQLException, Throwable, InvocationTargetException {
    Throwable t = e.getTargetException();

    if (t != null) {
        if (this.lastExceptionDealtWith != t && shouldExceptionTriggerConnectionSwitch(t)) {
            invalidateCurrentConnection();
            pickNewConnection();
            this.lastExceptionDealtWith = t;
        }
        throw t;
    }
    throw e;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:MultiHostConnectionProxy.java

示例8: invokeMethod

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
private Object invokeMethod(Method method, Object[] args) throws Throwable {
	try {
		return method.invoke( rs, args );
	}
	catch ( InvocationTargetException e ) {
		throw e.getTargetException();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:ResultSetWrapperProxy.java

示例9: invoke

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

    // Thrift transport layer is not thread-safe (it's a wrapper on a socket), hence we need locking.
    synchronized (transport) {

        LOG.debug("Invoking method... > fromThread={}, method={}, args={}",
                  Thread.currentThread().getId(), method.getName(), args);

        try {

            return method.invoke(baseClient, args);
        } catch (InvocationTargetException e) {
            if (e.getTargetException() instanceof TTransportException) {
                TTransportException cause = (TTransportException) e.getTargetException();

                if (RESTARTABLE_CAUSES.contains(cause.getType())) {
                    // Try to reconnect. If fail, a TTransportException will be thrown.
                    reconnectOrThrowException();
                    try {
                        // If here, transport has been successfully open, hence new exceptions will be thrown.
                        return method.invoke(baseClient, args);
                    } catch (InvocationTargetException e1) {
                        LOG.debug("Exception: {}", e1.getTargetException());
                        throw e1.getTargetException();
                    }
                }
            }
            // Target exception is neither a TTransportException nor a restartable cause.
            LOG.debug("Exception: {}", e.getTargetException());
            throw e.getTargetException();
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:SafeThriftClient.java

示例10: handleInvocationTargetException

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
/**
 * If the {@link InvocationTargetException} wraps an exception that shouldn't be wrapped,
 * throw the wrapped exception.
 */
private static void handleInvocationTargetException(InvocationTargetException x) throws JAXBException {
    Throwable t = x.getTargetException();
    if( t != null ) {
        if( t instanceof JAXBException )
            // one of our exceptions, just re-throw
            throw (JAXBException)t;
        if( t instanceof RuntimeException )
            // avoid wrapping exceptions unnecessarily
            throw (RuntimeException)t;
        if( t instanceof Error )
            throw (Error)t;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ContextFinder.java

示例11: findIllegalArgumentExceptionInCauses

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
private Throwable findIllegalArgumentExceptionInCauses(
        InvocationTargetException e) {
    if (e.getCause() instanceof IllegalArgumentException) {
        return e.getCause();
    }
    if (e.getCause().getCause() instanceof IllegalArgumentException) {
        return e.getCause().getCause();
    }
    if (e.getTargetException() instanceof IllegalArgumentException) {
        return e.getTargetException();
    }
    return e;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:14,代码来源:NullArgumentTestBase.java

示例12: testConstructorThrowsException

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testConstructorThrowsException() throws Throwable {
	Constructor<?> constructor =
		WriterUtil.class.getDeclaredConstructors()[0];

	constructor.setAccessible(true);

	try {
		constructor.newInstance();
	}
	catch (InvocationTargetException ite) {
		throw ite.getTargetException();
	}
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:15,代码来源:WriterUtilTest.java

示例13: handleValueResponse

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
private Object handleValueResponse(RequestHandler handler) throws Throwable {
  ServiceResponseMessage response;
  try {
    //wait until response is received, or stream is closed
    response = handler.getNextResponse();
  } catch (InvocationTargetException e) {
    throw e.getTargetException();
  }
  if (response == null) {
    errors.increment();
    throw new ServiceTimeOutException();
  }
  if (LOGGER.isDebug()) LOGGER.debug("Got single response");
  return ((ServiceResponseValueMessage) response).getReturnValue();
}
 
开发者ID:mnemonic-no,项目名称:common-services,代码行数:16,代码来源:ServiceMessageClient.java

示例14: init

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
@Override
public final void init(VariableContext params) {
    try {
        initMethod.invoke(this, params);
    } catch (InvocationTargetException ex) {
        throw new MethodException("",ex.getTargetException());
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:9,代码来源:ParamsAction.java

示例15: testConstructorThrowsException

import java.lang.reflect.InvocationTargetException; //导入方法依赖的package包/类
@Test(expected = UnsupportedOperationException.class)
public void testConstructorThrowsException() throws Throwable {
	Constructor<?> constructor =
		MockDocumentationWriter.class.getDeclaredConstructors()[0];

	constructor.setAccessible(true);

	try {
		constructor.newInstance();
	}
	catch (InvocationTargetException ite) {
		throw ite.getTargetException();
	}
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:15,代码来源:MockDocumentationWriterTest.java


注:本文中的java.lang.reflect.InvocationTargetException.getTargetException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。