@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
// Check if we already have an OSGi deployment
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
Deployment deployment = OSGiDeploymentAttachment.getDeployment(deploymentUnit);
String contextName = deploymentUnit.getName();
ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
Deployment holderDep = DeploymentHolderService.getDeployment(serviceRegistry, contextName);
VirtualFile virtualFile = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
String location = holderDep != null ? holderDep.getLocation() : contextName;
boolean autoStart = holderDep != null ? holderDep.isAutoStart() : true;
// Check for attached BundleInfo
BundleInfo info = BundleInfoAttachment.getBundleInfo(deploymentUnit);
if (deployment == null && info != null) {
deployment = DeploymentFactory.createDeployment(info);