protected String getAttachmentName(C attachment) { return getComponentType().getName(); }
public void undeploy(DeploymentUnit unit, T deployment) { List<? extends C> components = getComponents(deployment); if (components != null && components.isEmpty() == false) { for (C component : components) { safeRemoveComponent(unit, component); } } }
public void deploy(DeploymentUnit unit, T deployment) throws DeploymentException { List<? extends C> components = getComponents(deployment); if (components != null && components.isEmpty() == false) { List<C> visited = new ArrayList<C>(); try { for (C component : components) { addComponent(unit, component); visited.add(component); } } catch (Throwable t) { for (int i = visited.size() - 1; i >= 0; i--) { safeRemoveComponent(unit, visited.get(i)); } throw DeploymentException.rethrowAsDeploymentException("Error deploying: " + unit.getName(), t); } } }
protected DeploymentUnit addComponent(DeploymentUnit unit, BeanMetaData attachment) { DeploymentUnit component = super.addComponent(unit, attachment); String className = attachment.getBean(); if (className != null) { Object qualifier; if (attachment.getClassLoader() == null) { ClassLoader cl = unit.getClassLoader(); try { qualifier = cl.loadClass(className); } catch (Exception e) { throw new IllegalArgumentException("Exception loading class for ScopeKey addition.", e); } } else { qualifier = className; } component.getScope().addScope(CommonLevels.CLASS, qualifier); } return component; }
/** * Ignore all error during component removal. * * @param unit the deployment unit * @param attachment the attachment */ protected void safeRemoveComponent(DeploymentUnit unit, C attachment) { try { removeComponent(unit, attachment); } catch (Throwable ignored) { log.warn("Error during component removal: " + unit.getName(), ignored); } } }