use of org.apache.cxf.jaxrs.impl.FeatureContextImpl in project cxf by apache.
the class JAXRSClientFactoryBean method applyFeatures.
protected void applyFeatures(AbstractClient client) {
if (getFeatures() != null) {
getFeatures().forEach(feature -> {
feature.initialize(client.getConfiguration(), getBus());
});
}
// Process JAX-RS features which are passed through as providers
final Set<Object> providers = new HashSet<>();
for (final Object provider : getProviders()) {
if (provider instanceof Feature) {
final Feature feature = (Feature) provider;
final FeatureContextImpl context = new FeatureContextImpl();
final Configurable<?> configurable = getConfigurableFor(context);
final Configuration configuration = configurable.getConfiguration();
final Set<Object> registered = configuration.getInstances();
if (!configuration.isRegistered(feature)) {
configurable.register(feature);
// Disregarding if the feature is enabled or disabled, register only newly added providers,
// excluding pre-existing ones and the feature instance itself.
final Set<Object> added = new HashSet<Object>(configuration.getInstances());
added.remove(feature);
added.removeAll(registered);
providers.addAll(added);
}
}
}
if (!providers.isEmpty()) {
setProviders(Arrays.asList(providers));
}
}
use of org.apache.cxf.jaxrs.impl.FeatureContextImpl in project cxf by apache.
the class ServerProviderFactory method createServerFeatureContext.
private FeatureContext createServerFeatureContext() {
final FeatureContextImpl featureContext = new FeatureContextImpl();
final ServerConfigurableFactory factory = getBus().getExtension(ServerConfigurableFactory.class);
final Configurable<FeatureContext> configImpl = (factory == null) ? new ServerFeatureContextConfigurable(featureContext) : factory.create(featureContext);
featureContext.setConfigurable(configImpl);
if (application != null) {
Map<String, Object> appProps = application.getProvider().getProperties();
for (Map.Entry<String, Object> entry : appProps.entrySet()) {
configImpl.property(entry.getKey(), entry.getValue());
}
}
return featureContext;
}
Aggregations