Package org.glassfish.hk2.api

Examples of org.glassfish.hk2.api.DynamicConfiguration


        return result;
    }

    private static void bind(final ServiceLocator locator, final Binder binder) {
        final DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        final DynamicConfiguration dc = dcs.createDynamicConfiguration();

        locator.inject(binder);
        binder.bind(dc);

        dc.commit();
    }
View Full Code Here


        final Set<Binder> allConfigured = Sets.newIdentityHashSet();
        allConfigured.addAll(configured);

        final Collection<Binder> binders = getBinders(configured);
        if (!binders.isEmpty()) {
            final DynamicConfiguration dc = Injections.getConfiguration(locator);

            for (final Binder binder : binders) {
                binder.bind(dc);
                allConfigured.add(binder);
            }
            dc.commit();
        }

        return allConfigured;
    }
View Full Code Here

    // ComponentProvider
    @Override
    public void initialize(final ServiceLocator locator) {
        this.locator = locator;
        final DynamicConfiguration configuration = Injections.getConfiguration(locator);
        Injections.addBinding(Injections.newBinder(this).to(ResourceMethodInvocationHandlerProvider.class), configuration);
        configuration.commit();
    }
View Full Code Here

        if (!ejbInterceptorRegistered) {
            registerEjbInterceptor();
        }

        DynamicConfiguration dc = Injections.getConfiguration(locator);

        final ServiceBindingBuilder bindingBuilder = Injections.newFactoryBinder(new EjbFactory(component, initialContext));

        bindingBuilder.to(component);
        for (Class contract : providerContracts) {
            bindingBuilder.to(contract);
        }

        Injections.addBinding(bindingBuilder, dc);

        dc.commit();

        if (LOGGER.isLoggable(Level.CONFIG)) {
            LOGGER.config(LocalizationMessages.EJB_CLASS_BOUND_WITH_CDI(component));
        }
View Full Code Here

    }

    @Override
    public void done() {
        if (ejbInterceptorRegistered) {
            final DynamicConfiguration dc = Injections.getConfiguration(locator);
            Injections.addBinding(
                    Injections.newBinder(EjbExceptionMapper.class).to(ExceptionMapper.class).in(Singleton.class), dc);
            dc.commit();
        }
    }
View Full Code Here

        if (!isCdiManaged && !isManagedBean && !isJaxRsComponent) {
            return false;
        }

        DynamicConfiguration dc = Injections.getConfiguration(locator);

        final ServiceBindingBuilder bindingBuilder =
                Injections.newFactoryBinder(new CdiFactory(clazz, locator, beanManager, isCdiManaged));

        bindingBuilder.to(clazz);
        for (Class contract : providerContracts) {
            bindingBuilder.to(contract);
        }

        Injections.addBinding(bindingBuilder, dc);

        dc.commit();

        if (LOGGER.isLoggable(Level.CONFIG)) {
            LOGGER.config(LocalizationMessages.CDI_CLASS_BOUND_WITH_CDI(clazz));
        }
View Full Code Here

                skippedElements > 0 ? new InjecteeSkippingAnalyzer(
                                                defaultClassAnalyzer,
                                                methodsToSkip,
                                                fieldsToSkip) : defaultClassAnalyzer;

        DynamicConfiguration dc = Injections.getConfiguration(locator);

        final ScopedBindingBuilder bindingBuilder =
                Injections.newBinder(customizedClassAnalyzer);

        bindingBuilder.analyzeWith(ClassAnalyzer.DEFAULT_IMPLEMENTATION_NAME)
                .to(ClassAnalyzer.class)
                .named(CDI_CLASS_ANALYZER);

        Injections.addBinding(bindingBuilder, dc);

        dc.commit();
    }
View Full Code Here

        Set<Bean<?>> beans = manager.getBeans(failedInjectionPoint.getRequiredType(), qualifiers);
        if (beans == null || beans.isEmpty()) {
            return false;
        }
       
        DynamicConfiguration config = ServiceLocatorUtilities.createDynamicConfiguration(locator);
        for (Bean<?> bean : beans) {
            // Add a bean to the service locator
            CDIHK2Descriptor<Object> descriptor = new CDIHK2Descriptor<Object>(manager, (Bean<Object>) bean);
            config.addActiveDescriptor(descriptor);
        }
       
        config.commit();
       
        return true;
    }
View Full Code Here

   
    private WebConfigListener addAndGetWebConfigListener() {
      ServiceLocator locator = (ServiceLocator) habitat;
     
      DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
      DynamicConfiguration config = dcs.createDynamicConfiguration();
     
      config.addActiveDescriptor(WebConfigListener.class);
     
      config.commit();
     
      return locator.getService(WebConfigListener.class);
    }
View Full Code Here

    // ComponentProvider
    @Override
    public void initialize(final ServiceLocator locator) {
        this.locator = locator;
        final DynamicConfiguration configuration = Injections.getConfiguration(locator);
        Injections.addBinding(Injections.newBinder(this).to(ResourceMethodInvocationHandlerProvider.class), configuration);
        configuration.commit();
    }
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.api.DynamicConfiguration

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.