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 }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size() - 1), false); final ModelNode subModel = web.getModel(); final String host = DeploymentDefinition.VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString(); final String path = DeploymentDefinition.CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString(); final String server = DeploymentDefinition.SERVER.resolveModelAttribute(context, subModel).asString(); context.addStep(new OperationStepHandler() { @Override public void execute(final OperationContext context, final ModelNode operation) { final ServiceController<?> deploymentServiceController = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (deploymentServiceController == null) { return; } final UndertowDeploymentService deploymentService = (UndertowDeploymentService) deploymentServiceController.getService(); final DeploymentInfo deploymentInfo = deploymentService.getDeploymentInfoInjectedValue().getValue(); final ServletInfo servlet = deploymentInfo.getServlets().get(context.getCurrentAddressValue()); ModelNode response = new ModelNode(); response.setEmptyList(); for (String mapping : servlet.getMappings()) { response.add(mapping); } } }, OperationContext.Stage.RUNTIME); } });
@Override public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { for (ModelNode property : resourceModel.get(attribute.getName()).asList()) { writer.writeStartElement(attribute.getXmlName()); writer.writeAttribute(org.jboss.as.controller.parsing.Attribute.NAME.getLocalName(), property.asProperty().getName()); writer.writeCharacters(property.asProperty().getValue().asString()); writer.writeEndElement(); } }
private void recordCapabilitiesAndRequirements(OperationContext context, Resource resource) throws OperationFailedException { context.deregisterCapability(MailServerDefinition.SERVER_CAPABILITY.getDynamicName(context.getCurrentAddress())); ModelNode model = resource.getModel(); for (AttributeDefinition ad : attributes) { if (ad != null && (model.hasDefined(ad.getName()) || ad.hasCapabilityRequirements())) { ad.removeCapabilityRequirements(context, resource, model.get(ad.getName())); } } }
static ModelNode resolveValue(final OperationContext context, final ModelNode operation, final AttributeDefinition attribute) throws OperationFailedException { final ModelNode value = new ModelNode(); if (operation.has(attribute.getName())) { value.set(operation.get(attribute.getName())); } return attribute.resolveValue(context, value); }
private ModelNode getResolvedModel(OperationContext context, ModelNode model) throws OperationFailedException { ModelNode resolved = new ModelNode(); for (AttributeDefinition attribute : attributes) { resolved.get(attribute.getName()).set(attribute.resolveModelAttribute(context, model)); } return resolved; }
@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); } };
@Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size()), false); final ModelNode subModel = web.getModel(); final String host = VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString(); final String path = CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString(); final String server = SERVER.resolveModelAttribute(context, subModel).asString(); SessionStat stat = SessionStat.getStat(operation.require(ModelDescriptionConstants.NAME).asString()); context.getFailureDescription().set(UndertowLogger.ROOT_LOGGER.unknownMetric(operation.require(ModelDescriptionConstants.NAME).asString())); } else { ModelNode result = new ModelNode(); final ServiceController<?> controller = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (controller != null && controller.getState() != ServiceController.State.UP) {//check if deployment is active at all return;
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); final String name = context.getCurrentAddressValue(); final String locationType = address.getElement(address.size() - 2).getKey(); final PathAddress hostAddress = address.getParent(); final PathAddress serverAddress = hostAddress.getParent(); final String serverName = serverAddress.getLastElement().getValue(); final String hostName = hostAddress.getLastElement().getValue(); locationService = context.getCapabilityServiceName(Capabilities.CAPABILITY_HOST, FilterLocation.class, serverName, hostName); } else { final PathAddress locationAddress = address.getParent(); if (model.hasDefined(PREDICATE.getName())) { String predicateString = model.get(PREDICATE.getName()).asString(); predicate = PredicateParser.parse(predicateString, getClass().getClassLoader()); int priority = PRIORITY.resolveModelAttribute(context, operation).asInt(); final FilterRef service = new FilterRef(predicate, priority); final ServiceTarget target = context.getServiceTarget();
protected void installServices(final OperationContext context, final PathAddress address, final ModelNode profileNode) throws OperationFailedException { try { final String profileName = address.getLastElement().getValue(); final ServiceName profileServiceName = RemotingProfileService.BASE_SERVICE_NAME.append(profileName); final ModelNode staticEjbDiscoery = StaticEJBDiscoveryDefinition.INSTANCE.resolveModelAttribute(context, profileNode); List<StaticEJBDiscoveryDefinition.StaticEjbDiscovery> discoveryList = StaticEJBDiscoveryDefinition.createStaticEjbList(context, staticEjbDiscoery); final RemotingProfileService profileService = new RemotingProfileService(urls, map); final ServiceBuilder<RemotingProfileService> builder = context.getServiceTarget().addService(profileServiceName, profileService); if (profileNode.hasDefined(EJB3SubsystemModel.REMOTING_EJB_RECEIVER)) { for (final Property receiverProperty : profileNode.get(EJB3SubsystemModel.REMOTING_EJB_RECEIVER) .asPropertyList()) { final ModelNode receiverNode = receiverProperty.getValue(); final String connectionRef = RemotingEjbReceiverDefinition.OUTBOUND_CONNECTION_REF.resolveModelAttribute(context, receiverNode).asString(); final long timeout = RemotingEjbReceiverDefinition.CONNECT_TIMEOUT.resolveModelAttribute(context, receiverNode).asLong(); .resolveModelAttribute(context, profileNode).asBoolean();
protected void writeJobExecutorContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException { ModelNode node = context.getModelNode(); ModelNode jobExecutorNode = node.get(Element.JOB_EXECUTOR.getLocalName()); if (jobExecutorNode.isDefined()) { writer.writeStartElement(Element.JOB_EXECUTOR.getLocalName()); for (Property property : jobExecutorNode.asPropertyList()) { ModelNode propertyValue = property.getValue(); for (AttributeDefinition jobExecutorAttribute : SubsystemAttributeDefinitons.JOB_EXECUTOR_ATTRIBUTES) { if (jobExecutorAttribute.equals(SubsystemAttributeDefinitons.NAME)) { ((SimpleAttributeDefinition) jobExecutorAttribute).marshallAsAttribute(propertyValue, writer); } else { jobExecutorAttribute.marshallAsElement(propertyValue, writer); } } writeJobAcquisitionsContent(writer, context, propertyValue); } // end job-executor writer.writeEndElement(); } }
final SessionCookieConfig config = SessionCookieDefinition.INSTANCE.getConfig(context, fullModel.get(SessionCookieDefinition.INSTANCE.getPathElement().getKeyValuePair())); final CrawlerSessionManagerConfig crawlerSessionManagerConfig = CrawlerSessionManagementDefinition.INSTANCE.getConfig(context, fullModel.get(CrawlerSessionManagementDefinition.INSTANCE.getPathElement().getKeyValuePair())); final boolean persistentSessions = PersistentSessionsDefinition.isEnabled(context, fullModel.get(PersistentSessionsDefinition.INSTANCE.getPathElement().getKeyValuePair())); final boolean allowNonStandardWrappers = ServletContainerDefinition.ALLOW_NON_STANDARD_WRAPPERS.resolveModelAttribute(context, model).asBoolean(); final boolean proactiveAuth = ServletContainerDefinition.PROACTIVE_AUTHENTICATION.resolveModelAttribute(context, model).asBoolean(); final String bufferCache = ServletContainerDefinition.DEFAULT_BUFFER_CACHE.resolveModelAttribute(context, model).asString(); final boolean disableFileWatchService = ServletContainerDefinition.DISABLE_FILE_WATCH_SERVICE.resolveModelAttribute(context, model).asBoolean(); final boolean disableSessionIdReususe = ServletContainerDefinition.DISABLE_SESSION_ID_REUSE.resolveModelAttribute(context, model).asBoolean(); final String stackTracesString = ServletContainerDefinition.STACK_TRACE_ON_ERROR.resolveModelAttribute(context, model).asString(); final boolean useListenerEncoding = ServletContainerDefinition.USE_LISTENER_ENCODING.resolveModelAttribute(context, model).asBoolean(); final boolean ignoreFlush = ServletContainerDefinition.IGNORE_FLUSH.resolveModelAttribute(context, model).asBoolean(); final boolean eagerFilterInit = ServletContainerDefinition.EAGER_FILTER_INIT.resolveModelAttribute(context, model).asBoolean(); final boolean disableCachingForSecuredPages = ServletContainerDefinition.DISABLE_CACHING_FOR_SECURED_PAGES.resolveModelAttribute(context, model).asBoolean(); final int sessionIdLength = ServletContainerDefinition.SESSION_ID_LENGTH.resolveModelAttribute(context, model).asInt(); final int fileCacheMetadataSize = ServletContainerDefinition.FILE_CACHE_METADATA_SIZE.resolveModelAttribute(context, model).asInt(); final int fileCacheMaxFileSize = ServletContainerDefinition.FILE_CACHE_MAX_FILE_SIZE.resolveModelAttribute(context, model).asInt(); final ModelNode fileCacheTtlNode = ServletContainerDefinition.FILE_CACHE_TIME_TO_LIVE.resolveModelAttribute(context, model); final Integer fileCacheTimeToLive = fileCacheTtlNode.isDefined() ? fileCacheTtlNode.asInt() : null; final int defaultCookieVersion = ServletContainerDefinition.DEFAULT_COOKIE_VERSION.resolveModelAttribute(context, model).asInt(); directoryListingEnabled = ServletContainerDefinition.DIRECTORY_LISTING.resolveModelAttribute(context, model).asBoolean(); maxSessions = ServletContainerDefinition.MAX_SESSIONS.resolveModelAttribute(context, model).asInt(); final int sessionTimeout = ServletContainerDefinition.DEFAULT_SESSION_TIMEOUT.resolveModelAttribute(context, model).asInt();
JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute().marshallAsElement(workManager, writer); for (Property prop : workManager.asPropertyList()) { if ((JcaDistributedWorkManagerDefinition.DWmParameters.POLICY.getAttribute().getName().equals(prop.getName()) && prop.getValue().isDefined()) || (JcaDistributedWorkManagerDefinition.DWmParameters.POLICY.getAttribute().getName().equals(prop.getName()) && workManager.hasDefined(JcaDistributedWorkManagerDefinition.DWmParameters.POLICY_OPTIONS.getAttribute().getName()))) { writer.writeStartElement(Element.POLICY.getLocalName()); if (prop.getValue().isDefined() ) writer.writeAttribute(JcaDistributedWorkManagerDefinition.DWmParameters.NAME.getAttribute().getXmlName(), prop.getValue().asString()); else writer.writeAttribute(JcaDistributedWorkManagerDefinition.DWmParameters.NAME.getAttribute().getXmlName(), JcaDistributedWorkManagerDefinition.DWmParameters.POLICY.getAttribute().getDefaultValue().asString()); if (workManager.hasDefined(JcaDistributedWorkManagerDefinition.DWmParameters.POLICY_OPTIONS.getAttribute().getName())) { for (Property option : workManager.get(JcaDistributedWorkManagerDefinition.DWmParameters.POLICY_OPTIONS.getAttribute().getName()).asPropertyList()) { writeProperty(writer, option.getName(), option .getValue().asString(), Element.OPTION.getLocalName()); if (JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR.getAttribute().getName().equals(prop.getName()) && prop.getValue().isDefined()) { writer.writeStartElement(Element.SELECTOR.getLocalName()); writer.writeAttribute(JcaDistributedWorkManagerDefinition.DWmParameters.NAME.getAttribute().getXmlName(), prop.getValue().asString()); if (workManager.hasDefined(JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR_OPTIONS.getAttribute().getName())) { for (Property option : workManager.get(JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR_OPTIONS.getAttribute().getName()).asPropertyList()) { writeProperty(writer, option.getName(), option .getValue().asString(), Element.OPTION.getLocalName());
definition.validateOperation(operation); PathAddress currentAddress = context.getCurrentAddress(); AttributeDefinition sourceParameter = entry.getKey(); AttributeTranslation translation = entry.getValue(); if (operation.hasDefined(sourceParameter.getName())) { ModelNode value = sourceParameter.validateOperation(operation); ModelNode targetValue = translation.getWriteTranslator().translate(context, value); Attribute targetAttribute = translation.getTargetAttribute(); if (!operation.hasDefined(targetName)) { operation.get(targetName).set(targetValue); ImmutableManagementResourceRegistration targetRegistration = translation.getResourceRegistrationTransformation().apply(context.getResourceRegistration()); OperationStepHandler writeAttributeHandler = targetRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, targetAttribute.getName()).getWriteHandler(); context.addStep(writeAttributeOperation, writeAttributeHandler, OperationContext.Stage.MODEL); ModelNode model = resource.getModel(); ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); for (String attributeName : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeDefinition definition = attribute.getAttributeDefinition(); if ((attribute.getStorageType() == AttributeAccess.Storage.CONFIGURATION) && !translations.containsKey(definition)) { definition.validateAndSet(operation, model); addRequiredChildren(context, this.descriptor.getRequiredChildren(), (Resource parent, PathElement path) -> parent.hasChild(path)); addRequiredChildren(context, this.descriptor.getRequiredSingletonChildren(), (Resource parent, PathElement path) -> parent.hasChildren(path.getKey()));
@Override protected void populateModel(final OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); for (AttributeDefinition attr : EJB3SubsystemRootResourceDefinition.ATTRIBUTES) { attr.validateAndSet(operation, model); ModelNode defClustered = DEFAULT_CLUSTERED_SFSB_CACHE.validateOperation(operation); if (defClustered.isDefined()) { boolean setDefaultSfsbCache = true; if (model.hasDefined(DEFAULT_SFSB_CACHE)) { if (model.hasDefined(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)) { if (!defClustered.equals(model.get(DEFAULT_SFSB_CACHE))) { if(context.getRunningMode() == RunningMode.ADMIN_ONLY) { EjbLogger.ROOT_LOGGER.logInconsistentAttributeNotSupported(DEFAULT_CLUSTERED_SFSB_CACHE.getName(), DEFAULT_SFSB_CACHE); setDefaultSfsbCache = false; // don't overwrite default-sfsb-cache } else { throw EjbLogger.ROOT_LOGGER.inconsistentAttributeNotSupported(DEFAULT_CLUSTERED_SFSB_CACHE.getName(), DEFAULT_SFSB_CACHE); model.get(DEFAULT_SFSB_CACHE).set(defClustered); EjbLogger.ROOT_LOGGER.remappingCacheAttributes(context.getCurrentAddress().toCLIStyleString(), defClustered, model.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE));
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); final String proxyName = address.getElement(address.size() - 2).getValue(); final String socketBinding = OUTBOUND_SOCKET_BINDING.resolveModelAttribute(context, model).asString(); final String scheme = SCHEME.resolveModelAttribute(context, model).asString(); final String path = PATH.resolveModelAttribute(context, model).asString(); final boolean enableHttp2 = ENABLE_HTTP2.resolveModelAttribute(context, model).asBoolean(); final String jvmRoute; final ModelNode securityRealm = SECURITY_REALM.resolveModelAttribute(context, model); final ModelNode sslContext = SSL_CONTEXT.resolveModelAttribute(context, model); if (model.hasDefined(Constants.INSTANCE_ID)) { jvmRoute = INSTANCE_ID.resolveModelAttribute(context, model).asString(); } else { jvmRoute = null; } ReverseProxyHostService service = new ReverseProxyHostService(scheme, jvmRoute, path, enableHttp2); CapabilityServiceBuilder<ReverseProxyHostService> builder = context.getCapabilityServiceTarget() .addCapability(REVERSE_PROXY_HOST_RUNTIME_CAPABILITY, service) .addCapabilityRequirement(Capabilities.CAPABILITY_HANDLER, HttpHandler.class, service.proxyHandler, proxyName) .addCapabilityRequirement(Capabilities.REF_OUTBOUND_SOCKET, OutboundSocketBinding.class, service.socketBinding, socketBinding); if (sslContext.isDefined()) { builder.addCapabilityRequirement(REF_SSL_CONTEXT, SSLContext.class, service.sslContext, sslContext.asString()); } if(securityRealm.isDefined()) { SecurityRealm.ServiceUtil.addDependency(builder, service.securityRealm, securityRealm.asString()); } builder.install(); } }
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException { String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue(); ServiceRegistry registry = context.getServiceRegistry(true); EJBSuspendHandlerService service = (EJBSuspendHandlerService) registry.getRequiredService(EJBSuspendHandlerService.SERVICE_NAME).getValue(); if (service!= null && this.gracefulTxnShutdownAttribute.getName().equals(attributeName)) { boolean enableGracefulTxnShutdown = this.gracefulTxnShutdownAttribute.resolveModelAttribute(context, model) .asBoolean(); service.enableGracefulTxnShutdown(enableGracefulTxnShutdown); } }
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) { if (InfinispanModel.VERSION_6_0_0.requiresTransformation(version)) { Converter converter = (PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) -> { PathAddress storeAddress = address.getParent(); PathElement storePath = storeAddress.getLastElement(); if (storePath.equals(StringKeyedJDBCStoreResourceDefinition.STRING_JDBC_PATH) || storePath.equals(StringKeyedJDBCStoreResourceDefinition.LEGACY_PATH)) { storeAddress = storeAddress.getParent().append(StringKeyedJDBCStoreResourceDefinition.PATH); } else if (storePath.equals(BinaryKeyedJDBCStoreResourceDefinition.LEGACY_PATH)) { storeAddress = storeAddress.getParent().append(BinaryKeyedJDBCStoreResourceDefinition.PATH); } else if (storePath.equals(MixedKeyedJDBCStoreResourceDefinition.LEGACY_PATH)) { storeAddress = storeAddress.getParent().append(MixedKeyedJDBCStoreResourceDefinition.PATH); } ModelNode store = context.readResourceFromRoot(storeAddress).getModel(); value.set(store.hasDefined(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getName()) ? store.get(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getName()) : StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getDefinition().getDefaultValue()); }; builder.getAttributeBuilder().setValueConverter(new SimpleAttributeConverter(converter), DeprecatedAttribute.BATCH_SIZE.getDefinition()); } }
private void parseDistributedWorkManager(final XMLExtendedStreamReader reader, final ModelNode parentAddress, final List<ModelNode> list, final ModelNode node, boolean defaultWm) throws XMLStreamException { final ModelNode distributedWorkManagerOperation = new ModelNode(); distributedWorkManagerOperation.get(OP).set(ADD); final String attributeName = attributeDefinition.getXmlName(); for (int i = 0; i < cnt; i++) { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); case NAME: { name = rawAttributeText(reader, attributeName); ((SimpleAttributeDefinition) attributeDefinition).parseAndSetParameter(name, distributedWorkManagerOperation, reader); break; case JCA_5_0: { String value = rawElementText(reader); ((SimpleAttributeDefinition) JcaDistributedWorkManagerDefinition.DWmParameters.ELYTRON_ENABLED.getAttribute()).parseAndSetParameter(value, distributedWorkManagerOperation, reader); break;
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { if (this.readHandler != null) { this.readHandler.execute(context, operation); } else { try { // If attribute has no read handler, simulate one ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS, false).getModel(); ModelNode result = context.getResult(); if (model.hasDefined(this.targetAttribute.getName())) { result.set(model.get(this.targetAttribute.getName())); } else if (Operations.isIncludeDefaults(operation)) { result.set(this.targetAttribute.getDefinition().getDefaultValue()); } } catch (Resource.NoSuchResourceException ignore) { // If the target resource does not exist return UNDEFINED return; } } ModelNode result = context.getResult(); result.set(this.translator.translate(context, result)); } }