Package org.apache.geronimo.deployment.service

Examples of org.apache.geronimo.deployment.service.ServiceConfigBuilder


        Maven2Repository repository = new Maven2Repository(localRepo);
        new DependencyManager(bundleContext, Collections.<Repository>singleton(repository), null);

        GBeanBuilder gBeanBuilder = new GBeanBuilder(null, null);
        ServiceConfigBuilder builder = new ServiceConfigBuilder(null, Collections.<Repository>singleton(repository), Collections.<NamespaceDrivenBuilder>singleton(gBeanBuilder), new Jsr77Naming(), bundleContext);
        ConfigurationStore targetConfigurationStore = new NullConfigurationStore() {
            public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
                StringBuilder configurationPathBuilder = new StringBuilder("repository");
                configurationPathBuilder.append(File.separator).append(configId.getGroupId().replace('.', '/'));
                configurationPathBuilder.append(File.separator).append(configId.getArtifactId());
                configurationPathBuilder.append(File.separator).append(configId.getVersion());
                File configurationDir = new File(buildDir, configurationPathBuilder.toString());
                configurationDir.mkdirs();
                return configurationDir;
            }
        };

        ArtifactManager artifactManager = new DefaultArtifactManager();
        ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, repository);

        Object config = builder.getDeploymentPlan(plan, null, new ModuleIDBuilder());

        DeploymentContext context = builder.buildConfiguration(
                false,
                builder.getConfigurationID(config, null, new ModuleIDBuilder()),
                config,
                null,
                Collections.singleton(targetConfigurationStore),
                artifactResolver,
                targetConfigurationStore);
View Full Code Here


        ModuleType config = ModuleDocument.Factory.parse(plan).getModule();

        Maven1Repository repository = new Maven1Repository(localRepo);
        GBeanBuilder gBeanBuilder = new GBeanBuilder(null, null);
        ServiceConfigBuilder builder = new ServiceConfigBuilder(null, Collections.singleton(repository), Collections.singleton(gBeanBuilder), new Jsr77Naming());
        ConfigurationStore targetConfigurationStore = new NullConfigurationStore() {
            public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
                return buildDir;
            }
        };

        ArtifactManager artifactManager = new DefaultArtifactManager();
        ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.singleton(repository), null);
        DeploymentContext context = builder.buildConfiguration(false, builder.getConfigurationID(config, null, new ModuleIDBuilder()), config, null, Collections.singleton(targetConfigurationStore), artifactResolver, targetConfigurationStore);
        JarOutputStream out = null;
        try {
            ConfigurationData configurationData = context.getConfigurationData();
            out = new JarOutputStream(new FileOutputStream(carFile));
            ExecutableConfigurationUtil.writeConfiguration(configurationData, out);
View Full Code Here

            // create the service builder, repository and config store objects
            LocalConfigStore configStore = new LocalConfigStore(new File(storeDir));
            ReadOnlyRepository repository = new ReadOnlyRepository(new File(repositoryDir));

            //TODO should the defaultParentId be null??
            ServiceConfigBuilder builder = new ServiceConfigBuilder(null, repository);

            // create the manifext
            Manifest manifest = new Manifest();
            Attributes mainAttributes = manifest.getMainAttributes();
            mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), "org.apache.geronimo.deployment.cli.DeployTool");
            mainAttributes.putValue(Attributes.Name.CLASS_PATH.toString(), deployerClassPath);
            mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), deployerGBean);
            mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
            mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());

            // attribute that indicates to a JSR-88 tool that we have a Deployment factory
            mainAttributes.putValue("J2EE-DeploymentFactory-Implementation-Class", deploymentFactory);

            // write the deployer system out to a jar

            // create a temp directory to build into
            File configurationDir = null;
            try {
                configurationDir = configStore.createNewConfigurationDir();

                // build the deployer-system configuration into the configurationDir
                builder.buildConfiguration(deployerSystemConfig, null, configurationDir);

                // Write the manifest
                File metaInf = new File(configurationDir, "META-INF");
                metaInf.mkdirs();
                FileOutputStream out = null;
                try {
                    out = new FileOutputStream(new File(metaInf, "MANIFEST.MF"));
                    manifest.write(out);
                } finally {
                    DeploymentUtil.close(out);
                }

                // add the startup file which allows us to locate the startup directory
                File startupJarTag = new File(metaInf, "startup-jar");
                startupJarTag.createNewFile();

                // jar up the directory
                DeploymentUtil.jarDirectory(configurationDir,  new File(deployerJar));

                // delete the startup file before moving this to the config store
                startupJarTag.delete();

                // install the configuration
                configStore.install(configurationDir);
            } catch(Throwable e) {
                DeploymentUtil.recursiveDelete(configurationDir);
                if (e instanceof Error) {
                    throw (Error)e;
                } else if (e instanceof Exception) {
                    throw (Exception)e;
                }
                throw new Error(e);
            }

            // build and install the j2ee-deployer configuration
            try {
                configurationDir = configStore.createNewConfigurationDir();

                // build the j2ee-deployer configuration into the configurationDir
                builder.buildConfiguration(j2eeDeployerConfig, null, configurationDir);

                // install the configuration
                configStore.install(configurationDir);
            } catch(Throwable e) {
                DeploymentUtil.recursiveDelete(configurationDir);
View Full Code Here

            ConfigurationType j2eeDeployerConfig = ((ConfigurationDocument) j2eeDeployerXML).getConfiguration();

            // create the service builder, repository and config store objects
            LocalConfigStore configStore = new LocalConfigStore(new File(storeDir));
            ReadOnlyRepository repository = new ReadOnlyRepository(new File(repositoryDir));
            ServiceConfigBuilder builder = new ServiceConfigBuilder(repository);

            // create the manifext
            Manifest manifest = new Manifest();
            Attributes mainAttributes = manifest.getMainAttributes();
            mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), "org.apache.geronimo.system.main.CommandLine");
            mainAttributes.putValue(Attributes.Name.CLASS_PATH.toString(), deployerClassPath);
            mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), deployerGBean);
            mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
            mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());

            // build and install the deployer-system configuration
            // write the deployer system out to a jar
            File outputFile = new File(deployerJar);
            JarOutputStream jos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)), manifest);
            try {
                // add the startup jar entry which allows us to locat the startup directory
                jos.putNextEntry(new ZipEntry("META-INF/startup-jar"));
                jos.closeEntry();

                // add the deployment system configuration to the jar
                builder.buildConfiguration(jos, deployerSystemXML);
            } finally {
                jos.close();
            }
            configStore.install(outputFile.toURL());

            // build and install the j2ee-deployer configuration
            File tempFile = File.createTempFile("j2ee-deployer", ".car");
            try {
                builder.buildConfiguration(tempFile, manifest, (InputStream)null, j2eeDeployerXML);
                configStore.install(tempFile.toURL());
            } finally {
                tempFile.delete();
            }
        } finally {
View Full Code Here

            ConfigurationType j2eeDeployerConfig = ((ConfigurationDocument) j2eeDeployerXML).getConfiguration();

            // create the service builder, repository and config store objects
            LocalConfigStore configStore = new LocalConfigStore(new File(storeDir));
            ReadOnlyRepository repository = new ReadOnlyRepository(new File(repositoryDir));
            ServiceConfigBuilder builder = new ServiceConfigBuilder(repository);

            // create the manifext
            Manifest manifest = new Manifest();
            Attributes mainAttributes = manifest.getMainAttributes();
            mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), "org.apache.geronimo.system.main.CommandLine");
            mainAttributes.putValue(Attributes.Name.CLASS_PATH.toString(), deployerClassPath);
            mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), deployerGBean);
            mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
            mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());

            // attribute that indicates to a JSR-88 tool that we have a Deployment factory
            mainAttributes.putValue("J2EE-DeploymentFactory-Implementation-Class", deploymentFactory);

            // build and install the deployer-system configuration
            // write the deployer system out to a jar
            File outputFile = new File(deployerJar);
            JarOutputStream jos = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(outputFile)), manifest);
            try {
                // add the startup jar entry which allows us to locate the startup directory
                jos.putNextEntry(new ZipEntry("META-INF/startup-jar"));
                jos.closeEntry();

                // add the deployment system configuration to the jar
                builder.buildConfiguration(jos, deployerSystemXML);
            } finally {
                jos.close();
            }
            configStore.install(outputFile.toURL());

            // build and install the j2ee-deployer configuration
            File tempFile = File.createTempFile("j2ee-deployer", ".car");
            try {
                builder.buildConfiguration(tempFile, manifest, (InputStream)null, j2eeDeployerXML);
                configStore.install(tempFile.toURL());
            } finally {
                tempFile.delete();
            }
        } finally {
View Full Code Here

    public void bootstrap() throws Exception {
        ConfigurationType config = ConfigurationDocument.Factory.parse(plan).getConfiguration();

        ReadOnlyRepository repository = new ReadOnlyRepository(localRepo);
        ServiceConfigBuilder builder = new ServiceConfigBuilder(null, repository);
        ConfigurationData configurationData = builder.buildConfiguration(config, null, buildDir);

        JarOutputStream out = new JarOutputStream(new FileOutputStream(carFile));
        ExecutableConfigurationUtil.writeConfiguration(configurationData, out);
        out.flush();
        out.close();
View Full Code Here

        ModuleType config = ModuleDocument.Factory.parse(plan).getModule();

        Maven2Repository repository = new Maven2Repository(localRepo);
        GBeanBuilder gBeanBuilder = new GBeanBuilder(null, null);
        ServiceConfigBuilder builder = new ServiceConfigBuilder(null, Collections.singleton(repository), Collections.<NamespaceDrivenBuilder>singleton(gBeanBuilder), new Jsr77Naming());
        ConfigurationStore targetConfigurationStore = new NullConfigurationStore() {
            public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
                return buildDir;
            }
        };

        ArtifactManager artifactManager = new DefaultArtifactManager();
        ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.singleton(repository), null);
        DeploymentContext context = builder.buildConfiguration(
                false,
                builder.getConfigurationID(config, null, new ModuleIDBuilder()),
                config,
                null,
                Collections.singleton(targetConfigurationStore),
                artifactResolver,
                targetConfigurationStore);
View Full Code Here

        ModuleType config = ModuleDocument.Factory.parse(plan).getModule();

        Maven2Repository repository = new Maven2Repository(localRepo);
        GBeanBuilder gBeanBuilder = new GBeanBuilder(null, null);
        ServiceConfigBuilder builder = new ServiceConfigBuilder(null, Collections.singleton(repository), Collections.singleton(gBeanBuilder), new Jsr77Naming());
        ConfigurationStore targetConfigurationStore = new NullConfigurationStore() {
            public File createNewConfigurationDir(Artifact configId) throws ConfigurationAlreadyExistsException {
                return buildDir;
            }
        };

        ArtifactManager artifactManager = new DefaultArtifactManager();
        ArtifactResolver artifactResolver = new DefaultArtifactResolver(artifactManager, Collections.singleton(repository), null);
        DeploymentContext context = builder.buildConfiguration(
                false,
                builder.getConfigurationID(config, null, new ModuleIDBuilder()),
                config,
                null,
                Collections.singleton(targetConfigurationStore),
                artifactResolver,
                targetConfigurationStore);
View Full Code Here

            // create the service builder, repository and config store objects
            LocalConfigStore configStore = new LocalConfigStore(new File(storeDir));
            ReadOnlyRepository repository = new ReadOnlyRepository(new File(repositoryDir));

            //TODO should the defaultParentId be null??
            ServiceConfigBuilder builder = new ServiceConfigBuilder(null, repository);

            // create the manifext
            Manifest manifest = new Manifest();
            Attributes mainAttributes = manifest.getMainAttributes();
            mainAttributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            mainAttributes.putValue(Attributes.Name.MAIN_CLASS.toString(), "org.apache.geronimo.deployment.cli.DeployTool");
            mainAttributes.putValue(Attributes.Name.CLASS_PATH.toString(), deployerClassPath);
            mainAttributes.putValue(CommandLineManifest.MAIN_GBEAN.toString(), deployerGBean);
            mainAttributes.putValue(CommandLineManifest.MAIN_METHOD.toString(), "deploy");
            mainAttributes.putValue(CommandLineManifest.CONFIGURATIONS.toString(), j2eeDeployerConfig.getConfigId());
            mainAttributes.putValue(CommandLineManifest.ENDORSED_DIRS.toString(), deployerEndorsedDirs);

            // attribute that indicates to a JSR-88 tool that we have a Deployment factory
            mainAttributes.putValue("J2EE-DeploymentFactory-Implementation-Class", deploymentFactory);

            // write the deployer system out to a jar

            // create a temp directory to build into
            File configurationDir = null;
            try {
                configurationDir = configStore.createNewConfigurationDir();

                // build the deployer-system configuration into the configurationDir
                ConfigurationData configurationData = builder.buildConfiguration(deployerSystemConfig, null, configurationDir);

                ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, manifest, configurationDir, new File(deployerJar));

                // install the configuration
                configStore.install(configurationData, configurationDir);
            } catch (Throwable e) {
                DeploymentUtil.recursiveDelete(configurationDir);
                if (e instanceof Error) {
                    throw (Error) e;
                } else if (e instanceof Exception) {
                    throw (Exception) e;
                }
                throw new Error(e);
            }
           
            //get the domain and server from the parent xml config
            String domain = deployerSystemConfig.getDomain();
            String server = deployerSystemConfig.getServer();

            // build and install the j2ee-deployer configuration
            try {
                configurationDir = configStore.createNewConfigurationDir();

                // build the j2ee-deployer configuration into the configurationDir
                ConfigurationData configurationData = builder.buildConfiguration(j2eeDeployerConfig, domain, server, configurationDir);

                // install the configuration
                configStore.install(configurationData, configurationDir);
            } catch (Throwable e) {
                DeploymentUtil.recursiveDelete(configurationDir);
View Full Code Here

TOP

Related Classes of org.apache.geronimo.deployment.service.ServiceConfigBuilder

Copyright © 2018 www.massapicom. 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.