Package org.glassfish.hk2.api

Examples of org.glassfish.hk2.api.DynamicConfiguration


        ServiceLocator locator = grizzlyService.getHabitat();
        IndexedFilter removeFilter = BuilderHelper.createNameAndContractFilter(Mapper.class.getName(),
                (address.toString() + port));

        DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();

        config.addUnbindFilter(removeFilter);

        config.commit();

        unregisterMonitoringStatsProviders();
        super.stop();
    }
View Full Code Here


        return rc;
    }
   
    private static void atomicReplace(ServiceLocator locator, ProgramOptions options) {
        DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();
       
        config.addUnbindFilter(BuilderHelper.createContractFilter(ProgramOptions.class.getName()));
        ActiveDescriptor<ProgramOptions> desc = BuilderHelper.createConstantDescriptor(
                options, null, ProgramOptions.class);
        config.addActiveDescriptor(desc);
       
        config.commit();
    }
View Full Code Here

            logger.log(level, "Startup class : {0}", getClass().getName());
        }

        // prepare the global variables
        DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();

        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(logger));
        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(masterListener));

        config.addUnbindFilter(BuilderHelper.createContractFilter(ProcessEnvironment.class.getName()));

        config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(
                env.isEmbedded() ?
                new ProcessEnvironment(ProcessEnvironment.ProcessType.Embedded):
                new ProcessEnvironment(ProcessEnvironment.ProcessType.Server)));
        config.commit();
       
       

        // activate the run level services
        masterListener.reset();
View Full Code Here

        return main.endsWith(".java");
    }

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

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

        dc.commit();
    }
View Full Code Here

        DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
        if (dcs == null) {
            throw new IllegalStateException("This service locator has no DynamicConfiugurationService: " + locator);
        }
       
        DynamicConfiguration config = dcs.createDynamicConfiguration();
       
        if (addContext) {
            config.addActiveDescriptor(GuiceScopeContext.class);
        }
       
        if (addService) {
            config.addActiveDescriptor(GuiceIntoHK2BridgeImpl.class);
        }
       
        config.commit();

    }
View Full Code Here

            Globals.setDefaultHabitat(habitat);
           
            ServiceLocator locator = habitat;
           
            DynamicConfigurationService dcs = locator.getService(DynamicConfigurationService.class);
            DynamicConfiguration config = dcs.createDynamicConfiguration();
           
            /*
             * Remove any already-loaded startup context so we can replace it
             * with the ACC one.
             */
            config.addUnbindFilter(BuilderHelper.createContractFilter(StartupContext.class.getName()));
           
            /*
             * Following the example from AppServerStartup, remove any
             * pre-loaded lazy inhabitant for ProcessEnvironment that exists
             * from HK2's scan for services.  Then add in
             * an ACC ProcessEnvironment.
             */
            config.addUnbindFilter(BuilderHelper.createContractFilter(ProcessEnvironment.class.getName()));
           
            config.commit();
           
            config = dcs.createDynamicConfiguration();
           
            StartupContext startupContext = new ACCStartupContext();
            AbstractActiveDescriptor<?> startupContextDescriptor = BuilderHelper.createConstantDescriptor(startupContext);
            startupContextDescriptor.addContractType(StartupContext.class);
            config.addActiveDescriptor(startupContextDescriptor);
           
            ModulesRegistry modulesRegistry = new StaticModulesRegistry(ACCModulesManager.class.getClassLoader());
            config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(modulesRegistry));
           
            config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(
                    new ProcessEnvironment(ProcessEnvironment.ProcessType.ACC)));

            /*
             * Create the ClientNamingConfigurator used by naming.
             */
            ClientNamingConfigurator cnc = new ClientNamingConfiguratorImpl();
            config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(cnc));
           
            Logger logger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
            AbstractActiveDescriptor<Logger> di = BuilderHelper.createConstantDescriptor(logger);
            di.addContractType(Logger.class);
            config.addActiveDescriptor(di);
           
            config.commit();
       }
    }
View Full Code Here

        return main.endsWith(".java");
    }

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

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

        dc.commit();
    }
View Full Code Here

        }
       
        testLocator = ServiceLocatorFactory.getInstance().create(name);
       
        DynamicConfigurationService dcs = testLocator.getService(DynamicConfigurationService.class);
        DynamicConfiguration config = dcs.createDynamicConfiguration();
       
        config.addActiveDescriptor(ErrorServiceImpl.class);
        config.addActiveDescriptor(JustInTimeInjectionResolverImpl.class);
       
        addServicesFromDefault(config);
       
        addServicesFromPackage(config, packages);
       
        for (Class<?> clazz : clazzes) {
            config.addActiveDescriptor(clazz);
        }
       
        config.commit();
       
        testLocator.inject(this);
    }
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

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

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

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

        return allConfigured;
    }
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.