@Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { Resource untransformedResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode untransformedModel = Resource.Tools.readModel(untransformedResource); String statefulCache = untransformedModel.get(DEFAULT_SFSB_CACHE).asString(); String statefulPassivationDisabledCache = untransformedModel.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE).asString(); ModelNode transformed = resource.getModel(); transformed.get(DEFAULT_SFSB_CACHE).set(statefulPassivationDisabledCache); transformed.get(EJB3SubsystemModel.DEFAULT_CLUSTERED_SFSB_CACHE).set(statefulCache); transformed.remove(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE); final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource); childContext.processChildren(resource); } }
@Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { Resource untransformedResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode untransformedModel = Resource.Tools.readModel(untransformedResource); String defaultDataStore = untransformedModel.get(TimerServiceResourceDefinition.DEFAULT_DATA_STORE.getName()).asString(); ModelNode transformed = resource.getModel(); transformed.remove(TimerServiceResourceDefinition.DEFAULT_DATA_STORE.getName()); ModelNode fileStore = untransformedModel.get(EJB3SubsystemModel.FILE_DATA_STORE, defaultDataStore); if (!fileStore.isDefined()) {//happens where default is not file-store rejectIncompatibleDataStores(context, address); } else if ((untransformedModel.hasDefined(EJB3SubsystemModel.DATABASE_DATA_STORE) && untransformedModel.get(EJB3SubsystemModel.DATABASE_DATA_STORE).keys().size() > 0) || untransformedModel.get(EJB3SubsystemModel.FILE_DATA_STORE).keys().size() > 1) { rejectIncompatibleDataStores(context, address); } ModelNode path = fileStore.get(EJB3SubsystemModel.PATH); transformed.get(EJB3SubsystemModel.PATH).set(path); transformed.get(EJB3SubsystemModel.RELATIVE_TO).set(fileStore.get(EJB3SubsystemModel.RELATIVE_TO)); context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource); //do not process children! }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode authModules = Resource.Tools.readModel(resource).get(newKeyName); ModelNode result = new ModelNode(); if (authModules.isDefined()) { List<Property> loginModules = authModules.asPropertyList(); for (Property p : loginModules) { result.add(p.getValue()); } } context.getResult().set(result); } }
public void installRuntimeServices(OperationContext context, ModelNode model, String name) throws OperationFailedException { final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS), 2);
final ModelNode jacorbModel = Resource.Tools.readModel(jacorbResource).clone();
final PathAddress serverAddress = address.getParent(); final PathAddress subsystemAddress = serverAddress.getParent(); final ModelNode subsystemModel = Resource.Tools.readModel(context.readResourceFromRoot(subsystemAddress, false), 0); final ModelNode serverModel = Resource.Tools.readModel(context.readResourceFromRoot(serverAddress, false), 0);
return DiscardPolicy.REJECT_AND_WARN; ModelNode infinispanModel = Resource.Tools.readModel(infinispanResource);
PathAddress proxyAddress = context.getCurrentAddress().append(ProxyConfigurationResourceDefinition.pathElement(proxyName)); adapterNames.add(proxyName); ModelNode proxyModel = Resource.Tools.readModel(proxyResource);
@SuppressWarnings("deprecation") @Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); final ModelNode maxBatchSize = model.remove(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getName()); final ModelNode binaryTableModel = Resource.Tools.readModel(resource.removeChild(BinaryTableResourceDefinition.PATH)); if (binaryTableModel != null && binaryTableModel.isDefined()) { model.get(DeprecatedAttribute.BINARY_TABLE.getName()).set(binaryTableModel); model.get(DeprecatedAttribute.BINARY_TABLE.getName()).get(TableResourceDefinition.DeprecatedAttribute.BATCH_SIZE.getName()).set((maxBatchSize != null) ? maxBatchSize : new ModelNode()); } final ModelNode stringTableModel = Resource.Tools.readModel(resource.removeChild(StringTableResourceDefinition.PATH)); if (stringTableModel != null && stringTableModel.isDefined()) { model.get(DeprecatedAttribute.STRING_TABLE.getName()).set(stringTableModel); model.get(DeprecatedAttribute.STRING_TABLE.getName()).get(TableResourceDefinition.DeprecatedAttribute.BATCH_SIZE.getName()).set((maxBatchSize != null) ? maxBatchSize : new ModelNode()); } final ModelNode properties = model.remove(StoreResourceDefinition.Attribute.PROPERTIES.getName()); final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource); LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources(properties, address, childContext); context.processChildren(resource); } });
private OptionMap getChannelCreationOptions(final OperationContext context) throws OperationFailedException { // read the full model of the current resource final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); final ModelNode channelCreationOptions = fullModel.get(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS); if (channelCreationOptions.isDefined() && channelCreationOptions.asInt() > 0) { final ClassLoader loader = this.getClass().getClassLoader(); final OptionMap.Builder builder = OptionMap.builder(); for (final Property optionProperty : channelCreationOptions.asPropertyList()) { final String name = optionProperty.getName(); final ModelNode propValueModel = optionProperty.getValue(); final String type = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.resolveModelAttribute(context,propValueModel).asString(); final String optionClassName = this.getClassNameForChannelOptionType(type); final String fullyQualifiedOptionName = optionClassName + "." + name; final Option option = Option.fromString(fullyQualifiedOptionName, loader); final String value = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.resolveModelAttribute(context, propValueModel).asString(); builder.set(option, option.parseValue(value, loader)); } return builder.getMap(); } return OptionMap.EMPTY; }
/** * Make any runtime changes necessary to effect the changes indicated by the given {@code operation}. E * <p> * It constructs a MailSessionService that provides mail session and registers it to Naming service. * </p> * * @param context the operation context * @param operation the operation being executed * @param model persistent configuration model node that corresponds to the address of {@code operation} * @throws org.jboss.as.controller.OperationFailedException * if {@code operation} is invalid or updating the runtime otherwise fails */ @Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); ModelNode fullTree = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); installRuntimeServices(context, address, fullTree); }
@SuppressWarnings("deprecation") @Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); final ModelNode maxBatchSize = model.remove(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getName()); final ModelNode stringTableModel = Resource.Tools.readModel(resource.removeChild(StringTableResourceDefinition.PATH)); if (stringTableModel != null && stringTableModel.isDefined()) { model.get(DeprecatedAttribute.TABLE.getName()).set(stringTableModel); model.get(DeprecatedAttribute.TABLE.getName()).get(TableResourceDefinition.DeprecatedAttribute.BATCH_SIZE.getName()).set((maxBatchSize != null) ? maxBatchSize : new ModelNode()); } final ModelNode properties = model.remove(StoreResourceDefinition.Attribute.PROPERTIES.getName()); final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource); LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources(properties, address, childContext); context.processChildren(resource); } });
@SuppressWarnings("deprecation") @Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { final ModelNode model = resource.getModel(); final ModelNode maxBatchSize = model.remove(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getName()); final ModelNode binaryTableModel = Resource.Tools.readModel(resource.removeChild(BinaryTableResourceDefinition.PATH)); if (binaryTableModel != null && binaryTableModel.isDefined()) { model.get(DeprecatedAttribute.TABLE.getName()).set(binaryTableModel); model.get(DeprecatedAttribute.TABLE.getName()).get(TableResourceDefinition.DeprecatedAttribute.BATCH_SIZE.getName()).set((maxBatchSize != null) ? maxBatchSize : new ModelNode()); } final ModelNode properties = model.remove(StoreResourceDefinition.Attribute.PROPERTIES.getName()); final ResourceTransformationContext childContext = context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource); LegacyPropertyResourceTransformer.transformPropertiesToChildrenResources(properties, address, childContext); context.processChildren(resource); } });
private void addCommonHostListenerDeps(OperationContext context, ServiceBuilder<WebServerService> builder, final PathElement listenerPath) { ModelNode listeners = Resource.Tools.readModel(context.readResource(PathAddress.pathAddress(listenerPath)), 1); if (listeners.isDefined()) { for (Property p : listeners.asPropertyList()) { for (Property listener : p.getValue().asPropertyList()) { builder.requires(ListenerResourceDefinition.LISTENER_CAPABILITY.getCapabilityServiceName(listener.getName())); } } } } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode node = Resource.Tools.readModel(resource); launchServices(context, node); // Rollback handled by the parent step context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
@Override public void transformResource(ResourceTransformationContext context, PathAddress address, Resource resource) throws OperationFailedException { if (resource.hasChild(SimpleLoadProviderResourceDefinition.PATH)) { ModelNode model = resource.getModel(); ModelNode simpleModel = Resource.Tools.readModel(resource.removeChild(SimpleLoadProviderResourceDefinition.PATH)); model.get(DeprecatedAttribute.SIMPLE_LOAD_PROVIDER.getName()).set(simpleModel.get(SimpleLoadProviderResourceDefinition.Attribute.FACTOR.getName())); } context.addTransformedResource(PathAddress.EMPTY_ADDRESS, resource).processChildren(resource); } });
@Override public void installServices(OperationContext context, ModelNode model) throws OperationFailedException { super.installServices(context, Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS))); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); final ModelNode model = Resource.Tools.readModel(resource); final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); RemotingProfileAdd.INSTANCE.installServices(context, address, model); } }
@Override public DiscardPolicy checkResource(TransformationContext context, PathAddress address) { ModelNode model = Resource.Tools.readModel(context.readResourceFromRoot(address)); for (Attribute attribute : this.attributes) { if (model.hasDefined(attribute.getName())) { return DiscardPolicy.REJECT_AND_WARN; } } return DiscardPolicy.SILENT; } }
@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);