Examples of ModuleType


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

        }
        return environment.getConfigId();
    }

    public DeploymentContext buildConfiguration(boolean inPlaceDeployment, Artifact configId, Object plan, JarFile jar, Collection<ConfigurationStore> configurationStores, ArtifactResolver artifactResolver, ConfigurationStore targetConfigurationStore) throws IOException, DeploymentException {
        ModuleType configType = (ModuleType) plan;

        return buildConfiguration(inPlaceDeployment, configId, configType, jar, configurationStores, artifactResolver, targetConfigurationStore);
    }
View Full Code Here

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

    }
   
    private XmlObject actionGeneratePlan(PortletRequest request, RealmData data) {
        normalize(data);
        ModuleDocument doc = ModuleDocument.Factory.newInstance();
        ModuleType root = doc.addNewModule();
        EnvironmentType environment = root.addNewEnvironment();
        ArtifactType configId = environment.addNewModuleId();
        configId.setGroupId("console.realm");
        String artifactId = getArtifactId(data.getName());
       
        configId.setArtifactId(artifactId);
        configId.setVersion("1.0");
        configId.setType("car");

        // Parent

        DependenciesType dependenciesType = environment.addNewDependencies();
        ArtifactType parent = dependenciesType.addNewDependency();
        parent.setGroupId("org.apache.geronimo.framework");
        parent.setArtifactId("j2ee-security");
        parent.setType("car");
        // Dependencies
        if (data.getJar() != null) {
            ArtifactType artifactType = dependenciesType.addNewDependency();
            Artifact artifact = Artifact.create(data.getJar());
            artifactType.setGroupId(artifact.getGroupId());
            artifactType.setArtifactId(artifact.getArtifactId());
            artifactType.setVersion(artifact.getVersion().toString());
            artifactType.setType(artifact.getType());
        }
        // Build the realm GBean
        GbeanType realm = GbeanType.Factory.newInstance();
        realm.setName(data.getName());
        realm.setClass1("org.apache.geronimo.security.realm.GenericSecurityRealm");
        AttributeType realmName = realm.addNewAttribute();
        realmName.setName("realmName");
        realmName.setStringValue(data.getName());
        AttributeType global = realm.addNewAttribute();
        global.setName("global");
        global.setStringValue(data.getGlobal());
        ReferenceType serverInfo = realm.addNewReference();
        serverInfo.setName2("ServerInfo");
        serverInfo.setName((String) PortletManager.getNameFor(request, PortletManager.getCurrentServer(request).getServerInfo()).getName().get("name"));
        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(LoginModuleControlFlag.OPTIONAL) ? GerControlFlagType.OPTIONAL :
                    details.getControlFlag().equals(LoginModuleControlFlag.REQUIRED) ? GerControlFlagType.REQUIRED :
                            details.getControlFlag().equals(LoginModuleControlFlag.REQUISITE) ? GerControlFlagType.REQUISITE :
                                    details.getControlFlag().equals(LoginModuleControlFlag.SUFFICIENT) ? GerControlFlagType.SUFFICIENT :
                                            GerControlFlagType.OPTIONAL);
            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);

                                ArtifactType artifactType = dependenciesType.addNewDependency();
                                Artifact artifact = Artifact.create(moduleName);
                                artifactType.setGroupId(artifact.getGroupId());
                                artifactType.setArtifactId(artifact.getArtifactId());
                                artifactType.setVersion(artifact.getVersion().toString());
                                artifactType.setType(artifact.getType());
                                break;
                            }
                        } catch (MalformedObjectNameException e) {
                            log.error("Unable to parse ObjectName", e);
                        }
                    }
                }
            }
        }
        // Copy the content into the XmlAttributeType
        XmlCursor loginCursor = lcDoc.newCursor();
        loginCursor.toFirstContentToken();
        XmlCursor destination = config.newCursor();
        destination.toNextToken();
        loginCursor.moveXml(destination);
        loginCursor.dispose();
        destination.dispose();
        config.setName("LoginModuleConfiguration");
        root.setServiceArray(new AbstractServiceType[]{realm});


        //Above code inserts gbean using xsi:type=dep:GBeanType.  We also need to account for the substitution group
        //by changing the qname:
        XmlCursor gbeanCursor = root.newCursor();
        try {
            if (!gbeanCursor.toChild(ServiceDocument.type.getDocumentElementName())) {
                throw new RuntimeException("Could not find service element");
            }
            gbeanCursor.setName(GBEAN_QNAME);
View Full Code Here

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

        NamespaceDrivenBuilder gbeanBuilder = new GBeanBuilder(referenceCollection, null);
//        ConfigurationBuilder serviceBuilder = new ServiceConfigBuilder(parentEnvironment, null, Collections.singleton(gbeanBuilder), naming);
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        final URL plan1 = cl.getResource("services/plan1.xml");
        ModuleDocument doc = ModuleDocument.Factory.parse(plan1);
        ModuleType plan = doc.getModule();
        File outFile = File.createTempFile("foo", "bar");
        outFile.delete();
        if (!outFile.mkdirs()) {
            fail("could not create temp dir");
        }
        try {

            Environment environment = EnvironmentBuilder.buildEnvironment(plan.getEnvironment());
            Map<Artifact, File> repo = new HashMap<Artifact, File>();
            File file = new File(plan1.getFile());
            locations.put(file.getAbsolutePath(), environment.getConfigId());
            repo.put(Artifact.create("geronimo/foo1/DEV/jar"), file);
            repo.put(Artifact.create("geronimo/foo2/DEV/jar"), file);
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.ModuleType

    }
    public static ModuleType loadModule(Reader in) throws ParserConfigurationException, IOException, SAXException, JAXBException, XMLStreamException {
        Unmarshaller unmarshaller = MODULE_CONTEXT.createUnmarshaller();
        XMLStreamReader xmlStream = XMLINPUT_FACTORY.createXMLStreamReader(in);
        JAXBElement<ModuleType> element = unmarshaller.unmarshal(xmlStream, ModuleType.class);
        ModuleType pluginList = element.getValue();
        return pluginList;
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.ModuleType

    public void testCommentXml() throws Exception {
        String comment = "This comment should get properly parsed";

        Reader in = new StringReader(REFERENCE_COMMENT_XML);
        ModuleType module = AttributesXmlUtil.loadModule(in);
        ConfigurationOverride commentConfig = new ConfigurationOverride(module, expressionParser);

        assertNotNull(commentConfig);
        assertEquals(commentConfig.getComment(), comment);
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.ModuleType

    public void testCommentXml() throws Exception {
        String comment = "This comment should get properly parsed";

        Reader in = new StringReader(REFERENCE_COMMENT_XML);
        ModuleType module = AttributesXmlUtil.loadModule(in);
        ConfigurationOverride commentConfig = new ConfigurationOverride(module, expressionParser);

        assertNotNull(commentConfig);
        assertEquals(commentConfig.getComment(), comment);
    }
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.ModuleType

    static void write(ServerOverride serverOverride, Writer writer) throws XMLStreamException, JAXBException, IOException {
        AttributesType attributes = serverOverride.writeXml();
       
        // we don't need to write wab configuration to config.xml
        for (Iterator<ModuleType> it = attributes.getModule().iterator(); it.hasNext();) {
            ModuleType module = it.next();
            if (module.getName().endsWith("wab")) {
                it.remove();
            }
        }
       
        AttributesXmlUtil.writeAttributes(attributes, writer);
View Full Code Here

Examples of org.apache.geronimo.system.plugin.model.ModuleType

    }
    public static ModuleType loadModule(Reader in) throws ParserConfigurationException, IOException, SAXException, JAXBException, XMLStreamException {
        Unmarshaller unmarshaller = MODULE_CONTEXT.createUnmarshaller();
        XMLStreamReader xmlStream = XMLINPUT_FACTORY.createXMLStreamReader(in);
        JAXBElement<ModuleType> element = unmarshaller.unmarshal(xmlStream, ModuleType.class);
        ModuleType pluginList = element.getValue();
        return pluginList;
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.j2ee.ModuleType

            if (earFile != null) {
                ModuleType[] moduleTypes = application.getModuleArray();
                //paths is used to check that all modules in the geronimo plan are in the application.xml.
                Set paths = new HashSet();
                for (int i = 0; i < moduleTypes.length; i++) {
                    ModuleType type = moduleTypes[i];
                    if (type.isSetEjb()) {
                        paths.add(type.getEjb().getStringValue());
                    } else if (type.isSetWeb()) {
                        paths.add(type.getWeb().getWebUri().getStringValue());
                    } else if (type.isSetConnector()) {
                        paths.add(type.getConnector().getStringValue());
                    } else if (type.isSetJava()) {
                        paths.add(type.getJava().getStringValue());
                    }
                }

                // build map from module path to alt vendor dd
                GerModuleType gerModuleTypes[] = gerApplication.getModuleArray();
                for (int i = 0; i < gerModuleTypes.length; i++) {
                    GerModuleType gerModule = gerModuleTypes[i];
                    String path = null;
                    if (gerModule.isSetEjb()) {
                        path = gerModule.getEjb().getStringValue();
                    } else if (gerModule.isSetWeb()) {
                        path = gerModule.getWeb().getStringValue();
                    } else if (gerModule.isSetConnector()) {
                        path = gerModule.getConnector().getStringValue();
                    } else if (gerModule.isSetJava()) {
                        path = gerModule.getJava().getStringValue();
                    }
                    if (!paths.contains(path)) {
                        throw new DeploymentException("Geronimo deployment plan refers to module '" + path + "' but that was not defined in the META-INF/application.xml");
                    }

                    if (gerModule.isSetAltDd()) {
                        // the the url of the alt dd
                        try {
                            altVendorDDs.put(path, DeploymentUtil.toTempFile(earFile, gerModule.getAltDd().getStringValue()));
                        } catch (IOException e) {
                            throw new DeploymentException("Invalid alt vendor dd url: " + gerModule.getAltDd().getStringValue(), e);
                        }
                    } else {
                        //dd is included explicitly
                        XmlObject[] anys = gerModule.selectChildren(GerModuleType.type.qnameSetForWildcardElements());
                        if (anys.length != 1) {
                            throw new DeploymentException("Unexpected count of xs:any elements in embedded vendor plan " + anys.length + " qnameset: " + GerModuleType.type.qnameSetForWildcardElements());
                        }
                        altVendorDDs.put(path, anys[0]);
                    }
                }

                // get a set containing all of the files in the ear that are actually modules
                for (int i = 0; i < moduleTypes.length; i++) {
                    ModuleType moduleXml = moduleTypes[i];

                    String modulePath;
                    ModuleBuilder builder;

                    Object moduleContextInfo = null;
                    String moduleTypeName;
                    if (moduleXml.isSetEjb()) {
                        modulePath = moduleXml.getEjb().getStringValue();
                        builder = getEjbConfigBuilder();
                        if (builder == null) {
                            throw new DeploymentException("Cannot deploy ejb application; No ejb deployer defined: " + modulePath);
                        }
                        moduleTypeName = "an EJB";
                    } else if (moduleXml.isSetWeb()) {
                        modulePath = moduleXml.getWeb().getWebUri().getStringValue();
                        if (getWebConfigBuilder() == null) {
                            throw new DeploymentException("Cannot deploy web application; No war deployer defined: " + modulePath);
                        }
                        builder = getWebConfigBuilder();
                        moduleTypeName = "a war";
                        moduleContextInfo = moduleXml.getWeb().getContextRoot().getStringValue().trim();
                    } else if (moduleXml.isSetConnector()) {
                        modulePath = moduleXml.getConnector().getStringValue();
                        if (getConnectorConfigBuilder() == null) {
                            throw new DeploymentException("Cannot deploy resource adapter; No rar deployer defined: " + modulePath);
                        }
                        builder = getConnectorConfigBuilder();
                        moduleTypeName = "a connector";
                    } else if (moduleXml.isSetJava()) {
                        modulePath = moduleXml.getJava().getStringValue();
                        if (getAppClientConfigBuilder() == null) {
                            throw new DeploymentException("Cannot deploy app client; No app client deployer defined: " + modulePath);
                        }
                        builder = getAppClientConfigBuilder();
                        moduleTypeName = "an application client";
                    } else {
                        throw new DeploymentException("Could not find a module builder for module: " + moduleXml);
                    }

                    moduleLocations.add(modulePath);

                    URL altSpecDD = null;
                    if (moduleXml.isSetAltDd()) {
                        try {
                            altSpecDD = DeploymentUtil.createJarURL(earFile, moduleXml.getAltDd().getStringValue());
                        } catch (MalformedURLException e) {
                            throw new DeploymentException("Invalid alt sped dd url: " + moduleXml.getAltDd().getStringValue(), e);
                        }
                    }

                    NestedJarFile moduleFile;
                    try {
View Full Code Here

Examples of org.apache.geronimo.xbeans.j2ee.ModuleType

        try {
            if (earFile != null) {
                ModuleType[] moduleTypes = application.getModuleArray();
                Set paths = new HashSet();
                for (int i = 0; i < moduleTypes.length; i++) {
                    ModuleType type = moduleTypes[i];
                    if (type.isSetEjb()) {
                        paths.add(type.getEjb().getStringValue());
                    } else if (type.isSetWeb()) {
                        paths.add(type.getWeb().getWebUri().getStringValue());
                    } else if (type.isSetConnector()) {
                        paths.add(type.getConnector().getStringValue());
                    } else if (type.isSetJava()) {
                        paths.add(type.getJava().getStringValue());
                    }
                }

                // build map from module path to alt vendor dd
                GerModuleType gerModuleTypes[] = gerApplication.getModuleArray();
                for (int i = 0; i < gerModuleTypes.length; i++) {
                    GerModuleType gerModule = gerModuleTypes[i];
                    String path = null;
                    if (gerModule.isSetEjb()) {
                        path = gerModule.getEjb().getStringValue();
                    } else if (gerModule.isSetWeb()) {
                        path = gerModule.getWeb().getStringValue();
                    } else if (gerModule.isSetConnector()) {
                        path = gerModule.getConnector().getStringValue();
                    } else if (gerModule.isSetJava()) {
                        path = gerModule.getJava().getStringValue();
                    }
                    if (!paths.contains(path)) {
                        throw new DeploymentException("Geronimo deployment plan refers to module '" + path + "' but that was not defined in the META-INF/application.xml");
                    }

                    if (gerModule.isSetAltDd()) {
                        // the the url of the alt dd
                        try {
                            altVendorDDs.put(path, DeploymentUtil.toTempFile(earFile, gerModule.getAltDd().getStringValue()));
                        } catch (IOException e) {
                            throw new DeploymentException("Invalid alt vendor dd url: " + gerModule.getAltDd().getStringValue(), e);
                        }
                    } else {
                        //dd is included explicitly
                        XmlObject[] anys = gerModule.selectChildren(GerModuleType.type.qnameSetForWildcardElements());
                        if (anys.length != 1) {
                            throw new DeploymentException("Unexpected count of xs:any elements in embedded vendor plan " + anys.length + " qnameset: " + GerModuleType.type.qnameSetForWildcardElements());
                        }
                        altVendorDDs.put(path, anys[0]);
                    }
                }


                // get a set containing all of the files in the ear that are actually modules
                for (int i = 0; i < moduleTypes.length; i++) {
                    ModuleType moduleXml = moduleTypes[i];

                    String modulePath;
                    ModuleBuilder builder;

                    Object moduleContextInfo = null;
                    String moduleTypeName;
                    if (moduleXml.isSetEjb()) {
                        modulePath = moduleXml.getEjb().getStringValue();
                        if (ejbConfigBuilder == null) {
                            throw new DeploymentException("Cannot deploy ejb application; No ejb deployer defined: " + modulePath);
                        }
                        builder = ejbConfigBuilder;
                        moduleTypeName = "an EJB";
                    } else if (moduleXml.isSetWeb()) {
                        modulePath = moduleXml.getWeb().getWebUri().getStringValue();
                        if (webConfigBuilder == null) {
                            throw new DeploymentException("Cannot deploy web application; No war deployer defined: " + modulePath);
                        }
                        builder = webConfigBuilder;
                        moduleTypeName = "a war";
                        moduleContextInfo = moduleXml.getWeb().getContextRoot().getStringValue().trim();
                    } else if (moduleXml.isSetConnector()) {
                        modulePath = moduleXml.getConnector().getStringValue();
                        if (connectorConfigBuilder == null) {
                            throw new DeploymentException("Cannot deploy resource adapter; No rar deployer defined: " + modulePath);
                        }
                        builder = connectorConfigBuilder;
                        moduleTypeName = "a connector";
                    } else if (moduleXml.isSetJava()) {
                        modulePath = moduleXml.getJava().getStringValue();
                        if (appClientConfigBuilder == null) {
                            throw new DeploymentException("Cannot deploy app client; No app client deployer defined: " + modulePath);
                        }
                        builder = appClientConfigBuilder;
                        moduleTypeName = "an application client";
                    } else {
                        throw new DeploymentException("Could not find a module builder for module: " + moduleXml);
                    }

                    moduleLocations.add(modulePath);

                    URL altSpecDD = null;
                    if (moduleXml.isSetAltDd()) {
                        try {
                            altSpecDD = DeploymentUtil.createJarURL(earFile, moduleXml.getAltDd().getStringValue());
                        } catch (MalformedURLException e) {
                            throw new DeploymentException("Invalid alt sped dd url: " + moduleXml.getAltDd().getStringValue(), e);
                        }
                    }

                    NestedJarFile moduleFile = null;
                    try {
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.