private JerseyTest createJerseyTest(Boolean binaryCompressionOnly) { return new JerseyTest() { @Override protected Application configure() { ResourceConfig config = new ResourceConfig(); config.register(TestResource.class); config.register(EncodingFilter.class); config.register(GZipEncoder.class); config.register(GatewayBinaryResponseFilter.class); if (binaryCompressionOnly != null) { config.property(GatewayBinaryResponseFilter.BINARY_COMPRESSION_ONLY_PROPERTY, binaryCompressionOnly); } return config; } }; }
private Main() { packages("us.askplatyp.kb.lucene.http"); register(JacksonFeature.class); register(EntityFilteringFeature.class); register(new AbstractBinder() { @Override protected void configure() { bindFactory(WikidataLuceneIndexFactory.class).to(LuceneIndex.class); } }); register(CORSFilter.class); register(ApiListingResource.class); register(SwaggerSerializers.class); EncodingFilter.enableFor(this, GZipEncoder.class); EncodingFilter.enableFor(this, DeflateEncoder.class); configureSwagger(); }
/** * コンストラクタです。 */ public RackApiApplicationConfig() { packages(RackApiScanPackage.class.getPackage().getName()); packages(ConnectorScanPackage.class.getPackage().getName()); packages(SpringLifecycleListener.class.getPackage().getName()); property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE, true); property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); register(ValidationConfigurationContextResolver.class); register(JacksonFeature.class); register(LoggingFilter.class); register(LocaleContextFilter.class); register(EncodingFilter.class); register(GZipEncoder.class); registerClasses(JerseyConfigs.getExcpetionMappers()); }
public RestResourceConfig() { log.info("-----------------------------loading JERSEY2 restful---------------------------"); packages("com.framework.rest.service"); register(RestAuthRequestFilter.class); register(RestResponseFilter.class); register(LoggingFilter.class); register(JacksonFeature.class); register(DeflateEncoder.class); EncodingFilter.enableFor(this, GZipEncoder.class); }
public JerseyConfig() { log.info("Registering classes"); register(AppConfiguration.class); packages("com.pokebattler.fight.data"); packages("com.pokebattler.fight.resources"); register(ProtobufJsonProvider.class); register(ProtobufBinaryProvider.class); // need to be in order register(ETagResponseFilter.class); register(CORSResponseFilter.class); register(CacheControlResponseFilter.class); register(EntityFilteringFeature.class); EncodingFilter.enableFor(this, GZipEncoder.class); }
@Override protected Application configure() { return new ResourceConfig(MockServer.class) .register(RolesAllowedDynamicFeature.class) .register(new MockSecurityFilter(), Priorities.AUTHENTICATION) .register(JerseyClient.createMoxyJsonResolver()) .register(GZipEncoder.class) .register(EncodingFilter.class); }
private GatewayRequestObjectHandlerImpl createAndStartHandler(ResourceConfig config, TestService testService) { config.register(GatewayFeature.class); Binder binder = new InstanceBinder.Builder().addInstance(testService, TestService.class).build(); config.register(binder); config.register(TestResource.class); config.register(EncodingFilter.class); config.register(GZipEncoder.class); config.register(SomeCheckedAppExceptionMapper.class); config.register(SomeUncheckedAppExceptionMapper.class); config.register(GlobalExceptionMapper.class); GatewayRequestObjectHandlerImpl handler = new GatewayRequestObjectHandlerImpl(); handler.init(config); handler.start(); return handler; }
public RequestHandler() { // configure the application with the resource init(new ResourceConfig() .register(GatewayFeature.class) .register(MultiPartFeature.class) .register(EncodingFilter.class) .register(GZipEncoder.class) .packages("com.jrestless.aws.examples")); start(); }
protected static void registerStuff(ResourceConfig rConfig) { rConfig.register(AccessOriginFilter.class); /* * rConfig.register(ErrorMapper.class); * rConfig.register(PreFilter.class); * rConfig.register(PostFilter.class); */ rConfig.register(GenericExceptionMapper.class); rConfig.register(org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainerProvider.class); EncodingFilter.enableFor(rConfig, GZipEncoder.class); rConfig.register(JsonIteratorConverter.class); }
private HttpServer createHttpServer() throws IOException, IllegalArgumentException, UriBuilderException, URISyntaxException { ResourceConfig resourceConfig = new ResourceConfig() .packages(true, Configuration.instance().getStrings("APP.Jersey.Resources").toArray(new String[0])) .register(FrontendFeature.class); EncodingFilter.enableFor(resourceConfig, GZipEncoder.class); return GrizzlyHttpServerFactory.createHttpServer(getURI(), resourceConfig, false); }
/** * Register JAX-RS application components. */ public RestDemoJaxRsApplication() { packages("org.codingpedia.demo.rest"); // // register application resources // register(PodcastsResource.class); // register(PodcastLegacyResource.class); // // // register filters // register(RequestContextFilter.class); // register(LoggingResponseFilter.class); // register(CORSResponseFilter.class); // // // register exception mappers // register(GenericExceptionMapper.class); // register(AppExceptionMapper.class); // register(CustomReasonPhraseExceptionMapper.class); // register(NotFoundExceptionMapper.class); // // // register features // register(JacksonFeature.class); register(EntityFilteringFeature.class); EncodingFilter.enableFor(this, GZipEncoder.class); // property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, new Annotation[] {PodcastDetailedView.Factory.get()}); }
@Override public void deploy(WebAppContext context) { context.addFilter(new FilterHolder(maintenanceModeFilter), "/whois/*", EnumSet.allOf(DispatcherType.class)); final ResourceConfig resourceConfig = new ResourceConfig(); EncodingFilter.enableFor(resourceConfig, GZipEncoder.class); EncodingFilter.enableFor(resourceConfig, DeflateEncoder.class); resourceConfig.register(MultiPartFeature.class); resourceConfig.register(whoisRestService); resourceConfig.register(whoisSearchService); resourceConfig.register(whoisVersionService); resourceConfig.register(syncUpdatesService); resourceConfig.register(asnTransfersRestService); resourceConfig.register(inetnumTransfersRestService); resourceConfig.register(whoisMetadata); resourceConfig.register(geolocationService); resourceConfig.register(abuseContactService); resourceConfig.register(autocompleteService); resourceConfig.register(referencesService); resourceConfig.register(defaultExceptionMapper); resourceConfig.register(domainObjectService); resourceConfig.register(fullTextSearch); resourceConfig.register(batchUpdatesService); resourceConfig.register(new CacheControlFilter()); final JacksonJaxbJsonProvider jaxbJsonProvider = new JacksonJaxbJsonProvider(); jaxbJsonProvider.configure(SerializationFeature.INDENT_OUTPUT, true); jaxbJsonProvider.configure(SerializationFeature.WRAP_ROOT_VALUE, false); resourceConfig.register(jaxbJsonProvider); // only allow cross-origin requests from ripe.net final FilterHolder crossOriginFilterHolder = context.addFilter(org.eclipse.jetty.servlets.CrossOriginFilter.class, "/whois/*", EnumSet.allOf(DispatcherType.class)); crossOriginFilterHolder.setInitParameter(org.eclipse.jetty.servlets.CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "https?://*.ripe.net"); context.addServlet(new ServletHolder("Whois REST API", new ServletContainer(resourceConfig)), "/whois/*"); }
public MockWebApplication(boolean operational, long timeout) { Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(EncodingFilter.class); classes.add(GZipEncoder.class); classes.add(ClientEncodingAssertingFilter.class); this.classes = Collections.unmodifiableSet(classes); Set<Object> singletons = new HashSet<Object>(); singletons.add(new MockWebService(operational, timeout)); this.singletons = Collections.unmodifiableSet(singletons); }
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); }
private void enableContentEncodingGzip(Environment environment) { EncodingFilter.enableFor(environment.jersey().getResourceConfig(), GZipEncoder.class); }
public JerseyConfig() { EncodingFilter.enableFor(this, GZipEncoder.class); }
public void start() throws IllegalStateException, IOException { synchronized(this) { if (server == null) { if (config.isSecure()) { // Start a HTTPS secure server. server = new RestServer(config.getAddress(), config.getPort(), config.getHttpsConfig().getSSLContext()); } else { // Start an insecure HTTP server. server = new RestServer(config.getAddress(), config.getPort()); } server.addInterface(EncodingFilter.class) .addInterface(GZipEncoder.class) .addInterface(DeflateEncoder.class) .addInterface(DiscoveryService.class) .addInterface(Portal.class) .addInterface(ManagementService.class) .setPackages(config.getPackageName()) .setFileCacheMaxAge(FILE_CACHE_MAX_AGE); if (config.getStaticPath() != null) { server.setStaticPath(config.getStaticPath()) .setRelativePath(config.getRelativePath()); } log.debug("DDSServer.start: Starting Grizzly on " + config.getUrl() + " for resources " + config.getPackageName()); server.start(); while (!server.isStarted()) { try { log.debug("DDSServer.start: Waiting for Grizzly to start ..."); Thread.sleep(1000); } catch (InterruptedException ex) { log.debug("Sleep interupted while waiting for DDS server to start", ex); } } log.debug("DDSServer.start: Started Grizzly."); } else { log.error("DDSServer.start: Grizzly already started."); throw new IllegalStateException(); } } }
public Openscoring(){ super(ModelResource.class, MetricResource.class); final Config config = ConfigFactory.load(); Binder binder = new AbstractBinder(){ @Override public void configure(){ bind(config).to(Config.class).named("openscoring"); bind(ModelRegistry.class).to(ModelRegistry.class).in(Singleton.class); bind(MetricRegistry.class).to(MetricRegistry.class).in(Singleton.class); } }; register(binder); // JSON support register(JacksonJsonProvider.class); register(ObjectMapperProvider.class); // Convert exceptions to JSON objects register(WebApplicationExceptionMapper.class); // Permit the HTTP POST method to be changed to HTTP PUT or DELETE methods register(HttpMethodOverrideFilter.class); // File upload support register(MultiPartFeature.class); // Security support register(RolesAllowedDynamicFeature.class); // GZip and Deflate encoding support register(EncodingFilter.class); register(GZipEncoder.class); register(DeflateEncoder.class); Config applicationConfig = config.getConfig("application"); List<String> componentClassNames = applicationConfig.getStringList("componentClasses"); for(String componentClassName : componentClassNames){ Class<?> clazz; try { clazz = Class.forName(componentClassName); } catch(ClassNotFoundException cnfe){ throw new IllegalArgumentException(cnfe); } register(clazz); } }
private void registerEndpoints() { register(NoteResource.class); register(LoggingFeature.class); EncodingFilter.enableFor(this, GZipEncoder.class); }
/** * Register JAX-RS application components. */ public JaxRsApplication() { packages("org.podcastpedia.web.api"); // register features EncodingFilter.enableFor(this, GZipEncoder.class); }