@Override public String[] apply(PathAddress address) { return new String[] { address.getLastElement().getValue() }; } },
@Override protected ServiceName getParentServiceName(PathAddress parentAddress) { String profileName = null; for (final PathElement element : parentAddress) { if (element.getKey().equals(EJB3SubsystemModel.REMOTING_PROFILE)) { profileName = element.getValue(); } } return RemotingProfileService.BASE_SERVICE_NAME.append(profileName); }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String name = address.getLastElement().getValue(); context.removeService(RemotingProfileService.BASE_SERVICE_NAME.append(name)); }
PathAddress pa = PathAddress.pathAddress(op.get(OP_ADDR)); if (pa.size() == 1 && EXTENSION.equals(pa.getElement(0).getKey()) && BEAN_VALIDATION_MODULE.equals(pa.getElement(0).getValue())) { hasBeanValidationExtension = true; break; addBeanValidationExtensionOp.get(OP).set(ADD); PathAddress beanValidationExtensionAddress = PathAddress.pathAddress(PathElement.pathElement(EXTENSION, BEAN_VALIDATION_MODULE)); addBeanValidationExtensionOp.get(OP_ADDR).set(beanValidationExtensionAddress.toModelNode()); addBeanValidationExtensionOp.get(MODULE).set(BEAN_VALIDATION_MODULE); otherBootOperations.add(addBeanValidationExtensionOp); addBeanValidationSubsystemOp.get(OP).set(ADD); PathAddress beanValidationSubsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, BEAN_VALIDATION_SUBSYSTEM)); addBeanValidationSubsystemOp.get(OP_ADDR).set(beanValidationSubsystemAddress.toModelNode()); legacyEEOps.add(addBeanValidationSubsystemOp);
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); final PathAddress parent = address.getParent(); final String name = address.getLastElement().getValue(); final String serverName = parent.getLastElement().getValue(); final ServiceName virtualHostServiceName = HostDefinition.HOST_CAPABILITY.getCapabilityServiceName(serverName, name); context.removeService(virtualHostServiceName); final ServiceName consoleRedirectName = UndertowService.consoleRedirectServiceName(serverName, name); context.removeService(consoleRedirectName); final ServiceName commonHostName = WebHost.SERVICE_NAME.append(name); context.removeService(commonHostName); final String defaultWebModule = HostDefinition.DEFAULT_WEB_MODULE.resolveModelAttribute(context, model).asString(); DefaultDeploymentMappingProvider.instance().removeMapping(defaultWebModule); }
private static void writeThreadPoolElements(XMLElement element, ThreadPoolResourceDefinition pool, XMLExtendedStreamWriter writer, ModelNode transport) throws XMLStreamException { PathElement path = pool.getPathElement(); if (transport.get(path.getKey()).hasDefined(path.getValue())) { ModelNode threadPool = transport.get(path.getKeyValuePair()); if (hasDefined(threadPool, pool.getAttributes())) { writer.writeStartElement(element.getLocalName()); writeAttributes(writer, threadPool, pool.getAttributes()); writer.writeEndElement(); } } }
@Override public final void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)); int current = address.size() - 1; String groupName = address.getElement(current--).getValue(); String balancerName = address.getElement(current--).getValue(); String modClusterName = address.getElement(current--).getValue(); ModClusterService service = ModClusterResource.service(modClusterName); if (service == null) { context.getResult().set(new ModelNode()); context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); return; } ModClusterStatus.LoadBalancer balancer = service.getModCluster().getController().getStatus().getLoadBalancer(balancerName); if (balancer == null) { context.getResult().set(new ModelNode()); context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); return; } handleGroup(context, balancer, groupName, operation); }
@SuppressWarnings("deprecation") @Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); String protocol = address.getLastElement().getValue(); PathAddress stackAddress = address.getParent(); ModelNode legacyOperation = Util.createOperation("remove-protocol", stackAddress); legacyOperation.get(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).set(protocol); return legacyOperation; } };
@Override protected void executeReadAttribute(final String attributeName, final OperationContext context, final XaDataSource dataSource, final PathAddress address) { final String target = address.getLastElement().getKey(); if (target.equals(XA_DATASOURCE_PROPERTIES)) { handlePropertyAttribute(attributeName, context, dataSource, address.getLastElement().getValue()); } else if (target.equals(XA_DATA_SOURCE)) { handleDatasourceAttribute(attributeName, context, dataSource); } }
@Override public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) { PathAddress target = this.getTargetAddress(); List<PathElement> result = new ArrayList<>(address.size()); for (int i = 0; i < address.size(); ++i) { PathElement element = address.getElement(i); if (i < target.size()) { PathElement targetElement = target.getElement(i); result.add(targetElement.isWildcard() ? PathElement.pathElement(targetElement.getKey(), element.getValue()) : targetElement); } else { result.add(element); } } return PathAddress.pathAddress(result); } }
@Override public OperationStepHandler apply(OperationStepHandler handler) { return (context, operation) -> { if (this.legacy.test(operation)) { PathElement path = context.getCurrentAddress().getLastElement(); // This is a legacy add operation - process it using the generic handler OperationStepHandler genericHandler = context.getResourceRegistration().getParent().getOperationHandler(PathAddress.pathAddress(ProtocolResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.ADD); Operations.setPathAddress(operation, context.getCurrentAddress().getParent().append(GenericProtocolResourceDefinition.pathElement(path.getValue()))); // Process this step first to preserve protocol order context.addStep(operation, genericHandler, OperationContext.Stage.MODEL, true); } else { handler.execute(context, operation); } }; } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); installRuntimeServices(context, name, model); }
final String stackName; if (ModelDescriptionConstants.ADD.equals(Operations.getName(operation)) && operation.hasDefined("type")) { stackName = operation.get("type").asString(); } else { Resource root = null; try { root = aliasContext.readResourceFromRoot(PathAddress.pathAddress(result)); } catch (Resource.NoSuchResourceException ignored) { } else if (i < target.size()) { PathElement targetElement = target.getElement(i); result.add(targetElement.isWildcard() ? PathElement.pathElement(targetElement.getKey(), element.getValue()) : targetElement); } else { result.add(element); return PathAddress.pathAddress(result);
@Override protected ServiceName getParentServiceName(PathAddress parentAddress) { String profileName = null; for (final PathElement element : parentAddress) { if (element.getKey().equals(EJB3SubsystemModel.REMOTING_PROFILE)) { profileName = element.getValue(); } } return RemotingProfileService.BASE_SERVICE_NAME.append(profileName); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress hostAddress = context.getCurrentAddress().getParent(); final PathAddress serverAddress = hostAddress.getParent(); final String name = context.getCurrentAddressValue(); final String handler = LocationDefinition.HANDLER.resolveModelAttribute(context, model).asString(); final LocationService service = new LocationService(name); final String serverName = serverAddress.getLastElement().getValue(); final String hostName = hostAddress.getLastElement().getValue(); final ServiceName serviceName = UndertowService.locationServiceName(serverName, hostName, name); final ServiceBuilder<LocationService> builder = context.getCapabilityServiceTarget().addCapability(LocationDefinition.LOCATION_CAPABILITY, service) .addCapabilityRequirement(Capabilities.CAPABILITY_HANDLER, HttpHandler.class, service.getHttpHandler(),handler) .addCapabilityRequirement(Capabilities.CAPABILITY_HOST, Host.class, service.getHost(), serverName, hostName); builder.setInitialMode(ServiceController.Mode.ACTIVE) .addAliases(serviceName) .install(); } }
private static <P extends ScheduledThreadPoolDefinition & ResourceDefinition> void writeScheduledThreadPoolElements(XMLElement element, P pool, XMLExtendedStreamWriter writer, ModelNode container) throws XMLStreamException { if (container.get(pool.getPathElement().getKey()).hasDefined(pool.getPathElement().getValue())) { ModelNode threadPool = container.get(pool.getPathElement().getKeyValuePair()); Iterable<Attribute> attributes = Arrays.asList(pool.getMaxThreads(), pool.getKeepAliveTime()); if (hasDefined(threadPool, attributes)) { writer.writeStartElement(element.getLocalName()); writeAttributes(writer, threadPool, attributes); writer.writeEndElement(); } } } }
@Override public final void execute(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)); int current = address.size() - 1; String nodeName = address.getElement(current--).getValue(); String balancerName = address.getElement(current--).getValue(); String modClusterName = address.getElement(current--).getValue(); ModClusterService service = ModClusterResource.service(modClusterName); if (service == null) { context.getResult().set(new ModelNode()); context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); return; } ModClusterStatus.LoadBalancer balancer = service.getModCluster().getController().getStatus().getLoadBalancer(balancerName); if (balancer == null) { context.getResult().set(new ModelNode()); context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); return; } ModClusterStatus.Node node = balancer.getNode(nodeName); if (node == null) { context.getResult().set(new ModelNode()); context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER); return; } handleNode(context, node, operation); }
@Override protected ServiceName getParentServiceName(PathAddress parentAddress) { return UndertowService.SERVLET_CONTAINER.append(parentAddress.getLastElement().getValue()); } }
@Override protected void executeReadAttribute(final String attributeName, final OperationContext context, final DataSource dataSource, final PathAddress address) { final String target = address.getLastElement().getKey(); if(target.equals(CONNECTION_PROPERTIES)) { handlePropertyAttribute(attributeName, context, dataSource, address.getLastElement().getValue()); } else if(target.equals(DATA_SOURCE)) { handleDatasourceAttribute(attributeName, context, dataSource); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, final ModelNode model) { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String securityDomain = address.getLastElement().getValue(); // This needs to run after all child resources so that they can detect a fresh state context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); launchServices(context, securityDomain, Resource.Tools.readModel(resource)); // Rollback handled by the parent step context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME); }