Examples of GlassFish


Examples of org.glassfish.embeddable.GlassFish

                "DomainCreation");
        glassFishProperties.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY,
                domDir.getAbsolutePath());
        glassFishProperties.setProperty("-domain", domainConfig.getDomainName());

        GlassFish glassfish = runtime.newGlassFish(glassFishProperties);
        glassfish.start();

        // Will always need DAS's name & config. No harm using the name 'server'
        // to fetch <server-config>
        com.sun.enterprise.config.serverbeans.Server serverConfig =
                glassfish.getService(com.sun.enterprise.config.serverbeans.Server.class,
                "server");
        Config config = glassfish.getService(
                Config.class, serverConfig.getConfigRef());

        // Create a context object for this domain creation to enable the new
        // modules to make decisions
        DomainContext ctx = new DomainContext();
        ctx.setDomainType("dev"); //TODO : Whenever clustering/HA is supported
        // this setting needs to be fixed. Domain type can be dev/ha/cluster and
        // this type needs to be extracted possibly using an api from installer
        ctx.setLogger(LogDomains.getLogger(
                DomainInitializer.class, LogDomains.SERVER_LOGGER));

        // now for every such Inhabitant, fetch the actual initial config and
        // insert it into the module that initial config was targeted for.
        ServiceLocator habitat = glassfish.getService(ServiceLocator.class);
        Collection<DomainInitializer> inits =
                habitat.getAllServices(DomainInitializer.class);
        if (inits.isEmpty()) {
            logger.info(strings.get("NoCustomization"));
        }
        for (DomainInitializer inhabitant : habitat.<DomainInitializer>getAllServices(
                DomainInitializer.class)) {
            logger.info(strings.get("InvokeInitializer",
                    inhabitant.getClass()));
            Container newContainerConfig = inhabitant.getInitialConfig(ctx);
            try {
                ConfigSupport.apply((new ConfigCode() {
                    @Override
                    @SuppressWarnings("unchecked")
                    public Object run(ConfigBeanProxy... objects) throws PropertyVetoException, TransactionFailure {
                        ((Config) objects[0]).getContainers().add((Container) objects[1]);
                        return Boolean.TRUE;
                    }
                }), new ConfigBeanProxy[]{config, newContainerConfig});
            }
            catch (TransactionFailure e) {
                logger.severe(strings.get("InitializerTransactionFailure",
                        inhabitant.getClass()));
            }
        }
        glassfish.dispose();
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

                "DomainCreation");
        glassFishProperties.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY,
                domDir.getAbsolutePath());
        glassFishProperties.setProperty("-domain", domainConfig.getDomainName());

        GlassFish glassfish = runtime.newGlassFish(glassFishProperties);
        glassfish.start();

        // Will always need DAS's name & config. No harm using the name 'server'
        // to fetch <server-config>
        com.sun.enterprise.config.serverbeans.Server serverConfig =
                glassfish.getService(com.sun.enterprise.config.serverbeans.Server.class,
                "server");
        Config config = glassfish.getService(
                Config.class, serverConfig.getConfigRef());

        // Create a context object for this domain creation to enable the new
        // modules to make decisions
        DomainContext ctx = new DomainContext();
        ctx.setDomainType("dev"); //TODO : Whenever clustering/HA is supported
        // this setting needs to be fixed. Domain type can be dev/ha/cluster and
        // this type needs to be extracted possibly using an api from installer


        // bnevins 12/20/12 -- I'm not touching this ancient getLogger call.
        // because it looks risky.
        ctx.setLogger(LogDomains.getLogger(
                DomainInitializer.class, LogDomains.SERVER_LOGGER));

        // now for every such Inhabitant, fetch the actual initial config and
        // insert it into the module that initial config was targeted for.
        ServiceLocator habitat = glassfish.getService(ServiceLocator.class);
        Collection<DomainInitializer> inits =
                habitat.getAllServices(DomainInitializer.class);
        if (inits.isEmpty()) {
            logger.info(strings.get("NoCustomization"));
        }
        for (DomainInitializer inhabitant : habitat.<DomainInitializer>getAllServices(
                DomainInitializer.class)) {
            logger.info(strings.get("InvokeInitializer",
                    inhabitant.getClass()));
            Container newContainerConfig = inhabitant.getInitialConfig(ctx);
            try {
                ConfigSupport.apply((new ConfigCode() {
                    @Override
                    @SuppressWarnings("unchecked")
                    public Object run(ConfigBeanProxy... objects) throws PropertyVetoException, TransactionFailure {
                        ((Config) objects[0]).getContainers().add((Container) objects[1]);
                        return Boolean.TRUE;
                    }
                }), new ConfigBeanProxy[]{config, newContainerConfig});
            }
            catch (TransactionFailure e) {
                logger.severe(strings.get("InitializerTransactionFailure",
                        inhabitant.getClass()));
            }
        }
        glassfish.dispose();
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

            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) {
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

            System.setProperty(com.sun.enterprise.glassfish.bootstrap.Constants.INSTANCE_ROOT_URI_PROP_NAME, instanceRoot.toURI().toString());
        }
    }

    protected GlassFish createGlassFish(ModuleStartup gfKernel, ServiceLocator habitat, Properties gfProps) throws GlassFishException {
        GlassFish gf = new GlassFishImpl(gfKernel, habitat, gfProps);
        return new EmbeddedOSGiGlassFishImpl(gf, getBundleContext());
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

            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) {
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

            System.setProperty(com.sun.enterprise.glassfish.bootstrap.Constants.INSTANCE_ROOT_URI_PROP_NAME, instanceRoot.toURI().toString());
        }
    }

    protected GlassFish createGlassFish(ModuleStartup gfKernel, ServiceLocator habitat, Properties gfProps) throws GlassFishException {
        GlassFish gf = new GlassFishImpl(gfKernel, habitat, gfProps);
        return new EmbeddedOSGiGlassFishImpl(gf, getBundleContext());
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

        framework = null; // guard against repeated calls.
    }

    @Override
    public GlassFish newGlassFish(GlassFishProperties glassfishProperties) throws GlassFishException {
        GlassFish embeddedGf = super.newGlassFish(glassfishProperties);
        int finalStartLevel = Integer.valueOf(glassfishProperties.getProperties().getProperty(
                Constants.FINAL_START_LEVEL_PROP, "2"));
        return new OSGiGlassFishImpl(embeddedGf, framework.getBundleContext(), finalStartLevel);
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

                "DomainCreation");
        glassFishProperties.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY,
                domDir.getAbsolutePath());
        glassFishProperties.setProperty("-domain", domainConfig.getDomainName());

        GlassFish glassfish = runtime.newGlassFish(glassFishProperties);
        glassfish.start();

        // Will always need DAS's name & config. No harm using the name 'server'
        // to fetch <server-config>
        com.sun.enterprise.config.serverbeans.Server serverConfig =
                glassfish.getService(com.sun.enterprise.config.serverbeans.Server.class,
                "server");
        Config config = glassfish.getService(
                Config.class, serverConfig.getConfigRef());

        // Create a context object for this domain creation to enable the new
        // modules to make decisions
        DomainContext ctx = new DomainContext();
        ctx.setDomainType("dev"); //TODO : Whenever clustering/HA is supported
        // this setting needs to be fixed. Domain type can be dev/ha/cluster and
        // this type needs to be extracted possibly using an api from installer


        // bnevins 12/20/12 -- I'm not touching this ancient getLogger call.
        // because it looks risky.
        ctx.setLogger(LogDomains.getLogger(
                DomainInitializer.class, LogDomains.SERVER_LOGGER));

        // now for every such Inhabitant, fetch the actual initial config and
        // insert it into the module that initial config was targeted for.
        ServiceLocator habitat = glassfish.getService(ServiceLocator.class);
        Collection<DomainInitializer> inits =
                habitat.getAllServices(DomainInitializer.class);
        if (inits.isEmpty()) {
            logger.info(strings.get("NoCustomization"));
        }
        for (DomainInitializer inhabitant : habitat.<DomainInitializer>getAllServices(
                DomainInitializer.class)) {
            logger.info(strings.get("InvokeInitializer",
                    inhabitant.getClass()));
            Container newContainerConfig = inhabitant.getInitialConfig(ctx);
            try {
                ConfigSupport.apply((new ConfigCode() {
                    @Override
                    @SuppressWarnings("unchecked")
                    public Object run(ConfigBeanProxy... objects) throws PropertyVetoException, TransactionFailure {
                        ((Config) objects[0]).getContainers().add((Container) objects[1]);
                        return Boolean.TRUE;
                    }
                }), new ConfigBeanProxy[]{config, newContainerConfig});
            }
            catch (TransactionFailure e) {
                logger.severe(strings.get("InitializerTransactionFailure",
                        inhabitant.getClass()));
            }
        }
        glassfish.dispose();
    }
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

    public static synchronized GlassFish startGlassFish(String serverID, String installRoot,
                                                        String instanceRoot, String configFileURI,
                                                        boolean configFileReadOnly, int httpPort)
            throws GlassFishException {
        GlassFish glassfish = gfMap.get(serverID);
        if (glassfish != null) {
            return glassfish;
        }
        if (glassfishRuntime == null) {
            BootstrapProperties bootstrapProperties = new BootstrapProperties();
            if (installRoot != null) {
                bootstrapProperties.setInstallRoot(installRoot);
            }
            glassfishRuntime = GlassFishRuntime.bootstrap(bootstrapProperties);
        }

        GlassFishProperties glassfishProperties = new GlassFishProperties();
        if (instanceRoot != null) {
            glassfishProperties.setInstanceRoot(instanceRoot);
        }
        if (configFileURI != null) {
            glassfishProperties.setConfigFileURI(configFileURI);
            glassfishProperties.setConfigFileReadOnly(configFileReadOnly);
        }

        if (instanceRoot==null && configFileURI==null) {
            // only set port if embedded domain.xml is used
            if (httpPort != -1) {
                glassfishProperties.setPort("http-listener", httpPort);
            }
        }

        glassfish = glassfishRuntime.newGlassFish(glassfishProperties);
        glassfish.start();

        gfMap.put(serverID, glassfish);

        System.out.println("Started GlassFish [" + serverID + "]");
View Full Code Here

Examples of org.glassfish.embeddable.GlassFish

        return glassfish;
    }

    public static void deploy(String app, String serverId, List<String> deployParams)
            throws Exception {
        GlassFish glassfish = gfMap.get(serverId);
        if (glassfish == null) {
            throw new Exception("Embedded GlassFish [" + serverId + "] not running");
        }
        if (app == null) {
            throw new Exception("Application can not be null");
        }
        Deployer deployer = glassfish.getDeployer();
        if (deployParams.size() > 0) {
            deployer.deploy(new File(app).toURI(), deployParams.toArray(new String[0]));
            System.out.println("Deployed [" + app + "] with parameters " + deployParams);
        } else {
            deployer.deploy(new File(app).toURI());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.