Package org.apache.geronimo.xbeans.javaee6

Examples of org.apache.geronimo.xbeans.javaee6.DataSourceType


            // not for us
            return null;
        }

        String specDD = null;
        WebAppType webApp = null;

        URL specDDUrl = BundleUtils.getEntry(bundle, "WEB-INF/web.xml");
        if (specDDUrl == null) {
            webApp = WebAppType.Factory.newInstance();
        } else {
            try {
                specDD = JarUtils.readAll(specDDUrl);
                XmlObject parsed = XmlBeansUtil.parse(specDD);
                WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
                webApp = webAppDoc.getWebApp();
                WebDeploymentValidationUtils.validateWebApp(webApp);
            } catch (XmlException e) {
                throw new DeploymentException("Error parsing web.xml for " + bundle.getSymbolicName(), e);
            } catch (Exception e) {
                throw new DeploymentException("Error reading web.xml for " + bundle.getSymbolicName(), e);
            }
        }

        AbstractName earName = null;
        String targetPath = ".";
        boolean standAlone = true;

        Deployable deployable = new DeployableBundle(bundle);
        // parse vendor dd
        JettyWebAppType jettyWebApp = getJettyWebApp(null, deployable, standAlone, targetPath, webApp);

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

        if (webApp.getDistributableArray().length == 1) {
            clusteringBuilders.buildEnvironment(jettyWebApp, environment);
        }

        idBuilder.resolve(environment, bundle.getSymbolicName(), "wab");
View Full Code Here


    private void discoverPOJOWebServices(Module module,
                                         Map portLocations,
                                         Map<String, PortInfo> map)
        throws DeploymentException {
        Bundle bundle = module.getEarContext().getDeploymentBundle();
        WebAppType webApp = (WebAppType) module.getSpecDD();

        if (webApp.isSetMetadataComplete()) {
            // full web.xml, just examine all servlet entries for web services

            ServletType[] servletTypes = webApp.getServletArray();
            for (ServletType servletType : servletTypes) {
                String servletName = servletType.getServletName().getStringValue().trim();
                PortInfo portInfo = getPortInfo(servletType, bundle, portLocations);
                if (portInfo != null) {
                    LOG.debug("Found POJO Web Service: {}", servletName);
                    map.put(servletName, portInfo);
                }
            }

        } else {
            // partial web.xml, discover all web service classes

            Map<String, List<String>> classServletMap = createClassServetMap(webApp);
            List<Class> services = WARWebServiceFinder.discoverWebServices(module, bundle, 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 class: {}", service.getName());

                List<String> mappedServlets = classServletMap.get(service.getName());
                if (mappedServlets == null) {
                    // no <servlet/> entry, add one

                    LOG.debug("POJO Web Service class {} is not mapped to any servlet", service.getName());

                    ServletType servlet = webApp.addNewServlet();
                    servlet.addNewServletName().setStringValue(service.getName());
                    servlet.addNewServletClass().setStringValue(service.getName());

                    String location = (String)portLocations.get(service.getName());
                    if (location == null) {
                        // add new <servlet-mapping/> element
                        location = "/" + JAXWSUtils.getServiceName(service);
                        ServletMappingType servletMapping = webApp.addNewServletMapping();
                        servletMapping.addNewServletName().setStringValue(service.getName());
                        servletMapping.addNewUrlPattern().setStringValue(location);
                    } else {
                        // weird, there was no servlet entry for this class but
                        // servlet-mapping exists
                        LOG.warn("Found <servlet-mapping> but corresponding <servlet> was not defined");
                    }

                    // map service
                    PortInfo portInfo = new PortInfo();
                    portInfo.setLocation(contextRoot + location);
                    map.put(service.getName(), portInfo);
                } else {
                    // found at least one mapped <servlet/> entry
                    for (String servlet : mappedServlets) {
                        LOG.debug("POJO Web Service class {} is mapped to {} servlet", service.getName(), servlet);
                        PortInfo portInfo = createPortInfo(servlet, portLocations);
                        map.put(servlet, portInfo);
                    }
                }
            }

            // double check servlets in case we missed something
            ServletType[] servletTypes = webApp.getServletArray();
            for (ServletType servletType : servletTypes) {
                String servletName = servletType.getServletName().getStringValue().trim();
                if (map.get(servletName) == null) {
                    PortInfo portInfo = getPortInfo(servletType, bundle, portLocations);
                    if (portInfo != null) {
View Full Code Here

        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 = JarUtils.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 = JarUtils.readAll(specDDUrl);

            // we found web.xml, if it won't parse that's an error.
            XmlObject parsed = XmlBeansUtil.parse(specDD);
            WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(parsed);
            webApp = webAppDoc.getWebApp();
            WebDeploymentValidationUtils.validateWebApp(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();
        }

        Deployable deployable = new DeployableJarFile(moduleFile);
        // parse vendor dd
        boolean standAlone = earEnvironment == null;
        JettyWebAppType jettyWebApp = getJettyWebApp(plan, deployable, standAlone, targetPath, webApp);
        contextRoot = getContextRoot(jettyWebApp, contextRoot, webApp, standAlone, moduleFile, targetPath);

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

        if (webApp.getDistributableArray().length == 1) {
            clusteringBuilders.buildEnvironment(jettyWebApp, environment);
        }

        if (!standAlone && COMBINED_BUNDLE) {
            EnvironmentBuilder.mergeEnvironments(earEnvironment, environment);
View Full Code Here

    public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection repository) throws DeploymentException {
        EARContext moduleContext = module.getEarContext();
        AbstractName moduleName = module.getModuleName();
        WebModule webModule = (WebModule) module;

        WebAppType webApp = (WebAppType) webModule.getSpecDD();
        JettyWebAppType jettyWebApp = (JettyWebAppType) webModule.getVendorDD();
        GBeanData webModuleData = new GBeanData(moduleName, WebAppContextWrapper.class);

        configureBasicWebModuleAttributes(webApp, jettyWebApp, moduleContext, earContext, webModule, webModuleData);

        // unsharableResources, applicationManagedSecurityResources
        GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
        //N.B. use earContext not moduleContext
        //TODO fix this for javaee 5 !!!
        resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
        try {
            moduleContext.addGBean(webModuleData);

            // configure WebAppContextManager with right priority so that it starts last
            AbstractName contextManagerName = earContext.getNaming().createChildName(moduleName, "WebAppContextManager", NameFactory.SERVICE_MODULE);
            GBeanData contextManagerGBean = new GBeanData(contextManagerName, WebAppContextManager.class);
            contextManagerGBean.setPriority(100);
            contextManagerGBean.setReferencePattern("webApp", moduleName);
            moduleContext.addGBean(contextManagerGBean);

            // configure hosts and virtual-hosts
            configureHosts(earContext, jettyWebApp, webModuleData);

            String contextPath = webModule.getContextRoot();
            if (contextPath == null) {
                throw new DeploymentException("null contextPath");
            }
            if (!contextPath.startsWith("/")) {
                contextPath = "/" + contextPath;
            }
            webModuleData.setAttribute("contextPath", contextPath);

            if (jettyWebApp.isSetWorkDir()) {
                String workDir = jettyWebApp.getWorkDir();
                webModuleData.setAttribute("workDir", workDir);
            }

            if (jettyWebApp.isSetWebContainer()) {
                AbstractNameQuery webContainerName = ENCConfigBuilder.getGBeanQuery(GBeanInfoBuilder.DEFAULT_J2EE_TYPE, jettyWebApp.getWebContainer());
                webModuleData.setReferencePattern("JettyContainer", webContainerName);
            } else {
                webModuleData.setReferencePattern("JettyContainer", jettyContainerObjectName);
            }
            //stuff that jetty used to do
            if (webApp.getDisplayNameArray().length > 0) {
                webModuleData.setAttribute("displayName", webApp.getDisplayNameArray()[0].getStringValue());
            }

            // configure context parameters.
            configureContextParams(webApp, webModuleData);

            // configure listeners.
            configureListeners(webApp, webModuleData);

            webModuleData.setAttribute(WebAppContextWrapper.GBEAN_ATTR_SESSION_TIMEOUT,
                    (webApp.getSessionConfigArray().length == 1 && webApp.getSessionConfigArray(0).getSessionTimeout() != null) ?
                            webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue() * 60 :
                            defaultSessionTimeoutSeconds);

            Boolean distributable = webApp.getDistributableArray().length == 1 ? TRUE : FALSE;
            webModuleData.setAttribute("distributable", distributable);
            if (TRUE == distributable) {
                clusteringBuilders.build(jettyWebApp, earContext, moduleContext);
                if (webModuleData.getReferencePatterns(WebAppContextWrapper.GBEAN_REF_SESSION_HANDLER_FACTORY) == null) {
                    log.warn("No clustering builders configured: app will not be clustered");
                    configureNoClustering(moduleContext, webModuleData);
                }
            } else {
                configureNoClustering(moduleContext, webModuleData);
            }

            // configure mime mappings.
            configureMimeMappings(webApp, webModuleData);

            // configure welcome file lists.
            configureWelcomeFileLists(webApp, webModuleData);

            // configure local encoding mapping lists.
            configureLocaleEncodingMappingLists(webApp, webModuleData);

            // configure error pages.
            configureErrorPages(webApp, webModuleData);

            // configure tag libs.
            Set<String> knownServletMappings = new HashSet<String>();
            Set<String> knownJspMappings = new HashSet<String>();
            Map<String, Set<String>> servletMappings = new HashMap<String, Set<String>>();
            if (jspServlet != null) {
                configureTagLibs(module, webApp, webModuleData, servletMappings, knownJspMappings, jspServlet.getServletName());
                GBeanData jspServletData = configureDefaultServlet(jspServlet, earContext, moduleName, knownJspMappings);
                knownServletMappings.addAll(knownJspMappings);
                module.getSharedContext().put(DEFAULT_JSP_SERVLET_KEY, jspServletData);
            }

            // configure login configs.
            configureAuthentication(module, webApp, jettyWebApp, webModuleData);

            // Make sure that servlet mappings point to available servlets and never add a duplicate pattern.

            buildServletMappings(module, webApp, servletMappings, knownServletMappings);

            //be careful that the jsp servlet defaults don't override anything configured in the app.
            if (jspServlet != null) {
                GBeanData jspServletData = (GBeanData) module.getSharedContext().get(DEFAULT_JSP_SERVLET_KEY);
                Set<String> jspMappings = (Set<String>) jspServletData.getAttribute("servletMappings");
                jspMappings.removeAll(knownServletMappings);
                jspMappings.addAll(knownJspMappings);
                jspServletData.setAttribute("servletMappings", jspMappings);
            }

            //"previous" filter mapping for linked list to keep dd's ordering.
            AbstractName previous = null;

            //add default filters
            if (defaultFilters != null) {
                previous = addDefaultFiltersGBeans(earContext, moduleContext, moduleName, previous);
            }

            //add default filtermappings
//            if (defaultFilterMappings != null) {
//                for (Iterator iterator = defaultFilterMappings.iterator(); iterator.hasNext();) {
//                    Object defaultFilterMapping = iterator.next();
//                    GBeanData filterMappingGBeanData = getGBeanData(kernel, defaultFilterMapping);
//                    String filterName = (String) filterMappingGBeanData.getAttribute("filterName");
//                    ObjectName defaultFilterMappingObjectName;
//                    if (filterMappingGBeanData.getAttribute("urlPattern") != null) {
//                        String urlPattern = (String) filterMappingGBeanData.getAttribute("urlPattern");
//                        defaultFilterMappingObjectName = NameFactory.getWebFilterMappingName(null, null, null, null, filterName, null, urlPattern, moduleName);
//                    } else {
//                        Set servletNames = filterMappingGBeanData.getReferencePatterns("Servlet");
//                        if (servletNames == null || servletNames.size() != 1) {
//                            throw new DeploymentException("Exactly one servlet name must be supplied");
//                        }
//                        ObjectName servletObjectName = (ObjectName) servletNames.iterator().next();
//                        String servletName = servletObjectName.getKeyProperty("name");
//                        defaultFilterMappingObjectName = NameFactory.getWebFilterMappingName(null, null, null, null, filterName, servletName, null, moduleName);
//                    }
//                    filterMappingGBeanData.setName(defaultFilterMappingObjectName);
//                    filterMappingGBeanData.setReferencePattern("JettyFilterMappingRegistration", webModuleName);
//                    moduleContext.addGBean(filterMappingGBeanData);
//                }
//            }

            // add filter mapping GBeans.
            addFilterMappingsGBeans(earContext, moduleContext, moduleName, webApp, previous);

            // add filter GBeans.
            addFiltersGBeans(earContext, moduleContext, moduleName, webApp);

            //add default servlets
            if (defaultServlets != null) {
                addDefaultServletsGBeans(earContext, moduleContext, moduleName, knownServletMappings);
            }

            //set up servlet gbeans.
            ServletType[] servletTypes = webApp.getServletArray();
            addServlets(moduleName, webModule, servletTypes, servletMappings, moduleContext);

            if (jettyWebApp.isSetSecurityRealmName()) {
                configureSecurityRealm(earContext, webApp, jettyWebApp, bundle, webModuleData);
            }

            //See Jetty-386, GERONIMO-3738
            if (jettyWebApp.getCompactPath()) {
                webModuleData.setAttribute("compactPath", Boolean.TRUE);
            }

            //TODO this may definitely not be the best place for this!
            for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
                mbe.addGBeans(earContext, module, bundle, repository);
            }

            //not truly metadata complete until MBEs have run
            if (!webApp.getMetadataComplete()) {
                webApp.setMetadataComplete(true);
                if (INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >= 2.5f) {
                    String specDeploymentPlan = getSpecDDAsString(webModule);
                    module.setOriginalSpecDD(specDeploymentPlan);
                    earContext.addFile(new URI("./WEB-INF/web.xml"), specDeploymentPlan);
                }
View Full Code Here

        // 1. resource-ref
        //
        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);
        ResourceAnnotationHelper.processAnnotations(annotatedWebApp, classFinder, ResourceRefBuilder.ResourceRefProcessor.INSTANCE);
        URL expectedXML = classLoader.getResource("annotation/resource-ref-expected.xml");
        XmlObject expected = XmlObject.Factory.parse(expectedXML);
        log.debug("[@Resource <resource-ref> Source XML] " + '\n' + webApp.toString() + '\n');
        log.debug("[@Resource <resource-ref> Expected XML]" + '\n' + expected.toString() + '\n');
        List problems = new ArrayList();
        boolean ok = compareXmlObjects(webApp, expected, problems);
        assertTrue("Differences: " + problems, ok);
    }
View Full Code Here

        Map<String, WebFragmentDocument> jarURLWebFragmentDocumentMap = new LinkedHashMap<String, WebFragmentDocument>();
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testA.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentA.xml"));
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testB.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentB.xml"));
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testC.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentC.xml"));
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testD.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentD.xml"));
        WebAppType webApp = ((WebAppDocument) loadXmlObject("webfragments/absolute/web-withothers.xml")).getWebApp();
        WebFragmentEntry[] webFragmentEntries = MergeHelper.sortWebFragments(new DummyEARContext(), null, null, webApp, jarURLWebFragmentDocumentMap);
        Assert.assertEquals(4, webFragmentEntries.length);
        Assert.assertEquals("webfragmentD", webFragmentEntries[0].getName());
        Assert.assertEquals("webfragmentB", webFragmentEntries[1].getName());
        Assert.assertEquals("webfragmentC", webFragmentEntries[2].getName());
View Full Code Here

        Map<String, WebFragmentDocument> jarURLWebFragmentDocumentMap = new LinkedHashMap<String, WebFragmentDocument>();
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testA.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentA.xml"));
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testB.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentB.xml"));
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testC.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentC.xml"));
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testD.jar", (WebFragmentDocument) loadXmlObject("webfragments/absolute/webfragmentD.xml"));
        WebAppType webApp = ((WebAppDocument) loadXmlObject("webfragments/absolute/web-withoutothers.xml")).getWebApp();
        WebFragmentEntry[] webFragmentEntries = MergeHelper.sortWebFragments(new DummyEARContext(), null, null, webApp, jarURLWebFragmentDocumentMap);
        Assert.assertEquals(2, webFragmentEntries.length);
        Assert.assertEquals("webfragmentD", webFragmentEntries[0].getName());
        Assert.assertEquals("webfragmentA", webFragmentEntries[1].getName());
    }
View Full Code Here

        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testB.jar", (WebFragmentDocument) loadXmlObject("webfragments/relative/webfragmentB.xml"));
        //C -(before) -> others
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testC.jar", (WebFragmentDocument) loadXmlObject("webfragments/relative/webfragmentC.xml"));
        //D -(after) -> others
        jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testD.jar", (WebFragmentDocument) loadXmlObject("webfragments/relative/webfragmentD.xml"));
        WebAppType webApp = ((WebAppDocument) loadXmlObject("webfragments/relative/web.xml")).getWebApp();
        WebFragmentEntry[] webFragmentEntries = MergeHelper.sortWebFragments(new DummyEARContext(), null, null, webApp, jarURLWebFragmentDocumentMap);
        Assert.assertEquals("webfragmentC", webFragmentEntries[0].getName());
        Assert.assertEquals("webfragmentB", webFragmentEntries[1].getName());
        Assert.assertEquals("webfragmentA", webFragmentEntries[2].getName());
        Assert.assertEquals("webfragmentD", webFragmentEntries[3].getName());
View Full Code Here

            //A  -(before)-> A
            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testA.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusA/webfragmentA.xml"));
            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testB.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusA/webfragmentB.xml"));
            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testC.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusA/webfragmentC.xml"));
            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testD.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusA/webfragmentD.xml"));
            WebAppType webApp = ((WebAppDocument) loadXmlObject("webfragments/circus/circusA/web.xml")).getWebApp();
            MergeHelper.sortWebFragments(new DummyEARContext(), null, null, webApp, jarURLWebFragmentDocumentMap);
            fail("Circus Dependency should be found");
        } catch (DeploymentException e) {
            Assert.assertTrue(e.getMessage().indexOf("WEB-INF/lib/testA.jar") != -1);
        }
View Full Code Here

            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testA.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusB/webfragmentA.xml"));
            //B -(before) -> A
            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testB.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusB/webfragmentB.xml"));
            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testC.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusB/webfragmentC.xml"));
            jarURLWebFragmentDocumentMap.put("WEB-INF/lib/testD.jar", (WebFragmentDocument) loadXmlObject("webfragments/circus/circusB/webfragmentD.xml"));
            WebAppType webApp = ((WebAppDocument) loadXmlObject("webfragments/circus/circusB/web.xml")).getWebApp();
            MergeHelper.sortWebFragments(new DummyEARContext(), null, null, webApp, jarURLWebFragmentDocumentMap);
            fail("Circus Dependency should be found");
        } catch (DeploymentException e) {
            Assert.assertTrue(e.getMessage().indexOf("WEB-INF/lib/testA.jar") != -1 || e.getMessage().indexOf("WEB-INF/lib/testB.jar") != -1);
        }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.xbeans.javaee6.DataSourceType

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.