use of javax.ws.rs.core.Configuration in project cxf by apache.
the class ConfigurationImplTest method testServerFilterContractsOnClientIsRejected.
@Test
public void testServerFilterContractsOnClientIsRejected() {
try (ConfigurableImpl<Client> configurable = new ConfigurableImpl<>(createClientProxy(), RuntimeType.CLIENT)) {
Configuration config = configurable.getConfiguration();
configurable.register(TestFilter.class);
Map<Class<?>, Integer> contracts = config.getContracts(TestFilter.class);
assertTrue(contracts.containsKey(ClientRequestFilter.class));
assertTrue(contracts.containsKey(ClientResponseFilter.class));
assertFalse(contracts.containsKey(ContainerRequestFilter.class));
assertFalse(contracts.containsKey(ContainerResponseFilter.class));
}
}
use of javax.ws.rs.core.Configuration in project cxf by apache.
the class SseEventSourceImpl method open.
@Override
public void open() {
if (!tryChangeState(SseSourceState.CLOSED, SseSourceState.CONNECTING)) {
throw new IllegalStateException("The SseEventSource is already in " + state.get() + " state");
}
// Create the executor for scheduling the reconnect tasks
final Configuration configuration = target.getConfiguration();
if (executor == null) {
executor = (ScheduledExecutorService) configuration.getProperty("scheduledExecutorService");
if (executor == null) {
executor = Executors.newSingleThreadScheduledExecutor();
managedExecutor = false;
/* we manage lifecycle */
}
}
final Object lastEventId = configuration.getProperty(HttpHeaders.LAST_EVENT_ID_HEADER);
connect(lastEventId != null ? lastEventId.toString() : null);
}
use of javax.ws.rs.core.Configuration in project jersey by jersey.
the class ServerFiltersAutoDiscoverable method configure.
@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);
}
}
use of javax.ws.rs.core.Configuration in project jersey by jersey.
the class ClientConfigTest method testGetFeatures.
/**
* Copied from DefaultConfigTest.
*/
@Test
public void testGetFeatures() {
final EmptyFeature emptyFeature = new EmptyFeature();
final UnconfigurableFeature unconfigurableFeature = new UnconfigurableFeature();
ClientConfig clientConfig = new ClientConfig();
clientConfig.register(emptyFeature);
clientConfig.register(unconfigurableFeature);
// Features are registered at the time of provider bindings.
final JerseyClient jerseyClient = new JerseyClient(clientConfig, (UnsafeValue<SSLContext, IllegalStateException>) null, null);
clientConfig = jerseyClient.getConfiguration();
clientConfig.getRuntime();
final Configuration runtimeConfig = clientConfig.getRuntime().getConfig();
assertTrue(runtimeConfig.isEnabled(emptyFeature));
}
use of javax.ws.rs.core.Configuration in project jersey by jersey.
the class SecurityEntityFilteringFeature method configure.
@Override
public boolean configure(final FeatureContext context) {
final Configuration config = context.getConfiguration();
if (!config.isRegistered(SecurityEntityProcessor.class)) {
// RolesAllowed feature.
if (!config.isRegistered(RolesAllowedDynamicFeature.class)) {
context.register(RolesAllowedDynamicFeature.class);
}
// Binder (FilteringObjectProvider/FilteringGraphTransformer).
if (!config.isRegistered(EntityFilteringBinder.class)) {
context.register(new EntityFilteringBinder());
}
// Entity Processors.
context.register(SecurityEntityProcessor.class);
if (!config.isRegistered(DefaultEntityProcessor.class)) {
context.register(DefaultEntityProcessor.class);
}
// Scope Providers.
context.register(SecurityScopeResolver.class);
if (RuntimeType.SERVER.equals(config.getRuntimeType())) {
context.register(SecurityServerScopeResolver.class);
}
// Scope Resolver.
if (RuntimeType.SERVER == config.getRuntimeType()) {
context.register(SecurityServerScopeProvider.class);
} else {
context.register(CommonScopeProvider.class);
}
return true;
}
return false;
}
Aggregations