Search in sources :

Example 1 with TargetModuleID

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;
}
Also used : Target(javax.enterprise.deploy.spi.Target) TargetModuleID(javax.enterprise.deploy.spi.TargetModuleID) HashSet(java.util.HashSet)

Example 2 with TargetModuleID

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);
    }
}
Also used : TargetModuleID(javax.enterprise.deploy.spi.TargetModuleID) TreeSet(java.util.TreeSet) NoSuchApplicationException(org.apache.openejb.NoSuchApplicationException) UndeployException(org.apache.openejb.UndeployException)

Example 3 with TargetModuleID

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);
    }
}
Also used : PrintStream(java.io.PrintStream) OpenEJBException(org.apache.openejb.OpenEJBException) TargetModuleID(javax.enterprise.deploy.spi.TargetModuleID) ByteArrayOutputStream(java.io.ByteArrayOutputStream) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Aggregations

TargetModuleID (javax.enterprise.deploy.spi.TargetModuleID)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 Target (javax.enterprise.deploy.spi.Target)1 NoSuchApplicationException (org.apache.openejb.NoSuchApplicationException)1 OpenEJBException (org.apache.openejb.OpenEJBException)1 UndeployException (org.apache.openejb.UndeployException)1 AppInfo (org.apache.openejb.assembler.classic.AppInfo)1 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)1