use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class InplantedTest 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);
ScatteredArchive war = builder.buildWar();
System.out.println("War content");
Enumeration<String> contents = war.entries();
while (contents.hasMoreElements()) {
System.out.println(contents.nextElement());
}
try {
System.out.println("Port created " + server.createPort(14587));
server.addContainer(ContainerBuilder.Type.web);
server.start();
DeployCommandParameters dp = new DeployCommandParameters(f);
String appName = server.getDeployer().deploy(war, dp);
System.out.println("Application deployed under name = " + appName);
if (appName != null) {
server.getDeployer().undeploy(appName, null);
}
} catch (IOException e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
} catch (LifecycleException e) {
// To change body of catch statement use File | Settings | File Templates.
e.printStackTrace();
}
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class InplantedTest 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);
ScatteredArchive war = builder.buildWar();
System.out.println("War content");
Enumeration<String> contents = war.entries();
while (contents.hasMoreElements()) {
System.out.println(contents.nextElement());
}
Port http = server.createPort(8080);
ContainerBuilder b = server.createConfig(ContainerBuilder.Type.web);
server.addContainer(b);
EmbeddedWebContainer embedded = (EmbeddedWebContainer) b.create(server);
embedded.bind(http, "http");
DeployCommandParameters dp = new DeployCommandParameters(f);
String appName = server.getDeployer().deploy(war, dp);
WebClient webClient = new WebClient();
Page page = webClient.getPage("http://localhost:8080/test-classes/hello");
System.out.println("Got response " + page.getWebResponse().getContentAsString());
Assert.assertTrue("Servlet returned wrong content", page.getWebResponse().getContentAsString().startsWith("Hello World"));
server.getDeployer().undeploy(appName, null);
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ResourceValidator method loadOnCurrentInstance.
/**
* Copy from ApplicationLifeCycle.java
*/
private boolean loadOnCurrentInstance() {
final DeployCommandParameters commandParams = dc.getCommandParameters(DeployCommandParameters.class);
final Properties appProps = dc.getAppProps();
if (commandParams.enabled) {
// if the current instance match with the target
if (domain.isCurrentInstanceMatchingTarget(commandParams.target, commandParams.name(), server.getName(), dc.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class))) {
return true;
}
if (server.isDas()) {
String objectType = appProps.getProperty(ServerTags.OBJECT_TYPE);
if (objectType != null) {
// if it's a system application needs to be loaded on DAS
if (objectType.equals(DeploymentProperties.SYSTEM_ADMIN) || objectType.equals(DeploymentProperties.SYSTEM_ALL)) {
return true;
}
}
}
}
return false;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ResourceValidator method event.
@Override
public void event(Event event) {
if (event.is(Deployment.AFTER_APPLICATION_CLASSLOADER_CREATION)) {
dc = (DeploymentContext) event.hook();
Application application = dc.getModuleMetaData(Application.class);
DeployCommandParameters commandParams = dc.getCommandParameters(DeployCommandParameters.class);
target = commandParams.target;
if (System.getProperty("deployment.resource.validation", "true").equals("false")) {
deplLogger.log(Level.INFO, SKIP_RESOURCE_VALIDATION);
return;
}
if (application == null) {
return;
}
AppResources appResources = new AppResources();
// Puts all resouces found in the application via annotation or xml into appResources
parseResources(application, appResources);
// Ensure we have a valid component invocation before triggering lookups
String componentId = null;
for (BundleDescriptor bundleDescriptor : application.getBundleDescriptors()) {
if (bundleDescriptor instanceof JndiNameEnvironment) {
componentId = DOLUtils.getComponentEnvId((JndiNameEnvironment) bundleDescriptor);
if (componentId != null) {
break;
}
}
}
contextUtil.setInstanceComponentId(componentId);
try (Context ctx = contextUtil.pushContext()) {
validateResources(application, appResources);
}
}
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class HotDeployService method getApplicationState.
public Optional<ApplicationState> getApplicationState(DeploymentContext context) {
DeployCommandParameters commandParams = context.getCommandParameters(DeployCommandParameters.class);
boolean hotDeploy = commandParams != null ? commandParams.hotDeploy : false;
return getApplicationState(hotDeploy, context.getSourceDir());
}
Aggregations