public boolean hasAttachments() { if (deploymentContext.getTransientAttachments().hasAttachments()) return true; else if (deploymentContext.getTransientManagedObjects().hasAttachments()) return true; else if (deploymentContext.getPredeterminedManagedObjects().hasAttachments()) return true; if (deploymentContext.isComponent()) return deploymentContext.getParent().getDeploymentUnit().hasAttachments(); return false; }
/** * Add a context. * * @param context the context * @param addToDeploy should we add to deploy collection */ private void addContext(DeploymentContext context, boolean addToDeploy) { allDeployments.put(context.getName(), context); if (context.getState() == DeploymentState.ERROR) { log.debug("Not scheduling addition of context already in error: " + context.getName() + " reason=" + context.getProblem()); return; } context.setState(DeploymentState.DEPLOYING); DeploymentContext parent = context.getParent(); log.debug("Scheduling deployment: " + context.getName() + " parent=" + parent); // Process the top level only if (context.isTopLevel() && addToDeploy) deploy.add(context); // Add all the children List<DeploymentContext> children = context.getChildren(); if (children != null) { for (DeploymentContext child : children) addContext(child, addToDeploy); } }
public boolean removeComponent(DeploymentContext component) { if (component == null) throw new IllegalArgumentException("Null component"); List<DeploymentContext> componentComponents = component.getComponents(); if (componentComponents.isEmpty() == false) log.warn("Removing component " + name + " which still has components " + componentComponents); boolean result = components.remove(component); component.cleanup(); if (result) log.debug("Removed component " + component.getName() + " from " + getName()); return result; }
public DeploymentUnit getTopLevel() { DeploymentContext context = deploymentContext.getTopLevel(); return context.getDeploymentUnit(); }
public DeploymentUnit getParent() { DeploymentContext parent = deploymentContext.getParent(); if (parent == null) return null; return parent.getDeploymentUnit(); }
public ClassLoader getClassLoader() { ClassLoader cl = deploymentContext.getClassLoader(); if (cl == null) throw new IllegalStateException("ClassLoader has not been set"); deploymentContext.deployed(); return cl; }
List<DeploymentContext> children = context.getChildren(); for (int i = 0; i < children.size(); ++i) List<DeploymentContext> components = context.getComponents(); if (components != null) DeploymentUnit unit = context.getDeploymentUnit(); if (isRelevant(deployer, unit, context.isTopLevel(), context.isComponent())) context.setState(DeploymentState.ERROR); context.setProblem(e); throw e; log.trace("Deployer " + deployer + " not relevant for " + context.getName());
List<DeploymentContext> children = context.getChildren(); if (children != null && children.isEmpty() == false) List<DeploymentContext> components = context.getComponents(); if (components != null && components.isEmpty() == false) DeploymentUnit unit = context.getDeploymentUnit(); if (isRelevant(deployer, unit, context.isTopLevel(), context.isComponent())) deployer.undeploy(unit); else if (log.isTraceEnabled()) log.trace("Deployer " + deployer + " not relevant for " + context.getName());
public Map<String, Object> getAttachments() { DeploymentContext parent = deploymentContext.getParent(); if (deploymentContext.isComponent() == false) parent = null; HashMap<String, Object> result = new HashMap<String, Object>(); if (parent != null) result.putAll(parent.getTransientAttachments().getAttachments()); result.putAll(deploymentContext.getTransientAttachments().getAttachments()); if (parent != null) result.putAll(parent.getTransientManagedObjects().getAttachments()); result.putAll(deploymentContext.getTransientManagedObjects().getAttachments()); if (parent != null) result.putAll(parent.getPredeterminedManagedObjects().getAttachments()); result.putAll(deploymentContext.getPredeterminedManagedObjects().getAttachments()); if (result.isEmpty() == false) deploymentContext.deployed(); return Collections.unmodifiableMap(result); }
List<DeploymentContext> children = context.getChildren(); if (children.isEmpty()) return; log.warn("Error during visit error: " + child.getName(), t); log.warn("Error during visit error: " + context.getName(), t);
if (DeploymentState.ERROR.equals(context.getState()) == false) context.setState(DeploymentState.UNDEPLOYING); log.debug("Undeploying " + context.getName()); DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class); if (deploymentControllerContext == null) if (ControllerState.ERROR.equals(context.getState()) == false) context.setState(DeploymentState.ERROR); context.setProblem(t); context.getTransientAttachments().removeAttachment(ControllerContext.class); try log.debug("Fully Undeployed " + context.getName()); context.setState(DeploymentState.ERROR); context.setProblem(t); context.setState(DeploymentState.DEPLOYING); log.debug("Deploying " + context.getName()); context.getTransientAttachments().addAttachment(ControllerContext.class, deploymentControllerContext); if (scopeBuilder != null) context.getTransientAttachments().addAttachment(ScopeBuilder.class, scopeBuilder); if (repository != null) context.getTransientAttachments().addAttachment(MutableMetaDataRepository.class, repository); context.setState(DeploymentState.ERROR); context.setProblem(t);
public ScopeKey getComponentScope(DeploymentContext context) { if (context == null) throw new IllegalArgumentException("Null context"); DeploymentContext parent = context; while (parent.isComponent()) { parent = context.getParent(); if (parent == null) throw new IllegalStateException("Component has no regular parent?"); } ScopeKey result = parent.getScope().clone(); result.addScope(CommonLevels.INSTANCE, context.getName()); return result; }
public String getName() { return deploymentContext.getName(); }
public List<DeploymentUnit> getChildren() { List<DeploymentContext> children = deploymentContext.getChildren(); if (children == null || children.isEmpty()) return Collections.emptyList(); List<DeploymentUnit> result = new ArrayList<DeploymentUnit>(children.size()); for (DeploymentContext child : children) { DeploymentUnit unit = child.getDeploymentUnit(); result.add(unit); } return result; }
log.trace("Unable to unregister deployment mbean " + context.getName(), e); List<DeploymentContext> children = context.getChildren(); for (DeploymentContext child : children) unregisterMBeans(child, true, false); List<DeploymentContext> components = context.getComponents(); for (DeploymentContext component : components) unregisterMBeans(component, false, false);
public DeploymentUnit getComponent(String name) { if (name == null) throw new IllegalArgumentException("Null name"); DeploymentContext component = getComponentContext(name); return component != null ? component.getDeploymentUnit() : null; }
/** * Get component deployment context. * * @param name the name * @return component component context or null if no match */ protected DeploymentContext getComponentContext(String name) { List<DeploymentContext> components = deploymentContext.getComponents(); if (components == null || components.isEmpty()) return null; for (DeploymentContext component : components) { if (name.equals(component.getName())) return component; } return null; }
public boolean removeComponent(String name) { if (name == null) throw new IllegalArgumentException("Null name"); for (DeploymentContext component : deploymentContext.getComponents()) { if (name.equals(component.getName())) return deploymentContext.removeComponent(component); } return false; }
log.trace("Populating Context " + context.getName() + " metaData=" + metaData); throw new IllegalStateException("Child deployment context is null"); context.addChild(childContext); childContext.setParent(context); throw DeploymentException.rethrowAsDeploymentException("Error populating context " + context.getName(), t);
/** * Get the scope builder for a deployment context * * @param deploymentContext the deployment context * @return the scope builder */ public static ScopeBuilder getScopeBuilder(DeploymentContext deploymentContext) { if (deploymentContext == null) throw new IllegalArgumentException("Null deployment context"); ScopeBuilder builder = deploymentContext.getTransientAttachments().getAttachment(ScopeBuilder.class); if (builder != null) return builder; DeploymentContext parent = deploymentContext.getParent(); if (parent != null) return getScopeBuilder(parent); return DefaultScopeBuilder.INSTANCE; }