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();
}
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);
}
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);
}
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);
}
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;
}
Aggregations