use of org.jboss.as.clustering.controller.ListAttributeTranslation in project wildfly by wildfly.
the class CacheResourceDefinition method register.
@SuppressWarnings("deprecation")
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = this.configurator.apply(new ResourceDescriptor(this.getResourceDescriptionResolver())).addAttributes(Attribute.class).addAttributes(ListAttribute.class).addIgnoredAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MODULE))).addAttributeTranslation(DeprecatedAttribute.MODULE, new ListAttributeTranslation(ListAttribute.MODULES)).addCapabilities(Capability.class).addCapabilities(CLUSTERING_CAPABILITIES.values()).addRequiredChildren(ExpirationResourceDefinition.PATH, LockingResourceDefinition.PATH, TransactionResourceDefinition.PATH).addRequiredSingletonChildren(HeapMemoryResourceDefinition.PATH, NoStoreResourceDefinition.PATH);
new SimpleResourceRegistration(descriptor, this.handler).register(registration);
if (registration.isRuntimeOnlyRegistrationValid()) {
for (DeprecatedMetric metric : EnumSet.allOf(DeprecatedMetric.class)) {
metric.register(registration);
}
for (FixedMetric metric : EnumSet.allOf(FixedMetric.class)) {
metric.register(registration);
}
}
new HeapMemoryResourceDefinition().register(registration);
new OffHeapMemoryResourceDefinition().register(registration);
new ExpirationResourceDefinition().register(registration);
new LockingResourceDefinition().register(registration);
new TransactionResourceDefinition().register(registration);
new NoStoreResourceDefinition().register(registration);
new CustomStoreResourceDefinition().register(registration);
new FileStoreResourceDefinition().register(registration);
new BinaryKeyedJDBCStoreResourceDefinition().register(registration);
new MixedKeyedJDBCStoreResourceDefinition().register(registration);
new StringKeyedJDBCStoreResourceDefinition().register(registration);
new RemoteStoreResourceDefinition().register(registration);
new HotRodStoreResourceDefinition().register(registration);
return registration;
}
use of org.jboss.as.clustering.controller.ListAttributeTranslation in project wildfly by wildfly.
the class CacheContainerResourceDefinition method register.
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(ListAttribute.class).addIgnoredAttributes(ExecutorAttribute.class).addIgnoredAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MODULE))).addAttributeTranslation(DeprecatedAttribute.MODULE, new ListAttributeTranslation(ListAttribute.MODULES)).addCapabilities(Capability.class).addCapabilities(model -> model.hasDefined(Attribute.DEFAULT_CACHE.getName()), DEFAULT_CAPABILITIES.values()).addCapabilities(model -> model.hasDefined(Attribute.DEFAULT_CACHE.getName()), DEFAULT_CLUSTERING_CAPABILITIES.values()).addRequiredChildren(EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT))).addRequiredChildren(ScheduledThreadPoolResourceDefinition.class).addRequiredSingletonChildren(NoTransportResourceDefinition.PATH).setResourceTransformation(CacheContainerResource::new);
ServiceValueExecutorRegistry<EmbeddedCacheManager> managerExecutors = new ServiceValueExecutorRegistry<>();
ServiceValueExecutorRegistry<Cache<?, ?>> cacheExecutors = new ServiceValueExecutorRegistry<>();
ResourceServiceHandler handler = new CacheContainerServiceHandler(managerExecutors, cacheExecutors);
new SimpleResourceRegistration(descriptor, handler).register(registration);
// Translate legacy add-alias operation to list-add operation
OperationStepHandler addAliasHandler = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode legacyOperation) {
String value = legacyOperation.get(ALIAS.getName()).asString();
ModelNode operation = Operations.createListAddOperation(context.getCurrentAddress(), ListAttribute.ALIASES, value);
context.addStep(operation, ListOperations.LIST_ADD_HANDLER, context.getCurrentStage());
}
};
registration.registerOperationHandler(ALIAS_ADD, addAliasHandler);
// Translate legacy remove-alias operation to list-remove operation
OperationStepHandler removeAliasHandler = new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode legacyOperation) throws OperationFailedException {
String value = legacyOperation.get(ALIAS.getName()).asString();
ModelNode operation = Operations.createListRemoveOperation(context.getCurrentAddress(), ListAttribute.ALIASES, value);
context.addStep(operation, ListOperations.LIST_REMOVE_HANDLER, context.getCurrentStage());
}
};
registration.registerOperationHandler(ALIAS_REMOVE, removeAliasHandler);
if (registration.isRuntimeOnlyRegistrationValid()) {
new MetricHandler<>(new CacheContainerMetricExecutor(managerExecutors), CacheContainerMetric.class).register(registration);
new CacheRuntimeResourceDefinition(cacheExecutors).register(registration);
}
new JGroupsTransportResourceDefinition().register(registration);
new NoTransportResourceDefinition().register(registration);
for (ThreadPoolResourceDefinition pool : EnumSet.complementOf(EnumSet.of(ThreadPoolResourceDefinition.CLIENT))) {
pool.register(registration);
}
for (ScheduledThreadPoolResourceDefinition pool : EnumSet.allOf(ScheduledThreadPoolResourceDefinition.class)) {
pool.register(registration);
}
new LocalCacheResourceDefinition(cacheExecutors).register(registration);
new InvalidationCacheResourceDefinition(cacheExecutors).register(registration);
new ReplicatedCacheResourceDefinition(cacheExecutors).register(registration);
new DistributedCacheResourceDefinition(cacheExecutors).register(registration);
new ScatteredCacheResourceDefinition(cacheExecutors).register(registration);
return registration;
}
use of org.jboss.as.clustering.controller.ListAttributeTranslation in project wildfly by wildfly.
the class RemoteCacheContainerResourceDefinition method register.
@SuppressWarnings("deprecation")
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parentRegistration) {
ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(ListAttribute.class).addIgnoredAttributes(EnumSet.complementOf(EnumSet.of(DeprecatedAttribute.MODULE))).addAttributeTranslation(DeprecatedAttribute.MODULE, new ListAttributeTranslation(ListAttribute.MODULES)).addCapabilities(Capability.class).addRequiredChildren(ConnectionPoolResourceDefinition.PATH, ThreadPoolResourceDefinition.CLIENT.getPathElement(), SecurityResourceDefinition.PATH, RemoteTransactionResourceDefinition.PATH).addRequiredSingletonChildren(NoNearCacheResourceDefinition.PATH).setResourceTransformation(RemoteCacheContainerResource::new);
ServiceValueExecutorRegistry<RemoteCacheContainer> executors = new ServiceValueExecutorRegistry<>();
ResourceServiceHandler handler = new RemoteCacheContainerServiceHandler(this, executors);
new SimpleResourceRegistration(descriptor, handler).register(registration);
new ConnectionPoolResourceDefinition().register(registration);
new RemoteClusterResourceDefinition(this, executors).register(registration);
new SecurityResourceDefinition().register(registration);
new RemoteTransactionResourceDefinition().register(registration);
new InvalidationNearCacheResourceDefinition().register(registration);
new NoNearCacheResourceDefinition().register(registration);
ThreadPoolResourceDefinition.CLIENT.register(registration);
if (registration.isRuntimeOnlyRegistrationValid()) {
new MetricHandler<>(new RemoteCacheContainerMetricExecutor(executors), RemoteCacheContainerMetric.class).register(registration);
new RemoteCacheResourceDefinition(executors).register(registration);
}
return registration;
}
Aggregations