Package org.apache.openejb.jee

Examples of org.apache.openejb.jee.WebApp$JAXB


        }
    }

    private WebModule createDummyWebModule(EARContext rootContext) throws Exception {
        WebModule webModule = new WebModule(true, new AbstractName(new URI("test/test/1.0/car?J2EEApplication=null,j2eeType=WebModule,name=test.war")), "test.war", new Environment(), new DeployableBundle(new MockBundle(WebFragmentTest.class.getClassLoader(), "", 1L)), "",
                new WebApp(), null, "", "", "", null, null);
        webModule.setEarContext(new DummyEARContext());
        return webModule;
    }
View Full Code Here


    private boolean referenceNotResolved = false;

    public void parseWebDD(JndiConsumer annotatedWebAppDD, GerWebAppType webApp) {
        if (annotatedWebAppDD instanceof WebApp) {
            WebApp webAppDD = (WebApp) annotatedWebAppDD;
            List<MessageDestination> messageDestinations = webAppDD.getMessageDestination();
            for (MessageDestination messageDestination: messageDestinations) {
                String messageDestinationName = messageDestination.getMessageDestinationName();
                GerMessageDestinationType gerMessageDestination = webApp.addNewMessageDestination();
                messageDestination.setMessageDestinationName(messageDestinationName);
                // messageDestination.setAdminObjectLink(messageDestinationName);
View Full Code Here

            "  <admin-object-link>l2</admin-object-link>" +
            "</message-destination>" +
            "</web-app>";

    public void testMessageDestinations() throws Exception {
        WebApp specDD = load(SPECDD1, WebApp.class);
        XmlObject plan = parse(PLAN1);
        adminObjectRefBuilder.initContext(specDD, plan, module);
        AbstractName n1 = naming.createChildName(baseName, "l1", NameFactory.JCA_ADMIN_OBJECT);
        AbstractName n2 = naming.createChildName(baseName, "l2", NameFactory.JCA_ADMIN_OBJECT);
        configuration.addGBean(new GBeanData(n1, AdminObjectWrapperGBean.class));
View Full Code Here

            "  <admin-object-module>testRoot</admin-object-module>" +
            "  <admin-object-link>l2</admin-object-link>" +
            "</message-destination>" +
            "</tmp>";
    public void testMessageDestinationsWithModule() throws Exception {
        WebApp specDD = load(SPECDD1, WebApp.class);
        XmlObject plan = parse(PLAN2);
        adminObjectRefBuilder.initContext(specDD, plan, module);
        AbstractName n1 = naming.createChildName(baseName, "l1", NameFactory.JCA_ADMIN_OBJECT);
        AbstractName n2 = naming.createChildName(baseName, "l2", NameFactory.JCA_ADMIN_OBJECT);
        configuration.addGBean(new GBeanData(n1, AdminObjectWrapperGBean.class));
View Full Code Here

    private static final String SPECDD2 = "<web-app xmlns=\"http://java.sun.com/xml/ns/j2ee\">" +
            "</web-app>";


    public void testMessageDestinationsMatch() throws Exception {
        WebApp specDD = load(SPECDD2, WebApp.class);
        XmlObject plan = parse(PLAN1);
        try {
            adminObjectRefBuilder.initContext(specDD, plan, module);
            fail("tried to register a GerMessageDestination witout a MessageDestination and it succeeded");
        } catch (DeploymentException e) {
View Full Code Here

    }

    private void discoverPOJOWebServices(WebModule module, Map<String, String> portLocations, Map<String, PortInfo> servletNamePortInfoMap) throws DeploymentException {

        Bundle bundle = module.getEarContext().getDeploymentBundle();
        WebApp webApp = module.getSpecDD();

        Set<String> ignoredEJBWebServiceClassNames = getEJBWebServiceClassNames(module);

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

            List<Servlet> servletTypes = webApp.getServlet();
            for (Servlet servletType : servletTypes) {
                String servletName = servletType.getServletName().trim();
                PortInfo portInfo = getPortInfo(servletType, bundle, portLocations);
                if (portInfo != null) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Found POJO Web Service: {}", servletName);
                    }
                    servletNamePortInfoMap.put(servletName, portInfo);
                }
            }

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

            Map<String, List<String>> classServletMap = createClassServetMap(webApp);
            List<Class<?>> services = discoverWebServices(module);
            String contextRoot = (module).getContextRoot();
            for (Class<?> service : services) {
                // skip interfaces and such
                if (!JAXWSUtils.isWebService(service)) {
                    continue;
                }

                if (ignoredEJBWebServiceClassNames.contains(service.getName())) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Web service " + service.getClass().getName() + "  is ignored as it is also an EJB, it will exposed as an EJB Web Service ");
                    }
                    continue;
                }

                if (LOG.isDebugEnabled()) {
                    LOG.debug("Discovered POJO Web Service class: {}", service.getName());
                }
                List<String> mappedServlets = classServletMap.get(service.getName());
                if (mappedServlets == null) {
                    // no <servlet/> entry, add one
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("POJO Web Service class {} is not mapped to any servlet", service.getName());
                    }
                    Servlet servlet = new Servlet();
                    servlet.setServletName(service.getName());
                    servlet.setServletClass(service.getName());
                    webApp.getServlet().add(servlet);

                    String location = portLocations.get(service.getName());
                    if (location == null) {
                        // add new <servlet-mapping/> element
                        location = "/" + JAXWSUtils.getServiceName(service);
                        ServletMapping servletMapping = new ServletMapping();
                        servletMapping.setServletName(service.getName());
                        servletMapping.getUrlPattern().add(location);
                        webApp.getServletMapping().add(servletMapping);
                    } 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", location, service.getName());
                    }

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

            // double check servlets in case we missed something
            List<Servlet> servletTypes = webApp.getServlet();
            for (Servlet servletType : servletTypes) {
                String servletName = servletType.getServletName().trim();
                if (servletNamePortInfoMap.get(servletName) == null) {
                    PortInfo portInfo = getPortInfo(servletType, bundle, portLocations);
                    if (portInfo != null) {
View Full Code Here

    public Object getValue(XmlObject xmlObject, XmlObject enclosing, String s, Bundle bundle) throws DeploymentException {
        try {
            XMLStreamReader reader = enclosing.newXMLStreamReader();
            while (reader.hasNext() && reader.next() != 1);
            if (s.endsWith("WebAppInfo")) {
                WebApp webApp = (WebApp) unmarshalJavaee(WebApp.class, reader);
                return new WebAppInfoBuilder(webApp, new DefaultWebAppInfoFactory()).build();
            }
            throw new DeploymentException("Unrecognized xml: " + enclosing.xmlText());
        } catch (XMLStreamException e) {
            throw new DeploymentException("xml problem", e);
View Full Code Here

        Collection<String> moduleLocations = EARContext.MODULE_LIST_KEY.get(webModule.getRootEarContext().getGeneralData());
        URI baseUri = URI.create(webModule.getTargetPath());
        URI resolutionUri = invertURI(baseUri);
        earContext.getCompleteManifestClassPath(webModule.getDeployable(), baseUri, resolutionUri, manifestcp, moduleLocations);
        //Security Configuration Validation
        WebApp webApp = webModule.getSpecDD();
        boolean hasSecurityRealmName = (Boolean) webModule.getEarContext().getGeneralData().get(WEB_MODULE_HAS_SECURITY_REALM);
        if ((!webApp.getSecurityConstraint().isEmpty() || !webApp.getSecurityRole().isEmpty())) {
            if (!hasSecurityRealmName) {
                throw new DeploymentException("web.xml for web app " + webModule.getName()
                        + " includes security elements but Geronimo deployment plan is not provided or does not contain <security-realm-name> element necessary to configure security accordingly.");
            }
        }
        if (hasSecurityRealmName) {
            earContext.setHasSecurity(true);
        }

      //Inform errors if login-config element contains more than one
        List<LoginConfig> loginConfigs = webApp.getLoginConfig();
        if (loginConfigs.size() > 1) {
            throw new DeploymentException("Web app " + webApp.getDisplayName() + " cannot have more than one login-config element.  Currently has " + loginConfigs.size() + " login-config elements.");
        }

       //Inform errors if session-config element contains more than one
        List<SessionConfig> sessionConfigs = webApp.getSessionConfig();
        if (sessionConfigs.size() > 1) {
            throw new DeploymentException("Web app " + webApp.getDisplayName() + " cannot have more than one sesion-config element.  Currently has " + sessionConfigs.size() + " session-config elements.");
        }

        //TODO think about how to provide a default security realm name
        XmlObject[] securityElements = XmlBeansUtil.selectSubstitutionGroupElements(SECURITY_QNAME, gerWebApp);
        if (securityElements.length > 0 && !hasSecurityRealmName) {
            throw new DeploymentException("You have supplied a security configuration for web app " + webModule.getName() + " but no security-realm-name to allow login");
        }

        //Process Naming
        getNamingBuilders().buildEnvironment(webApp, webModule.getVendorDD(), webModule.getEnvironment());
        getNamingBuilders().initContext(webApp, gerWebApp, webModule);

        float originalSpecDDVersion;
        String originalSpecDD = webModule.getOriginalSpecDD();
        if (originalSpecDD == null) {
            originalSpecDDVersion = 3.0f;
        } else {
            originalSpecDDVersion = identifySpecDDSchemaVersion(originalSpecDD);
        }
        webModule.getEarContext().getGeneralData().put(INITIAL_WEB_XML_SCHEMA_VERSION, originalSpecDDVersion);
        //Process web fragments and annotations
        if (INITIAL_WEB_XML_SCHEMA_VERSION.get(webModule.getEarContext().getGeneralData()) >= 2.5f && !webApp.isMetadataComplete()) {
            MergeHelper.processWebFragmentsAndAnnotations(earContext, webModule, bundle, webApp);
        }
        MergeHelper.processServletContainerInitializer(earContext, webModule, bundle);
        serviceBuilders.build(gerWebApp, earContext, webModule.getEarContext());
    }
View Full Code Here

    public Map<String, PortInfo> discoverWebServices(WebModule module, Map<String, String> correctedPortLocations) throws DeploymentException {

        Map<String, PortInfo> servletNamePortInfoMap = new HashMap<String, PortInfo>();

        Bundle bundle = module.getEarContext().getDeploymentBundle();
        WebApp webApp = module.getSpecDD();

        // find web services
        List<Servlet> servletTypes = webApp.getServlet();
        Set<String> ignoredEJBWebServiceClassNames = getEJBWebServiceClassNames(module);

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

                if (ignoredEJBWebServiceClassNames.contains(service.getName())) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Web service " + service.getClass().getName() + "  is ignored as it is also an EJB, it will exposed as an EJB Web Service ");
                    }
                    continue;
                }

                if (LOG.isDebugEnabled()) {
                    LOG.debug("Discovered POJO Web Service: " + service.getName());
                }
                // add new <servlet/> element
                Servlet servlet = new Servlet();
                servlet.setServletName(service.getName());
                servlet.setServletClass(service.getName());
                webApp.getServlet().add(servlet);
                // add new <servlet-mapping/> element
                String location = "/" + JAXWSUtils.getServiceName(service);
                ServletMapping servletMapping = new ServletMapping();
                servletMapping.setServletName(service.getName());
                servletMapping.getUrlPattern().add(location);
View Full Code Here

            // not for us
            return null;
        }

        String specDD = null;
        WebApp webApp = null;

        URL specDDUrl = BundleUtils.getEntry(bundle, "WEB-INF/web.xml");
        if (specDDUrl == null) {
            webApp = new WebApp();
        } else {
            try {
                specDD = JarUtils.readAll(specDDUrl);

                InputStream in = specDDUrl.openStream();
                try {
                    webApp = (WebApp) JaxbJavaee.unmarshalJavaee(WebApp.class, in);
                } finally {
                    in.close();
                }

            } 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
        TomcatWebAppType tomcatWebApp = getTomcatWebApp(null, deployable, standAlone, targetPath, webApp);

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

        if (webApp.getDistributable().size() == 1) {
            clusteringBuilders.buildEnvironment(tomcatWebApp, environment);
        }

        idBuilder.resolve(environment, bundle.getSymbolicName(), "wab");

        AbstractName moduleName;
        if (earName == null) {
            earName = naming.createRootName(environment.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
            moduleName = naming.createChildName(earName, environment.getConfigId().toString(), NameFactory.WEB_MODULE);
        } else {
            moduleName = naming.createChildName(earName, targetPath, NameFactory.WEB_MODULE);
        }

        String name = webApp.getModuleName();
        if (name == null) {
            name = bundle.getSymbolicName();
        }

        WebModule module = new WebModule(standAlone, moduleName, name, environment, deployable, targetPath, webApp, tomcatWebApp, specDD, contextPath, TOMCAT_NAMESPACE, shareJndi(null), null);
View Full Code Here

TOP

Related Classes of org.apache.openejb.jee.WebApp$JAXB

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.