Details
Description
//Resource class
@Path("resource")
public class Resource {
private static final AsyncResponseBlockingQueue[] step =
{ new AsyncResponseBlockingQueue(1), new AsyncResponseBlockingQueue(1), new AsyncResponseBlockingQueue(1)};
@GET
@Path("suspend")
public void suspend(@Suspended AsyncResponse asyncResponse)
@GET
@Path("register")
public String registerObject(@QueryParam("step") String step)
@GET
@Path("exception")
public String throwExceptionOnAsyncResponse(
@QueryParam("step") String step)
}
/////// StringBean
public class StringBean {
private String header;
public String get()
{ return header; }public void set(String header)
{ this.header = header; } @Override
public String toString()
public StringBean(String header)
{ super(); this.header = header; }}
/////// Throw Exception here
public class ExceptionThrowingStringBean extends StringBean {
public ExceptionThrowingStringBean(String header)
@Override
public String get()
}
////// Register a provider to deal with StringBean,
// This cause we have an exception thrown in JaxrsOutInterceptor
@Provider
public class StringBeanEntityProvider implements MessageBodyReader<StringBean>,
MessageBodyWriter<StringBean> {
@Override
public boolean isWriteable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType)
@Override
public long getSize(StringBean t, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType)
@Override
public void writeTo(StringBean t, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException,
WebApplicationException
@Override
public boolean isReadable(Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType)
@Override
public StringBean readFrom(Class<StringBean> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
throws IOException, WebApplicationException
}
////// Need to get the exception throwed from ExceptionThrowingStringBean.get() method in this callback
public class MyCompletionCallback implements CompletionCallback {
private static String throwableName;
public static final String NULL = "NULL";
public static final String NONAME = "No name has been set yet";
@Override
public void onComplete(Throwable throwable)
public static final String getLastThrowableName()
{ return throwableName; }public static final void resetLastThrowableName()
{ throwableName = NONAME; }}