Package org.apache.geronimo.deployment.xbeans

Examples of org.apache.geronimo.deployment.xbeans.ConfigurationType


public class ConfigPlanTest extends TestCase {
    private URL plan1;

    public void testParser() throws Exception {
        ConfigurationDocument doc = ConfigurationDocument.Factory.parse(plan1);
        ConfigurationType configuration = doc.getConfiguration();
        assertEquals("test/plan1", configuration.getConfigId());

        DependencyType[] dependencies = configuration.getDependencyArray();
        assertEquals(1, dependencies.length);
        assertEquals("geronimo", dependencies[0].getGroupId());
        assertEquals("geronimo-kernel", dependencies[0].getArtifactId());
        assertEquals("DEV", dependencies[0].getVersion());

        GbeanType[] gbeans = configuration.getGbeanArray();
        assertEquals(1, gbeans.length);
        assertEquals("geronimo.test:name=MyMockGMBean", gbeans[0].getName());
        AttributeType[] attrs = gbeans[0].getAttributeArray();
        assertEquals(2, attrs.length);
        assertEquals("Value", attrs[0].getName());
View Full Code Here


        Thread.currentThread().setContextClassLoader(Bootstrap.class.getClassLoader());
        try {
            // parse the deployment-system and j2ee-deployer plans
            XmlObject deployerSystemXML = XmlBeans.getContextTypeLoader().parse(new File(deployerSystemPlan), null, null);
            XmlObject j2eeDeployerXML = XmlBeans.getContextTypeLoader().parse(new File(j2eeDeployerPlan), null, null);
            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);
View Full Code Here

        Thread.currentThread().setContextClassLoader(Bootstrap.class.getClassLoader());
        try {
            // parse the deployment-system and j2ee-deployer plans
            XmlObject deployerSystemXML = XmlBeans.getContextTypeLoader().parse(new File(deployerSystemPlan), null, null);
            XmlObject j2eeDeployerXML = XmlBeans.getContextTypeLoader().parse(new File(j2eeDeployerPlan), null, null);
            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
View Full Code Here

        }

    }

    public void buildConfiguration(JarOutputStream os, XmlObject plan) throws DeploymentException, IOException {
        ConfigurationType configType = ((ConfigurationDocument) plan).getConfiguration();
        URI configID;
        try {
            configID = new URI(configType.getConfigId());
        } catch (URISyntaxException e) {
            throw new DeploymentException("Invalid configId " + configType.getConfigId(), e);
        }
        URI parentID;
        if (configType.isSetParentId()) {
            try {
                parentID = new URI(configType.getParentId());
            } catch (URISyntaxException e) {
                throw new DeploymentException("Invalid parentId " + configType.getParentId(), e);
            }
        } else {
            parentID = null;
        }

        DeploymentContext context = null;
        try {
            context = new DeploymentContext(os, configID, ConfigurationModuleType.SERVICE, parentID, kernel);
        } catch (MalformedObjectNameException e) {
            throw new DeploymentException(e);
        }
        addIncludes(context, configType);
        addDependencies(context, configType.getDependencyArray());
        ClassLoader cl = context.getClassLoader(repository);
        GbeanType[] gbeans = configType.getGbeanArray();
        for (int i = 0; i < gbeans.length; i++) {
            GBeanHelper.addGbean(new ServiceGBeanAdapter(gbeans[i]), cl, context);

        }
        context.close();
View Full Code Here

    public void setCarFile(File carFile) {
        this.carFile = carFile;
    }

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

public class ConfigPlanTest extends TestCase {
    private URL plan1;

    public void testParser() throws Exception {
        ConfigurationDocument doc = ConfigurationDocument.Factory.parse(plan1);
        ConfigurationType configuration = doc.getConfiguration();
        assertEquals("test/plan1", configuration.getConfigId());

        DependencyType[] dependencies = configuration.getDependencyArray();
        assertEquals(4, dependencies.length);
        assertEquals("geronimo", dependencies[0].getGroupId());
        assertEquals("foo1", dependencies[0].getArtifactId());
        assertEquals("DEV", dependencies[0].getVersion());

        GbeanType[] gbeans = configuration.getGbeanArray();
        assertEquals(1, gbeans.length);
        assertEquals("geronimo.test:name=MyMockGMBean", gbeans[0].getGbeanName());
        AttributeType[] attrs = gbeans[0].getAttributeArray();
        assertEquals(2, attrs.length);
        assertEquals("value", attrs[0].getName());
View Full Code Here

        referenceCollection.add(javaBeanXmlAttributeBuilder);
        new ServiceConfigBuilder(parentIdArray, null, referenceCollection, null, null);
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        final URL plan1 = cl.getResource("services/plan1.xml");
        ConfigurationDocument doc = ConfigurationDocument.Factory.parse(plan1);
        ConfigurationType plan = doc.getConfiguration();
        File outFile = File.createTempFile("foo", "bar");
        outFile.delete();
        if (!outFile.mkdirs()) {
            fail("could not create temp dir");
        }
        try {
            DeploymentContext context = new DeploymentContext(outFile, URI.create("foo/bar"), ConfigurationModuleType.SERVICE, parentId, "domain", "server", null);
            J2eeContext j2eeContext = new J2eeContextImpl("domain", "server", "null", "test", "configtest", "foo", NameFactory.J2EE_MODULE);
            ServiceConfigBuilder.addDependencies(context, plan.getDependencyArray(), new Repository() {

                public boolean hasURI(URI uri) {
                    return true;
                }

                public URL getURL(URI uri) throws MalformedURLException {
                    return plan1;
                }
            });
            GbeanType[] gbeans = plan.getGbeanArray();
            ServiceConfigBuilder.addGBeans(gbeans, cl, j2eeContext, context);
            Set beanDatas = context.listGBeans(new ObjectName("*:*"));
            assertEquals(1, beanDatas.size());
            ObjectName beanName = (ObjectName) beanDatas.iterator().next();
            GBeanData data = context.getGBeanInstance(beanName);
View Full Code Here

            throw new DeploymentException("no plan at " + planFile, e);
        }
    }

    public URI getConfigurationID(Object plan, JarFile module) throws IOException, DeploymentException {
        ConfigurationType configType = (ConfigurationType) plan;
        try {
            return new URI(configType.getConfigId());
        } catch (URISyntaxException e) {
            throw new DeploymentException("Invalid configId " + configType.getConfigId(), e);
        }
    }
View Full Code Here

            throw new DeploymentException("Invalid configId " + configType.getConfigId(), e);
        }
    }

    public ConfigurationData buildConfiguration(Object plan, JarFile unused, File outfile) throws IOException, DeploymentException {
        ConfigurationType configType = (ConfigurationType) plan;
        String domain = null;
        String server = null;

        return buildConfiguration(configType, domain, server, outfile);
    }
View Full Code Here

    }

    private XmlObject actionGeneratePlan(PortletRequest request, RealmData data) {
        normalize(data);
        ConfigurationDocument doc = ConfigurationDocument.Factory.newInstance();
        ConfigurationType root = doc.addNewConfiguration();
        root.setConfigId("SecurityRealm-"+data.getName());
        // Use a parentId of null to pick up the default
        // Dependencies
        if(data.getJar() != null) {
            DependencyType jar = root.addNewDependency();
            jar.setUri(data.getJar());
        }
        // Build the realm GBean
        GbeanType realm = root.addNewGbean();
        realm.setName(data.getName());
        realm.setClass1("org.apache.geronimo.security.realm.GenericSecurityRealm");
        AttributeType realmName = realm.addNewAttribute();
        realmName.setName("realmName");
        realmName.setStringValue(data.getName());
        ReferenceType serverInfo = realm.addNewReference();
        serverInfo.setName2("ServerInfo");
        serverInfo.setGbeanName(PortletManager.getCurrentServer(request).getServerInfo());
        ReferenceType loginService = realm.addNewReference();
        loginService.setName2("LoginService");
        loginService.setGbeanName(PortletManager.getCurrentServer(request).getLoginService());
        XmlAttributeType config = realm.addNewXmlReference();
        // Construct the content to put in the XmlAttributeType
        GerLoginConfigDocument lcDoc = GerLoginConfigDocument.Factory.newInstance();
        GerLoginConfigType login = lcDoc.addNewLoginConfig();
        for (int i = 0; i < data.getModules().length; i++) {
            LoginModuleDetails details = data.getModules()[i];
            if(details.getLoginDomainName() == null || details.getLoginDomainName().equals("")) {
                continue;
            }
            GerLoginModuleType module = login.addNewLoginModule();
            module.setControlFlag(details.getControlFlag().equals("OPTIONAL") ? GerControlFlagType.OPTIONAL :
                    details.getControlFlag().equals("REQUIRED") ? GerControlFlagType.REQUIRED :
                    details.getControlFlag().equals("REQUISITE") ? GerControlFlagType.REQUISITE :
                    details.getControlFlag().equals("SUFFICIENT") ? GerControlFlagType.SUFFICIENT :
                    GerControlFlagType.OPTIONAL);
            module.setServerSide(details.isServerSide());
            module.setLoginDomainName(details.getLoginDomainName());
            module.setLoginModuleClass(details.getClassName());
            module.setWrapPrincipals(details.isWrapPrincipals());
            for (Iterator it = details.getOptions().entrySet().iterator(); it.hasNext();) {
                Map.Entry entry = (Map.Entry) it.next();
                GerOptionType option = module.addNewOption();
                option.setName((String) entry.getKey());
                option.setStringValue((String) entry.getValue());
            }

            // bit of a hack -- to put the DataSource module in as a parent for SQL modules
            if(details.getClassName().indexOf("SQL") > -1) {
                String poolName = (String) details.getOptions().get("dataSourceName");
                String appName = (String) details.getOptions().get("dataSourceApplication");
                if(poolName != null) {
                    if(appName == null) appName = "null";
                    JCAManagedConnectionFactory[] factories = PortletManager.getOutboundFactoriesOfType(request, "javax.sql.DataSource");
                    for (int j = 0; j < factories.length; j++) {
                        JCAManagedConnectionFactory factory = factories[j];
                        try {
                            ObjectName objectName = ObjectName.getInstance(factory.getObjectName());
                            final String testName = objectName.getKeyProperty(NameFactory.J2EE_NAME);
                            final String testApp = objectName.getKeyProperty(NameFactory.J2EE_APPLICATION);
                            if(testName.equals(poolName) && testApp.equals(appName)) {
                                String moduleName = objectName.getKeyProperty(NameFactory.JCA_RESOURCE);
                                DependencyType imp = root.addNewImport();
                                imp.setUri(moduleName);
                                break;
                            }
                        } catch (MalformedObjectNameException e) {
                            log.error("Unable to parse ObjectName", e);
View Full Code Here

TOP

Related Classes of org.apache.geronimo.deployment.xbeans.ConfigurationType

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.