Search in sources :

Example 6 with BootstrapProperties

use of org.glassfish.embeddable.BootstrapProperties in project Payara by payara.

the class OSGiGlassFishRuntimeBuilder method build.

public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishException {
    try {
        MainHelper.buildStartupContext(bsProps.getProperties());
        Properties properties = bsProps.getProperties();
        // Set the builder name so that when we check for nonEmbedded() inside GlassFishMainActivator,
        // we can identify the environment.
        properties.setProperty(Constants.BUILDER_NAME_PROPERTY, getClass().getName());
        // Step 0: Locate and launch a framework
        long t0 = System.currentTimeMillis();
        fwLauncher = new OSGiFrameworkLauncher(properties);
        framework = fwLauncher.launchOSGiFrameWork();
        long t1 = System.currentTimeMillis();
        logger.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "build", "Launched {0}", new Object[] { framework });
        // Step 1: install/update/delete bundles
        if (newFramework()) {
            storeProvisioningOptions(properties);
        } else {
            // this will reconfigure if any provisioning options have changed.
            reconfigure(properties);
        }
        BundleProvisioner bundleProvisioner = BundleProvisioner.createBundleProvisioner(framework.getBundleContext(), properties);
        List<Long> bundleIds = bundleProvisioner.installBundles();
        if (bundleProvisioner.hasAnyThingChanged()) {
            bundleProvisioner.refresh();
            // clean hk2 cache so that updated bundle details will go in there.
            deleteHK2Cache(properties);
            // Save the bundle ids for use during restart.
            storeBundleIds(bundleIds.toArray(new Long[bundleIds.size()]));
        }
        if (bundleProvisioner.isSystemBundleUpdationRequired()) {
            logger.log(Level.INFO, LogFacade.UPDATING_SYSTEM_BUNDLE);
            framework.update();
            framework.waitForStop(0);
            framework.init();
            bundleProvisioner.setBundleContext(framework.getBundleContext());
        }
        // Step 2: Start bundles
        bundleProvisioner.startBundles();
        long t2 = System.currentTimeMillis();
        // Step 3: Start the framework, so bundles will get activated as per their start levels
        framework.start();
        long t3 = System.currentTimeMillis();
        printStats(bundleProvisioner, t0, t1, t2, t3);
        // Step 4: Obtain reference to GlassFishRuntime and return the same
        return getGlassFishRuntime();
    } catch (Exception e) {
        throw new GlassFishException(e);
    }
}
Also used : GlassFishException(org.glassfish.embeddable.GlassFishException) Properties(java.util.Properties) BootstrapProperties(org.glassfish.embeddable.BootstrapProperties) GlassFishException(org.glassfish.embeddable.GlassFishException) BundleException(org.osgi.framework.BundleException)

Aggregations

BootstrapProperties (org.glassfish.embeddable.BootstrapProperties)6 GlassFishProperties (org.glassfish.embeddable.GlassFishProperties)5 GlassFishException (org.glassfish.embeddable.GlassFishException)4 File (java.io.File)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Properties (java.util.Properties)2 GlassFish (org.glassfish.embeddable.GlassFish)2 BundleException (org.osgi.framework.BundleException)2 OSGiFrameworkLauncher (com.sun.enterprise.glassfish.bootstrap.OSGiFrameworkLauncher)1 BootstrapException (fish.payara.micro.BootstrapException)1 ValidationException (fish.payara.micro.cmd.options.ValidationException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 BindException (java.net.BindException)1 MalformedURLException (java.net.MalformedURLException)1 JarFile (java.util.jar.JarFile)1 NamingException (javax.naming.NamingException)1 Deployer (org.glassfish.embeddable.Deployer)1 GlassFishRuntime (org.glassfish.embeddable.GlassFishRuntime)1