Search in sources :

Example 16 with AbstractBinder

use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.

the class ServiceFinderBinderTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    AbstractBinder binder = new AbstractBinder() {

        @Override
        protected void configure() {
            bind(TestServiceB.class).to(TestContract.class);
            bind(TestServiceD.class).to(TestContract.class);
            install(new ServiceFinderBinder<>(TestContract.class, null, RuntimeType.SERVER));
        }
    };
    injectionManager = Injections.createInjectionManager(binder);
}
Also used : AbstractBinder(org.glassfish.jersey.internal.inject.AbstractBinder) BeforeClass(org.junit.BeforeClass)

Example 17 with AbstractBinder

use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.

the class BindingTestHelper method bind.

/**
     * Accepts the provided consumer to created and register the binder.
     *
     * @param injectionManager injection manager which accepts the consumer.
     * @param bindConsumer     consumer to populate a binder.
     */
static void bind(InjectionManager injectionManager, Consumer<AbstractBinder> bindConsumer) {
    AbstractBinder binder = new AbstractBinder() {

        @Override
        protected void configure() {
            bindConsumer.accept(this);
        }
    };
    injectionManager.register(binder);
}
Also used : AbstractBinder(org.glassfish.jersey.internal.inject.AbstractBinder)

Example 18 with AbstractBinder

use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.

the class WadlFeature method configure.

@Override
public boolean configure(FeatureContext context) {
    final boolean disabled = PropertiesHelper.isProperty(context.getConfiguration().getProperty(ServerProperties.WADL_FEATURE_DISABLE));
    if (disabled) {
        return false;
    }
    context.register(WadlModelProcessor.class);
    context.register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(WadlApplicationContextImpl.class).to(WadlApplicationContext.class).in(Singleton.class);
        }
    });
    return true;
}
Also used : WadlApplicationContextImpl(org.glassfish.jersey.server.wadl.internal.WadlApplicationContextImpl) Singleton(javax.inject.Singleton) AbstractBinder(org.glassfish.jersey.internal.inject.AbstractBinder)

Example 19 with AbstractBinder

use of org.glassfish.jersey.internal.inject.AbstractBinder in project jersey by jersey.

the class InjectionManagerProviderTest method testFeatureInstance.

@Test
public void testFeatureInstance() {
    final Response response = target().path("resource").register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(new MyInjectedService("feature")).to(MyInjectedService.class);
        }
    }).register(new MyFeature()).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));
}
Also used : Response(javax.ws.rs.core.Response) AbstractBinder(org.glassfish.jersey.internal.inject.AbstractBinder) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Aggregations

AbstractBinder (org.glassfish.jersey.internal.inject.AbstractBinder)19 Test (org.junit.Test)7 Singleton (javax.inject.Singleton)5 Binder (org.glassfish.jersey.internal.inject.Binder)4 InjectionManager (org.glassfish.jersey.internal.inject.InjectionManager)4 JerseyTest (org.glassfish.jersey.test.JerseyTest)4 Configuration (javax.ws.rs.core.Configuration)3 ArrayList (java.util.ArrayList)2 Response (javax.ws.rs.core.Response)2 Binding (org.glassfish.jersey.internal.inject.Binding)2 ClassBinding (org.glassfish.jersey.internal.inject.ClassBinding)2 RequestScope (org.glassfish.jersey.process.internal.RequestScope)2 HeaderDelegateProvider (org.glassfish.jersey.spi.HeaderDelegateProvider)2 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 ServletContext (javax.servlet.ServletContext)1 RuntimeType (javax.ws.rs.RuntimeType)1 ClassAnalyzer (org.glassfish.hk2.api.ClassAnalyzer)1 HK2InjectionManager (org.glassfish.jersey.hk2.HK2InjectionManager)1 ServiceFinderBinder (org.glassfish.jersey.internal.ServiceFinderBinder)1 PerThread (org.glassfish.jersey.internal.inject.PerThread)1