Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.XmlCursor


        Collection errors = new ArrayList();
        xmlOptions.setErrorListener(errors);
        if (!loginConfig.validate(xmlOptions)) {
            throw new DeploymentException("Invalid login configuration:\n" + errors + "\nDescriptor: " + loginConfig.toString());
        }
        XmlCursor xmlCursor = loginConfig.newCursor();
        ObjectName nextName = null;
        try {
            boolean atStart = true;
            while ((atStart && xmlCursor.toFirstChild()) || (!atStart && xmlCursor.toNextSibling())) {
                atStart = false;
                XmlObject child = xmlCursor.getObject();
                GerAbstractLoginModuleType abstractLoginModule = (GerAbstractLoginModuleType) child;
                String controlFlag = abstractLoginModule.getControlFlag().toString();
                ObjectName loginModuleName;
                String name;
                if (abstractLoginModule instanceof GerLoginModuleRefType) {
                    GerLoginModuleRefType loginModuleRef = (GerLoginModuleRefType) abstractLoginModule;
                    String domain = trim(loginModuleRef.getDomain());
                    String server = trim(loginModuleRef.getServer());
                    String application = trim(loginModuleRef.getApplication());
                    String module = trim(loginModuleRef.getModule());
                    String type = trim(loginModuleRef.getType());
                    if (type == null) {
                        type = NameFactory.LOGIN_MODULE;
                    }
                    name = trim(loginModuleRef.getName());
                    try {
                        loginModuleName = NameFactory.getComponentName(domain, server, application, module, name, type, j2eeContext);
                    } catch (MalformedObjectNameException e) {
                        throw new DeploymentException("cannot construct login module name from parts,", e);
                    }
                } else if (abstractLoginModule instanceof GerLoginModuleType) {
                    //create the LoginModuleGBean also
                    name = null;
                    loginModuleName = null;

                    GerLoginModuleType loginModule = (GerLoginModuleType) abstractLoginModule;
                    name = trim(loginModule.getLoginDomainName());
                    String className = trim(loginModule.getLoginModuleClass());
                    boolean serverSide = loginModule.getServerSide();
                    Properties options = new Properties();
                    GerOptionType[] optionArray = loginModule.getOptionArray();
                    for (int j = 0; j < optionArray.length; j++) {
                        GerOptionType gerOptionType = optionArray[j];
                        String key = gerOptionType.getName();
                        String value = trim(gerOptionType.getStringValue());
                        options.setProperty(key, value);
                    }
                    try {
                        loginModuleName = NameFactory.getComponentName(null, null, null, null, name, NameFactory.LOGIN_MODULE, j2eeContext);
                    } catch (MalformedObjectNameException e) {
                        throw new DeploymentException("cannot construct login module use name from parts,", e);
                    }
                    GBeanData loginModuleGBeanData = new GBeanData(loginModuleName, LoginModuleGBean.GBEAN_INFO);
                    loginModuleGBeanData.setAttribute("loginDomainName", name);
                    loginModuleGBeanData.setAttribute("loginModuleClass", className);
                    loginModuleGBeanData.setAttribute("options", options);
                    loginModuleGBeanData.setAttribute("serverSide", new Boolean(serverSide));

                    context.addGBean(loginModuleGBeanData);
                } else {
                    throw new DeploymentException("Unknown abstract login module type: " + abstractLoginModule.getClass());
                }
                ObjectName thisName;
                try {
                    thisName = NameFactory.getComponentName(null, null, null, null, name, "LoginModuleUse", j2eeContext);
                } catch (MalformedObjectNameException e) {
                    throw new DeploymentException("cannot construct login module use name from parts,", e);
                }
                GBeanData loginModuleUseGBeanData = new GBeanData(thisName, JaasLoginModuleUse.GBEAN_INFO);
                loginModuleUseGBeanData.setAttribute("controlFlag", controlFlag);
                loginModuleUseGBeanData.setReferencePattern("LoginModule", loginModuleName);
                if (nextName != null) {
                    loginModuleUseGBeanData.setReferencePattern("Next", nextName);
                }
                context.addGBean(loginModuleUseGBeanData);
                nextName = thisName;
            }
        } finally {
            xmlCursor.dispose();
        }
        return Collections.singleton(nextName);
    }
View Full Code Here


//        System.out.println(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application_1_4.xsd";
            String version = "1.4";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = SchemaConversionUtils.convertToApplicationClientSchema(xmlObject);
View Full Code Here

//        System.out.println(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/application_1_4.xsd";
            String version = "1.4";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = SchemaConversionUtils.convertToApplicationSchema(xmlObject);
View Full Code Here

//        System.out.println(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd";
            String version = "1.4";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = SchemaConversionUtils.convertToConnectorSchema(xmlObject);
View Full Code Here

//        System.out.println(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
            String version = "2.1";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = SchemaConversionUtils.convertToEJBSchema(xmlObject);
View Full Code Here

//        System.out.println(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
            String version = "2.1";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = SchemaConversionUtils.convertToEJBSchema(xmlObject);
View Full Code Here

        InputStream is = null;
        try {
            is = descriptor.openStream();
        try {
        XmlObject xmlObject = XmlBeansUtil.parse(is);
            XmlCursor c = xmlObject.newCursor();
            try {
                c.toStartDoc();
                c.toFirstChild();
                docBean = new DDBeanImpl(this, "/" + c.getName().getLocalPart(), c);
            } finally {
                c.dispose();
            }
        } finally {
            is.close();
        }
        } catch (Exception e) {
View Full Code Here

//        System.out.println(expected.toString());
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences: " + problems, ok);
        //make sure trying to convert twice has no bad effects
        XmlCursor cursor2 = xmlObject.newCursor();
        try {
            String schemaLocationURL = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";
            String version = "2.1";
            assertFalse(SchemaConversionUtils.convertToSchema(cursor2, SchemaConversionUtils.J2EE_NAMESPACE, schemaLocationURL, version));
        } finally {
            cursor2.dispose();
        }
        boolean ok2 = compareXmlObjects(xmlObject, expected, problems);
        assertTrue("Differences after reconverting to schema: " + problems, ok2);
        //do the whole transform twice...
        xmlObject = SchemaConversionUtils.convertToEJBSchema(xmlObject);
View Full Code Here

    public void testOrderDescriptionGroup() throws Exception {
        File srcXml = new File(basedir, "src/test-data/j2ee_1_3dtd/DescriptionGroupTestSource.xml");
        File expectedOutputXml = new File(basedir, "src/test-data/j2ee_1_3dtd/DescriptionGroupTestExpected.xml");
        XmlObject srcObject = XmlObject.Factory.parse(srcXml);
        XmlCursor srcCursor = srcObject.newCursor();
        XmlCursor moveable = srcObject.newCursor();
        try {
            srcCursor.toFirstChild();
            srcCursor.toFirstChild();
            assertTrue(srcCursor.getName().toString(), "filter".equals(srcCursor.getName().getLocalPart()));
            do {
View Full Code Here

    public void testOrderJNDIEnvironmentRefsGroup() throws Exception {
        File srcXml = new File(basedir, "src/test-data/j2ee_1_3dtd/JNDIEnvironmentRefsGroupTestSource.xml");
        File expectedOutputXml = new File(basedir, "src/test-data/j2ee_1_3dtd/JNDIEnvironmentRefsGroupTestExpected.xml");
        XmlObject srcObject = XmlObject.Factory.parse(srcXml);
        XmlCursor srcCursor = srcObject.newCursor();
        XmlCursor moveable = srcObject.newCursor();
        try {
            srcCursor.toFirstChild();
            srcCursor.toFirstChild();
            assertTrue(srcCursor.getName().toString(), "web-app".equals(srcCursor.getName().getLocalPart()));
            do {
                srcCursor.push();
                srcCursor.toFirstChild();
                srcCursor.toNextSibling();
                srcCursor.toNextSibling();
                moveable.toCursor(srcCursor);
                SchemaConversionUtils.convertToJNDIEnvironmentRefsGroup(srcCursor, moveable);
                srcCursor.pop();
            } while (srcCursor.toNextSibling());
        } finally {
            srcCursor.dispose();
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.XmlCursor

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.