use of javax.enterprise.deploy.spi.TargetModuleID in project tomee by apache.
the class OpenEJBDeploymentManager method toTargetModuleIds.
private Set<TargetModuleID> toTargetModuleIds(final Set<String> modules) {
final Set<TargetModuleID> targetModuleIds = new HashSet<TargetModuleID>();
for (final String module : modules) {
String moduleId;
final String webUrl;
final int spaceIndex = module.indexOf(' ');
if (spaceIndex > 1) {
moduleId = module.substring(0, spaceIndex);
webUrl = module.substring(spaceIndex + 1);
} else {
moduleId = module;
webUrl = null;
}
Target target = getTargetFor(moduleId);
if (target != null) {
if (moduleId.startsWith(target.getName())) {
moduleId = moduleId.substring(target.getName().length());
}
} else {
target = defaultTarget;
}
final TargetModuleIDImpl targetModuleID = new TargetModuleIDImpl(target, moduleId, webUrl);
targetModuleIds.add(targetModuleID);
}
return targetModuleIds;
}
use of javax.enterprise.deploy.spi.TargetModuleID in project tomee by apache.
the class VmDeploymentManager method undeploy.
@Override
public ProgressObject undeploy(final TargetModuleID[] moduleIdList) {
if (!connected) {
throw new IllegalStateException("Deployment manager is disconnected");
}
UndeployException undeployException = null;
final Set<TargetModuleID> results = new TreeSet<TargetModuleID>();
for (final TargetModuleID targetModuleId : moduleIdList) {
try {
getDeployer().undeploy(targetModuleId.getModuleID());
results.add(targetModuleId);
} catch (final UndeployException e) {
if (undeployException == null) {
undeployException = e;
}
} catch (final NoSuchApplicationException e) {
// app was not deployed... this should be ignored by jsr88
}
}
if (undeployException == null) {
return new ProgressObjectImpl(CommandType.UNDEPLOY, results);
} else {
return new ProgressObjectImpl(CommandType.UNDEPLOY, undeployException);
}
}
use of javax.enterprise.deploy.spi.TargetModuleID in project tomee by apache.
the class VmDeploymentManager method deploy.
private ProgressObject deploy(final Target[] targetList, final Properties properties) {
if (targetList == null) {
return new ProgressObjectImpl(CommandType.DISTRIBUTE, new NullPointerException("targetList is null"));
}
if (!containsDefaultTarget(targetList)) {
return new ProgressObjectImpl(CommandType.DISTRIBUTE, Collections.<TargetModuleID>emptySet());
}
try {
final AppInfo appInfo = getDeployer().deploy(properties);
final TargetModuleID targetModuleId = toTargetModuleId(appInfo, null);
return new ProgressObjectImpl(CommandType.DISTRIBUTE, Collections.singleton(targetModuleId));
} catch (ValidationFailedException e) {
final String s = JavaSecurityManagers.getSystemProperty(ReportValidationResults.VALIDATION_LEVEL, "3");
final int level = Integer.parseInt(s);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final PrintStream out = new PrintStream(baos);
out.println(e.getMessage());
print(e.getErrors(), out, level);
print(e.getFailures(), out, level);
print(e.getWarnings(), out, level);
out.close();
e = new ValidationFailedException(new String(baos.toByteArray()), e);
return new ProgressObjectImpl(CommandType.DISTRIBUTE, e);
} catch (final OpenEJBException e) {
return new ProgressObjectImpl(CommandType.DISTRIBUTE, e);
}
}
Aggregations