@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException { final String configPropertyValue = CONFIG_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString(); final ModelNode address = operation.require(OP_ADDR); PathAddress path = PathAddress.pathAddress(address); final String archiveName = path.getElement(path.size() -3).getValue(); final String aoName = path.getElement(path.size() -2).getValue(); final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue(); ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName, aoName, configPropertyName); ServiceName aoServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, archiveName, aoName); final ServiceTarget serviceTarget = context.getServiceTarget(); final AOConfigPropertiesService service = new AOConfigPropertiesService(configPropertyName, configPropertyValue); serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE) .addDependency(aoServiceName, ModifiableAdminObject.class, service.getAOInjector() ) .install(); } }
/** * {@inheritDoc} */ @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); list.add(Util.createAddOperation(PathAddress.pathAddress(NamingExtension.SUBSYSTEM_PATH))); if(!appclient) { //we do not add remote naming to the application client //note that this is a bi list.add(Util.createAddOperation(PathAddress.pathAddress(NamingExtension.SUBSYSTEM_PATH).append(NamingSubsystemModel.SERVICE, NamingSubsystemModel.REMOTE_NAMING))); } } }
/** * Sets the address of the specified operation. * @param operation an operation * @param address a path address */ public static void setPathAddress(ModelNode operation, PathAddress address) { operation.get(ModelDescriptionConstants.OP_ADDR).set(address.toModelNode()); }
@Override public PathAddress transform(PathAddress address) { return address.subAddress(0, address.size() - 1).append(LEGACY_PATH); } };
static PathAddress cacheAddress(PathAddress transactionAddress) { return transactionAddress.subAddress(0, transactionAddress.size() - 1); }
@Override public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) { PathElement element = address.getLastElement(); element = PathElement.pathElement(Constants.ACL_MODULE, element.getValue()); return address.subAddress(0, address.size() -1).append(element); } });
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Resource existing = context.readResource(PathAddress.EMPTY_ADDRESS); OperationStepHandler addHandler = context.getResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS.append(newKeyName)).getOperationHandler(PathAddress.EMPTY_ADDRESS, "add"); ModelNode value = operation.get(VALUE); if (value.isDefined()) { List<ModelNode> modules = new ArrayList<ModelNode>(value.asList()); Collections.reverse(modules); //need to reverse it to make sure they are added in proper order for (ModelNode module : modules) { ModelNode addModuleOp = module.clone(); String code = addModuleOp.get(Constants.CODE).asString(); PathElement relativePath = PathElement.pathElement(newKeyName, code); PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(relativePath); addModuleOp.get(OP_ADDR).set(address.toModelNode()); addModuleOp.get(OP).set(ADD); context.addStep(new ModelNode(), addModuleOp, addHandler, OperationContext.Stage.MODEL, true); } } //remove on the end to make sure it is executed first for (Resource.ResourceEntry entry : existing.getChildren(newKeyName)) { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)).append(entry.getPathElement()); ModelNode removeModuleOp = Util.createRemoveOperation(address); context.addStep(new ModelNode(), removeModuleOp, new SecurityDomainReloadRemoveHandler(), OperationContext.Stage.MODEL, true); } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { operationDeprecated(context, operation); PathAddress address = translateProxyPath(context); String type = operation.require(LoadMetricResourceDefinition.Attribute.TYPE.getName()).asString(); PathAddress metricPath = PathAddress.pathAddress(DynamicLoadProviderResourceDefinition.LEGACY_PATH, LoadMetricResourceDefinition.pathElement(type)); PathAddress metricPathAddress = address.append(metricPath); ModelNode metricOperation = Util.createAddOperation(metricPathAddress); OperationEntry addOperationEntry = context.getResourceRegistration().getOperationEntry(PathAddress.pathAddress(metricPath), ModelDescriptionConstants.ADD); for (AttributeDefinition attribute : addOperationEntry.getOperationDefinition().getParameters()) { String name = attribute.getName(); if (operation.hasDefined(name)) { metricOperation.get(name).set(operation.get(name)); } } context.addStep(metricOperation, addOperationEntry.getOperationHandler(), OperationContext.Stage.MODEL, true); } };
private void parseLookupBinding(final XMLExtendedStreamReader reader, List<ModelNode> operations, PathAddress parentAddress) throws XMLStreamException { final int attCount = reader.getAttributeCount(); String name = null; final ModelNode bindingAdd = Util.createAddOperation(); bindingAdd.get(BINDING_TYPE).set(LOOKUP); final EnumSet<NamingSubsystemXMLAttribute> required = EnumSet.of(NamingSubsystemXMLAttribute.NAME, NamingSubsystemXMLAttribute.LOOKUP); for (int i = 0; i < attCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final NamingSubsystemXMLAttribute attribute = NamingSubsystemXMLAttribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { break; case LOOKUP: NamingBindingResourceDefinition.LOOKUP.parseAndSetParameter(value, bindingAdd, reader); break; default: throw unexpectedAttribute(reader, i); throw missingRequired(reader, required); requireNoContent(reader); bindingAdd.get(OP_ADDR).set(parentAddress.append(BINDING, name).toModelNode()); operations.add(bindingAdd);
protected void performRuntime(final OperationContext context, ModelNode operation, final ModelNode model) throws OperationFailedException { final ModelNode pathNode = FileDataStoreResourceDefinition.PATH.resolveModelAttribute(context, model); final String path = pathNode.isDefined() ? pathNode.asString() : null; final ModelNode relativeToNode = FileDataStoreResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, model); final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null; final FileTimerPersistence fileTimerPersistence = new FileTimerPersistence(true, path, relativeTo); final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final ServiceName serviceName = TimerPersistence.SERVICE_NAME.append(address.getLastElement().getValue()); final ServiceBuilder sb = context.getServiceTarget().addService(serviceName, fileTimerPersistence); sb.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ModuleLoader.class, fileTimerPersistence.getModuleLoader()); sb.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, fileTimerPersistence.getPathManager()); sb.requires(context.getCapabilityServiceName("org.wildfly.transactions.global-default-local-provider", null)); sb.addDependency(context.getCapabilityServiceName("org.wildfly.transactions.transaction-synchronization-registry", null), TransactionSynchronizationRegistry.class, fileTimerPersistence.getTransactionSynchronizationRegistry()); sb.install(); }
private void parseAuthProtocol(XMLExtendedStreamReader reader, PathAddress stackAddress, Map<PathAddress, ModelNode> operations) throws XMLStreamException { String type = require(reader, XMLAttribute.TYPE); PathAddress address = stackAddress.append(ProtocolResourceDefinition.pathElement(type)); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); for (int i = 0; i < reader.getAttributeCount(); i++) { this.parseProtocolAttribute(reader, i, operation); } while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { this.parseAuthProtocolElement(reader, address, operations); } if (!operations.containsKey(address.append(AuthTokenResourceDefinition.WILDCARD_PATH))) { throw ParseUtils.missingOneOf(reader, EnumSet.of(XMLElement.PLAIN_TOKEN, XMLElement.DIGEST_TOKEN, XMLElement.CIPHER_TOKEN)); } }
protected void installServices(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final String groupName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement() .getValue(); final boolean active = MdbDeliveryGroupResourceDefinition.ACTIVE.resolveModelAttribute(context, model).asBoolean(); context.getServiceTarget().addService(getDeliveryGroupServiceName(groupName), Service.NULL) .setInitialMode(active? ServiceController.Mode.ACTIVE: ServiceController.Mode.NEVER).install(); } }
@Override public AttributeValueTranslator getReadTranslator() { return (context, value) -> { String poolName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { Resource resource = subsystem.getChild(PathElement.pathElement(type, poolName)); if (resource != null) { return resource.getModel().get("jndi-name"); } } throw InfinispanLogger.ROOT_LOGGER.dataSourceNotFound(poolName); }; }
@Override public OperationStepHandler apply(OperationStepHandler handler) { return (context, operation) -> { if (operation.hasDefined(this.attribute.getName())) { // Translate deprecated table attribute into separate add table operation ModelNode addTableOperation = Util.createAddOperation(context.getCurrentAddress().append(this.path)); ModelNode parameters = operation.get(this.attribute.getName()); for (Property parameter : parameters.asPropertyList()) { addTableOperation.get(parameter.getName()).set(parameter.getValue()); } context.addStep(addTableOperation, context.getResourceRegistration().getOperationHandler(PathAddress.pathAddress(this.path), ModelDescriptionConstants.ADD), context.getCurrentStage()); } 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(); final String jndiName = ManagedExecutorServiceResourceDefinition.JNDI_NAME_AD.resolveModelAttribute(context, model).asString(); final int priority = ManagedThreadFactoryResourceDefinition.PRIORITY_AD.resolveModelAttribute(context, model).asInt(); final ManagedThreadFactoryService service = new ManagedThreadFactoryService(name, jndiName, priority); final ServiceBuilder<ManagedThreadFactoryImpl> serviceBuilder = context.getServiceTarget().addService(ConcurrentServiceNames.getManagedThreadFactoryServiceName(name), service); String contextService = null; if(model.hasDefined(ManagedThreadFactoryResourceDefinition.CONTEXT_SERVICE)) { contextService = ManagedThreadFactoryResourceDefinition.CONTEXT_SERVICE_AD.resolveModelAttribute(context, model).asString(); } if (contextService != null) { serviceBuilder.addDependency(ConcurrentServiceNames.getContextServiceServiceName(contextService), ContextServiceImpl.class, service.getContextServiceInjector()); } serviceBuilder.install(); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode strictMaxPoolModel) throws OperationFailedException { final String poolName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); final int maxPoolSize = StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.resolveModelAttribute(context, strictMaxPoolModel).asInt(); final Derive derive = StrictMaxPoolResourceDefinition.parseDeriveSize(context, strictMaxPoolModel); final long timeout = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.resolveModelAttribute(context, strictMaxPoolModel).asLong(); final String unit = StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.resolveModelAttribute(context, strictMaxPoolModel).asString(); // create and install the service final StrictMaxPoolConfigService poolConfigService = new StrictMaxPoolConfigService(poolName, maxPoolSize, derive, timeout, TimeUnit.valueOf(unit)); final ServiceName serviceName = StrictMaxPoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName); ServiceBuilder<StrictMaxPoolConfig> svcBuilder = context.getServiceTarget().addService(serviceName, poolConfigService); if (context.hasOptionalCapability(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, null, null)) { ServiceName name = context.getCapabilityServiceName(IO_MAX_THREADS_RUNTIME_CAPABILITY_NAME, Integer.class); svcBuilder.addDependency(name, Integer.class, poolConfigService.getMaxThreadsInjector()); } svcBuilder.install(); }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { // If this is a legacy configuration containing a default-stack, but no default-channel, then fabricate a default channel using the default stack // This ensures that the default channel factory capability is available to the /subsystem=infinispan/cache-container=*/transport=jgroups resource, which requires them // We can drop this compatibility workaround after we drop support for model version 3.0. if (!operation.hasDefined(Attribute.DEFAULT_CHANNEL.getName()) && operation.hasDefined(Attribute.DEFAULT_STACK.getName())) { String defaultChannel = "auto"; PathAddress channelAddress = context.getCurrentAddress().append(ChannelResourceDefinition.pathElement(defaultChannel)); ModelNode channelOperation = Util.createAddOperation(channelAddress); channelOperation.get(ChannelResourceDefinition.Attribute.STACK.getName()).set(operation.get(Attribute.DEFAULT_STACK.getName())); context.addStep(channelOperation, context.getRootResourceRegistration().getOperationHandler(channelAddress, ModelDescriptionConstants.ADD), OperationContext.Stage.MODEL); operation.get(Attribute.DEFAULT_CHANNEL.getName()).set(new ModelNode(defaultChannel)); } handler.execute(context, operation); } };
@Override public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) { if (value.isDefined()) { PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); String poolName = value.asString(); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { if (entry.getName().equals(poolName)) { value.set(entry.getModel().get("jndi-name")); return; } } } } } } };
private ModelNode createAddStrictMaxBeanInstancePoolOperation(final String name, final Integer maxPoolSize, final Long timeout, final String timeoutUnit) { // create /subsystem=ejb3/strict-max-bean-instance-pool=name:add(...) final ModelNode addStrictMaxPoolOperation = new ModelNode(); addStrictMaxPoolOperation.get(OP).set(ADD); // set the address for this operation final PathAddress address = this.getEJB3SubsystemAddress().append(PathElement.pathElement(STRICT_MAX_BEAN_INSTANCE_POOL, name)); addStrictMaxPoolOperation.get(OP_ADDR).set(address.toModelNode()); // set the params for the operation if (maxPoolSize != null) { addStrictMaxPoolOperation.get(MAX_POOL_SIZE).set(maxPoolSize); } if (timeout != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT).set(timeout); } if (timeoutUnit != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT_UNIT).set(timeoutUnit); } return addStrictMaxPoolOperation; }
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { final ModelNode address = operation.require(OP_ADDR); final String driverName = PathAddress.pathAddress(address).getLastElement().getValue(); for (AttributeDefinition attribute : Constants.JDBC_DRIVER_ATTRIBUTES) { // https://issues.jboss.org/browse/WFLY-9324 skip validation on driver-name if (!attribute.getName().equals(DRIVER_NAME_NAME)) { attribute.validateAndSet(operation, model); } } model.get(DRIVER_NAME.getName()).set(driverName);//this shouldn't be here anymore }