Examples of GerWebAppType


Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

        assertEquals(1, jettyWebApp.getResourceRefArray().length);
    }

    public void testConstructPlan() throws Exception {
        GerWebAppDocument jettyWebAppDoc = GerWebAppDocument.Factory.newInstance();
        GerWebAppType jettyWebAppType = jettyWebAppDoc.addNewWebApp();
        jettyWebAppType.setConfigId("configId");
        jettyWebAppType.setParentId("parentId");
        jettyWebAppType.setContextPriorityClassloader(false);
        GerResourceRefType ref = jettyWebAppType.addNewResourceRef();
        ref.setRefName("ref");
        ref.setTargetName("target");

        SchemaConversionUtils.validateDD(jettyWebAppType);
        System.out.println(jettyWebAppType.toString());
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

    private File basedir = new File(System.getProperty("basedir", "."));

    public void testResourceRef() throws Exception {
        File resourcePlan = new File(basedir, "src/test-resources/plans/plan1.xml");
        assertTrue(resourcePlan.exists());
        GerWebAppType jettyWebApp = builder.getTomcatWebApp(resourcePlan, null, true, null, null);
        assertEquals(1, jettyWebApp.getResourceRefArray().length);
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

        assertEquals(1, jettyWebApp.getResourceRefArray().length);
    }

    public void testConstructPlan() throws Exception {
        GerWebAppDocument tomcatWebAppDoc = GerWebAppDocument.Factory.newInstance();
        GerWebAppType tomcatWebAppType = tomcatWebAppDoc.addNewWebApp();
        tomcatWebAppType.setConfigId("configId");
        tomcatWebAppType.setParentId("parentId");
        tomcatWebAppType.setContextPriorityClassloader(false);
        GerResourceRefType ref = tomcatWebAppType.addNewResourceRef();
        ref.setRefName("ref");
        ref.setTargetName("target");

        SchemaConversionUtils.validateDD(tomcatWebAppType);
        System.out.println(tomcatWebAppType.toString());
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

        }
        check(webApp);


        // parse vendor dd
        GerWebAppType tomcatWebApp = getTomcatWebApp(plan, moduleFile, standAlone, targetPath, webApp);

        // get the ids from either the application plan or for a stand alone module from the specific deployer
        URI configId = null;
        try {
            configId = new URI(tomcatWebApp.getConfigId());
        } catch (URISyntaxException e) {
            throw new DeploymentException("Invalid configId " + tomcatWebApp.getConfigId(), e);
        }

        URI parentId = null;
        if (tomcatWebApp.isSetParentId()) {
            try {
                parentId = new URI(tomcatWebApp.getParentId());
            } catch (URISyntaxException e) {
                throw new DeploymentException("Invalid parentId " + tomcatWebApp.getParentId(), e);
            }
        } else {
            parentId = defaultParentId;
        }
        if (contextRoot == null) {
            contextRoot = tomcatWebApp.getContextRoot();
        }
        //look for a webservices dd
        Map portMap = Collections.EMPTY_MAP;
        //TODO Jeff, please review
        Map servletNameToPathMap = buildServletNameToPathMap(webApp, contextRoot);
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

        }
        return map;
    }

    GerWebAppType getTomcatWebApp(Object plan, JarFile moduleFile, boolean standAlone, String targetPath, WebAppType webApp) throws DeploymentException {
        GerWebAppType tomcatWebApp = null;
        try {
            // load the geronimo-web.xml from either the supplied plan or from the earFile
            try {
                if (plan instanceof XmlObject) {
                    tomcatWebApp = (GerWebAppType) SchemaConversionUtils.getNestedObjectAsType((XmlObject) plan,
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

            if (id.endsWith("/")) {
                id = id.substring(0, id.length() - 1);
            }
        }

        GerWebAppType tomcatWebApp = GerWebAppType.Factory.newInstance();

        // set the parentId, configId and context root
        tomcatWebApp.setParentId(defaultParentId.toString());
        if (null != webApp.getId()) {
            id = webApp.getId();
        }
        tomcatWebApp.setConfigId(id);
        tomcatWebApp.setContextRoot("/" + id);
        return tomcatWebApp;
    }
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

            // we have to explicitly add these since we are unpacking the web module
            // and the url class loader will not pick up a manifiest from an unpacked dir
            earContext.addManifestClassPath(warFile, URI.create(module.getTargetPath()));

            // add the dependencies declared in the geronimo-web.xml file
            GerWebAppType tomcatWebApp = (GerWebAppType) module.getVendorDD();
            DependencyType[] dependencies = tomcatWebApp.getDependencyArray();
            ServiceConfigBuilder.addDependencies(earContext, dependencies, repository);
        } catch (IOException e) {
            throw new DeploymentException("Problem deploying war", e);
        } catch (URISyntaxException e) {
            throw new DeploymentException("Could not construct URI for location of war entry", e);
View Full Code Here

Examples of org.apache.geronimo.xbeans.geronimo.web.GerWebAppType

        J2eeContext earJ2eeContext = earContext.getJ2eeContext();
        J2eeContext moduleJ2eeContext = J2eeContextImpl.newModuleContextFromApplication(earJ2eeContext, NameFactory.WEB_MODULE, module.getName());
        WebModule webModule = (WebModule) module;

        WebAppType webApp = (WebAppType) webModule.getSpecDD();
        GerWebAppType tomcatWebApp = (GerWebAppType) webModule.getVendorDD();

        boolean contextPriorityClassLoader = false;
        if (tomcatWebApp != null) {
            contextPriorityClassLoader = Boolean.valueOf(tomcatWebApp.getContextPriorityClassloader()).booleanValue();
        }
        // construct the webClassLoader
        ClassLoader webClassLoader = getWebClassLoader(earContext, webModule, cl, contextPriorityClassLoader);

        if (tomcatWebApp != null) {
            GbeanType[] gbeans = tomcatWebApp.getGbeanArray();
            ServiceConfigBuilder.addGBeans(gbeans, webClassLoader, moduleJ2eeContext, earContext);
        }

        ObjectName webModuleName = null;
        try {
            webModuleName = NameFactory.getModuleName(null, null, null, null, null, moduleJ2eeContext);
        } catch (MalformedObjectNameException e) {
            throw new DeploymentException("Could not construct module name", e);
        }

        UserTransaction userTransaction = new OnlineUserTransaction();
        //this may add to the web classpath with enhanced classes.
        Map compContext = buildComponentContext(earContext, webModule, webApp, tomcatWebApp, userTransaction, webClassLoader);

        GBeanData webModuleData = new GBeanData(webModuleName, TomcatWebAppContext.GBEAN_INFO);
        try {
            webModuleData.setReferencePattern("J2EEServer", earContext.getServerObjectName());
            if (!earContext.getJ2EEApplicationName().equals("null")) {
                webModuleData.setReferencePattern("J2EEApplication", earContext.getApplicationObjectName());
            }

            webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
            Set securityRoles = collectRoleNames(webApp);
            Map rolePermissions = new HashMap();

            URI baseUri = earContext.getTargetFile(URI.create(webModule.getTargetPath() + "/")).toURI();
            webModuleData.setAttribute("webAppRoot", baseUri);
            webModuleData.setAttribute("path", webModule.getContextRoot());

            webModuleData.setAttribute("componentContext", compContext);
            webModuleData.setAttribute("userTransaction", userTransaction);
            //classpath may have been augmented with enhanced classes
            webModuleData.setAttribute("webClassPath", getFinalWebClasspath(webModule));
            // unsharableResources, applicationManagedSecurityResources
            GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
            ENCConfigBuilder.setResourceEnvironment(earContext, webModule.getModuleURI(), rebuilder, webApp.getResourceRefArray(), tomcatWebApp.getResourceRefArray());

            webModuleData.setAttribute("contextPriorityClassLoader", Boolean.valueOf(contextPriorityClassLoader));

            webModuleData.setReferencePattern("transactionContextManager", earContext.getTransactionContextManagerObjectName());
            webModuleData.setReferencePattern("trackedConnectionAssociator", earContext.getConnectionTrackerObjectName());
            webModuleData.setReferencePattern("Container", tomcatContainerObjectName);

            String virtualServer = null;
            // Process the Tomcat container-config elements
            if (tomcatWebApp != null && tomcatWebApp.sizeOfContainerConfigArray() > 0) {
                Map values = new HashMap();
                GerContainerConfigType[] configs = tomcatWebApp.getContainerConfigArray();
                for (int i = 0; i < configs.length; i++) {
                    GerContainerConfigType config = configs[i];
                    if(config.getContainer().intValue() != GerWebContainerType.INT_TOMCAT) {
                        continue;
                    }
                    GerConfigParamType[] params = config.getConfigParamArray();
                    for (int j = 0; j < params.length; j++) {
                        GerConfigParamType param = params[j];
                        values.put(param.getName(), param.getStringValue());
                    }
                }

                //Is there a Tomcat virtual server declaration?
                virtualServer = (String) values.remove("VirtualServer");

                //Is there a Tomcat realm declaration?
                String tomcatRealm = (String) values.remove("TomcatRealm");
                if (tomcatRealm != null) {
                    ObjectName realmName = NameFactory.getComponentName(null, null, null, null, tomcatRealm.trim(), RealmGBean.GBEAN_INFO.getJ2eeType(), moduleJ2eeContext);
                    webModuleData.setReferencePattern("TomcatRealm", realmName);
                }
                //Is there a Tomcat Valve Chain declaration?
                String tomcatValveChain = (String) values.remove("TomcatValveChain");
                if (tomcatValveChain != null) {
                    ObjectName valveName = NameFactory.getComponentName(null, null, null, null, tomcatValveChain.trim(), ValveGBean.J2EE_TYPE, moduleJ2eeContext);
                    //NameFactory.getComponentName(null, null, null, null, tomcatValveChain.trim(), ValveGbean., moduleJ2eeContext);
                    webModuleData.setReferencePattern("TomcatValveChain", valveName);
                }

                // Are there any leftover values?  If so, that's a problem.
                if(values.size() > 0) {
                    StringBuffer msg = new StringBuffer();
                    msg.append("Unexpected container-config/config-params found for Tomcat in web app deployment plan (");
                    boolean first = true;
                    for (Iterator it = values.keySet().iterator(); it.hasNext();) {
                        String value = (String) it.next();
                        if(!first) {
                            msg.append(",");
                        }
                        msg.append(value);
                    }
                    msg.append(")");
                    throw new DeploymentException(msg.toString());
                }
            }


            Map portMap = webModule.getPortMap();

            //Handle the role permissions and webservices on the servlets.
            ServletType[] servletTypes = webApp.getServletArray();
            Map webServices = new HashMap();
            for (int i = 0; i < servletTypes.length; i++) {
                ServletType servletType = servletTypes[i];

                //Handle the Role Ref Permissions
                processRoleRefPermissions(servletType, securityRoles, rolePermissions);

                //Do we have webservices configured?
                if (portMap != null) {
                    //Check if the Servlet is a Webservice
                    String servletName = servletType.getServletName().getStringValue().trim();
                    if (portMap.containsKey(servletName)) {
                        //Yes, this servlet is a web service so let the web service builder
                        // deal with configuring the web service stack
                        String servletClassName = servletType.getServletClass().getStringValue().trim();
                        Object portInfo = portMap.get(servletName);
                        if (portInfo == null) {
                            throw new DeploymentException("No web service deployment info for servlet name " + servletName);
                        }

                        StoredObject wsContainer = configurePOJO(webModule.getModuleFile(), portInfo, servletClassName, webClassLoader);
                        webServices.put(servletName, wsContainer);
                    }
                }
            }
            webModuleData.setAttribute("webServices", webServices);

            if (tomcatWebApp.isSetSecurityRealmName()) {

                SecurityHolder securityHolder = new SecurityHolder();
                String securityRealmName = tomcatWebApp.getSecurityRealmName().trim();

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

                ComponentPermissions componentPermissions = buildSpecSecurityConfig(webApp, securityRoles, rolePermissions);
                securityHolder.setExcluded(componentPermissions.getExcludedPermissions());
                PermissionCollection checkedPermissions = new Permissions();
                for (Iterator iterator = rolePermissions.values().iterator(); iterator.hasNext();) {
                    PermissionCollection permissionsForRole = (PermissionCollection) iterator.next();
                    for (Enumeration iterator2 = permissionsForRole.elements(); iterator2.hasMoreElements();) {
                        Permission permission = (Permission) iterator2.nextElement();
                        checkedPermissions.add(permission);
                    }
                }
                securityHolder.setChecked(checkedPermissions);
                earContext.addSecurityContext(policyContextID, componentPermissions);
                if (tomcatWebApp.isSetSecurity()) {
                    SecurityConfiguration securityConfiguration = SecurityBuilder.buildSecurityConfiguration(tomcatWebApp.getSecurity());
                    earContext.setSecurityConfiguration(securityConfiguration);
                }
                DefaultPrincipal defaultPrincipal = earContext.getSecurityConfiguration().getDefaultPrincipal();
                securityHolder.setDefaultPrincipal(defaultPrincipal);

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.