public static String encodeResponseForFailure(Method serviceMethod, Throwable cause, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (cause == null) { throw new NullPointerException("cause cannot be null"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } if (serviceMethod != null && !RPCServletUtils.isExpectedException(serviceMethod, cause)) { throw new UnexpectedException("Service method '" + getSourceRepresentation(serviceMethod) + "' threw an unexpected exception: " + cause.toString(), cause); } return encodeResponse(cause.getClass(), cause, true, flags, serializationPolicy); }
public static String encodeResponseForSuccess(Method serviceMethod, Object object, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (serviceMethod == null) { throw new NullPointerException("serviceMethod cannot be null"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } Class<?> methodReturnType = serviceMethod.getReturnType(); if (methodReturnType != void.class && object != null) { Class<?> actualReturnType; if (methodReturnType.isPrimitive()) { actualReturnType = getPrimitiveClassFromWrapper(object.getClass()); } else { actualReturnType = object.getClass(); } if (actualReturnType == null || !methodReturnType.isAssignableFrom(actualReturnType)) { throw new IllegalArgumentException("Type '" + printTypeName(object.getClass()) + "' does not match the return type in the method's signature: '" + getSourceRepresentation(serviceMethod) + "'"); } } return encodeResponse(methodReturnType, object, false, flags, serializationPolicy); }
public static String encodeResponseForFailure(Method serviceMethod, Throwable cause, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (cause == null) { throw new NullPointerException("cause cannot be null"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } if (serviceMethod != null && !RPCServletUtils.isExpectedException(serviceMethod, cause)) { throw new UnexpectedException("Service method '" + getSourceRepresentation(serviceMethod) + "' threw an unexpected exception: " + cause.toString(), cause); } return encodeResponse(cause.getClass(), cause, true, flags, serializationPolicy); }
public static String encodeResponseForFailure(Method serviceMethod, Throwable cause, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (cause == null) { throw new NullPointerException("cause cannot be null"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } if (serviceMethod != null && !RPCServletUtils.isExpectedException(serviceMethod, cause)) { throw new UnexpectedException("Service method '" + getSourceRepresentation(serviceMethod) + "' threw an unexpected exception: " + cause.toString(), cause); } return encodeResponse(cause.getClass(), cause, true, flags, serializationPolicy); }
public static String encodeResponseForSuccess(Method serviceMethod, Object object, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (serviceMethod == null) { throw new NullPointerException("serviceMethod cannot be null"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } Class<?> methodReturnType = serviceMethod.getReturnType(); if (methodReturnType != void.class && object != null) { Class<?> actualReturnType; if (methodReturnType.isPrimitive()) { actualReturnType = getPrimitiveClassFromWrapper(object.getClass()); } else { actualReturnType = object.getClass(); } if (actualReturnType == null || !methodReturnType.isAssignableFrom(actualReturnType)) { throw new IllegalArgumentException("Type '" + printTypeName(object.getClass()) + "' does not match the return type in the method's signature: '" + getSourceRepresentation(serviceMethod) + "'"); } } return encodeResponse(methodReturnType, object, false, flags, serializationPolicy); }
public static String encodeResponseForSuccess(Method serviceMethod, Object object, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (serviceMethod == null) { throw new NullPointerException("serviceMethod cannot be null"); } if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } Class<?> methodReturnType = serviceMethod.getReturnType(); if (methodReturnType != void.class && object != null) { Class<?> actualReturnType; if (methodReturnType.isPrimitive()) { actualReturnType = getPrimitiveClassFromWrapper(object.getClass()); } else { actualReturnType = object.getClass(); } if (actualReturnType == null || !methodReturnType.isAssignableFrom(actualReturnType)) { throw new IllegalArgumentException("Type '" + printTypeName(object.getClass()) + "' does not match the return type in the method's signature: '" + getSourceRepresentation(serviceMethod) + "'"); } } return encodeResponse(methodReturnType, object, false, flags, serializationPolicy); }