protected void performRuntime( OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); String name = address.getLastElement().getValue(); ModelNode pathNode = operation.get(PATH); ModelNode relNode = operation.get(RELATIVE_TO); String path = pathNode.isDefined() ? pathNode.asString() : null; String relativeTo = relNode.isDefined() ? relNode.asString() : null; final ServiceTarget target = context.getServiceTarget(); if (relativeTo == null) { newControllers.add( AbsolutePathService.addService(name, path, target, newControllers, verificationHandler)); } else { newControllers.add( RelativePathService.addService( name, path, relativeTo, target, newControllers, verificationHandler)); } }
/** * Add the deployment scanner service to a batch. * * @param serviceTarget the service target * @param name the repository name * @param relativeTo the relative to * @param path the path * @param scanInterval the scan interval * @param scanEnabled scan enabled * @param deploymentTimeout the deployment timeout * @return */ public static ServiceController<?> addService( final ServiceTarget serviceTarget, final String name, final String relativeTo, final String path, final Integer scanInterval, TimeUnit unit, final Boolean autoDeployZip, final Boolean autoDeployExploded, final Boolean scanEnabled, final Long deploymentTimeout, final ServiceListener<Object>... listeners) { final DeploymentScannerService service = new DeploymentScannerService( relativeTo, scanInterval, unit, autoDeployZip, autoDeployExploded, scanEnabled, deploymentTimeout); final ServiceName serviceName = getServiceName(name); final ServiceName pathService = serviceName.append("path"); final ServiceName relativePathService = relativeTo != null ? RelativePathService.pathNameOf(relativeTo) : null; if (relativeTo != null) { RelativePathService.addService(pathService, path, relativeTo, serviceTarget); } else { AbsolutePathService.addService(pathService, path, serviceTarget); } 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); ServiceBuilder builder = serviceTarget .addService(serviceName, service) .addDependency(pathService, String.class, service.pathValue) .addDependency( Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.controllerValue) .addDependency( ServerDeploymentRepository.SERVICE_NAME, ServerDeploymentRepository.class, service.deploymentRepositoryValue) .addDependency( ContentRepository.SERVICE_NAME, ContentRepository.class, service.contentRepositoryValue) .addDependency(org.jboss.as.server.deployment.Services.JBOSS_DEPLOYMENT_CHAINS) .addInjection(service.scheduledExecutorValue, scheduledExecutorService); if (relativePathService != null) { builder.addDependency(relativePathService, String.class, service.relativePathValue); } builder.addListener(listeners); return builder.setInitialMode(Mode.ACTIVE).install(); }