use of org.jboss.as.controller.OperationContext in project wildfly by wildfly.
the class IDMConfigAddStepHandler method configureModelValidators.
private void configureModelValidators(ModelValidationStepHandler[] modelValidators) {
List<AttributeDefinition> alternativeAttributes = new ArrayList<AttributeDefinition>();
for (AttributeDefinition attribute : this.attributes) {
if (attribute.getAlternatives() != null && attribute.getAlternatives().length > 0) {
alternativeAttributes.add(attribute);
}
}
if (!alternativeAttributes.isEmpty()) {
this.modelValidators.add(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()]), isAlternativesRequired()));
}
if (modelValidators != null) {
this.modelValidators.addAll(Arrays.asList(modelValidators));
}
this.modelValidators.add(new ModelValidationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
Resource resource = context.readResourceFromRoot(address);
final ModelNode parentModel = Resource.Tools.readModel(resource);
PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
context.stepCompleted();
}
});
}
use of org.jboss.as.controller.OperationContext in project wildfly by wildfly.
the class IdentityStoreRemoveStepHandler method updateModel.
@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
checkIfLastIdentityStore(context);
super.updateModel(context, operation);
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
String configurationName = address.getElement(address.size() - 2).getValue();
String partitionManagerName = address.getElement(address.size() - 3).getValue();
String identityStoreName = address.getLastElement().getValue();
context.removeService(PartitionManagerService.createIdentityStoreServiceName(partitionManagerName, configurationName, identityStoreName));
context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
}
}, OperationContext.Stage.RUNTIME);
}
use of org.jboss.as.controller.OperationContext in project wildfly by wildfly.
the class LogStoreParticipantDeleteHandler method refreshParticipant.
void refreshParticipant(OperationContext context) {
final ModelNode operation = Util.createEmptyOperation("refresh-log-store", context.getCurrentAddress().getParent().getParent());
context.addStep(operation, new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
probeHandler.execute(context, operation);
}
}, OperationContext.Stage.MODEL);
}
use of org.jboss.as.controller.OperationContext in project wildfly by wildfly.
the class CacheServiceHandler method removeServices.
@Override
public void removeServices(OperationContext context, ModelNode model) {
PathAddress cacheAddress = context.getCurrentAddress();
PathAddress containerAddress = cacheAddress.getParent();
String containerName = containerAddress.getLastElement().getValue();
String cacheName = cacheAddress.getLastElement().getValue();
for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
for (ServiceNameProvider builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(cacheAddress), containerName, cacheName)) {
context.removeService(builder.getServiceName());
}
}
context.removeService(InfinispanBindingFactory.createCacheBinding(containerName, cacheName).getBinderServiceName());
context.removeService(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName).getBinderServiceName());
context.removeService(new XAResourceRecoveryBuilder(cacheAddress).getServiceName());
context.removeService(CacheComponent.MODULE.getServiceName(cacheAddress));
EnumSet.allOf(CacheResourceDefinition.Capability.class).stream().map(capability -> capability.getServiceName(cacheAddress)).forEach(serviceName -> context.removeService(serviceName));
}
use of org.jboss.as.controller.OperationContext in project wildfly by wildfly.
the class CacheServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress cacheAddress = context.getCurrentAddress();
PathAddress containerAddress = cacheAddress.getParent();
String containerName = containerAddress.getLastElement().getValue();
String cacheName = cacheAddress.getLastElement().getValue();
ServiceTarget target = context.getServiceTarget();
ServiceName moduleServiceName = CacheComponent.MODULE.getServiceName(cacheAddress);
if (model.hasDefined(MODULE.getName())) {
new ModuleBuilder(moduleServiceName, MODULE).configure(context, model).build(target).install();
} else {
new AliasServiceBuilder<>(moduleServiceName, CacheContainerComponent.MODULE.getServiceName(containerAddress), Module.class).build(target).install();
}
this.builderFactory.createBuilder(cacheAddress).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
new CacheBuilder<>(CACHE.getServiceName(cacheAddress), containerName, cacheName).configure(context).build(target).install();
new XAResourceRecoveryBuilder(cacheAddress).build(target).install();
new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheConfigurationBinding(containerName, cacheName), CONFIGURATION.getServiceName(cacheAddress), Configuration.class).build(target).install();
BinderServiceBuilder<?> bindingBuilder = new BinderServiceBuilder<>(InfinispanBindingFactory.createCacheBinding(containerName, cacheName), CACHE.getServiceName(cacheAddress), Cache.class);
ModelNodes.optionalString(JNDI_NAME.resolveModelAttribute(context, model)).map(jndiName -> ContextNames.bindInfoFor(JndiNameFactory.parse(jndiName).getAbsoluteName())).ifPresent(aliasBinding -> bindingBuilder.alias(aliasBinding));
bindingBuilder.build(target).install();
for (CacheBuilderProvider provider : ServiceLoader.load(this.providerClass, this.providerClass.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(cacheAddress), containerName, cacheName)) {
builder.configure(context).build(target).install();
}
}
}
Aggregations