List Info

Thread: - Checking DeploymentContext




- Checking DeploymentContext
user name
2007-11-14 10:07:09
Since jboss.org is down I'll answer here...

On Wed, 2007-11-14 at 10:48 -0500, alesj wrote:
> Regarding ht
tp://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?

You don't need to do anything so complicated.

You just need the relevant deployers to record the context
names in some
well defined place, e.g. the Deployment{Unit|Context}

It's probably important enough to use a special method
rather than
an attachment.

e.g.

public class BeanMetaDataDeployer extends
AbstractSimpleRealDeployer<BeanMetaData>
{
   /** The kernel controller */
   private final KernelController controller;
   
   /**
    * Create a new BeanDeployer.
    * 
    * param kernel the kernel
    * throws IllegalArgumentException for a null kernel
    */
   public BeanMetaDataDeployer(Kernel kernel)
   {
      super(BeanMetaData.class);
      if (kernel == null)
         throw new IllegalArgumentException("Null
kernel");
      controller = kernel.getController();
      setComponentsOnly(true);
   }

   Override
   public void deploy(DeploymentUnit unit, BeanMetaData
deployment)
throws DeploymentException
   {
      KernelControllerContext context = new
AbstractKernelControllerContext(null, deployment, null);
      try
      {
         controller.install(context);
+      
unit.addControllerContextName(deployment.getName());
      }
      catch (Throwable t)
      {
         throw
DeploymentException.rethrowAsDeploymentException("Error

deploying: " + deployment.getName(), t);
      }
   }

   Override
   public void undeploy(DeploymentUnit unit, BeanMetaData
deployment)
   {
+    
unit.removeControllerContextName(deployment.getName());
      controller.uninstall(deployment.getName());
   }
}

In practice, the component deployment unit name should be
the context
name.
This is at least true for the POJO and Service deployers.

So you could just add it as some kind of easy declaration in
the
constructor:

   public BeanMetaDataDeployer(Kernel kernel)
   {
      super(BeanMetaData.class);
      if (kernel == null)
         throw new IllegalArgumentException("Null
kernel");
      controller = kernel.getController();
      setComponentsOnly(true);
      // obviously some shorter property name 
     
setComponentDeploymentNameIsControllerContextName(true);
   }

and handle it in the abstract classes:

   deploy(...); // will throw an error if not registered in
the
controller
   if (unit.isComponent() &&
isComponentDeploymentNameControllerContextName())
      addComponentContextName(unit.getSimpleName());


> 
> 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
> _______________________________________________
> jboss-dev-forums mailing list
> jboss-dev-forumslists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jboss-dev-foru
ms
-- 
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Adrian Brock
Chief Scientist
JBoss, a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxxx

_______________________________________________
jboss-development mailing list
jboss-developmentlists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-develop
ment

Re: - Checking DeploymentCon
country flaguser name
Slovenia
2007-11-14 10:37:38
How does this take care of DeploymentControllerContext?
Since it's not a part of Deployers.

Or just treating this ControllerContext lookup differently?

Via AttachmentCreator this was transparent. 

public class ControllerContextAttachmentChecker extends 
AbstractAttachmentChecker<ControllerContext>
{
    public ControllerContextAttachmentChecker()
    {
       super(ControllerContext.class);
    }

    protected ControllerContext
getControllerContext(Controller 
controller, ControllerContext attachment)
    {
       return attachment;
    }
}

> You don't need to do anything so complicated.
> 
> You just need the relevant deployers to record the
context names in some
> well defined place, e.g. the Deployment{Unit|Context}
> 
> It's probably important enough to use a special method
rather than
> an attachment.
> 
> e.g.
> 
> public class BeanMetaDataDeployer extends
> AbstractSimpleRealDeployer<BeanMetaData>
> {
>    /** The kernel controller */
>    private final KernelController controller;
>    
>    /**
>     * Create a new BeanDeployer.
>     * 
>     * param kernel the kernel
>     * throws IllegalArgumentException for a null kernel
>     */
>    public BeanMetaDataDeployer(Kernel kernel)
>    {
>       super(BeanMetaData.class);
>       if (kernel == null)
>          throw new IllegalArgumentException("Null
kernel");
>       controller = kernel.getController();
>       setComponentsOnly(true);
>    }
> 
>    Override
>    public void deploy(DeploymentUnit unit, BeanMetaData
deployment)
> throws DeploymentException
>    {
>       KernelControllerContext context = new
> AbstractKernelControllerContext(null, deployment,
null);
>       try
>       {
>          controller.install(context);
> +      
unit.addControllerContextName(deployment.getName());
>       }
>       catch (Throwable t)
>       {
>          throw
DeploymentException.rethrowAsDeploymentException("Error

> deploying: " + deployment.getName(), t);
>       }
>    }
> 
>    Override
>    public void undeploy(DeploymentUnit unit,
BeanMetaData deployment)
>    {
> +    
unit.removeControllerContextName(deployment.getName());
>       controller.uninstall(deployment.getName());
>    }
> }
> 
> In practice, the component deployment unit name should
be the context
> name.
> This is at least true for the POJO and Service
deployers.
> 
> So you could just add it as some kind of easy
declaration in the
> constructor:
> 
>    public BeanMetaDataDeployer(Kernel kernel)
>    {
>       super(BeanMetaData.class);
>       if (kernel == null)
>          throw new IllegalArgumentException("Null
kernel");
>       controller = kernel.getController();
>       setComponentsOnly(true);
>       // obviously some shorter property name 
>      
setComponentDeploymentNameIsControllerContextName(true);
>    }
> 
> and handle it in the abstract classes:
> 
>    deploy(...); // will throw an error if not
registered in the
> controller
>    if (unit.isComponent() &&
> isComponentDeploymentNameControllerContextName())
>       addComponentContextName(unit.getSimpleName());
> 
> 
>> 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
>> _______________________________________________
>> jboss-dev-forums mailing list
>> jboss-dev-forumslists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jboss-dev-foru
ms
_______________________________________________
jboss-development mailing list
jboss-developmentlists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-develop
ment

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )