Package org.glassfish.hk2.utilities.binding

Examples of org.glassfish.hk2.utilities.binding.AbstractBinder


        resourceConfig.property(name, value);
        return this;
    }

    public Jersey withInjectables(final Object... instances) {
        resourceConfig.register(new AbstractBinder() {
            @SuppressWarnings("unchecked")
            @Override
            protected void configure() {
                for (final Object instance : instances) {
                    bind(instance).to((Class<Object>) instance.getClass());
View Full Code Here


    };

    public static ServiceLocator createServiceLocator(Binder... customBinders) {
        Binder[] binders = new Binder[customBinders.length + 2];

        binders[0] = new AbstractBinder() {
            @Override
            protected void configure() {
                bindFactory(new Factory<Configuration>() {
                    @Override
                    public Configuration provide() {
View Full Code Here

    @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);
View Full Code Here

        }

        // SPI/extension hook to configure ResourceConfig
        configure(resourceConfig);

        final AbstractBinder webComponentBinder = new WebComponentBinder(resourceConfig.getProperties());
        resourceConfig.register(webComponentBinder);

        this.appHandler = new ApplicationHandler(resourceConfig, webComponentBinder);

        this.asyncExtensionDelegate = getAsyncExtensionDelegate();
View Full Code Here

    public ServiceFinderBinderTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
        locator = Injections.createLocator(new AbstractBinder() {
            @Override
            protected void configure() {
                bind(TestServiceB.class).to(TestContract.class);
                bind(TestServiceD.class).to(TestContract.class);
                new ServiceFinderBinder<TestContract>(TestContract.class, null, RuntimeType.SERVER).bind(this);
View Full Code Here

    @Override
    public void configure(final FeatureContext context) {
        final Map<String, Object> properties = context.getConfiguration().getProperties();
        final RuntimeType runtimeType = context.getConfiguration().getRuntimeType();

        context.register(new AbstractBinder() {
            @Override
            protected void configure() {
                // Message Body providers.
                install(new ServiceFinderBinder<MessageBodyReader>(MessageBodyReader.class, properties, runtimeType));
                install(new ServiceFinderBinder<MessageBodyWriter>(MessageBodyWriter.class, properties, runtimeType));
View Full Code Here

        register(AppScopedFieldInjectedResource.class);
        register(AppScopedCtorInjectedResource.class);
        register(RequestScopedFieldInjectedResource.class);
        register(RequestScopedCtorInjectedResource.class);

        register(new AbstractBinder() {
            @Override
            protected void configure() {
                bind(new MyInjection("no way CDI would chime in")).to(MyInjection.class);
            }
        });
View Full Code Here

class TestUtil {

    public static ResourceConfig registerHK2Services(ResourceConfig rc) {
        rc
                .register(new AbstractBinder() {
                    @Override
                    protected void configure() {
                        bind(BuilderHelper.link(HK2ServiceSingleton.class).in(Singleton.class).build());
                    }
                })
                .register(new AbstractBinder() {
                    @Override
                    protected void configure() {
                        bind(BuilderHelper.link(HK2ServiceRequestScoped.class).in(RequestScoped.class).build());
                    }
                })
                .register(new AbstractBinder() {
                    @Override
                    protected void configure() {
                        bind(BuilderHelper.link(HK2ServicePerLookup.class).in(PerLookup.class).build());
                    }
                });
View Full Code Here

        final List<Object> providers = Lists.newArrayList(componentBag.getInstances(ComponentBag.EXCLUDE_META_PROVIDERS));

        // Get instances of providers.
        final Set<Class<?>> providerClasses = componentBag.getClasses(ComponentBag.EXCLUDE_META_PROVIDERS);
        if (!providerClasses.isEmpty()) {
            locator = Injections.createLocator(locator, new AbstractBinder() {
                @Override
                protected void configure() {
                    bind(config).to(Configuration.class);
                }
            });
View Full Code Here

            }
        }

        if (monitoringEnabled) {
            context.register(ApplicationInfoListener.class);
            context.register(new AbstractBinder() {
                @Override
                protected void configure() {
                    bindFactory(ReferencingFactory.<ApplicationInfo>referenceFactory()).to(
                            new TypeLiteral<Ref<ApplicationInfo>>() {
                            }
                    ).in(Singleton.class);

                    bindFactory(ApplicationInfoInjectionFactory.class).to(
                            ApplicationInfo.class).in(PerLookup.class);
                }
            });
        }

        if (statisticsEnabled) {
            context.register(MonitoringEventListener.class);
            context.register(new AbstractBinder() {
                @Override
                protected void configure() {
                    bindFactory(ReferencingFactory.<MonitoringStatistics>referenceFactory()).to(
                            new TypeLiteral<Ref<MonitoringStatistics>>() {
                            }).in(Singleton.class);
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.utilities.binding.AbstractBinder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.