Java 类javax.ws.rs.container.TimeoutHandler 实例源码

项目:pentaho-osgi-bundles    文件:NotificationServiceTest.java   
@Test
public void testGetNotificationTimeout() {
  final AsyncResponse asyncResponse = mock( AsyncResponse.class );
  NotificationRequestWrapper notificationRequestWrapper = new NotificationRequestWrapper();
  NotificationRequest notificationRequest = new NotificationRequest();
  notificationRequest.setNotificationType( "test-type" );
  NotificationRequestEntry notificationRequestEntry = new NotificationRequestEntry( "test-id", 10L );
  notificationRequest.setEntries( Arrays.asList( notificationRequestEntry ) );
  notificationRequestWrapper.setRequests( Arrays.asList( notificationRequest ) );
  doAnswer( new Answer<Void>() {
    @Override public Void answer( InvocationOnMock invocation ) throws Throwable {
      ( (TimeoutHandler) invocation.getArguments()[ 0 ] ).handleTimeout( asyncResponse );
      ( (TimeoutHandler) invocation.getArguments()[ 0 ] ).handleTimeout( asyncResponse );
      return null;
    }
  } ).when( asyncResponse ).setTimeoutHandler( any( TimeoutHandler.class ) );
  service.getNotifications( asyncResponse, notificationRequestWrapper );
  verify( asyncResponse, times( 1 ) ).resume( any( NotificationResponse.class ) );
}
项目:Tanaguru    文件:WebResourceImplRESTFacade.java   
@GET
    @Path("/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public void webresource(@javax.ws.rs.PathParam("id") Long id, @Suspended final AsyncResponse response) throws IOException {
//        WebResource webResource =  webResourceDataServiceDecorator.getWebResourceFullDeep(id);
        ObjectMapper mapper = new ObjectMapper();
        response.setTimeoutHandler(new TimeoutHandler() {
            @Override
            public void handleTimeout(AsyncResponse asyncResponse) {
                LOGGER.error("Timout error in audit page");
                AuditResult auditResult = new AuditResult();
                auditResult.setMessage((String) messages.get("global.timeout.error"));
                asyncResponse.resume(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity(auditResult).build());
            }
        });
        //Time out is fixed to 60 seconds
        response.setTimeout(60, TimeUnit.SECONDS);
//        response.resume(mapper.writeValueAsString(webResource));
    }
项目:reactive-data    文件:DefaultAsyncResponse.java   
@Override
public void setTimeoutHandler(TimeoutHandler handler) {
  throw new UnsupportedOperationException();

}
项目:micro-server    文件:MockAsyncResponse.java   
@Override
public void setTimeoutHandler(TimeoutHandler handler) {
    // TODO Auto-generated method stub

}
项目:mapcode-rest-service    文件:TestAsyncResponse.java   
@Override
public void setTimeoutHandler(final TimeoutHandler handler) {
    // Empty.
}
项目:app-ms    文件:VertxAsynchronousResponse.java   
/**
 * {@inheritDoc}.
 */
@Override
public void setTimeoutHandler(final TimeoutHandler handler) {

    timeoutHandler = handler;

}
项目:EDDI    文件:TestCaseRuntime.java   
@Override
public void setTimeoutHandler(TimeoutHandler handler) {

}