@Override public void registerAttributes(ManagementResourceRegistration registration) { super.registerAttributes(registration); // check that we don't need a special handler here? final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES); for (AttributeDefinition attr : ATTRIBUTES) { registration.registerReadWriteAttribute(attr, null, writeHandler); } }
@Override public void register(ManagementResourceRegistration parentRegistration) { ManagementResourceRegistration registration = parentRegistration.registerSubModel(this); parentRegistration.registerAlias(LEGACY_PATH, new SimpleAliasEntry(registration)); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()) .addAttributes(JDBCStoreResourceDefinition.Attribute.class) .addAttributes(StoreResourceDefinition.Attribute.class) .addExtraParameters(DeprecatedAttribute.class) .addExtraParameters(JDBCStoreResourceDefinition.DeprecatedAttribute.class) .addCapabilities(Capability.class) .addRequiredChildren(BinaryTableResourceDefinition.PATH) .addRequiredSingletonChildren(StoreWriteThroughResourceDefinition.PATH); ResourceServiceHandler handler = new SimpleResourceServiceHandler<>(new BinaryKeyedJDBCStoreBuilderFactory()); new AddStepHandler(descriptor, handler) { @Override protected void populateModel(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { translateAddOperation(context, operation); if (operation.hasDefined(DeprecatedAttribute.TABLE.getDefinition().getName())) { // Translate deprecated TABLE attribute into separate add table operation ModelNode addTableOperation = Util.createAddOperation( context.getCurrentAddress().append(BinaryTableResourceDefinition.PATH)); ModelNode parameters = operation.get(DeprecatedAttribute.TABLE.getDefinition().getName()); for (Property parameter : parameters.asPropertyList()) { addTableOperation.get(parameter.getName()).set(parameter.getValue()); } context.addStep( addTableOperation, registration.getOperationHandler( PathAddress.pathAddress(BinaryTableResourceDefinition.PATH), ModelDescriptionConstants.ADD), context.getCurrentStage()); } super.populateModel(context, operation, resource); } }.register(registration); new RemoveStepHandler(descriptor, handler).register(registration); registration.registerReadWriteAttribute( DeprecatedAttribute.TABLE.getDefinition(), LEGACY_READ_TABLE_HANDLER, LEGACY_WRITE_TABLE_HANDLER); new BinaryTableResourceDefinition().register(registration); super.register(registration); }
static void buildTransformation( ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH) : parent.addChildResource(PATH); if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) { builder.setCustomResourceTransformer( new ResourceTransformer() { @Override public void transformResource( ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); final ModelNode binaryTableModel = Resource.Tools.readModel( resource.removeChild(BinaryTableResourceDefinition.PATH)); if (binaryTableModel != null && binaryTableModel.isDefined()) { model .get(DeprecatedAttribute.TABLE.getDefinition().getName()) .set(binaryTableModel); } final ModelNode properties = model.remove( StoreResourceDefinition.Attribute.PROPERTIES.getDefinition().getName()); final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource); LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources( properties, address, childContext); context.processChildren(resource); } }); } BinaryTableResourceDefinition.buildTransformation(version, builder); JDBCStoreResourceDefinition.buildTransformation(version, builder); }
static void buildTransformation( ModelVersion version, ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH); JDBCStoreResourceDefinition.buildTransformation(version, builder); }