當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。