@Override
public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException
{
List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
ServiceDeployment serviceDeployment = new ServiceDeployment();
List<ServiceMetaData> componentServices = new ArrayList<ServiceMetaData>();
List<ServiceMetaData> serviceDefintion = group.getServices();
serviceDeployment.setName(unit.getName()+" services");
//For some reason, this didn't like the addAll method
for (ServiceMetaData data : serviceDefintion)
{
componentServices.add(data);
}
ComponentType type = null;
for (ManagedConnectionFactoryDeploymentMetaData data : deployments)
{
// TODO: there should be multiple component types
if( type == null )
{
if( data instanceof LocalDataSourceDeploymentMetaData )
type = KnownComponentTypes.DataSourceTypes.LocalTx.getType();
if( data instanceof NoTxDataSourceDeploymentMetaData )
type = KnownComponentTypes.DataSourceTypes.NoTx.getType();
if( data instanceof XADataSourceDeploymentMetaData )
type = KnownComponentTypes.DataSourceTypes.XA.getType();
}
for (AbstractBuilder builder : builders)
{
ServiceMetaData candidate = builder.build(data);
if(candidate != null)
{
componentServices.add(candidate);
}
}
}
serviceDeployment.setServices(componentServices);
// we shouldn't override ServiceDeployment - it's reserved for -service.xml files / SARDeployer
unit.addAttachment(ServiceDeployment.class.getName() + ".JCA", serviceDeployment, ServiceDeployment.class);
if( type != null )
unit.addAttachment(ComponentType.class, type);
}