Package org.glassfish.embeddable.archive

Examples of org.glassfish.embeddable.archive.ScatteredArchive


                  
                     // Create a scattered web application.
                     //ScatteredArchive archive = new ScatteredArchive("testapp", ScatteredArchive.Type.WAR);
                     //use global variable
                     //warArchive = new ScatteredArchive(baseUri.getRawPath()+File.separator+ SRC_WEBAPP_PATH+File.separator+"myWarArchive", ScatteredArchive.Type.WAR);
                     warArchive = new ScatteredArchive(baseUri.getRawPath(), ScatteredArchive.Type.WAR);


                     // required if exist already //The name for this metadata will be obtained by doing metadata.getName()
                    try {
                        warArchive.addMetadata(new File(SRC_WEBAPP_PATH+ "/"  + WEB_INF_PATH + "/", WEB_XML));
                    } catch (java.io.IOException ioe) {
                        LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SRC_WEBAPP_PATH+ "/"  + WEB_INF_PATH + "/" + WEB_XML + "]");
                        throw new TestContainerException(ioe);
                    }

                    //The name for this metadata will be obtained by doing metadata.getName()
                    //scatteredArchiveBuilder.addMetadata(new File(SRC_WEBAPP_PATH + "/"  + WEB_INF_PATH + "/" + SUN_WEB_XML));
                    // resources/sun-web.xml is my WEB-INF/sun-web.xml
                    //archive.addMetadata(new File("resources", "sun-web.xml"));
                    try {
                        warArchive.addMetadata(new File(SRC_WEBAPP_PATH+ "/"  + WEB_INF_PATH + "/", SUN_WEB_XML));
                    } catch (java.io.IOException ioe) {
                        LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SUN_WEB_XML + "]");
                        throw new TestContainerException(ioe);
                    }
                    // target/classes directory contains my complied servlets
                    //archive.addClassPath(new File("target", "classes"));
                    try {
                        warArchive.addClassPath(new File(TARGET_PATH, CLASSES_PATH));
                    } catch (java.io.IOException ioe) {
                        LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addClassPath [" + TARGET_PATH +"/"+ CLASSES_PATH+ "]");
                        throw new TestContainerException(ioe);
                    }
                    // resources/MyLogFactory is my META-INF/services/org.apache.commons.logging.LogFactory
                    //archive.addMetadata(new File("resources", "MyLogFactory"),
                    //"META-INF/services/org.apache.commons.logging.LogFactory");
                    LOGGER.info("#1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
                    System.out.println("jsb, #1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
                } catch (Exception ex) {
                    throw new TestContainerException(ex);
                }
            } else {
                try {                 
                    LOGGER.info("#2 inside method createArchive ==> webXmlGeneratedOnTheFly ==> Creating scatteredArchive [" + TARGET_WEBAPP_PATH + "]");
                    //use global variable
                    //warArchive = new ScatteredArchive(baseUri.getRawPath()+File.separator+TARGET_WEBAPP_PATH+File.separator+"myWarArchive", ScatteredArchive.Type.WAR);
                    warArchive = new ScatteredArchive(baseUri.getRawPath(), ScatteredArchive.Type.WAR);

                    //The name for this metadata will be obtained by doing metadata.getName()
                    try {
                        warArchive.addMetadata(new File(TARGET_WEBAPP_PATH+ "/"  + WEB_INF_PATH + "/", WEB_XML));
                    } catch (java.io.IOException ioe) {
View Full Code Here


            } else if(DeploymentElement.countEJBModules(modules) == 1 && DeploymentElement.hasWar(modules)) {
                // A WAR file with an EJB
                result = DeploymentElement.getWar(modules).getElement();
            } else {
                // EJB molule with libraries - create ScatteredArchive
                ScatteredArchive sa = null;
                for (DeploymentElement m : modules) {
                    if (m.isEJBModule) {
                        // XXX Work around GLASSFISH-16618
                        // The name was already calculated when DeploymentElement was created
                        sa = new ScatteredArchive(m.mname, ScatteredArchive.Type.JAR);
                        if (_logger.isLoggable(Level.INFO)) {
                            _logger.info("[DeploymentElement] adding EJB module to ScatteredArchive " + m.mname);
                        }
                        sa.addClassPath(m.element);
                        break;
                    }
                }

                if (sa != null) {
                    for (DeploymentElement m : modules) {
                        if (!m.isEJBModule) {
                            if (_logger.isLoggable(Level.INFO)) {
                                _logger.info("[DeploymentElement] adding library to ScatteredArchive " + m.element.getName());
                            }
       
                            sa.addClassPath(m.element);
                        }
                    }
                    result = sa;
                }
            }
View Full Code Here

                // Create a scattered web application.
                //ScatteredArchive archive = new ScatteredArchive("testapp", ScatteredArchive.Type.WAR);
                //use global variable
                //warArchive = new ScatteredArchive(baseUri.getRawPath()+File.separator+ SRC_WEBAPP_PATH+File.separator+"myWarArchive", ScatteredArchive.Type.WAR);
                warArchive = new ScatteredArchive(BASE_URI.getRawPath(), ScatteredArchive.Type.WAR);


                // required if exist already //The name for this metadata will be obtained by doing metadata.getName()
                try {
                    warArchive.addMetadata(new File(SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", WEB_XML));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/" + WEB_XML + "]");
                    throw new TestContainerException(ioe);
                }

                //The name for this metadata will be obtained by doing metadata.getName()
                //scatteredArchiveBuilder.addMetadata(new File(SRC_WEBAPP_PATH + "/"  + WEB_INF_PATH + "/" + SUN_WEB_XML));
                // resources/sun-web.xml is my WEB-INF/sun-web.xml
                //archive.addMetadata(new File("resources", "sun-web.xml"));
                try {
                    warArchive.addMetadata(new File(SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", SUN_WEB_XML));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SUN_WEB_XML + "]");
                    throw new TestContainerException(ioe);
                }
                // target/classes directory contains my complied servlets
                //archive.addClassPath(new File("target", "classes"));
                try {
                    warArchive.addClassPath(new File(TARGET_PATH, CLASSES_PATH));
                } catch (java.io.IOException ioe) {
                    LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addClassPath [" + TARGET_PATH + "/" + CLASSES_PATH + "]");
                    throw new TestContainerException(ioe);
                }
                // resources/MyLogFactory is my META-INF/services/org.apache.commons.logging.LogFactory
                //archive.addMetadata(new File("resources", "MyLogFactory"),
                //"META-INF/services/org.apache.commons.logging.LogFactory");
                LOGGER.info("#1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
                System.out.println("jsb, #1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
            } catch (Exception ex) {
                throw new TestContainerException(ex);
            }
        } else {
            try {
                LOGGER.info("#2 inside method createArchive ==> webXmlGeneratedOnTheFly ==> Creating scatteredArchive [" + TARGET_WEBAPP_PATH + "]");
                //use global variable
                //warArchive = new ScatteredArchive(baseUri.getRawPath()+File.separator+TARGET_WEBAPP_PATH+File.separator+"myWarArchive", ScatteredArchive.Type.WAR);
                warArchive = new ScatteredArchive(BASE_URI.getRawPath(), ScatteredArchive.Type.WAR);

                //The name for this metadata will be obtained by doing metadata.getName()
                try {
                    warArchive.addMetadata(new File(TARGET_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", WEB_XML));
                } catch (java.io.IOException ioe) {
View Full Code Here

TOP

Related Classes of org.glassfish.embeddable.archive.ScatteredArchive

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.