[jboss-dev-forums] [Design the new POJO MicroContainer] - Checking DeploymentContext for failures

alesj do-not-reply at jboss.com
Wed Nov 14 10:48:38 EST 2007


Regarding http://jira.jboss.com/jira/browse/JBMICROCONT-187.

What's the best way to get failing ControllerContexts that belong to DeploymentContext param?

This is what I came up currently:

  |    protected final void checkComplete(
  |          DeploymentContext context,
  |          Map<String, Throwable> contextsInError,
  |          Map<String, Set<MissingDependency>> contextsMissingDependencies,
  |          Set<ControllerContext> notInstalled,
  |          List<ControllerState> states)
  |    {
  |       Attachments attachments = context.getDeploymentUnit();
  |       if (attachments != null && checkers != null)
  |       {
  |          for (AttachmentChecker checker : checkers)
  |          {
  |             ControllerContext cc = checker.getControllerContext(controller, attachments);
  |             if (cc != null)
  |             {
  |                if (cc.getState().equals(cc.getRequiredState()) == false && notInstalled.contains(cc))
  |                {
  |                   checkControllerContext(cc, contextsInError, contextsMissingDependencies, states);
  |                }
  |             }
  |          }
  |       }
  |       List<DeploymentContext> children = context.getChildren();
  |       if (children != null && children.isEmpty() == false)
  |       {
  |          for(DeploymentContext child : children)
  |             checkComplete(child, contextsInError, contextsMissingDependencies, notInstalled, states);
  |       }
  |    }
  | 

where AttachmentChecker looks like this, e.g. Bean checker:

  | public abstract class AbstractAttachmentChecker<T> implements AttachmentChecker
  | {
  |    private Class<T> type;
  | 
  |    protected AbstractAttachmentChecker(Class<T> type)
  |    {
  |       if (type == null)
  |          throw new IllegalArgumentException("Null type.");
  |       this.type = type;
  |    }
  | 
  |    public ControllerContext getControllerContext(Controller controller, Attachments attachments)
  |    {
  |       T attachment = attachments.getAttachment(type);
  |       if (attachment != null)
  |          return getControllerContext(controller, attachment);
  | 
  |       return null;
  |    }
  | 
  |    protected abstract ControllerContext getControllerContext(Controller controller, T attachment);
  | }
  | 
  | public class BeanAttachmentChecker extends AbstractAttachmentChecker<BeanMetaData>
  | {
  |    public BeanAttachmentChecker()
  |    {
  |       super(BeanMetaData.class);
  |    }
  | 
  |    protected ControllerContext getControllerContext(Controller controller, BeanMetaData attachment)
  |    {
  |       return controller.getContext(attachment.getName(), null);
  |    }
  | }
  | 

Another checker implementations would include ServiceAC (mbeans) and ControllerContextAC (OSGi deployments).
Any others?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4104658#4104658

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104658



More information about the jboss-dev-forums mailing list