@Override public void onReload(Container container) { onShutdown(container); onStartup(container); } }
private StandaloneWebConverterConfiguration makeConfiguration() { return new StandaloneWebConverterConfiguration(baseFolder, corePoolSize, maximumPoolSize, keepAliveTime, processTimeout, requestTimeout, converterConfiguration); }
@Override protected void configure() { bind(webConverterConfiguration).to(IWebConverterConfiguration.class); } }
@GET @Produces(MediaType.APPLICATION_XML) public Response serverInformation() { return Response .status(ConverterNetworkProtocol.Status.OK.getStatusCode()) .entity(new ConverterServerInformation( webConverterConfiguration.getConverter().isOperational(), webConverterConfiguration.getTimeout(), ConverterNetworkProtocol.CURRENT_PROTOCOL_VERSION, webConverterConfiguration.getConverter().getSupportedConversions())) .type(MediaType.APPLICATION_XML_TYPE) .build(); }
public WebConverterApplication(IWebConverterConfiguration webConverterConfiguration) { Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(ConverterResource.class); classes.add(EncodingFilter.class); classes.add(GZipEncoder.class); this.classes = Collections.unmodifiableSet(classes); Set<Object> singletons = new HashSet<Object>(); singletons.add(new WebConverterConfigurationBinder(webConverterConfiguration)); this.singletons = Collections.unmodifiableSet(singletons); }
/** * Creates the conversion server that is specified by this builder. * * @return The conversion server that is specified by this builder. */ public HttpServer build() { checkNotNull(baseUri); StandaloneWebConverterConfiguration configuration = makeConfiguration(); // The configuration has to be configured both by a binder to make it injectable // and directly in order to trigger life cycle methods on the deployment container. ResourceConfig resourceConfig = ResourceConfig .forApplication(new WebConverterApplication(configuration)) .register(configuration); if (sslContext == null) { return GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig); } else { return GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, true, new SSLEngineConfigurator(sslContext)); } }
@POST public void convert( InputStream inputStream, @Suspended AsyncResponse asyncResponse, @HeaderParam(HttpHeaders.CONTENT_TYPE) String inputType, @HeaderParam(HttpHeaders.ACCEPT) String responseType, @DefaultValue("" + IConverter.JOB_PRIORITY_NORMAL) @HeaderParam(ConverterNetworkProtocol.HEADER_JOB_PRIORITY) int priority) { DocumentType targetType = new DocumentType(responseType); // The received input stream does not need to be closed since the underlying channel is automatically closed with responding. // If the stream was closed manually, this would in contrast lead to a NullPointerException since the channel was already detached. webConverterConfiguration.getConverter() .convert(inputStream, false).as(new DocumentType(inputType)) .to(AsynchronousConversionResponse.to(asyncResponse, targetType, webConverterConfiguration.getTimeout())).as(targetType) .prioritizeWith(priority) .schedule(); } }