@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); applyModelToRuntime(context, operation, attributeName, model); return false; }
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandback) { ModelNode subModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); ModelNode onAttribute = subModel.get(LogStoreConstants.JMX_ON_ATTRIBUTE); String jmxName = onAttribute.asString(); MBeanServer mbs = TransactionExtension.getMBeanServer(context); try { ObjectName on = new ObjectName(jmxName); // Invoke operation mbs.invoke(on, "clearHeuristic", null, null); return true; } catch (Exception e) { return false; } }
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandback) { ModelNode submodel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); //do the job return (submodel.hasDefined(Constants.ENABLED.getName()) && submodel.get(Constants.ENABLED.getName()).asBoolean()) || Constants.JNDI_NAME.getName().equals(attributeName); }
@Override public void unregister(OperationContext context) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate(); String protocolName = context.getCurrentAddressValue(); String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, resource.getModel()).asString(); Class<? extends Protocol> protocolClass = ChannelRuntimeResourceRegistration.findProtocolClass(context, protocolName, moduleName); for (String attribute : ProtocolMetricsHandler.findProtocolAttributes(protocolClass).keySet()) { registration.unregisterAttribute(attribute); } } }
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; }
@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); } }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.siteName = SITE.resolveModelAttribute(context, model).asString(); PathAddress address = context.getCurrentAddress(); Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); Set<Resource.ResourceEntry> entries = resource.getChildren(RemoteSiteResourceDefinition.WILDCARD_PATH.getKey()); this.sites = new ArrayList<>(entries.size()); for (Resource.ResourceEntry entry : entries) { this.sites.add(new ServiceSupplierDependency<>(new RemoteSiteServiceNameProvider(address, entry.getPathElement()))); } return super.configure(context, model); }
@Override protected void performRemove(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); if (removeInCurrentStep(resource)) { // We need to remove capabilities *before* removing the resource, since the capability reference resolution might involve reading the resource PathAddress address = context.getCurrentAddress(); for (Map.Entry<Capability, Predicate<ModelNode>> entry : this.descriptor.getCapabilities().entrySet()) { if (entry.getValue().test(model)) { context.deregisterCapability(entry.getKey().resolve(address).getName()); } } ImmutableManagementResourceRegistration registration = context.getResourceRegistration(); for (String attributeName : registration.getAttributeNames(PathAddress.EMPTY_ADDRESS)) { AttributeDefinition attribute = registration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, attributeName).getAttributeDefinition(); if (attribute.hasCapabilityRequirements()) { attribute.removeCapabilityRequirements(context, resource, model.get(attributeName)); } } for (CapabilityReferenceRecorder recorder : registration.getRequirements()) { recorder.removeCapabilityRequirements(context, resource, null); } if (this.requiresRuntime(context)) { for (RuntimeResourceRegistration runtimeRegistration : this.descriptor.getRuntimeResourceRegistrations()) { runtimeRegistration.unregister(context); } } } super.performRemove(context, operation, model); }
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); applyModelToRuntime(context, restored); }
@Override public void register(OperationContext context) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate(); String protocolName = context.getCurrentAddressValue(); String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, resource.getModel()).asString(); Class<? extends Protocol> protocolClass = ChannelRuntimeResourceRegistration.findProtocolClass(context, protocolName, moduleName);
public void installRuntimeServices(OperationContext context, ModelNode model, String name) throws OperationFailedException { final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS), 2); 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(); JSPConfig jspConfig = JspDefinition.INSTANCE.getConfig(context, fullModel.get(JspDefinition.INSTANCE.getPathElement().getKeyValuePair())); final String stackTracesString = ServletContainerDefinition.STACK_TRACE_ON_ERROR.resolveModelAttribute(context, model).asString(); final ModelNode defaultEncodingValue = ServletContainerDefinition.DEFAULT_ENCODING.resolveModelAttribute(context, model); final String defaultEncoding = defaultEncodingValue.isDefined()? defaultEncodingValue.asString() : null; final boolean useListenerEncoding = ServletContainerDefinition.USE_LISTENER_ENCODING.resolveModelAttribute(context, model).asBoolean(); final boolean ignoreFlush = ServletContainerDefinition.IGNORE_FLUSH.resolveModelAttribute(context, model).asBoolean();
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateDefaultDistinctName(context, model); return false; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode modelNode = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); if (modelNode.hasDefined(USE_JDBC_STORE.getName()) && modelNode.get(USE_JDBC_STORE.getName()).asBoolean() && !modelNode.hasDefined(JDBC_STORE_DATASOURCE.getName())) { throw TransactionLogger.ROOT_LOGGER.mustBeDefinedIfTrue(JDBC_STORE_DATASOURCE.getName(), USE_JDBC_STORE.getName()); } } }
if (!context.isBooting()) return; Resource subsystemResource = context.readResource(PathAddress.EMPTY_ADDRESS); enabledMetrics.addAll(metrics); String listenerName = LISTENER.resolveModelAttribute(context, proxyModel).asString(); int statusInterval = STATUS_INTERVAL.resolveModelAttribute(context, proxyModel).asInt();
@Override protected void revertUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode valueToRestore, ModelNode valueToRevert, Void handback) throws OperationFailedException { final ModelNode restored = context.readResource(PathAddress.EMPTY_ADDRESS).getModel().clone(); restored.get(attributeName).set(valueToRestore); updateDefaultMethodPermissionsDenyAccess(context, restored); }
static void checkAllowedOnJournal(OperationContext context, String operationName) throws OperationFailedException { ModelNode journalDatasource = ServerDefinition.JOURNAL_DATASOURCE.resolveModelAttribute(context, context.readResource(EMPTY_ADDRESS).getModel()); if (journalDatasource.isDefined() && journalDatasource.asString() != null && !"".equals(journalDatasource.asString())) { throw MessagingLogger.ROOT_LOGGER.operationNotAllowedOnJdbcStore(operationName); } } }
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String connectorName = address.getLastElement().getValue(); ServiceName tmpDirPath = ServiceName.JBOSS.append("server", "path", "jboss.controller.temp.dir"); final ServiceName securityRealm = model.hasDefined(SECURITY_REALM) ? SecurityRealmService.BASE_SERVICE_NAME .append(model.require(SECURITY_REALM).asString()) : null; final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); RemotingServices.installSecurityServices(context.getServiceTarget(), connectorName, securityRealm, null, tmpDirPath, verificationHandler, newControllers); launchServices(context, connectorName, fullModel, verificationHandler, newControllers); }
@Override protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<Void> voidHandbackHolder) throws OperationFailedException { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); updateToRuntime(context, model); return false; }
@Override public void execute(OperationContext operationContext, ModelNode operation) throws OperationFailedException { ModelNode node = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); if (node.hasDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.getName()) && node.get(TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.getName()).asBoolean()) { if (node.hasDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_BINDING.getName())) { throw TransactionLogger.ROOT_LOGGER.mustBeUndefinedIfTrue(TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_BINDING.getName(), TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.getName()); } else if (node.hasDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_MAX_PORTS.getName())) { throw TransactionLogger.ROOT_LOGGER.mustBeUndefinedIfTrue(TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_MAX_PORTS.getName(), TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.getName()); } } else if (node.hasDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_BINDING.getName())) { //it's fine do nothing } else if (node.hasDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_MAX_PORTS.getName())) { throw TransactionLogger.ROOT_LOGGER.mustBedefinedIfDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_BINDING.getName(), TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_MAX_PORTS.getName()); } else { // not uuid and also not sockets! throw TransactionLogger.ROOT_LOGGER.eitherTrueOrDefined(TransactionSubsystemRootResourceDefinition.PROCESS_ID_UUID.getName(), TransactionSubsystemRootResourceDefinition.PROCESS_ID_SOCKET_BINDING.getName()); } } }, OperationContext.Stage.MODEL);
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.connectionTimeout = Attribute.CONNECTION_TIMEOUT.resolveModelAttribute(context, model).asInt(); this.defaultRemoteCluster = Attribute.DEFAULT_REMOTE_CLUSTER.resolveModelAttribute(context, model).asString(); this.keySizeEstimate = Attribute.KEY_SIZE_ESTIMATE.resolveModelAttribute(context, model).asInt(); this.maxRetries = Attribute.MAX_RETRIES.resolveModelAttribute(context, model).asInt(); this.protocolVersion = Attribute.PROTOCOL_VERSION.resolveModelAttribute(context, model).asString(); this.socketTimeout = Attribute.SOCKET_TIMEOUT.resolveModelAttribute(context, model).asInt(); this.tcpNoDelay = Attribute.TCP_NO_DELAY.resolveModelAttribute(context, model).asBoolean(); this.tcpKeepAlive = Attribute.TCP_KEEP_ALIVE.resolveModelAttribute(context, model).asBoolean(); this.valueSizeEstimate = Attribute.VALUE_SIZE_ESTIMATE.resolveModelAttribute(context, model).asInt(); this.clusters.clear(); Resource container = context.readResource(PathAddress.EMPTY_ADDRESS); for (Resource.ResourceEntry entry : container.getChildren(RemoteClusterResourceDefinition.WILDCARD_PATH.getKey())) { String clusterName = entry.getName(); ModelNode cluster = entry.getModel(); List<String> bindings = StringListAttributeDefinition.unwrapValue(context, RemoteClusterResourceDefinition.Attribute.SOCKET_BINDINGS.resolveModelAttribute(context, cluster)); List<SupplierDependency<OutboundSocketBinding>> bindingDependencies = new ArrayList<>(bindings.size()); for (String binding : bindings) { bindingDependencies.add(new ServiceSupplierDependency<>(CommonUnaryRequirement.OUTBOUND_SOCKET_BINDING.getServiceName(context, binding))); } this.clusters.put(clusterName, bindingDependencies); } return this; }