public static Habitat getHabitat(final InputStream inputStream) { try { final Habitat habitat = getNewHabitat(); final ConfigParser parser = new ConfigParser(habitat); XMLInputFactory xif = XMLInputFactory.class.getClassLoader() == null ? XMLInputFactory.newInstance() : XMLInputFactory.newInstance(XMLInputFactory.class.getName(), XMLInputFactory.class.getClassLoader()); final DomDocument document = parser.parse(xif.createXMLStreamReader(inputStream)); habitat.addComponent("document", document); return habitat; } catch (Exception e) { e.printStackTrace(); throw new GrizzlyConfigException(e.getMessage(), e); } }
private void prepareHabitat() { // Bootstrap a hk2 environment. ModulesRegistry registry = new StaticModulesRegistry(getClass().getClassLoader()); habitat = registry.createHabitat("default"); StartupContext startupContext = new StartupContext(); habitat.add(new ExistingSingletonInhabitant(startupContext)); habitat.addComponent(null, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other)); }
EarlyLogHandler.earlyMessages.add(lr); habitat.addComponent("parent-class-loader", new ExistingSingletonInhabitant<ClassLoader>(ClassLoader.class, registry.getParentClassLoader()));
static private Habitat getHabitat() { Habitat habitat = Globals.getStaticHabitat(); StartupContext startupContext = new StartupContext(); habitat.add(new ExistingSingletonInhabitant(startupContext)); habitat.addComponent(null, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other)); return habitat; } }
habitat.addComponent("program-options", po); cmd = CLICommand.getCommand(habitat, command); rc = cmd.execute(args); habitat.addComponent("program-options", programOpts);
habitat.addComponent("environment", env); habitat.addComponent("program-options", po); cmd = CLICommand.getCommand(habitat, command); return cmd.execute(argv);