org.glassfish.jersey.server.validation.ValidationFeature Java Examples

The following examples show how to use org.glassfish.jersey.server.validation.ValidationFeature. 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: GrapheneRESTServer.java    From Graphene with GNU General Public License v3.0 6 votes vote down vote up
static ResourceConfig generateResourceConfig(Config config, Graphene graphene) {
	ResourceConfig rc = new ResourceConfig();

	// settings
	rc.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
	rc.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); // TODO: remove in production

	// basic features
	rc.register(CORSFilter.class);
	rc.register(JacksonFeature.class);
	rc.register(ValidationFeature.class);

	// custom resources
	GrapheneResourceFactory factory = new GrapheneResourceFactory(config, graphene);

	rc.register(factory.createResource(AdminResource.class));
	rc.register(factory.createResource(CoreferenceResource.class));
	rc.register(factory.createResource(DiscourseSimplificationResource.class));
	rc.register(factory.createResource(RelationExtractionResource.class));

	return rc;
}
 
Example #2
Source File: App.java    From jweb-cms with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void configure() {
    logger.info("init app, name={}, language={}, dir={}", name(), language(), dir());
    binder = new ModuleBinder();

    binder.bind(App.class).toInstance(this);
    binder.bind(MessageBundle.class).toInstance(message());

    binder.bind(Configuration.class).toInstance(Validation.byDefaultProvider().configure()
        .messageInterpolator(new MessageInterpolatorImpl())
        .addProperty("hibernate.validator.fail_fast", "true"));
    register(ValidationFeature.class);

    JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider();
    jacksonProvider.setMapper(JSON.OBJECT_MAPPER);
    register(jacksonProvider);
    register(JacksonFeature.class);

    register(binder.raw());
    register(new DefaultContainerLifecycleListener(this));

    register(new AppEventListener());
    register(DefaultExceptionMapper.class);

    validate();

    for (String moduleName : orderedModules()) {
        ModuleNode moduleNode = moduleNode(moduleName).orElseThrow();
        if (moduleNode.isOverrided()) {
            moduleNode.status = ModuleStatus.CONFIGURED;
        } else {
            try {
                Stopwatch w = Stopwatch.createStarted();
                configure(moduleNode.module);
                moduleNode.status = ModuleStatus.CONFIGURED;
            } catch (Exception e) {
                throw new ApplicationException("failed to install module {}, type={}", moduleName, moduleNode.module.getClass().getCanonicalName(), e);
            }
        }
    }
}
 
Example #3
Source File: CoffeeApplication.java    From maven-framework-project with MIT License 5 votes vote down vote up
@Override
public Set<Class<?>> getClasses() {
    Set<Class<?>> classes = new HashSet<Class<?>>();
    classes.add(CoffeesResource.class);
    classes.add(ValidationFeature.class);
    return classes;
}
 
Example #4
Source File: CoffeeApplication.java    From maven-framework-project with MIT License 5 votes vote down vote up
@Override
public Set<Class<?>> getClasses() {
    Set<Class<?>> classes = new HashSet<Class<?>>();
    classes.add(CoffeesResource.class);
    classes.add(ValidationFeature.class);
    return classes;
}
 
Example #5
Source File: Application.java    From rest-utils with Apache License 2.0 2 votes vote down vote up
/**
 * Register server features
 * @param config The config to register the features with
 * @param restConfig The application's configuration
 */
protected void registerFeatures(Configurable<?> config, T restConfig) {
  config.register(ValidationFeature.class);
}