FileDocCategorySizeDatePackage
EJBRegistrationDeployer.javaAPI DocJBoss 4.2.16775Fri Jul 13 20:53:48 BST 2007org.jboss.ejb3.deployers

EJBRegistrationDeployer

public class EJBRegistrationDeployer extends org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer
Creates initial EJB deployments and initializes only basic metadata. A registration process is required so that
author
Bill Burke
version
$Revision: 57082 $

Fields Summary
private static final Logger
log
private HashSet
ignoredJarsSet
private MBeanServer
mbeanServer
private org.jboss.kernel.Kernel
kernel
private Properties
defaultPersistenceProperties
private List
allowedSuffixes
Constructors Summary
public EJBRegistrationDeployer()


    
   
      // make sure we run before the stage 2 deployer
      // TODO: what's is the proper relative order?
      setRelativeOrder(COMPONENT_DEPLOYER - 1);
   
Methods Summary
public voiddeploy(org.jboss.deployers.spi.deployer.DeploymentUnit unit)

      try
      {
         if (unit.getDeploymentContext().isComponent()) return;
         VirtualFile jar = unit.getDeploymentContext().getRoot();
         if (jar.isLeaf() || ignoredJarsSet.contains(jar.getName())                 )
         {
            log.trace("EJBRegistrationDeployer ignoring: " + jar.getName());
            return;
         }
         if (allowedSuffixes != null)
         {
            for (String suffix : allowedSuffixes)
            {
               if (jar.getName().endsWith(suffix))
               {
                  log.trace("EJBRegistrationDeployer ignoring: " + jar.getName());
                  return;
               }
            }
         }
         log.debug("********* EJBRegistrationDepoyer Begin Unit: " + unit.getName() + " jar: " + jar.getName());
         VirtualFile ejbjar = unit.getMetaDataFile("ejb-jar.xml");
         if (ejbjar != null)
         {
            InputStream is = ejbjar.openStream();
            boolean has30EjbJarXml = EJB3Deployer.has30EjbJarXml(is);
            is.close();
            if (!has30EjbJarXml) return;
         }
         DeploymentScope scope = null;
         DeploymentContext parent = unit.getDeploymentContext().getParent();
         if (parent != null && parent.getRoot().getName().endsWith(".ear")) // todo should look for metadata instead of ".ear"
         {
            scope = parent.getTransientAttachments().getAttachment(DeploymentScope.class);
            if (scope == null)
            {
               scope = new JBoss5DeploymentScope(unit.getDeploymentContext().getParent());
               parent.getTransientAttachments().addAttachment(DeploymentScope.class, scope);
            }
         }
         JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
         du.setDefaultPersistenceProperties(defaultPersistenceProperties);
         Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope);
         if (scope != null) scope.register(deployment);
         // create() creates initial EJB containers and initializes metadata.
         deployment.create();
         if (deployment.getEjbContainers().size() == 0 && deployment.getPersistenceUnitDeployments().size() == 0)
         {
            log.trace("EJBRegistrationDeployer no containers in scanned jar, consider adding it to the ignore list: " + jar.getName() + " url: " + jar.toURL() + " unit: " + unit.getName());
            return;
         }
         unit.addAttachment(Ejb3Deployment.class, deployment);
      }
      catch (Exception e)
      {
         throw new DeploymentException(e);
      }
   
public java.util.ListgetAllowedSuffixes()

      return allowedSuffixes;
   
public java.util.PropertiesgetDefaultPersistenceProperties()

      return defaultPersistenceProperties;
   
public java.util.HashSetgetIgnoredJarsSet()

      return ignoredJarsSet;
   
public org.jboss.kernel.KernelgetKernel()

      return kernel;
   
public javax.management.MBeanServergetMbeanServer()

      return mbeanServer;
   
public voidsetAllowedSuffixes(java.util.List allowedSuffixes)

      this.allowedSuffixes = allowedSuffixes;
   
public voidsetDefaultPersistenceProperties(java.util.Properties defaultPersistenceProperties)

      this.defaultPersistenceProperties = defaultPersistenceProperties;
   
public voidsetIgnoredJarsSet(java.util.HashSet ignoredJarsSet)

      this.ignoredJarsSet = ignoredJarsSet;
   
public voidsetKernel(org.jboss.kernel.Kernel kernel)

      this.kernel = kernel;
   
public voidsetMbeanServer(javax.management.MBeanServer mbeanServer)

      this.mbeanServer = mbeanServer;
   
public voidundeploy(org.jboss.deployers.spi.deployer.DeploymentUnit unit)

      Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class);
      if (deployment == null) return;
      try
      {
         deployment.stop();
      }
      catch (Exception e)
      {
         log.error("failed to stop deployment", e);
      }
      try
      {
         deployment.destroy();
      }
      catch (Exception e)
      {
         log.error("failed to destroy deployment", e);
      }