use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project meecrowave by apache.
the class MeecrowaveContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
final File dump = toArchiveDump(archive);
archive.as(ZipExporter.class).exportTo(dump, true);
final String context = sanitizeName(archive);
container.deployWebapp(context, dump);
final int port = configuration.isSkipHttp() ? configuration.getHttpsPort() : configuration.getHttpPort();
return new ProtocolMetaData().addContext(new HTTPContext(configuration.getHost(), port).add(new Servlet("arquillian", context)));
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project Payara by payara.
the class CommonPayaraManager method deploy.
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
if (archive == null) {
throw new IllegalArgumentException("archive must not be null");
}
final String archiveName = archive.getName();
final ProtocolMetaData protocolMetaData = new ProtocolMetaData();
try {
InputStream deployment = archive.as(ZipExporter.class).exportAsInputStream();
// Build up the POST form to send to Payara
final FormDataMultiPart form = new FormDataMultiPart();
form.bodyPart(new StreamDataBodyPart("id", deployment, archiveName));
deploymentName = createDeploymentName(archiveName);
addDeployFormFields(deploymentName, form);
// Do Deploy the application on the remote Payara
HTTPContext httpContext = payaraClient.doDeploy(deploymentName, form);
protocolMetaData.addContext(httpContext);
} catch (PayaraClientException e) {
throw new DeploymentException("Could not deploy " + archiveName, e);
}
return protocolMetaData;
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project Payara by payara.
the class PayaraClientService method doDeploy.
/**
* Do deploy an application defined by a multipart form's fileds to a target server or a cluster
* of GlassFish 3.1
*
* @param name - name of the appliacation form - a form of MediaType.MULTIPART_FORM_DATA_TYPE
* @return subComponents - a map of SubComponents of the application
*/
public HTTPContext doDeploy(String name, FormDataMultiPart form) {
// Deploy the application on the Payara server
getClientUtil().POSTMultiPartRequest(APPLICATION, form);
// Fetch the list of SubComponents of the application
Map<String, Object> subComponentsResponse = getClientUtil().GETRequest(APPLICATION_COMPONENTS.replace("{application}", name));
@SuppressWarnings("unchecked") Map<String, String> subComponents = (Map<String, String>) subComponentsResponse.get("properties");
// Build up the HTTPContext object using the nodeAddress information
HTTPContext httpContext = new HTTPContext(nodeAddress.getHost(), nodeAddress.getHttpPort());
// Add the servlets to the HTTPContext
String contextRoot = getApplicationContextRoot(name);
if (subComponents != null) {
for (Entry<String, String> subComponent : subComponents.entrySet()) {
String componentName = subComponent.getKey().toString();
if (WEBMODULE.equals(subComponent.getValue())) {
@SuppressWarnings("unchecked") List<Map<String, Object>> children = (List<Map<String, Object>>) subComponentsResponse.get("children");
// Override the application contextRoot by the webmodule's contextRoot
contextRoot = resolveWebModuleContextRoot(componentName, children);
resolveWebModuleSubComponents(name, componentName, contextRoot, httpContext);
} else if (SERVLET.equals(subComponent.getValue())) {
httpContext.add(new Servlet(componentName, contextRoot));
}
}
}
return httpContext;
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project tomee by apache.
the class TomEEContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
try {
final Dump dump = dumpFile(archive);
final File file = dump.getFile();
final String fileName = file.getName();
if (dump.isCreated() && (fileName.endsWith(".war") || fileName.endsWith(".ear"))) {
// extracted folder, TODO: openejb work dir is ignored here
Files.deleteOnExit(new File(file.getParentFile(), fileName.substring(0, fileName.length() - 4)));
}
final AppInfo appInfo;
final String archiveName = archive.getName();
try {
if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(archiveName)) {
appInfo = doDeploy(archive, file);
if (appInfo != null) {
moduleIds.put(archiveName, new DeployedApp(appInfo.path, file));
// "i" folder
Files.deleteOnExit(file);
}
} else {
final String path = moduleIds.get(archiveName).path;
AppInfo selected = null;
for (final AppInfo info : getDeployedApps()) {
if (path.equals(info.path)) {
selected = info;
break;
}
}
appInfo = selected;
}
if (appInfo == null) {
LOGGER.severe("appInfo was not found for " + file.getPath() + ", available are: " + apps());
throw new OpenEJBException("can't get appInfo");
}
} catch (final OpenEJBException re) {
// clean up in undeploy needs it
moduleIds.put(archiveName, new DeployedApp(file.getPath(), file));
throw re;
}
if (options.get("tomee.appinfo.output", false)) {
Info.marshal(appInfo);
}
final HTTPContext httpContext = new HTTPContext(configuration.getHost(), configuration.getHttpPort());
addArquillianServlet(archive, appInfo, archiveName, httpContext);
addServlets(httpContext, appInfo);
return new ProtocolMetaData().addContext(httpContext);
} catch (final Exception e) {
throw new DeploymentException("Unable to deploy", e);
}
}
use of org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext in project tomee by apache.
the class EmbeddedTomEEContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
try {
/* don't do it since it should be configurable
final File tempDir = Files.createTempDir();
final File file = new File(tempDir, name);
*/
final String name = archive.getName();
final Dump dump = this.dumpFile(archive);
final File file = dump.getFile();
if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(name)) {
ARCHIVES.put(archive, file);
final Thread current = Thread.currentThread();
final ClassLoader loader = current.getContextClassLoader();
// multiple deployments, don't leak a loader
current.setContextClassLoader(ParentClassLoaderFinder.Helper.get());
try {
this.container.deploy(name, file);
} finally {
current.setContextClassLoader(loader);
}
}
final AppInfo info = this.container.getInfo(name);
final String context = this.getArchiveNameWithoutExtension(archive);
final HTTPContext httpContext = new HTTPContext(this.configuration.getHost(), this.configuration.getHttpPort());
httpContext.add(new Servlet("ArquillianServletRunner", "/" + context));
this.addServlets(httpContext, info);
// ensure tests can use request/session scopes even if we don't have a request
startCdiContexts(name);
TestObserver.ClassLoaders classLoaders = this.classLoader.get();
if (classLoaders == null) {
classLoaders = new TestObserver.ClassLoaders();
this.classLoader.set(classLoaders);
}
classLoaders.register(archive.getName(), SystemInstance.get().getComponent(ContainerSystem.class).getAppContext(info.appId).getClassLoader());
return new ProtocolMetaData().addContext(httpContext);
} catch (final Exception e) {
throw new DeploymentException("Unable to deploy", e);
}
}
Aggregations