Package org.apache.pluto.descriptors.services.castor

Examples of org.apache.pluto.descriptors.services.castor.WebAppDescriptorServiceImpl


                dispatchServletClass.length() == 0 ||
                dispatchServletClass.trim().length() == 0) {
            dispatchServletClass = Assembler.DISPATCH_SERVLET_CLASS;
        }

      WebAppDescriptorService descriptorSvc = new WebAppDescriptorServiceImpl()
      PortletAppDescriptorService portletAppDescriptorSvc = new PortletAppDescriptorServiceImpl();
       
        WebAppDD webAppDDIn = descriptorSvc.read(webXmlIn);
        PortletAppDD portletAppDD = portletAppDescriptorSvc.read(portletXmlIn);
        portletXmlIn.close();

        for (Iterator it = portletAppDD.getPortlets().iterator();
                it.hasNext(); ) {

            // Read portlet definition.
            PortletDD portlet = (PortletDD) it.next();
            String name = portlet.getPortletName();

            ServletDD servlet = new ServletDD();
            servlet.setServletName(name);

            servlet.setServletClass(dispatchServletClass);

            InitParamDD initParam = new InitParamDD();
            initParam.setParamName("portlet-name");
            initParam.setParamValue(name);
            servlet.getInitParams().add(initParam);

            LoadOnStartupDD onStartup = new LoadOnStartupDD();
            onStartup.setPriority(1);
            servlet.setLoadOnStartup(onStartup);

            ServletMappingDD servletMapping = new ServletMappingDD();
            servletMapping.setServletName(name);
            servletMapping.setUrlPattern("/PlutoInvoker/" + name);

            webAppDDIn.getServlets().add(servlet);
            webAppDDIn.getServletMappings().add(servletMapping);

        }

        descriptorSvc.write(webAppDDIn, assembledWebXmlOut);
       
    }
View Full Code Here


    protected void validateEarAssembly( File earFile ) throws Exception {
        assertTrue( "EAR archive [" + earFile.getAbsolutePath() + "] cannot be found or cannot be read",
                earFile.exists() && earFile.canRead() );
       
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
        PortletAppDD portletAppDD = null;
        WebAppDD webAppDD = null;
       
        int earEntryCount = 0;
        int warEntryCount = 0;
       
        JarInputStream earIn = new JarInputStream( new FileInputStream( earFile ) );
       
        JarEntry earEntry;
        JarEntry warEntry;
       
        while ( ( earEntry = earIn.getNextJarEntry() ) != null ) {
            earEntryCount++;
            if ( earEntry.getName().endsWith( ".war" ) ) {
                warEntryCount++;
                JarInputStream warIn = new JarInputStream( earIn );
                while ( ( warEntry = warIn.getNextJarEntry() ) != null ) {
                    if ( Assembler.PORTLET_XML.equals( warEntry.getName() ) ) {
                        portletAppDD = portletSvc.read(
                                new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                    if ( Assembler.SERVLET_XML.equals( warEntry.getName() ) ) {
                        webAppDD = webSvc.read(
                                new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                }               
            }
        }
View Full Code Here

    protected void validateEarAssembly( File earFile ) throws Exception {
        assertTrue( "EAR archive [" + earFile.getAbsolutePath() + "] cannot be found or cannot be read",
                earFile.exists() && earFile.canRead() );
       
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
        PortletAppDD portletAppDD = null;
        WebAppDD webAppDD = null;
       
        List portletWarEntries = Arrays.asList( testWarEntryNames );
        List unassembledWarEntries = Arrays.asList( unassembledWarEntryName );
        List testPortlets = Arrays.asList( testPortletNames );
       
        int earEntryCount = 0;
        int totalWarEntryCount = 0;
        int portletWarEntryCount = 0;
       
        JarInputStream earIn = new JarInputStream( new FileInputStream( earFile ) );
       
        JarEntry earEntry;
        JarEntry warEntry;
       
       
        while ( ( earEntry = earIn.getNextJarEntry() ) != null ) {           
            earEntryCount++;
           
            if ( earEntry.getName().endsWith( ".war" ) ) {
                totalWarEntryCount++;
                JarInputStream warIn = new JarInputStream( earIn );
               
                while ( ( warEntry = warIn.getNextJarEntry() ) != null ) {
                    if ( Assembler.PORTLET_XML.equals( warEntry.getName() ) ) {
                        portletAppDD = portletSvc.read(
                                new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                    if ( Assembler.SERVLET_XML.equals( warEntry.getName() ) ) {
                        webAppDD = webSvc.read(
                                new ByteArrayInputStream( IOUtils.toByteArray( warIn ) ) );
                    }
                }
               
                if ( portletWarEntries.contains( earEntry.getName() ) ) {
View Full Code Here

                getClass().getResourceAsStream( portletXmlResource ) );
        assembledWebXml.delete();
    }
   
    protected void verifyAssembly( InputStream webXml, InputStream portletXml ) throws Exception {
        WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        WebAppDD webApp = webSvc.read( webXml ) ;
        PortletAppDD portletApp = portletSvc.read( portletXml );
       
        assertNotNull( "Web Application Descripter was null.", webApp );
        assertNotNull( "Portlet Application Descriptor was null.", portletApp );
        assertTrue( "Portlet Application Descriptor doesn't define any portlets.", portletApp.getPortlets().size() > 0 );
View Full Code Here

        assertNotNull( "Unable to retrieve portlet dispatch for portlet named [" + testPortletName + "]", servlet );       
        assertEquals( "Dispatcher servlet incorrect for test portlet [" + testPortletName + "]",  Assembler.DISPATCH_SERVLET_CLASS, servlet.getServletClass() );       
    }

    protected void verifyAssembly( File warFile ) throws Exception {
        WebAppDescriptorService webSvc = new WebAppDescriptorServiceImpl();
        PortletAppDescriptorService portletSvc = new PortletAppDescriptorServiceImpl();
        int entryCount = 0;
        ByteArrayOutputStream portletXmlBytes = new ByteArrayOutputStream();
        ByteArrayOutputStream webXmlBytes = new ByteArrayOutputStream();
        WebAppDD webApp = null;
        PortletAppDD portletApp = null;       
               
        JarInputStream assembledWarIn = new JarInputStream( new FileInputStream( warFile ) );
        JarEntry tempEntry;
       
        while ( ( tempEntry = assembledWarIn.getNextJarEntry() ) != null  ) {
            entryCount++;
           
            if ( Assembler.PORTLET_XML.equals( tempEntry.getName() ) ) {
                IOUtils.copy( assembledWarIn, portletXmlBytes );
                portletApp = portletSvc.read( new ByteArrayInputStream( portletXmlBytes.toByteArray() ) );
            }
            if ( Assembler.SERVLET_XML.equals( tempEntry.getName() ) ) {
                IOUtils.copy( assembledWarIn, webXmlBytes );
                webApp = webSvc.read( new ByteArrayInputStream( webXmlBytes.toByteArray() ) );
            }
        }
       
        assertTrue( "Assembled WAR file was empty.", entryCount > 0 );
        assertNotNull( "Web Application Descripter was null.", webApp );
View Full Code Here

            dispatchServletClass.length() == 0 ||
            dispatchServletClass.trim().length() == 0) {
            dispatchServletClass = DISPATCH_SERVLET_CLASS;
        }
       
        WebAppDescriptorService descriptorSvc = new WebAppDescriptorServiceImpl();
        WebAppDD webAppDDIn = descriptorSvc.read(webXmlIn);

        PortletAppDescriptorService portletAppDescriptorService =
                new PortletAppDescriptorServiceImpl();
        PortletAppDD portletAppDD = portletAppDescriptorService.read(portletXmlIn);
        portletXmlIn.close();
       
        for (Iterator it = portletAppDD.getPortlets().iterator();
                it.hasNext(); ) {
           
            // Read portlet definition.
            PortletDD portlet = (PortletDD) it.next();
            String name = portlet.getPortletName();

            ServletDD servlet = new ServletDD();
            servlet.setServletName(name);
    
            servlet.setServletClass(dispatchServletClass);

            InitParamDD initParam = new InitParamDD();
            initParam.setParamName("portlet-name");
            initParam.setParamValue(name);
            servlet.getInitParams().add(initParam);
           
            LoadOnStartupDD onStartup = new LoadOnStartupDD();
            onStartup.setPriority(1);
            servlet.setLoadOnStartup(onStartup);

            ServletMappingDD servletMapping = new ServletMappingDD();
            servletMapping.setServletName(name);
            servletMapping.setUrlPattern("/PlutoInvoker/" + name);

            webAppDDIn.getServlets().add(servlet);
            webAppDDIn.getServletMappings().add(servletMapping);
           
        }
       
        descriptorSvc.write(webAppDDIn, webXmlOut);
    }
View Full Code Here

            dispatchServletClass.length() == 0 ||
            dispatchServletClass.trim().length() == 0) {
            dispatchServletClass = DISPATCH_SERVLET_CLASS;
        }

        WebAppDescriptorService descriptorSvc = new WebAppDescriptorServiceImpl();
        WebAppDD webAppDDIn = descriptorSvc.read(webXmlIn);

        PortletAppDescriptorService portletAppDescriptorService =
                new PortletAppDescriptorServiceImpl();
        PortletAppDD portletAppDD = portletAppDescriptorService.read(portletXmlIn);
        portletXmlIn.close();

        for (Iterator it = portletAppDD.getPortlets().iterator();
                it.hasNext(); ) {

            // Read portlet definition.
            PortletDD portlet = (PortletDD) it.next();
            String name = portlet.getPortletName();

            ServletDD servlet = new ServletDD();
            servlet.setServletName(name);

            servlet.setServletClass(dispatchServletClass);

            InitParamDD initParam = new InitParamDD();
            initParam.setParamName("portlet-name");
            initParam.setParamValue(name);
            servlet.getInitParams().add(initParam);

            LoadOnStartupDD onStartup = new LoadOnStartupDD();
            onStartup.setPriority(1);
            servlet.setLoadOnStartup(onStartup);

            ServletMappingDD servletMapping = new ServletMappingDD();
            servletMapping.setServletName(name);
            servletMapping.setUrlPattern("/PlutoInvoker/" + name);

            webAppDDIn.getServlets().add(servlet);
            webAppDDIn.getServletMappings().add(servletMapping);

        }

        descriptorSvc.write(webAppDDIn, webXmlOut);
    }
View Full Code Here

TOP

Related Classes of org.apache.pluto.descriptors.services.castor.WebAppDescriptorServiceImpl

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.