use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.
the class DeclarativeLinkingFeature method configure.
@Override
public boolean configure(FeatureContext context) {
Configuration config = context.getConfiguration();
if (!config.isRegistered(ResponseLinkFilter.class)) {
context.register(new AbstractBinder() {
@Override
protected void configure() {
bindAsContract(NaiveResourceMappingContext.class).to(ResourceMappingContext.class).in(Singleton.class);
}
});
context.register(ResponseLinkFilter.class);
// context.register(RequestLinkFilter.class);
return true;
}
return false;
}
use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.
the class CdiComponentProvider method bindHk2ClassAnalyzer.
private void bindHk2ClassAnalyzer() {
ClassAnalyzer defaultClassAnalyzer = injectionManager.getInstance(ClassAnalyzer.class, ClassAnalyzer.DEFAULT_IMPLEMENTATION_NAME);
int skippedElements = methodsToSkip.size() + fieldsToSkip.size();
ClassAnalyzer customizedClassAnalyzer = skippedElements > 0 ? new InjecteeSkippingAnalyzer(defaultClassAnalyzer, methodsToSkip, fieldsToSkip) : defaultClassAnalyzer;
Binder binder = new AbstractBinder() {
@Override
protected void configure() {
bind(customizedClassAnalyzer).analyzeWith(ClassAnalyzer.DEFAULT_IMPLEMENTATION_NAME).to(ClassAnalyzer.class).named(CDI_CLASS_ANALYZER);
}
};
injectionManager.register(binder);
}
use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.
the class InjectionManagerServerProviderTest method configure.
@Override
protected Application configure() {
final ResourceConfig resourceConfig = new ResourceConfig(TestResource.class);
resourceConfig.register(new AbstractBinder() {
@Override
protected void configure() {
bind(new MyInjectedService("hello")).to(MyInjectedService.class);
}
});
resourceConfig.register(new MyFeature());
resourceConfig.register(new MyReaderInterceptor());
resourceConfig.register(new MyWriterInterceptor());
return resourceConfig;
}
use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.
the class ValidatorTest method createInjectionManager.
private InjectionManager createInjectionManager() {
InjectionManager injectionManager = InjectionManagerFactory.createInjectionManager();
injectionManager.register(new AbstractBinder() {
@Override
protected void configure() {
bind(new CommonConfig(RuntimeType.SERVER, ComponentBag.EXCLUDE_EMPTY)).to(Configuration.class);
}
});
return injectionManager;
}
use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.
the class InjectionManagerProviderTest method testFeatureClass.
@Test
public void testFeatureClass() {
final Response response = target().path("resource").register(new AbstractBinder() {
@Override
protected void configure() {
bind(new MyInjectedService("feature")).to(MyInjectedService.class);
}
}).register(MyFeature.class).request().post(Entity.entity("will-be-extended-by", MediaType.TEXT_PLAIN_TYPE));
assertEquals(200, response.getStatus());
assertEquals("will-be-extended-by-interceptor-feature", response.readEntity(String.class));
}
Aggregations