org.glassfish.jersey.server.filter.EncodingFilter Java Examples

The following examples show how to use org.glassfish.jersey.server.filter.EncodingFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GatewayBinaryResponseFilterIntTest.java    From jrestless with Apache License 2.0 6 votes vote down vote up
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;
		}
	};
}
 
Example #2
Source File: RestResourceConfig.java    From frameworkAggregate with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #3
Source File: GatewayRequestObjectHandlerIntTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #4
Source File: RequestHandler.java    From jrestless-examples with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #5
Source File: CubeApplication.java    From cubedb with GNU General Public License v3.0 5 votes vote down vote up
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);
  }
 
Example #6
Source File: JerseyRestApplication.java    From micro-server with Apache License 2.0 5 votes vote down vote up
public JerseyRestApplication(List<Object> allResources,List<String> packages, List<Class<?>> resources, Map<String, Object> serverProperties) {
	
	if (allResources != null) {
		for (Object next : allResources) {
			if(isSingleton(next))
				register(next);
			else
				register(next.getClass());
		}
	}

	register(EncodingFilter.class); //Server encoding filter class
	register(GZipEncoder.class);

	register(new AsyncBinder());
	
	if (serverProperties.isEmpty()) {
		property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
        //http://stackoverflow.com/questions/25755773/bean-validation-400-errors-are-returning-default-error-page-html-instead-of-re
        property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");
	} else {
		for (Map.Entry<String, Object> entry : serverProperties.entrySet()) {
			property(entry.getKey(), entry.getValue());
		}
	}

       packages.stream().forEach( e -> packages(e));
	resources.stream().forEach( e -> register(e));
	
	Optional.ofNullable(this.resourceConfigManager.get(ServerThreadLocalVariables.getContext().get())).ifPresent(e->e.accept(new JaxRsProvider<>(this)));

}
 
Example #7
Source File: JerseyApplication.java    From XBDD with Apache License 2.0 5 votes vote down vote up
public JerseyApplication() {

		// Need to register all resources manually as spring fat jar doesn't like the resource scanning
		register(AdminUtils.class);
		register(Attachment.class);
		register(AutomationStatistics.class);
		register(BuildReOrdering.class);
		register(Environment.class);
		register(Favourites.class);
		register(Feature.class);
		register(MergeBuilds.class);
		register(Presence.class);
		register(PrintPDF.class);
		register(Recents.class);
		register(Report.class);
		register(Search.class);
		register(Stats.class);
		register(TagView.class);
		register(UploadAttachment.class);
		register(UserResource.class);

		EncodingFilter.enableFor(this, GZipEncoder.class);

		register(MultiPartFeature.class);

		property(ServerProperties.TRACING, TracingConfig.ON_DEMAND.name());
	}
 
Example #8
Source File: RestDemoJaxRsApplication.java    From demo-rest-jersey-spring with MIT License 5 votes vote down vote up
/**
	 * 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()});
	}
 
Example #9
Source File: JerseyRestApplicationTest.java    From micro-server with Apache License 2.0 4 votes vote down vote up
@Test
public void testGZipRegistration() {
    JerseyRestApplication app = new JerseyRestApplication();
    assertTrue(app.isRegistered(GZipEncoder.class));
    assertTrue(app.isRegistered(EncodingFilter.class));
}
 
Example #10
Source File: NiFiWebApiResourceConfig.java    From nifi with Apache License 2.0 4 votes vote down vote up
public NiFiWebApiResourceConfig(@Context ServletContext servletContext) {
    // get the application context to register the rest endpoints
    final ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);

    // request support
    register(RedirectResourceFilter.class);
    register(MultiPartFeature.class);

    // jackson
    register(JacksonFeature.class);
    register(ObjectMapperResolver.class);

    // rest api
    register(ctx.getBean("flowResource"));
    register(ctx.getBean("resourceResource"));
    register(ctx.getBean("controllerResource"));
    register(ctx.getBean("siteToSiteResource"));
    register(ctx.getBean("dataTransferResource"));
    register(ctx.getBean("snippetResource"));
    register(ctx.getBean("templateResource"));
    register(ctx.getBean("controllerServiceResource"));
    register(ctx.getBean("reportingTaskResource"));
    register(ctx.getBean("processGroupResource"));
    register(ctx.getBean("processorResource"));
    register(ctx.getBean("connectionResource"));
    register(ctx.getBean("flowfileQueueResource"));
    register(ctx.getBean("remoteProcessGroupResource"));
    register(ctx.getBean("inputPortResource"));
    register(ctx.getBean("outputPortResource"));
    register(ctx.getBean("labelResource"));
    register(ctx.getBean("funnelResource"));
    register(ctx.getBean("provenanceResource"));
    register(ctx.getBean("provenanceEventResource"));
    register(ctx.getBean("countersResource"));
    register(ctx.getBean("systemDiagnosticsResource"));
    register(ctx.getBean("accessResource"));
    register(ctx.getBean("accessPolicyResource"));
    register(ctx.getBean("tenantsResource"));
    register(ctx.getBean("versionsResource"));
    register(ctx.getBean("parameterContextResource"));

    // exception mappers
    register(AccessDeniedExceptionMapper.class);
    register(AuthorizationAccessExceptionMapper.class);
    register(InvalidAuthenticationExceptionMapper.class);
    register(AuthenticationCredentialsNotFoundExceptionMapper.class);
    register(AdministrationExceptionMapper.class);
    register(ClusterExceptionMapper.class);
    register(IllegalArgumentExceptionMapper.class);
    register(IllegalClusterResourceRequestExceptionMapper.class);
    register(IllegalClusterStateExceptionMapper.class);
    register(IllegalNodeDeletionExceptionMapper.class);
    register(IllegalNodeDisconnectionExceptionMapper.class);
    register(IllegalNodeReconnectionExceptionMapper.class);
    register(IllegalStateExceptionMapper.class);
    register(InvalidRevisionExceptionMapper.class);
    register(JsonMappingExceptionMapper.class);
    register(JsonParseExceptionMapper.class);
    register(JsonContentConversionExceptionMapper.class);
    register(MutableRequestExceptionMapper.class);
    register(NiFiCoreExceptionMapper.class);
    register(NoConnectedNodesExceptionMapper.class);
    register(NoClusterCoordinatorExceptionMapper.class);
    register(NoResponseFromNodesExceptionMapper.class);
    register(NodeDisconnectionExceptionMapper.class);
    register(NodeReconnectionExceptionMapper.class);
    register(ResourceNotFoundExceptionMapper.class);
    register(NotFoundExceptionMapper.class);
    register(UnknownNodeExceptionMapper.class);
    register(ValidationExceptionMapper.class);
    register(WebApplicationExceptionMapper.class);
    register(ThrowableMapper.class);

    // gzip
    EncodingFilter.enableFor(this, GZipEncoder.class);
}
 
Example #11
Source File: Openscoring.java    From openscoring with GNU Affero General Public License v3.0 4 votes vote down vote up
public Openscoring(){
	Config config = ConfigFactory.load();

	setConfig(config);

	Binder configBinder = new AbstractBinder(){

		@Override
		public void configure(){
			bind(config).to(Config.class).named("openscoring");
		}
	};
	register(configBinder);

	ModelRegistry modelRegistry = createModelRegistry(config);

	setModelRegistry(modelRegistry);

	Binder modelRegistryBinder = new AbstractBinder(){

		@Override
		public void configure(){
			bind(modelRegistry).to(ModelRegistry.class).named("openscoring");
		}
	};
	register(modelRegistryBinder);

	LoadingModelEvaluatorBuilder loadingModelEvaluatorBuilder = createLoadingModelEvaluatorBuilder(config);

	setLoadingModelEvaluatorBuilder(loadingModelEvaluatorBuilder);

	Binder loadingModelEvaluatorBuilderBinder = new AbstractBinder(){

		@Override
		public void configure(){
			bind(loadingModelEvaluatorBuilder).to(LoadingModelEvaluatorBuilder.class);
		}
	};
	register(loadingModelEvaluatorBuilderBinder);

	Config applicationConfig = config.getConfig("application");

	register(ModelResource.class);

	// Convert path variables to ModelRef objects
	register(loadClass(ModelRefConverterProvider.class, applicationConfig));

	// PMML support
	register(loadClass(ModelProvider.class, applicationConfig));

	// JSON support
	register(JacksonJsonProvider.class);
	register(ObjectMapperProvider.class);

	// CSV support
	register(loadClass(TableProvider.class, applicationConfig));

	// 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);

	// Application identification
	register(ApplicationHeaderFilter.class);

	List<String> componentClassNames = applicationConfig.getStringList("componentClasses");
	for(String componentClassName : componentClassNames){
		Class<?> clazz = loadClass(Object.class, componentClassName);

		register(clazz);
	}
}
 
Example #12
Source File: JaxRsApplication.java    From podcastpedia-web with MIT License 3 votes vote down vote up
/**
 * Register JAX-RS application components.
 */
public JaxRsApplication() {
	
       packages("org.podcastpedia.web.api");

	// register features
	EncodingFilter.enableFor(this, GZipEncoder.class);		
	
}