Java Code Examples for javax.ws.rs.core.FeatureContext#property()
The following examples show how to use
javax.ws.rs.core.FeatureContext#property() .
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: ServiceTalkJacksonSerializerFeature.java From servicetalk with Apache License 2.0 | 6 votes |
@Override public boolean configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); final String jsonFeature = getValue(config.getProperties(), config.getRuntimeType(), JSON_FEATURE, ST_JSON_FEATURE, String.class); // Do not register our JSON feature if another one is already registered if (!ST_JSON_FEATURE.equalsIgnoreCase(jsonFeature)) { LOGGER.warn("Skipping registration of: {} as JSON support is already provided by: {}", ST_JSON_FEATURE, jsonFeature); return false; } // Prevent other not yet registered JSON features to register themselves context.property(getPropertyNameForRuntime(JSON_FEATURE, config.getRuntimeType()), ST_JSON_FEATURE); if (!config.isRegistered(JacksonSerializerMessageBodyReaderWriter.class)) { context.register(SerializationExceptionMapper.class); context.register(JacksonSerializerMessageBodyReaderWriter.class); } return true; }
Example 2
Source File: DACJacksonJaxbJsonFeature.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public boolean configure(FeatureContext context) { final Configuration config = context.getConfiguration(); final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), InternalProperties.JSON_FEATURE, JSON_FEATURE_CLASSNAME, String.class); // Other JSON providers registered. if (!JSON_FEATURE_CLASSNAME.equalsIgnoreCase(jsonFeature)) { LOGGER.error("Another JSON provider has been registered: {}", jsonFeature); return false; } // Disable other JSON providers. context.property(PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()), JSON_FEATURE_CLASSNAME); context.register(DACJacksonJaxbJsonProvider.class); return true; }
Example 3
Source File: ParsecMoxyFeature.java From parsec-libraries with Apache License 2.0 | 6 votes |
@Override public boolean configure(FeatureContext context) { final Configuration config = context.getConfiguration(); if (CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), CommonProperties.MOXY_JSON_FEATURE_DISABLE, Boolean.FALSE, Boolean.class)) { return false; } final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), InternalProperties.JSON_FEATURE, JSON_FEATURE, String.class); // Other JSON providers registered. if (!JSON_FEATURE.equalsIgnoreCase(jsonFeature)) { return false; } // Disable other JSON providers. context.property(PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()), JSON_FEATURE); final int workerPriority = Priorities.USER + 3000; context.register(ParsecMoxyProvider.class, workerPriority); return true; }
Example 4
Source File: GuiceBundle.java From soabase with Apache License 2.0 | 6 votes |
private void applyInternalCommonConfig(FeatureContext context, InternalCommonConfig internalCommonConfig) { for ( Class<?> clazz : internalCommonConfig.getClasses() ) { log.info(String.format("Registering %s as a component", clazz)); context.register(clazz); } for ( Object obj : internalCommonConfig.getInstances() ) { log.info(String.format("Registering instance of %s as a component", obj.getClass())); context.register(obj); } for ( Map.Entry<String, Object> entry : internalCommonConfig.getProperties().entrySet() ) { String key = entry.getKey(); Object value = entry.getValue(); log.info(String.format("Registering property key: %s\tvalue: %s", key, value)); context.property(key, value); } }
Example 5
Source File: AgRuntime.java From agrest with Apache License 2.0 | 6 votes |
@Override public boolean configure(FeatureContext context) { // this gives everyone access to the Agrest services context.property(AgRuntime.AGREST_CONTAINER_PROPERTY, injector); @SuppressWarnings("unchecked") Map<String, Class> bodyWriters = injector.getInstance(Key.getMapOf(String.class, Class.class, AgRuntime.BODY_WRITERS_MAP)); for (Class<?> type : bodyWriters.values()) { context.register(type); } context.register(ResponseStatusDynamicFeature.class); context.register(EntityUpdateReader.class); context.register(EntityUpdateCollectionReader.class); for (Feature f : extraFeatures) { f.configure(context); } return true; }
Example 6
Source File: FastJsonFeature.java From fastjson-jaxrs-json-provider with Apache License 2.0 | 6 votes |
public boolean configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); final String jsonFeature = CommonProperties.getValue(config.getProperties(), config.getRuntimeType(), InternalProperties.JSON_FEATURE, JSON_FEATURE, String.class); // Other JSON providers registered. if (!JSON_FEATURE.equalsIgnoreCase(jsonFeature)) { return false; } // Disable other JSON providers. context.property(PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()), JSON_FEATURE); // Register FastJson. if (!config.isRegistered(FastJsonProvider.class)) { context.register(FastJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class); } return true; }
Example 7
Source File: FastJsonFeature.java From metrics with Apache License 2.0 | 5 votes |
public boolean configure(final FeatureContext context) { final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.' + context.getConfiguration().getRuntimeType().name().toLowerCase(); context.property(disableMoxy, true); context.register(FastJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class); return true; }
Example 8
Source File: FastJsonFeature.java From uavstack with Apache License 2.0 | 5 votes |
@Override public boolean configure(final FeatureContext context) { try { final Configuration config = context.getConfiguration(); final String jsonFeature = CommonProperties.getValue( config.getProperties() , config.getRuntimeType() , InternalProperties.JSON_FEATURE, JSON_FEATURE, String.class ); // Other JSON providers registered. if (!JSON_FEATURE.equalsIgnoreCase(jsonFeature)) { return false; } // Disable other JSON providers. context.property( PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()) , JSON_FEATURE); // Register FastJson. if (!config.isRegistered(FastJsonProvider.class)) { context.register(FastJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class); } } catch (NoSuchMethodError e) { // skip } return true; }
Example 9
Source File: ValidationFeature.java From ameba with MIT License | 5 votes |
/** {@inheritDoc} */ @Override public boolean configure(final FeatureContext context) { // disable Jersey default BeanValidation feature context.property(ServerProperties.BV_FEATURE_DISABLE, "true"); context.register(new ValidationBinder()) .register(ValidationExceptionMapper.class) .register(ValidationConfigurationContextResolver.class); return true; }
Example 10
Source File: JacksonFeature.java From micro-server with Apache License 2.0 | 4 votes |
private void addAll(Map<String, Object> map, FeatureContext context) { for(String key : map.keySet()){ context.property(key,map.get(key)); } }