use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.
the class ManagedSEDeployableContainer method getSystemProperties.
private Properties getSystemProperties(final Archive<?> archive) throws DeploymentException {
Node systemPropertiesNode = archive.get(ClassPath.SYSTEM_PROPERTIES_ARCHIVE_PATH);
if (systemPropertiesNode != null) {
try (InputStream in = systemPropertiesNode.getAsset().openStream()) {
Properties systemProperties = new Properties();
systemProperties.load(in);
return systemProperties;
} catch (IOException e) {
throw new DeploymentException("Could not load system properties", e);
}
}
return null;
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.
the class FileDeploymentUtils method materializeSubdirectories.
public static void materializeSubdirectories(File entryDirectory, Node node) throws DeploymentException, IOException {
for (Node child : node.getChildren()) {
if (child.getAsset() == null) {
materializeSubdirectories(entryDirectory, child);
} else {
if (ClassPathDirectory.isMarkerFileArchivePath(child.getPath())) {
// Do not materialize the marker file
continue;
}
// E.g. META-INF/my-super-descriptor.xml
File resourceFile = new File(entryDirectory, child.getPath().get().replace(DELIMITER_RESOURCE_PATH, File.separatorChar));
File resoureDirectory = resourceFile.getParentFile();
if (!resoureDirectory.exists() && !resoureDirectory.mkdirs()) {
throw new DeploymentException("Could not create class path directory: " + entryDirectory);
}
resourceFile.createNewFile();
try (InputStream in = child.getAsset().openStream();
OutputStream out = new FileOutputStream(resourceFile)) {
copy(in, out);
}
child.getPath().get();
}
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.
the class FileDeploymentUtils method materializeClass.
public static void materializeClass(File entryDirectory, ClassAsset classAsset) throws DeploymentException, IOException {
File classDirectory;
if (classAsset.getSource().getPackage() != null) {
classDirectory = new File(entryDirectory, classAsset.getSource().getPackage().getName().replace(DELIMITER_CLASS_NAME_PATH, File.separatorChar));
if (!classDirectory.mkdirs()) {
throw new DeploymentException("Could not create class package directory: " + classDirectory);
}
} else {
classDirectory = entryDirectory;
}
File classFile = new File(classDirectory, classAsset.getSource().getSimpleName().concat(EXTENSION_CLASS));
classFile.createNewFile();
try (InputStream in = classAsset.openStream();
OutputStream out = new FileOutputStream(classFile)) {
copy(in, out);
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.
the class TomEEContainer method undeploy.
@Override
public void undeploy(final Archive<?> archive) throws DeploymentException {
final String archiveName = archive.getName();
if (configuration.isSingleDeploymentByArchiveName(archiveName)) {
return;
}
final DeployedApp deployed = moduleIds.remove(archiveName);
try {
if (deployed == null) {
LOGGER.warning(archiveName + " was not deployed");
return;
}
doUndeploy(deployed);
} catch (final Exception e) {
throw new DeploymentException("Unable to undeploy " + archiveName, e);
} finally {
if (deployed != null && !configuration.isSingleDumpByArchiveName()) {
LOGGER.info("cleaning " + deployed.file.getAbsolutePath());
// "i" folder
Files.delete(deployed.file);
final File pathFile = new File(deployed.path);
if (!deployed.path.equals(deployed.file.getAbsolutePath()) && pathFile.exists()) {
LOGGER.info("cleaning " + pathFile);
Files.delete(pathFile);
}
final File parentFile = deployed.file.getParentFile();
final File[] parentChildren = parentFile.listFiles();
if (parentChildren == null || parentChildren.length == 0) {
Files.delete(deployed.file.getParentFile());
}
}
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.
the class EmbeddedTomEEContainer method undeploy.
@Override
public void undeploy(final Archive<?> archive) throws DeploymentException {
final String name = archive.getName();
stopCdiContexts(name);
if (configuration.isSingleDeploymentByArchiveName(name)) {
return;
}
try {
this.container.undeploy(name);
} catch (final Exception e) {
throw new DeploymentException("Unable to undeploy", e);
}
final File file = ARCHIVES.remove(archive);
if (!configuration.isSingleDumpByArchiveName()) {
final File folder = new File(file.getParentFile(), file.getName().substring(0, file.getName().length() - 4));
if (folder.exists()) {
Files.delete(folder);
}
Files.delete(file);
final File parentFile = file.getParentFile();
final File[] parentChildren = parentFile.listFiles();
if (parentChildren == null || parentChildren.length == 0) {
Files.delete(file.getParentFile());
}
}
}
Aggregations