Examples of WebAppType


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

     */
    public void testAllMethodsConstraint() throws Exception {
        roleSet.add("Admin");
        URL srcXml = classLoader.getResource("security/web2.xml");
        WebAppDocument webAppDoc = WebAppDocument.Factory.parse(srcXml, options);
        WebAppType webAppType = webAppDoc.getWebApp();
        ComponentPermissions permissions = builder.buildSpecSecurityConfig(webAppType, roleSet, rolePermissionMap);
        PermissionCollection unchecked = permissions.getUncheckedPermissions();
        assertFalse(unchecked.implies(new WebResourcePermission("/Test", "!")));
        PermissionCollection adminPermissions = permissions.getRolePermissions().get("Admin");
        assertTrue(adminPermissions.implies(new WebResourcePermission("/Test", "GET,POST")));
View Full Code Here

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

        File path = new File(BASEDIR, "src/test/resources/deployables/"
                + warName);

        // parse the spec dd
        String specDD = "";
        WebAppType webApp = null;
        UnpackedJarFile jarFile = new UnpackedJarFile(path);
        URL specDDUrl = DeploymentUtil.createJarURL(jarFile, "WEB-INF/web.xml");
        // read in the entire specDD as a string
        specDD = DeploymentUtil.readAll(specDDUrl);
        // parse it
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) {
                throw e2;
            }
        }
        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

        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
        AtomicBoolean isDefault = new AtomicBoolean(false);
        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath, webApp, isDefault);
        if (jettyWebApp.isSetContextRoot() && !isDefault.get()) {
            contextRoot = jettyWebApp.getContextRoot();
        } else if (contextRoot == null || contextRoot.trim().equals("")) {
            contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
        }

        contextRoot = contextRoot.trim();

        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

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

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

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

        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);
            Set<String> securityRoles = collectRoleNames(webApp);
            Map<String, PermissionCollection> rolePermissions = new HashMap<String, PermissionCollection>();

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

            //classpath may have been augmented with enhanced classes
//            webModuleData.setAttribute("webClassPath", webModule.getWebClasspath());

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

            if (jettyWebApp.isSetWebContainer()) {
                AbstractNameQuery webContainerName = ENCConfigBuilder.getGBeanQuery(NameFactory.GERONIMO_SERVICE, 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(JettyWebAppContext.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(JettyWebAppContext.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.
            configureTagLibs(module, webApp, webModuleData);

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

            // Make sure that servlet mappings point to available servlets and never add a duplicate pattern.
            Set<String> knownServletMappings = new HashSet<String>();
            Map<String, Set<String>> servletMappings = new HashMap<String, Set<String>>();

            buildServletMappings(module, webApp, servletMappings, knownServletMappings);

            //"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, securityRoles, rolePermissions, moduleContext);

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

            if (servletTypes.length > 0) {
                // Process security annotations for servlets only (before MBEs run)
                SecurityAnnotationHelper.processAnnotations(webApp, webModule.getClassFinder());
            }

            //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());
            }

            if (!module.isStandAlone()) {
View Full Code Here

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

        if (!(module instanceof WebModule)) {
            //not a web module, nothing to do
            return;
        }
        WebModule webModule = (WebModule) module;
        WebAppType webApp = (WebAppType) webModule.getSpecDD();
        if (!hasFacesServlet(webApp)) {
            return;
        }

        EnvironmentBuilder.mergeEnvironments(environment, defaultEnvironment);
View Full Code Here

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

        if (!(module instanceof WebModule)) {
            //not a web module, nothing to do
            return;
        }
        WebModule webModule = (WebModule) module;
        WebAppType webApp = (WebAppType) webModule.getSpecDD();
        if (!hasFacesServlet(webApp)) {
            return;
        }

        EARContext moduleContext = module.getEarContext();
        Map sharedContext = module.getSharedContext();
        //add the ServletContextListener to the web app context
        GBeanData webAppData = (GBeanData) sharedContext.get(WebModule.WEB_APP_DATA);
        //jetty specific support
        Object value = webAppData.getAttribute("listenerClassNames");
        if (value instanceof Collection && !((Collection) value).contains(CONTEXT_LISTENER_NAME)) {
            ((Collection<String>) value).add(CONTEXT_LISTENER_NAME);
        } else {
            //try to add listener to the web app xml
            ListenerType listenerType = webApp.addNewListener();
            FullyQualifiedClassType className = listenerType.addNewListenerClass();
            className.setStringValue(CONTEXT_LISTENER_NAME);
        }
        AbstractName moduleName = moduleContext.getModuleName();
        Map<NamingBuilder.Key, Object> buildingContext = new HashMap<NamingBuilder.Key, Object>();
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

        }
//        servletData.setAttribute("webRoleRefPermissions", webRoleRefPermissions);
    }

    protected void buildSubstitutionGroups(XmlObject gerWebApp, boolean hasSecurityRealmName, Module module, EARContext earContext) throws DeploymentException {
        WebAppType webApp = (WebAppType) module.getSpecDD();
//      makeMetadataComplete(webApp, module);
        if ((webApp.getSecurityConstraintArray().length > 0 || webApp.getSecurityRoleArray().length > 0) &&
                !hasSecurityRealmName) {
            throw new DeploymentException("web.xml for web app " + module.getName() + " includes security elements but Geronimo deployment plan is not provided or does not contain <security-realm-name> element necessary to configure security accordingly.");
        }
        XmlObject[] securityElements = XmlBeansUtil.selectSubstitutionGroupElements(SECURITY_QNAME, gerWebApp);
        if (securityElements.length > 0 && !hasSecurityRealmName) {
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;
        Boolean isJavaee;
        try {
            if (specDDUrl == null) {
                specDDUrl = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/web.xml");
            }
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.