/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jbpm.integration.jboss5;
import org.jboss.dependency.plugins.AbstractDependencyItem;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployerWithInput;
import org.jboss.deployers.spi.deployer.helpers.DeploymentVisitor;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.dependency.DependenciesMetaData;
import org.jbpm.integration.spi.JBPMDeploymentMetaData;
/**
* Adds dependency info to process deployments.
* I.e. every process deployment demands the TransactionManager.
* The microcontainer dependency information proper undeployment ordering upon server shutdown.
*
* @see http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4218501
*
* @author Heiko.Braun <heiko.braun@jboss.com>
*/
public class JBPMDependenciesDeployer extends AbstractRealDeployerWithInput<JBPMDeploymentMetaData>
{
private static final String USER_TX_SERVICE_NAME = "jboss:service=ClientUserTransaction";
private final static String JBPM_SERVICE_NAME = "org.jbpm:service=ProcessEngine";
public JBPMDependenciesDeployer()
{
setStage(DeploymentStages.PRE_REAL);
setOutput(DependenciesMetaData.class);
DeploymentVisitor<JBPMDeploymentMetaData> visitor = new DeploymentVisitor<JBPMDeploymentMetaData>()
{
public void deploy(DeploymentUnit unit, JBPMDeploymentMetaData deployment)
throws DeploymentException
{
log.debug("Encountered deployment " + unit.getTopLevel());
for(String serviceName : new String[] {USER_TX_SERVICE_NAME, JBPM_SERVICE_NAME})
{
unit.addIDependOn(
new AbstractDependencyItem(unit.getTopLevel().getName(),
serviceName,
new ControllerState("Real"),
ControllerState.INSTALLED)
);
}
}
public Class<JBPMDeploymentMetaData> getVisitorType()
{
return JBPMDeploymentMetaData.class;
}
public void undeploy(DeploymentUnit unit, JBPMDeploymentMetaData deployment)
{
}
};
setDeploymentVisitor(visitor);
}
}