public static String invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (serviceMethod == null) { throw new NullPointerException("serviceMethod"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } String responsePayload; try { Object result = serviceMethod.invoke(target, args); responsePayload = encodeResponseForSuccess(serviceMethod, result, serializationPolicy, flags); } catch (IllegalAccessException e) { SecurityException securityException = new SecurityException(formatIllegalAccessErrorMessage(target, serviceMethod)); securityException.initCause(e); throw securityException; } catch (IllegalArgumentException e) { SecurityException securityException = new SecurityException(formatIllegalArgumentErrorMessage(target, serviceMethod, args)); securityException.initCause(e); throw securityException; } catch (InvocationTargetException e) { // Try to encode the caught exception // Throwable cause = e.getCause(); responsePayload = encodeResponseForFailure(serviceMethod, cause, serializationPolicy, flags); } return responsePayload; }
public static String invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (serviceMethod == null) { throw new NullPointerException("serviceMethod"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } String responsePayload; try { Object result = serviceMethod.invoke(target, args); responsePayload = encodeResponseForSuccess(serviceMethod, result, serializationPolicy, flags); } catch (IllegalAccessException e) { SecurityException securityException = new SecurityException(formatIllegalAccessErrorMessage(target, serviceMethod)); securityException.initCause(e); throw securityException; } catch (IllegalArgumentException e) { SecurityException securityException = new SecurityException(formatIllegalArgumentErrorMessage(target, serviceMethod, args)); securityException.initCause(e); throw securityException; } catch (InvocationTargetException e) { // Try to encode the caught exception // Throwable cause = e.getCause(); responsePayload = encodeResponseForFailure(serviceMethod, cause, serializationPolicy, flags); } return responsePayload; }
public static String invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (serviceMethod == null) { throw new NullPointerException("serviceMethod"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } String responsePayload; try { Object result = serviceMethod.invoke(target, args); responsePayload = encodeResponseForSuccess(serviceMethod, result, serializationPolicy, flags); } catch (IllegalAccessException e) { SecurityException securityException = new SecurityException(formatIllegalAccessErrorMessage(target, serviceMethod)); securityException.initCause(e); throw securityException; } catch (IllegalArgumentException e) { SecurityException securityException = new SecurityException(formatIllegalArgumentErrorMessage(target, serviceMethod, args)); securityException.initCause(e); throw securityException; } catch (InvocationTargetException e) { // Try to encode the caught exception // Throwable cause = e.getCause(); responsePayload = encodeResponseForFailure(serviceMethod, cause, serializationPolicy, flags); } return responsePayload; }