Search in sources :

Example 6 with StartupContext

use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.

the class CommandRunnerTest method setup.

@BeforeClass
public void setup() {
    /*
         * The CommandRunnerImpl now injects Domain but these tests do not
         * exercise the code path that requires the domain.  So register a
         * dummy Domain instance with the habitat so injection will work.
         */
    ServiceLocatorUtilities.addOneDescriptor(testLocator, BuilderHelper.createConstantDescriptor(simpleDomain(), null, Domain.class));
    ServiceLocatorUtilities.addOneConstant(testLocator, new StartupContext());
    ServiceLocatorUtilities.addOneDescriptor(testLocator, BuilderHelper.createConstantDescriptor(new SingleModulesRegistry(CommandRunnerTest.class.getClassLoader()), null, ModulesRegistry.class));
}
Also used : StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) SingleModulesRegistry(com.sun.enterprise.module.single.SingleModulesRegistry) SingleModulesRegistry(com.sun.enterprise.module.single.SingleModulesRegistry) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) Domain(com.sun.enterprise.config.serverbeans.Domain) BeforeClass(org.junit.BeforeClass)

Example 7 with StartupContext

use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.

the class EmbeddedOSGiGlassFishRuntime method newGlassFish.

@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);
    }
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) GlassFishException(org.glassfish.embeddable.GlassFishException) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) ServiceTracker(org.osgi.util.tracker.ServiceTracker) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) BootException(com.sun.enterprise.module.bootstrap.BootException) Main(com.sun.enterprise.module.bootstrap.Main) GlassFish(org.glassfish.embeddable.GlassFish) ModuleStartup(com.sun.enterprise.module.bootstrap.ModuleStartup)

Example 8 with StartupContext

use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.

the class SunDeploymentManager method prepareHabitat.

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));
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) ModulesRegistry(com.sun.enterprise.module.ModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) StaticModulesRegistry(com.sun.enterprise.module.single.StaticModulesRegistry) ProcessEnvironment(org.glassfish.api.admin.ProcessEnvironment)

Example 9 with StartupContext

use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.

the class AppServerStartupTest method initialize.

// ----- test initialization ---------------------------------------------
private void initialize(ServiceLocator testLocator) {
    DynamicConfigurationService dcs = testLocator.getService(DynamicConfigurationService.class);
    DynamicConfiguration config = dcs.createDynamicConfiguration();
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new TestSystemTasks()));
    // These are services that would normally be started by hk2 core
    config.addActiveDescriptor(AppServerStartup.AppInstanceListener.class);
    AbstractActiveDescriptor<?> descriptor = BuilderHelper.createConstantDescriptor(new TestModulesRegistry());
    descriptor.addContractType(ModulesRegistry.class);
    config.addActiveDescriptor(descriptor);
    descriptor = BuilderHelper.createConstantDescriptor(new ExecutorServiceFactory().provide());
    descriptor.addContractType(ExecutorService.class);
    config.addActiveDescriptor(descriptor);
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new ServerEnvironmentImpl()));
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new EventsImpl()));
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new Version()));
    config.addActiveDescriptor(BuilderHelper.createConstantDescriptor(new StartupContext()));
    config.bind(BuilderHelper.link(RunLevelControllerImpl.class).to(RunLevelController.class).build());
    config.addUnbindFilter(BuilderHelper.createContractFilter(RunLevelContext.class.getName()));
    config.bind(BuilderHelper.link(RunLevelContext.class).to(Context.class).in(Singleton.class).build());
    config.addUnbindFilter(BuilderHelper.createContractFilter(AsyncRunLevelContext.class.getName()));
    config.bind(BuilderHelper.link(AsyncRunLevelContext.class).in(Singleton.class).build());
    config.bind(BuilderHelper.link(AppServerStartup.class).build());
    descriptor = BuilderHelper.createConstantDescriptor(testLocator);
    descriptor.addContractType(ServiceLocator.class);
    config.addActiveDescriptor(descriptor);
    bindService(config, TestInitRunLevelService.class);
    bindService(config, TestStartupService.class);
    bindService(config, TestStartupRunLevelService.class);
    bindService(config, TestPostStartupRunLevelService.class);
    bindService(config, CommonClassLoaderServiceImpl.class);
    bindService(config, APIClassLoaderServiceImpl.class);
    bindService(config, APIExporterImpl.class);
    config.commit();
}
Also used : RunLevelContext(org.glassfish.hk2.runlevel.RunLevelContext) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) AsyncRunLevelContext(org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext) Context(org.glassfish.hk2.api.Context) DynamicConfigurationService(org.glassfish.hk2.api.DynamicConfigurationService) StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) ServerEnvironmentImpl(org.glassfish.server.ServerEnvironmentImpl) DynamicConfiguration(org.glassfish.hk2.api.DynamicConfiguration) Version(com.sun.appserv.server.util.Version) AsyncRunLevelContext(org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext) RunLevelControllerImpl(org.glassfish.hk2.runlevel.internal.RunLevelControllerImpl) EventsImpl(org.glassfish.kernel.event.EventsImpl)

Example 10 with StartupContext

use of com.sun.enterprise.module.bootstrap.StartupContext in project Payara by payara.

the class PhoneHomeTask method getUptime.

private String getUptime() {
    RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
    long totalTime_ms = -1;
    if (mxbean != null)
        totalTime_ms = mxbean.getUptime();
    if (totalTime_ms <= 0 && env != null) {
        StartupContext ctx = env.getStartupContext();
        if (ctx != null) {
            long start = ctx.getCreationTime();
            totalTime_ms = System.currentTimeMillis() - start;
        }
    }
    return Long.toString(totalTime_ms);
}
Also used : StartupContext(com.sun.enterprise.module.bootstrap.StartupContext) RuntimeMXBean(java.lang.management.RuntimeMXBean)

Aggregations

StartupContext (com.sun.enterprise.module.bootstrap.StartupContext)13 ModulesRegistry (com.sun.enterprise.module.ModulesRegistry)6 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)6 ModuleStartup (com.sun.enterprise.module.bootstrap.ModuleStartup)3 StaticModulesRegistry (com.sun.enterprise.module.single.StaticModulesRegistry)3 File (java.io.File)3 Properties (java.util.Properties)3 DynamicConfiguration (org.glassfish.hk2.api.DynamicConfiguration)3 DynamicConfigurationService (org.glassfish.hk2.api.DynamicConfigurationService)3 SingleModulesRegistry (com.sun.enterprise.module.single.SingleModulesRegistry)2 FilenameFilter (java.io.FilenameFilter)2 JarFile (java.util.jar.JarFile)2 Logger (java.util.logging.Logger)2 ProcessEnvironment (org.glassfish.api.admin.ProcessEnvironment)2 GlassFishException (org.glassfish.embeddable.GlassFishException)2 Version (com.sun.appserv.server.util.Version)1 RankedConfigBeanProxy (com.sun.enterprise.config.modularity.RankedConfigBeanProxy)1 ConfigBeanDefaultValue (com.sun.enterprise.config.modularity.customization.ConfigBeanDefaultValue)1 Domain (com.sun.enterprise.config.serverbeans.Domain)1 EmbeddedInhabitantsParser (com.sun.enterprise.glassfish.bootstrap.EmbeddedInhabitantsParser)1