public static ServiceLocator getNewHabitat(String root) { Properties p = new Properties(); p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTALL_ROOT_PROP_NAME, root); p.put(com.sun.enterprise.glassfish.bootstrap.Constants.INSTANCE_ROOT_PROP_NAME, root); ModulesRegistry registry = new StaticModulesRegistry(Utils.class.getClassLoader(), new StartupContext(p)); ServiceLocator defaultSL = registry.createServiceLocator("default"); return defaultSL; }
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)); }
private void prepareHabitat() { ModulesRegistry registry = new StaticModulesRegistry(getClass().getClassLoader()); ServiceLocator serviceLocator = registry.createServiceLocator("default"); habitat = serviceLocator.getService(ServiceLocator.class); StartupContext startupContext = new StartupContext(); ServiceLocatorUtilities.addOneConstant(habitat, startupContext); ServiceLocatorUtilities.addOneConstant(habitat, new ProcessEnvironment(ProcessEnvironment.ProcessType.Other)); }
@Override public ServiceLocator createServiceLocator(String name) throws MultiException { ServiceLocator serviceLocator = super.createServiceLocator(name); StartupContext sc = startupContext; if (startupContext==null) { sc = new StartupContext(new Properties()); } DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); config.bind(BuilderHelper.createConstantDescriptor(sc)); config.commit(); return serviceLocator; }
@Override public ServiceLocator createServiceLocator(String name) throws MultiException { ServiceLocator serviceLocator = super.createServiceLocator(name); StartupContext sc = startupContext; if (startupContext==null) { sc = new StartupContext(new Properties()); } DynamicConfigurationService dcs = serviceLocator.getService(DynamicConfigurationService.class); DynamicConfiguration config = dcs.createDynamicConfiguration(); config.bind(BuilderHelper.createConstantDescriptor(sc)); config.commit(); return serviceLocator; }
@Override public synchronized GlassFish newGlassFish(GlassFishProperties gfProps) throws GlassFishException { try { // set env props before updating config, because configuration update may actually trigger // some code to be executed which may be depending on the environment variable values. setEnv(gfProps.getProperties()); final StartupContext startupContext = new StartupContext(gfProps.getProperties()); final ServiceTracker hk2Tracker = new ServiceTracker(getBundleContext(), Main.class.getName(), null); hk2Tracker.open(); final Main main = (Main) hk2Tracker.waitForService(0); hk2Tracker.close(); final ModulesRegistry mr = ModulesRegistry.class.cast(getBundleContext().getService(getBundleContext().getServiceReference(ModulesRegistry.class.getName()))); ServiceLocator serviceLocator = main.createServiceLocator(mr, startupContext, null, null); final ModuleStartup gfKernel = main.findStartupService(mr, serviceLocator, null, startupContext); GlassFish glassFish = createGlassFish(gfKernel, serviceLocator, gfProps.getProperties()); gfs.add(glassFish); return glassFish; } catch (BootException ex) { throw new GlassFishException(ex); } catch (InterruptedException ex) { throw new GlassFishException(ex); } }
@Override public synchronized GlassFish newGlassFish(GlassFishProperties gfProps) throws GlassFishException { try { // set env props before updating config, because configuration update may actually trigger // some code to be executed which may be depending on the environment variable values. setEnv(gfProps.getProperties()); final StartupContext startupContext = new StartupContext(gfProps.getProperties()); final ServiceTracker hk2Tracker = new ServiceTracker(getBundleContext(), Main.class.getName(), null); hk2Tracker.open(); final Main main = (Main) hk2Tracker.waitForService(0); hk2Tracker.close(); final ModulesRegistry mr = ModulesRegistry.class.cast(getBundleContext().getService(getBundleContext().getServiceReference(ModulesRegistry.class.getName()))); ServiceLocator serviceLocator = main.createServiceLocator(mr, startupContext, null, null); final ModuleStartup gfKernel = main.findStartupService(mr, serviceLocator, null, startupContext); GlassFish glassFish = createGlassFish(gfKernel, serviceLocator, gfProps.getProperties()); gfs.add(glassFish); return glassFish; } catch (BootException ex) { throw new GlassFishException(ex); } catch (InterruptedException ex) { throw new GlassFishException(ex); } }
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; } }
/** * Start the server from the command line * * @param args * the command line arguments */ public void start(String[] args) throws BootException { File bootstrap = this.getBootstrapFile(); File root = bootstrap.getAbsoluteFile().getParentFile(); // root is the directory in which this bootstrap.jar is located // For most cases, this is the lib directory although this is completely // dependent on the usage of this facility. if (root == null) { throw new BootException("Cannot find root installation from " + bootstrap); } // get the ModuleStartup implementation. ModulesRegistry mr = AbstractFactory.getInstance().createModulesRegistry(); StartupContext context = new StartupContext( ArgumentManager.argsToMap(args)); launch(mr, context.getPlatformMainServiceName(), context); }
/** * Start the server from the command line * * @param args * the command line arguments */ public void start(String[] args) throws BootException { File bootstrap = this.getBootstrapFile(); File root = bootstrap.getAbsoluteFile().getParentFile(); // root is the directory in which this bootstrap.jar is located // For most cases, this is the lib directory although this is completely // dependent on the usage of this facility. if (root == null) { throw new BootException("Cannot find root installation from " + bootstrap); } // get the ModuleStartup implementation. ModulesRegistry mr = AbstractFactory.getInstance().createModulesRegistry(); StartupContext context = new StartupContext( ArgumentManager.argsToMap(args)); launch(mr, context.getPlatformMainServiceName(), context); }
setEnv(gfProps); final StartupContext startupContext = new StartupContext(gfProps.getProperties());
setEnv(gfProps); final StartupContext startupContext = new StartupContext(gfProps.getProperties());