Examples of WebAppType


Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        EARContext moduleContext = module.getEarContext();
        ClassLoader webClassLoader = moduleContext.getClassLoader();
        AbstractName moduleName = moduleContext.getModuleName();
        WebModule webModule = (WebModule) module;

        WebAppType webApp = (WebAppType) webModule.getSpecDD();

        TomcatWebAppType tomcatWebApp = (TomcatWebAppType) webModule.getVendorDD();

        GBeanData webModuleData = new GBeanData(moduleName, TomcatWebAppContext.GBEAN_INFO);
        configureBasicWebModuleAttributes(webApp, tomcatWebApp, moduleContext, earContext, webModule, webModuleData);
        try {
            moduleContext.addGBean(webModuleData);
            Set<String> securityRoles = collectRoleNames(webApp);
            Map<String, PermissionCollection> rolePermissions = new HashMap<String, PermissionCollection>();
            webModuleData.setAttribute("contextPath", webModule.getContextRoot());
            // unsharableResources, applicationManagedSecurityResources
            GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
            //N.B. use earContext not moduleContext
            resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRefArray(), tomcatWebApp.getResourceRefArray());

            if (tomcatWebApp.isSetWebContainer()) {
                AbstractNameQuery webContainerName = ENCConfigBuilder.getGBeanQuery(NameFactory.GERONIMO_SERVICE, tomcatWebApp.getWebContainer());
                webModuleData.setReferencePattern("Container", webContainerName);
            } else {
                webModuleData.setReferencePattern("Container", tomcatContainerName);
            }
            // Process the Tomcat container-config elements
            if (tomcatWebApp.isSetHost()) {
                String virtualServer = tomcatWebApp.getHost().trim();
                webModuleData.setAttribute("virtualServer", virtualServer);
            }
            if (tomcatWebApp.isSetCrossContext()) {
                webModuleData.setAttribute("crossContext", Boolean.TRUE);
            }
            if (tomcatWebApp.isSetWorkDir()) {
                String workDir = tomcatWebApp.getWorkDir();
                webModuleData.setAttribute("workDir", workDir);
            }
            if (tomcatWebApp.isSetDisableCookies()) {
                webModuleData.setAttribute("disableCookies", Boolean.TRUE);
            }
            if (tomcatWebApp.isSetTomcatRealm()) {
                String tomcatRealm = tomcatWebApp.getTomcatRealm().trim();
                AbstractName realmName = earContext.getNaming().createChildName(moduleName, tomcatRealm, RealmGBean.GBEAN_INFO.getJ2eeType());
                webModuleData.setReferencePattern("TomcatRealm", realmName);
            }
            if (tomcatWebApp.isSetValveChain()) {
                String valveChain = tomcatWebApp.getValveChain().trim();
                AbstractName valveName = earContext.getNaming().createChildName(moduleName, valveChain, ValveGBean.J2EE_TYPE);
                webModuleData.setReferencePattern("TomcatValveChain", valveName);
            }
           
            if (tomcatWebApp.isSetListenerChain()) {
                String listenerChain = tomcatWebApp.getListenerChain().trim();
                AbstractName listenerName = earContext.getNaming().createChildName(moduleName, listenerChain, LifecycleListenerGBean.J2EE_TYPE);
                webModuleData.setReferencePattern("LifecycleListenerChain", listenerName);
            }

            if (tomcatWebApp.isSetCluster()) {
                String cluster = tomcatWebApp.getCluster().trim();
                AbstractName clusterName = earContext.getNaming().createChildName(moduleName, cluster, CatalinaClusterGBean.J2EE_TYPE);
                webModuleData.setReferencePattern("Cluster", clusterName);
            }

            if (tomcatWebApp.isSetManager()) {
                String manager = tomcatWebApp.getManager().trim();
                AbstractName managerName = earContext.getNaming().createChildName(moduleName, manager, ManagerGBean.J2EE_TYPE);
                webModuleData.setReferencePattern("Manager", managerName);
            }
           
            Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
            if (TRUE == distributable) {
                clusteringBuilders.build(tomcatWebApp, earContext, moduleContext);
                if (null == webModuleData.getReferencePatterns(TomcatWebAppContext.GBEAN_REF_CLUSTERED_VALVE_RETRIEVER)) {
                    log.warn("No clustering builders configured: app will not be clustered");
                }
            }

            //Handle the role permissions and webservices on the servlets.
            ServletType[] servletTypes = webApp.getServletArray();
            Map<String, AbstractName> webServices = new HashMap<String, AbstractName>();
            Class baseServletClass;
            try {
                baseServletClass = webClassLoader.loadClass(Servlet.class.getName());
            } catch (ClassNotFoundException e) {
                throw new DeploymentException("Could not load javax.servlet.Servlet in web classloader", e); // TODO identify web app in message
            }
            for (ServletType servletType : servletTypes) {
                //Handle the Role Ref Permissions
                processRoleRefPermissions(servletType, securityRoles, rolePermissions);

                if (servletType.isSetServletClass()) {
                    String servletName = servletType.getServletName().getStringValue().trim();
                    String servletClassName = servletType.getServletClass().getStringValue().trim();
                    Class servletClass;
                    try {
                        servletClass = webClassLoader.loadClass(servletClassName);
                    } catch (ClassNotFoundException e) {
                        throw new DeploymentException("Could not load servlet class " + servletClassName, e); // TODO identify web app in message
                    }
                    if (!baseServletClass.isAssignableFrom(servletClass)) {
                        //fake servletData
                        AbstractName servletAbstractName = moduleContext.getNaming().createChildName(moduleName, servletName, NameFactory.SERVLET);
                        GBeanData servletData = new GBeanData();
                        servletData.setAbstractName(servletAbstractName);
                        //let the web service builder deal with configuring the gbean with the web service stack
                        //Here we just extract the factory reference
                        boolean configured = false;
                        for (WebServiceBuilder serviceBuilder : webServiceBuilder) {
                            if (serviceBuilder.configurePOJO(servletData, servletName, module, servletClassName, moduleContext)) {
                                configured = true;
                                break;
                            }
                        }
                        if (!configured) {
                            throw new DeploymentException("POJO web service: " + servletName + " not configured by any web service builder");
                        }
                        ReferencePatterns patterns = servletData.getReferencePatterns("WebServiceContainerFactory");
                        AbstractName wsContainerFactoryName = patterns.getAbstractName();
                        webServices.put(servletName, wsContainerFactoryName);
                        //force all the factories to start before the web app that needs them.
                        webModuleData.addDependency(wsContainerFactoryName);
                    }

                }
            }

            // JACC v1.0 secion B.19
            addUnmappedJSPPermissions(securityRoles, rolePermissions);

            webModuleData.setAttribute("webServices", webServices);

            if (tomcatWebApp.isSetSecurityRealmName()) {
                if (earContext.getSecurityConfiguration() == null) {
                    throw new DeploymentException("You have specified a <security-realm-name> for the webapp " + moduleName + " but no <security> configuration (role mapping) is supplied in the Geronimo plan for the web application (or the Geronimo plan for the EAR if the web app is in an EAR)");
                }

                SecurityHolder securityHolder = new SecurityHolder();
                securityHolder.setSecurityRealm(tomcatWebApp.getSecurityRealmName().trim());

                webModuleData.setReferencePattern("RunAsSource", earContext.getJaccManagerName());

                /**
                 * TODO - go back to commented version when possible.
                 */
                String policyContextID = moduleName.toString().replaceAll("[, :]", "_");
                securityHolder.setPolicyContextID(policyContextID);

                ComponentPermissions componentPermissions = buildSpecSecurityConfig(webApp, securityRoles, rolePermissions);
                earContext.addSecurityContext(policyContextID, componentPermissions);
                //TODO WTF is this for?
                securityHolder.setSecurity(true);

                webModuleData.setAttribute("securityHolder", securityHolder);
            }

            //listeners added directly to the StandardContext will get loaded by the tomcat classloader, not the app classloader!
            //TODO this may definitely not be the best place for this!
            for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
                mbe.addGBeans(earContext, module, cl, repository);
            }
            //not truly metadata complete until MBEs have run
            if (!webApp.getMetadataComplete()) {
                webApp.setMetadataComplete(true);
                module.setOriginalSpecDD(module.getSpecDD().toString());
                webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
            }
            /**
             * This next bit of code is kind of a kludge to get Tomcat to get a default
             * web.xml if one does not exist.  This is primarily for jaxws.  This code is
             * necessary because Tomcat either has a bug or there is a problem dynamically
             * adding a wrapper to an already running context.  Although the wrapper
             * can be added, the url mappings do not get picked up at the proper level
             * and therefore Tomcat cannot dispatch the request.  Hence, creating and
             * writing out a web.xml to the deployed location is the only way around this
             * until Tomcat fixes that bug.
             *
             * For myfaces/jsf, the spec dd may have been updated with a listener.  So, we need to write it out again whether or not
             * there originally was one. This might not work on windows due to file locking problems.
             */

            if ((Boolean)module.getSharedContext().get(IS_JAVAEE)) {
                WebAppType shortWebApp = (WebAppType) webApp.copy();
                shortWebApp.setEjbLocalRefArray(new EjbLocalRefType[0]);
                shortWebApp.setEjbRefArray(new EjbRefType[0]);
                shortWebApp.setEnvEntryArray(new EnvEntryType[0]);
                shortWebApp.setMessageDestinationArray(new MessageDestinationType[0]);
                shortWebApp.setMessageDestinationRefArray(new MessageDestinationRefType[0]);
                shortWebApp.setPersistenceContextRefArray(new PersistenceContextRefType[0]);
                shortWebApp.setPersistenceUnitRefArray(new PersistenceUnitRefType[0]);
                shortWebApp.setPostConstructArray(new LifecycleCallbackType[0]);
                shortWebApp.setPreDestroyArray(new LifecycleCallbackType[0]);
                shortWebApp.setResourceEnvRefArray(new ResourceEnvRefType[0]);
                shortWebApp.setResourceRefArray(new ResourceRefType[0]);
                shortWebApp.setServiceRefArray(new ServiceRefType[0]);
                // TODO Tomcat will fail web services tck tests if the following security settings are set in shortWebApp
                // need to figure out why...
                //One clue is that without this stuff tomcat does not install an authenticator.... so there's no security
//                 shortWebApp.setSecurityConstraintArray(new SecurityConstraintType[0]);
//                 shortWebApp.setSecurityRoleArray(new SecurityRoleType[0]);
                File webXml = new File(moduleContext.getBaseDir(), "/WEB-INF/web.xml");
                File inPlaceDir = moduleContext.getInPlaceConfigurationDir();
                if (inPlaceDir != null) {
                    webXml = new File(inPlaceDir, "/WEB-INF/web.xml");
                }
//        boolean webXmlExists = (inPlaceDir != null && new File(inPlaceDir,"/WEB-INF/web.xml").exists()) || webXml.exists();
//        if (!webXmlExists) {
                webXml.getParentFile().mkdirs();
                try {
                    FileWriter outFile = new FileWriter(webXml);

                    XmlOptions opts = new XmlOptions();
                    opts.setSaveAggressiveNamespaces();
                    opts.setSaveSyntheticDocumentElement(WebAppDocument.type.getDocumentElementName());
                    opts.setUseDefaultNamespace();
                    opts.setSavePrettyPrint();

    //                WebAppDocument doc = WebAppDocument.Factory.newInstance();
    //                doc.setWebApp(webApp);

                    outFile.write(shortWebApp.xmlText(opts));
                    outFile.flush();
                    outFile.close();
                } catch (Exception e) {
                    throw new DeploymentException(e);
                }
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        WebDeployable webDeployable = new WebDeployable(warUrl);
        ClassLoader classLoader = webDeployable.getModuleLoader();

        ApplicationInfo applicationInfo = createApplicationInfo(request, warUrl);
        Module module = (Module) (applicationInfo.getModules().toArray()[0]);
        WebAppType webApp = (WebAppType) module.getSpecDD();

        ClassFinder classFinder = null;
        try {
            classFinder = AbstractWebModuleBuilder.createWebAppClassFinder(webApp, classLoader);
            // classFinder = new ClassFinder(classLoader);
        } catch (DeploymentException e1) {
            // Some of the class types referred in the WAR cannot be resolved.
            // A typical case would be references to EJBs already deployed into the system, and
            // hence not packaged inside WEB-INF/lib directory of WAR.
            // try adding all EJBs deployed in the system as parents of this WAR, and
            // see if referred classes can now be successfully resolved

            classLoader = new WebDeployable(warUrl, getEjbClassLoaders(request)).getModuleLoader();
            try {
                classFinder = AbstractWebModuleBuilder.createWebAppClassFinder(webApp, classLoader);
            } catch (DeploymentException e2) {
                return;
            }
        }
        AnnotatedApp annotatedApp = module.getAnnotatedApp();
        parseAnnotations(annotatedApp, classFinder);

        //DDBeanRoot ddBeanRoot = webDeployable.getDDBeanRoot();
        //DDBean ddBean = ddBeanRoot.getChildBean("web-app")[0];

        EjbRefType[] ejbRefs = annotatedApp.getEjbRefArray();
        for (int i = 0; i < ejbRefs.length; i++) {
            String refName = ejbRefs[i].getEjbRefName().getStringValue();
            data.getEjbRefs().add(new ReferenceData(refName));
        }
        /*DDBean[] ddBeans = ddBean.getChildBean("ejb-ref");
        for (int i = 0; ddBeans != null && i < ddBeans.length; i++) {
            String refName = ddBeans[i].getChildBean("ejb-ref-name")[0].getText();
            data.getEjbRefs().add(new ReferenceData(refName));
        }*/

        EjbLocalRefType[] ejbLocalRefs = annotatedApp.getEjbLocalRefArray();
        for (int i = 0; i < ejbLocalRefs.length; i++) {
            String refName = ejbLocalRefs[i].getEjbRefName().getStringValue();
            data.getEjbLocalRefs().add(new ReferenceData(refName));
        }
        /*ddBeans = ddBean.getChildBean("ejb-local-ref");
        for (int i = 0; ddBeans != null && i < ddBeans.length; i++) {
            String refName = ddBeans[i].getChildBean("ejb-ref-name")[0].getText();
            data.getEjbLocalRefs().add(new ReferenceData(refName));
        }*/

        ResourceRefType[] resourceRefs = annotatedApp.getResourceRefArray();
        for(int i = 0; i < resourceRefs.length; i++) {
            String refName = resourceRefs[i].getResRefName().getStringValue();
            String refType = resourceRefs[i].getResType().getStringValue();
            if ("javax.sql.DataSource".equalsIgnoreCase(refType)) {
                data.getJdbcPoolRefs().add(new ReferenceData(refName));
            } else if ("javax.jms.ConnectionFactory".equalsIgnoreCase(refType)
                    || "javax.jms.QueueConnectionFactory".equalsIgnoreCase(refType)
                    || "javax.jms.TopicConnectionFactory".equalsIgnoreCase(refType)) {
                data.getJmsConnectionFactoryRefs().add(new ReferenceData(refName));
            } else if ("javax.mail.Session".equalsIgnoreCase(refType)) {
                data.getJavaMailSessionRefs().add(new ReferenceData(refName));
            }
        }
        /*ddBeans = ddBean.getChildBean("resource-ref");
        for (int i = 0; ddBeans != null && i < ddBeans.length; i++) {
            String refName = ddBeans[i].getChildBean("res-ref-name")[0].getText();
            String refType = ddBeans[i].getChildBean("res-type")[0].getText();
            if ("javax.sql.DataSource".equalsIgnoreCase(refType)) {
                data.getJdbcPoolRefs().add(new ReferenceData(refName));
            } else if ("javax.jms.ConnectionFactory".equalsIgnoreCase(refType)
                    || "javax.jms.QueueConnectionFactory".equalsIgnoreCase(refType)
                    || "javax.jms.TopicConnectionFactory".equalsIgnoreCase(refType)) {
                data.getJmsConnectionFactoryRefs().add(new ReferenceData(refName));
            }
        }*/

        ServiceRefType[] serviceRefs = annotatedApp.getServiceRefArray();
        for(int i = 0; i < serviceRefs.length; i++) {
            String refName = serviceRefs[i].getServiceRefName().getStringValue();
            GerServiceRefType serviceRef = GerServiceRefType.Factory.newInstance();
            serviceRef.setServiceRefName(refName);
            data.getWebServiceRefs().add(serviceRef);
        }

        ResourceEnvRefType[] resourceEnvRefs = annotatedApp.getResourceEnvRefArray();
        for(int i = 0; i < resourceEnvRefs.length; i++) {
            String refName = resourceEnvRefs[i].getResourceEnvRefName().getStringValue();
            ReferenceData refData = new ReferenceData(refName);
            refData.setRefLink(refName);
            data.getJmsDestinationRefs().add(refData);
        }
        if(annotatedApp instanceof AnnotatedWebApp) {
            WebAppType webApp2 = ((AnnotatedWebApp)annotatedApp).getWebApp();
            MessageDestinationType[] messageDestinations = webApp2.getMessageDestinationArray();
            for(int i = 0; i < messageDestinations.length; i++) {
                String refName = messageDestinations[i].getMessageDestinationName().getStringValue();
                ReferenceData refData = new ReferenceData(refName);
                refData.setRefLink(refName);
                data.getMessageDestinations().add(refData);
            }

            SecurityRoleType[] securityRoles = webApp2.getSecurityRoleArray();
            if (securityRoles.length > 0) {
                data.setSecurity(GerSecurityType.Factory.newInstance());
                data.getSecurity().addNewRoleMappings();
            }
            for (int i = 0; i < securityRoles.length; i++) {
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

    private void discoverPOJOWebServices(Module module,
                                         Map correctedPortLocations,
                                         Map<String, PortInfo> map)
        throws DeploymentException {
        ClassLoader classLoader = module.getEarContext().getClassLoader();
        WebAppType webApp = (WebAppType) module.getSpecDD();

        // find web services
        ServletType[] servletTypes = webApp.getServletArray();

        if (webApp.getDomNode().getChildNodes().getLength() == 0) {
            // web.xml not present (empty really), discover annotated
            // classes and update DD
            List<Class> services = discoverWebServices(module.getModuleFile(), false);
            String contextRoot = ((WebModule) module).getContextRoot();
            for (Class service : services) {
                // skip interfaces and such
                if (!JAXWSUtils.isWebService(service)) {
                    continue;
                }

                LOG.debug("Discovered POJO Web Service: " + service.getName());
               
                // add new <servlet/> element
                ServletType servlet = webApp.addNewServlet();
                servlet.addNewServletName().setStringValue(service.getName());
                servlet.addNewServletClass().setStringValue(service.getName());

                // add new <servlet-mapping/> element
                String location = "/" + JAXWSUtils.getServiceName(service);
                ServletMappingType servletMapping = webApp.addNewServletMapping();
                servletMapping.addNewServletName().setStringValue(service.getName());
                servletMapping.addNewUrlPattern().setStringValue(location);

                // map service
                PortInfo portInfo = new PortInfo();
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        // Ensure annotations are processed correctly
        //-------------------------------------------------
        URL srcXML = classLoader.getResource("annotation/empty-web-src.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
        WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
        WebAppType webApp = webAppDoc.getWebApp();
        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
        EJBAnnotationHelper.processAnnotations(annotatedWebApp, classFinder);
        URL expectedXML = classLoader.getResource("annotation/ejb-expected.xml");
        XmlObject expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[@EJB Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[@EJB Expected XML]" + '\n' + expected.toString() + '\n');
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        // Ensure annotations are processed correctly
        //-------------------------------------------------
        URL srcXML = classLoader.getResource("annotation/handler-chain-src.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
        WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
        WebAppType webApp = webAppDoc.getWebApp();
        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
        HandlerChainAnnotationHelper.processAnnotations(annotatedWebApp, classFinder);
        URL expectedXML = classLoader.getResource("annotation/handler-chain-expected.xml");
        XmlObject expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[@HandlerChain Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[@HandlerChain Expected XML]" + '\n' + expected.toString() + '\n');
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        // Ensure annotations are processed correctly
        //-------------------------------------------------
        URL srcXML = classLoader.getResource("annotation/empty-web-src.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
        WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
        WebAppType webApp = webAppDoc.getWebApp();
        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
        PersistenceContextAnnotationHelper.processAnnotations(annotatedWebApp, classFinder);
        URL expectedXML = classLoader.getResource("annotation/persistence-context-expected.xml");
        XmlObject expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[@PersistenceContext Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[@PersistenceContext Expected XML]" + '\n' + expected.toString() + '\n');
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        // Ensure annotations are processed correctly
        //-------------------------------------------------
        URL srcXML = classLoader.getResource("annotation/empty-web-src.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
        WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
        WebAppType webApp = webAppDoc.getWebApp();
        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
        PersistenceUnitAnnotationHelper.processAnnotations(annotatedWebApp, classFinder);
        URL expectedXML = classLoader.getResource("annotation/persistence-unit-expected.xml");
        XmlObject expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[@PersistenceUnit Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[@PersistenceUnit Expected XML]" + '\n' + expected.toString() + '\n');
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        // Ensure annotations are processed correctly
        //-------------------------------------------------
        URL srcXML = classLoader.getResource("annotation/empty-web-src.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
        WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
        WebAppType webApp = webAppDoc.getWebApp();
        AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
        WebServiceRefAnnotationHelper.processAnnotations(annotatedWebApp, classFinder);
        URL expectedXML = classLoader.getResource("annotation/webservice-ref-expected.xml");
        XmlObject expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[@WebServiceRef Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[@WebServiceRef Expected XML]" + '\n' + expected.toString() + '\n');
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        // Ensure annotations are processed correctly
        //-------------------------------------------------
        URL srcXML = classLoader.getResource("annotation/empty-web-src.xml");
        XmlObject xmlObject = XmlObject.Factory.parse(srcXML, options);
        WebAppDocument webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
        WebAppType webApp = webAppDoc.getWebApp();
        SecurityAnnotationHelper.processAnnotations(webApp, classFinder);
        URL expectedXML = classLoader.getResource("annotation/security-expected.xml");
        XmlObject expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[Security Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[Security Expected XML]" + '\n' + expected.toString() + '\n');
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);

        srcXML = classLoader.getResource("annotation/security-src.xml");
        xmlObject = XmlObject.Factory.parse(srcXML, options);
        webAppDoc = (WebAppDocument) xmlObject.changeType(WebAppDocument.type);
        webApp = webAppDoc.getWebApp();
        SecurityAnnotationHelper.processAnnotations(webApp, classFinder);
        expectedXML = classLoader.getResource("annotation/security-expected-1.xml");
        expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[Security Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[Security Expected XML]" + '\n' + expected.toString() + '\n');
        problems = new ArrayList();
        ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.javaee.WebAppType

        assert targetPath != null : "targetPath is null";
        assert !targetPath.endsWith("/") : "targetPath must not end with a '/'";

        // parse the spec dd
        String specDD = null;
        WebAppType webApp = null;
        try {
            if (specDDUrl == null) {
                specDDUrl = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/web.xml");
            }

            // read in the entire specDD as a string, we need this for getDeploymentDescriptor
            // on the J2ee management object
            specDD = DeploymentUtil.readAll(specDDUrl);

            // we found web.xml, if it won't parse that's an error.
            XmlObject parsed = XmlBeansUtil.parse(specDD);
            WebAppDocument webAppDoc = convertToServletSchema(parsed);
            webApp = webAppDoc.getWebApp();
            check(webApp);
        } catch (XmlException e) {
            // Output the target path in the error to make it clearer to the user which webapp
            // has the problem.  The targetPath is used, as moduleFile may have an unhelpful
            // value such as C:\geronimo-1.1\var\temp\geronimo-deploymentUtil22826.tmpdir
            throw new DeploymentException("Error parsing web.xml for " + targetPath, e);
        } catch (Exception e) {
            if (!moduleFile.getName().endsWith(".war")) {
                //not for us
                return null;
            }
            //else ignore as jee5 allows optional spec dd for .war's
        }

        if (webApp == null) {
            webApp = WebAppType.Factory.newInstance();
        }

        // parse vendor dd
        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath, webApp);
        contextRoot = getContextRoot(jettyWebApp, contextRoot, webApp, standAlone, moduleFile, targetPath);

        EnvironmentType environmentType = jettyWebApp.getEnvironment();
        Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);

        Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
        if (TRUE == distributable) {
            clusteringBuilders.buildEnvironment(jettyWebApp, environment);
        }

        // Note: logic elsewhere depends on the default artifact ID being the file name less extension (ConfigIDExtractor)
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.