本文整理汇总了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);
}
示例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();
}
}
示例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;
}
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
}
示例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();
}
}
}
示例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;
}
}
示例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;
}
示例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();
}
}
示例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();
}
示例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());
}
}
示例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();
}
}