3 Replies Latest reply on Feb 21, 2008 2:53 PM by Ales Justin

    syntax for specifying dependencies?

    Jonathan Halliday Master

      Scott or any other guru

      I have a .sar file, inside which is a .war file containing a servlet (FooServlet).
      The .sar file has a jboss-service.xml:

       <mbean name="jboss.xts:service=XTSService" code="org.jboss.transactions.XTSService">

      which is all well and good as far as it goes.

      However, in addition to the above dependency, I want to ensure that XTSService does not start until FooServlet has been deployed by the web server. Does the server provide a way to express such a dependency? If so, how do I figure out the name of the FooServlet to use?



        • 1. Re: syntax for specifying dependencies?
          Adrian Brock Master

          Ask in the Tomcat forum, there's no such feature AFAIK.

          You should be able to depend upon the mbean that represents the war though (which will
          be less fine-grained than what you want).

          • 2. Re: syntax for specifying dependencies?
            Jonathan Halliday Master

            Thanks Adrian. As it happens the .war is fairly small and won't take long to deploy, so depending on it probably is not too much of a kludge.

            • 3. Re: syntax for specifying dependencies?
              Ales Justin Master

              Check org.jboss.web.deployers.AbstractWarDeployer for the mbean Adrian mentioned.

               protected void deployWebModule(VFSDeploymentUnit unit, JBossWebMetaData metaData,
               AbstractWarDeployment deployment)
               throws Exception
               log.debug("deployWebModule: " + unit.getName());
               ServiceMetaData webModule = new ServiceMetaData();
               String name = getObjectName(metaData);
               ObjectName objectName = new ObjectName(name);
               // WebModule(DeploymentUnit, AbstractWarDeployer, AbstractWarDeployment)
               ServiceConstructorMetaData constructor = new ServiceConstructorMetaData();
               constructor.setSignature(new String[] { VFSDeploymentUnit.class.getName(),
               AbstractWarDeployer.class.getName(), AbstractWarDeployment.class.getName()});
               constructor.setParameters(new Object[] {unit, this, deployment});
               // Dependencies...Still have old jmx names here
               Collection<String> depends = metaData.getDepends();
               List<ServiceDependencyMetaData> dependencies = new ArrayList<ServiceDependencyMetaData>();
               if (depends != null && depends.isEmpty() == false)
               if (log.isTraceEnabled())
               log.trace(name + " has dependencies: " + depends);
               for(String iDependOn : depends)
               ServiceDependencyMetaData sdmd = new ServiceDependencyMetaData();
               // Here's where a bit of magic happens. By attaching the ServiceMetaData
               // to the deployment, we now make the deployment "relevant" to
               // deployers that use ServiceMetaData as an input (e.g. the
               // org.jboss.system.deployers.ServiceDeployer). Those deployers
               // can now take over deploying the web module.
               // TODO could create multiple components for the deployment
               // The ServiceConstructorMetaData is not serializable due to its args
               unit.addAttachment(ServiceMetaData.class, webModule);
               catch (Exception e)
               throw DeploymentException.rethrowAsDeploymentException("Error creating rar deployment " + unit.getName(), e);
               * Get the object name of the ServiceMetaData instance associated with
               * the WebMetaData. This uses the pattern:
               * "jboss.web.deployment:war="+metaData.getContextRoot()
               * @param metaData - the web app metaData
               * @return "jboss.web.deployment:war="+metaData.getContextRoot();
               protected String getObjectName(JBossWebMetaData metaData)
               String ctxPath = metaData.getContextRoot();
               // The ctx path value cannot be empty in the object name
               if( ctxPath == null || ctxPath.length() == 0 )
               ctxPath = "/";
               String objectName = "jboss.web.deployment:war="+ctxPath;
               return objectName;