Refine search
@Override public boolean configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); // Validation disabled? if (PropertiesHelper.isProperty(config.getProperty(ServerProperties.BV_FEATURE_DISABLE))) { return false; } context.register(new ValidationBinder()); // Set ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR to make sure no sendError is called on servlet container // when ServerProperties.BV_SEND_ERROR_IN_RESPONSE is enabled. if (PropertiesHelper.isProperty(config.getProperty(ServerProperties.BV_SEND_ERROR_IN_RESPONSE)) && config.getProperty(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR) == null) { context.property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true); } return true; } }
@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 context.property( PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, config.getRuntimeType()) , JSON_FEATURE); if (!config.isRegistered(FastJsonProvider.class)) { context.register(FastJsonProvider.class, MessageBodyReader.class, MessageBodyWriter.class);
private void copyProviders(Configuration source, Configurable<?> target) { final Configuration targetConfig = target.getConfiguration(); for (Class<?> c : source.getClasses()) { if (!targetConfig.isRegistered(c)) { target.register(c, source.getContracts(c)); } } for (Object o : source.getInstances()) { Class<?> c = o.getClass(); if (!targetConfig.isRegistered(o)) { target.register(c, source.getContracts(c)); } } }
@Override public void configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); // UriConnegFilter. final Object languageMappings = config.getProperty(ServerProperties.LANGUAGE_MAPPINGS); final Object mediaTypesMappings = config.getProperty(ServerProperties.MEDIA_TYPE_MAPPINGS); if (!config.isRegistered(UriConnegFilter.class) && (languageMappings != null || mediaTypesMappings != null)) { context.register(UriConnegFilter.class); } } }
@Override public void configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); if (context.getConfiguration().isRegistered(SseFeature.class)) { return; } if (!PropertiesHelper.getValue( config.getProperties(), config.getRuntimeType(), SseFeature.DISABLE_SSE, Boolean.FALSE, Boolean.class, null)) { context.register(SseFeature.class); } } }
@Override public void configure(final FeatureContext context) { final Configuration config = context.getConfiguration(); // Register FastJson. if (!config.isRegistered(FastJsonFeature.class) && autoDiscover) { context.register(FastJsonFeature.class); } } }
@Override public boolean configure(final FeatureContext context) { final RuntimeType runtime = context.getConfiguration().getRuntimeType(); if (RuntimeType.SERVER.equals(runtime)) { context.register(FormDataParamInjectionFeature.class); context.register(MultiPartReaderServerSide.class); } else { context.register(MultiPartReaderClientSide.class); } context.register(MultiPartWriter.class); return true; } }
@Override public void configure(FeatureContext context) { final Configuration config = context.getConfiguration(); if (config.isRegistered(ViewResponseFilter.class)) { return; // already registered! } final boolean enableOzark = config.getClasses().stream().anyMatch(this::isController) || config.getInstances().stream().map(o -> o.getClass()).anyMatch(this::isController); if (enableOzark) { context.register(ViewResponseFilter.class); context.register(ViewableWriter.class); } }
@Override public Boolean get() { return PropertiesHelper.isProperty(config.getProperty(MessageProperties.JAXB_PROCESS_XML_ROOT_ELEMENT)); } });
this.disableMetaProviderConfiguration = !commonConfig.enabledFeatureClasses.isEmpty(); } else { setProperties(config.getProperties()); resetRegistrations(); for (final Class<?> clazz : config.getClasses()) { if (Feature.class.isAssignableFrom(clazz) && config.isEnabled((Class<? extends Feature>) clazz)) { this.disableMetaProviderConfiguration = true; register(clazz, config.getContracts(clazz)); for (final Object instance : config.getInstances()) { if (instance instanceof Feature && config.isEnabled((Feature) instance)) { this.disableMetaProviderConfiguration = true; register(instance, config.getContracts(instance.getClass()));
private LoggingInterceptor createLoggingFilter(FeatureContext context, RuntimeType runtimeType) { Map properties = context.getConfiguration().getProperties(); String filterLoggerName = CommonProperties.getValue( properties, runtimeType == RuntimeType.SERVER ? LOGGING_FEATURE_LOGGER_NAME_SERVER : LOGGING_FEATURE_LOGGER_NAME_CLIENT, CommonProperties.getValue( properties, LOGGING_FEATURE_LOGGER_NAME, DEFAULT_LOGGER_NAME )); String filterLevel = CommonProperties.getValue( properties, runtimeType == RuntimeType.SERVER ? LOGGING_FEATURE_LOGGER_LEVEL_SERVER : LOGGING_FEATURE_LOGGER_LEVEL_CLIENT, CommonProperties.getValue( context.getConfiguration().getProperties(), LOGGING_FEATURE_LOGGER_LEVEL, DEFAULT_LOGGER_LEVEL));
@Override public ResourceModel processResourceModel(final ResourceModel resourceModel, final Configuration configuration) { final boolean disabled = PropertiesHelper.isProperty(configuration.getProperty(ServerProperties.WADL_FEATURE_DISABLE)); if (disabled) { return resourceModel; } final ResourceModel.Builder builder = ModelProcessorUtil.enhanceResourceModel(resourceModel, false, methodList, true); // Do not add WadlResource if already present in the classes (i.e. added during scanning). if (!configuration.getClasses().contains(WadlResource.class)) { final Resource wadlResource = Resource.builder(WadlResource.class).build(); builder.addResource(wadlResource); } return builder.build(); }
@PostConstruct private void init() { final String paramName = (String) configuration.getProperty(SelectableEntityFilteringFeature.QUERY_PARAM_NAME); SELECTABLE_PARAM_NAME = paramName != null ? paramName : SELECTABLE_PARAM_NAME; }
private int getMaximumCacheLimit(Configuration configuration) { int limit = ClientProperties.getValue(configuration.getProperties(), ClientProperties.DIGESTAUTH_URI_CACHE_SIZELIMIT, MAXIMUM_DIGEST_CACHE_SIZE); if (limit < 1) { limit = MAXIMUM_DIGEST_CACHE_SIZE; } return limit; }
/** * Enable a buffering of serialized entity. The buffering will be configured from configuration. The property * determining the size of the buffer is {@link CommonProperties#OUTBOUND_CONTENT_LENGTH_BUFFER}. * </p> * The buffering functionality is by default disabled and could be enabled by calling this method. In this case * this method must be called before first bytes are written to the {@link #getEntityStream() entity stream}. * * @param configuration runtime configuration. */ public void enableBuffering(Configuration configuration) { final Integer bufferSize = CommonProperties.getValue(configuration.getProperties(), configuration.getRuntimeType(), CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, Integer.class); if (bufferSize != null) { committingOutputStream.enableBuffering(bufferSize); } else { committingOutputStream.enableBuffering(); } }
private void copyProviders(Configuration source, Configurable<?> target) { for (Class<?> c : source.getClasses()) { target.register(c, source.getContracts(c)); } for (Object o : source.getInstances()) { Class<?> c = o.getClass(); target.register(c, source.getContracts(c)); } }
private Set<Object> processProviders() { Set<Object> providers = new LinkedHashSet<>(); for (Object provider : configuration.getInstances()) { Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider); if (provider instanceof ClientRequestFilter || provider instanceof ClientResponseFilter) { FilterProviderInfo<Object> filter = new FilterProviderInfo<>(providerCls, providerCls, provider, getBus(), configuration.getContracts(providerCls)); providers.add(filter); } else { providers.add(provider); } } return providers; } }
@Override public Set<Object> getInstances() { return delegate.getInstances(); }
@Override public Map<Class<?>, Integer> getContracts(Class<?> componentClass) { Map<Class<?>, Integer> contracts = new HashMap<>(); contracts.putAll(getLocalContracts(componentClass)); contracts.putAll(delegate.getContracts(componentClass)); return contracts; }
@Override public Set<Class<?>> getClasses() { return delegate.getClasses(); }