final Boolean autoDeployXml = AUTO_DEPLOY_XML.resolveModelAttribute(context, operation).asBoolean();
final Long deploymentTimeout = DEPLOYMENT_TIMEOUT.resolveModelAttribute(context, operation).asLong();
final Integer scanInterval = SCAN_INTERVAL.resolveModelAttribute(context, operation).asInt();
final ThreadFactory threadFactory = new JBossThreadFactory(new ThreadGroup("DeploymentScanner-threads"), Boolean.FALSE, null, "%G - %t", null, null, AccessController.getContext());
final ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2, threadFactory);
final FileSystemDeploymentService bootTimeScanner;
if (bootTimeScan) {
final String pathName = pathManager.resolveRelativePathEntry(path, relativeTo);
File relativePath = null;
if (relativeTo != null) {
relativePath = new File(pathManager.getPathEntry(relativeTo).resolvePath());
}
bootTimeScanner = new FileSystemDeploymentService(relativeTo, new File(pathName), relativePath, null, scheduledExecutorService);
bootTimeScanner.setAutoDeployExplodedContent(autoDeployExp);
bootTimeScanner.setAutoDeployZippedContent(autoDeployZip);
bootTimeScanner.setAutoDeployXMLContent(autoDeployXml);
if (deploymentTimeout != null) {
bootTimeScanner.setDeploymentTimeout(deploymentTimeout);
}
if (scanInterval != null) {
bootTimeScanner.setScanInterval(scanInterval);
}
} else {
bootTimeScanner = null;
}
context.addStep(new OperationStepHandler() {
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
final List<ServiceController<?>> controllers = new ArrayList<ServiceController<?>>();
final ServiceVerificationHandler verificationHandler = new ServiceVerificationHandler();
performRuntime(context, operation, model, verificationHandler, controllers, scheduledExecutorService, bootTimeScanner);
context.addStep(verificationHandler, OperationContext.Stage.VERIFY);
context.completeStep(new OperationContext.RollbackHandler() {
@Override
public void handleRollback(OperationContext context, ModelNode operation) {
rollbackRuntime(context, operation, model, controllers);
}
});
}
}, OperationContext.Stage.RUNTIME);
if (bootTimeScan) {
final AtomicReference<ModelNode> deploymentOperation = new AtomicReference<ModelNode>();
final AtomicReference<ModelNode> deploymentResults = new AtomicReference<ModelNode>(new ModelNode());
final CountDownLatch scanDoneLatch = new CountDownLatch(1);
final CountDownLatch deploymentDoneLatch = new CountDownLatch(1);
final DeploymentOperations deploymentOps = new BootTimeScannerDeployment(deploymentOperation, deploymentDoneLatch, deploymentResults, scanDoneLatch);
scheduledExecutorService.submit(new Runnable() {
@Override
public void run() {
try {
bootTimeScanner.oneOffScan(deploymentOps);
} catch (Throwable t){