Search in sources :

Example 36 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class SecurityDeployer method load.

@Override
public DummyApplication load(SecurityContainer container, DeploymentContext context) {
    DeployCommandParameters dparams = context.getCommandParameters(DeployCommandParameters.class);
    Application app = context.getModuleMetaData(Application.class);
    handleCNonceCacheBSInit(app.getAppName(), app.getBundleDescriptors(WebBundleDescriptor.class), dparams.availabilityenabled);
    return new DummyApplication();
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) DummyApplication(org.glassfish.deployment.common.DummyApplication) DummyApplication(org.glassfish.deployment.common.DummyApplication) Application(com.sun.enterprise.deployment.Application)

Example 37 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class WebAllTest method testWeb.

@Test
public void testWeb() throws Exception {
    System.out.println("Starting Web " + server);
    ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
    System.out.println("builder is " + b);
    server.addContainer(b);
    EmbeddedDeployer deployer = server.getDeployer();
    System.out.println("Added Web");
    String p = System.getProperty("buildDir");
    System.out.println("Root is " + p);
    ScatteredArchive.Builder builder = new ScatteredArchive.Builder("sampleweb", new File(p));
    builder.resources(new File(p));
    builder.addClassPath((new File(p)).toURL());
    DeployCommandParameters dp = new DeployCommandParameters(new File(p));
    System.out.println("Deploying " + p);
    String appName = deployer.deploy(builder.buildWar(), dp);
    Assert.assertNotNull("Deployment failed!", appName);
    URL servlet = new URL("http://localhost:8080/classes/hello");
    URLConnection yc = servlet.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
    StringBuilder sb = new StringBuilder();
    String inputLine;
    while ((inputLine = in.readLine()) != null) {
        sb.append(inputLine);
    }
    in.close();
    System.out.println(inputLine);
    Assert.assertEquals("Hello World!", sb.toString());
    deployer.undeploy(appName, null);
}
Also used : InputStreamReader(java.io.InputStreamReader) URL(java.net.URL) URLConnection(java.net.URLConnection) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) BufferedReader(java.io.BufferedReader) File(java.io.File) Test(org.junit.Test)

Example 38 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class EmbeddedTest method testWeb.

@Test
public void testWeb() throws Exception {
    System.out.println("Starting Web " + server);
    ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
    System.out.println("builder is " + b);
    server.addContainer(b);
    EmbeddedDeployer deployer = server.getDeployer();
    System.out.println("Added Web");
    String testClass = "org/glassfish/tests/embedded/webwar/EmbeddedTest.class";
    URL source = this.getClass().getClassLoader().getResource(testClass);
    String p = source.getPath().substring(0, source.getPath().length() - testClass.length()) + "../../../war/target/test-war.war";
    System.out.println("Root is " + p);
    DeployCommandParameters dp = new DeployCommandParameters(new File(p));
    System.out.println("Deploying " + p);
    String appName = null;
    try {
        appName = deployer.deploy(new File(p), dp);
        System.out.println("Deployed " + appName);
        Assert.assertTrue(appName != null);
        try {
            URL servlet = new URL("http://localhost:8080/test-war/");
            URLConnection yc = servlet.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
            String inputLine = in.readLine();
            if (inputLine != null)
                System.out.println(inputLine);
            Assert.assertEquals(inputLine.trim(), "filterMessage=213");
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
    if (appName != null)
        deployer.undeploy(appName, null);
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) EmbeddedDeployer(org.glassfish.internal.embedded.EmbeddedDeployer) ContainerBuilder(org.glassfish.internal.embedded.ContainerBuilder) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) File(java.io.File) URL(java.net.URL) URLConnection(java.net.URLConnection) NamingException(javax.naming.NamingException) LifecycleException(org.glassfish.internal.embedded.LifecycleException) IOException(java.io.IOException) Test(org.junit.Test)

Example 39 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class ExistingDomainTest method testWeb.

// @Test
public void testWeb() throws Exception {
    System.out.println("test web");
    File f = new File(System.getProperty("basedir"));
    f = new File(f, "target");
    f = new File(f, "test-classes");
    ScatteredArchive.Builder builder = new ScatteredArchive.Builder("hello", f);
    builder.addClassPath(f.toURI().toURL());
    builder.resources(f);
    server.createPort(8080);
    server.addContainer(server.createConfig(ContainerBuilder.Type.web));
    DeployCommandParameters dp = new DeployCommandParameters(f);
    ScatteredArchive war = builder.buildWar();
    System.out.println("War content");
    Enumeration<String> contents = war.entries();
    while (contents.hasMoreElements()) {
        System.out.println(contents.nextElement());
    }
    String appName = server.getDeployer().deploy(builder.buildWar(), dp);
    server.getDeployer().undeploy(appName, null);
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) File(java.io.File)

Example 40 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class DescriptorFactory method createApplicationDescriptor.

/**
 * Returns the parsed DOL object from archive
 *
 * @param archiveFile original archive file
 * @param destRootDir root destination directory where the application
 *        should be expanded under in case of archive deployment
 * @param parentCl parent classloader
 *
 * @return the parsed DOL object
 */
public ResultHolder createApplicationDescriptor(File archiveFile, File destRootDir, ClassLoader parentCl) throws IOException {
    ReadableArchive archive = null;
    Application application = null;
    try {
        Descriptor.setBoundsChecking(false);
        archive = archiveFactory.openArchive(archiveFile);
        ArchiveHandler archiveHandler = deployment.getArchiveHandler(archive);
        ActionReport dummyReport = new HTMLActionReporter();
        String appName = DeploymentUtils.getDefaultEEName(archiveFile.getName());
        DeployCommandParameters params = new DeployCommandParameters();
        params.name = appName;
        ExtendedDeploymentContext context = new DeploymentContextImpl(dummyReport, archive, params, env);
        context.setArchiveHandler(archiveHandler);
        if (!archiveFile.isDirectory()) {
            // expand archive
            File destDir = new File(destRootDir, appName);
            if (destDir.exists()) {
                FileUtils.whack(destDir);
            }
            destDir.mkdirs();
            archiveHandler.expand(archive, archiveFactory.createArchive(destDir), context);
            archive.close();
            archive = archiveFactory.openArchive(destDir);
            context.setSource(archive);
        }
        // issue 14564
        context.addTransientAppMetaData(ExtendedDeploymentContext.IS_TEMP_CLASSLOADER, Boolean.TRUE);
        String archiveType = context.getArchiveHandler().getArchiveType();
        ClassLoader cl = archiveHandler.getClassLoader(parentCl, context);
        Archivist archivist = archivistFactory.getArchivist(archiveType, cl);
        if (archivist == null) {
            throw new IOException("Cannot determine the Java EE module type for " + archive.getURI());
        }
        archivist.setAnnotationProcessingRequested(true);
        String xmlValidationLevel = dasConfig.getDeployXmlValidation();
        archivist.setXMLValidationLevel(xmlValidationLevel);
        if (xmlValidationLevel.equals("none")) {
            archivist.setXMLValidation(false);
        }
        archivist.setRuntimeXMLValidation(false);
        try {
            application = applicationFactory.openArchive(appName, archivist, archive, true);
        } catch (SAXParseException e) {
            throw new IOException(e);
        }
        if (application != null) {
            application.setClassLoader(cl);
            application.visit((ApplicationVisitor) new ApplicationValidator());
        }
    } finally {
        if (archive != null) {
            archive.close();
        }
        // We need to reset it after descriptor building
        Descriptor.setBoundsChecking(true);
    }
    ResultHolder result = new ResultHolder();
    result.application = application;
    result.archive = archive;
    return result;
}
Also used : ArchiveHandler(org.glassfish.api.deployment.archive.ArchiveHandler) Archivist(com.sun.enterprise.deployment.archivist.Archivist) IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) DeploymentContextImpl(org.glassfish.deployment.common.DeploymentContextImpl) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) ApplicationValidator(com.sun.enterprise.deployment.util.ApplicationValidator) SAXParseException(org.xml.sax.SAXParseException) HTMLActionReporter(com.sun.enterprise.v3.common.HTMLActionReporter) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) Application(com.sun.enterprise.deployment.Application) File(java.io.File)

Aggregations

DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)69 IOException (java.io.IOException)25 File (java.io.File)24 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)24 ActionReport (org.glassfish.api.ActionReport)23 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)16 Application (com.sun.enterprise.deployment.Application)14 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)13 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)13 Logger (java.util.logging.Logger)12 Properties (java.util.Properties)10 DeploymentContextImpl (org.glassfish.deployment.common.DeploymentContextImpl)10 DeploymentException (org.glassfish.deployment.common.DeploymentException)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)9 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)9 Deployment (org.glassfish.internal.deployment.Deployment)9 PropertyVetoException (java.beans.PropertyVetoException)8 URI (java.net.URI)8 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)8