@Override public ModelNode transformOperation(ModelNode operation) { if (operation.get(NAME).asString().equals(PROPERTIES)) { String key = operation.get("key").asString(); PathAddress address = Operations.getPathAddress(operation); ModelNode transformedOperation = Util.createOperation(READ_ATTRIBUTE_OPERATION, address.append(PathElement.pathElement(PROPERTY, key))); transformedOperation.get(NAME).set(VALUE); return transformedOperation; } return operation; } }
private static PathAddress getDataSourceAddress(final String jndiName, DeploymentUnit deploymentUnit, boolean xa) { List<PathElement> elements = new ArrayList<PathElement>(); if (deploymentUnit.getParent() == null) { elements.add(PathElement.pathElement(ModelDescriptionConstants.DEPLOYMENT, deploymentUnit.getName())); } else { elements.add(PathElement.pathElement(ModelDescriptionConstants.DEPLOYMENT, deploymentUnit.getParent().getName())); elements.add(PathElement.pathElement(ModelDescriptionConstants.SUBDEPLOYMENT, deploymentUnit.getName())); } elements.add(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, DataSourcesExtension.SUBSYSTEM_NAME)); if (xa) { elements.add(PathElement.pathElement(XA_DATA_SOURCE, jndiName)); } else { elements.add(PathElement.pathElement(DATA_SOURCE, jndiName)); } return PathAddress.pathAddress(elements); }
void addManagementWebsocket(final DeploymentUnit unit, Class endpoint, String path) { try { final DeploymentResourceSupport deploymentResourceSupport = unit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); //websockets don't have the concept of a name, however the path much be unique final ModelNode node = deploymentResourceSupport.getDeploymentSubModel(UndertowExtension.SUBSYSTEM_NAME, PathElement.pathElement("websocket", path)); node.get("endpoint-class").set(endpoint.getName()); node.get("path").set(path); } catch (Exception e) { UndertowLogger.ROOT_LOGGER.failedToRegisterWebsocket(endpoint, path, e); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME)); final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
@Override public void stop(StopContext context) { PathElement peLocaldWm = PathElement.pathElement(Constants.STATISTICS_NAME, "extended"); if (overrideRegistration.getSubModel(PathAddress.pathAddress(peLocaldWm)) != null) overrideRegistration.unregisterSubModel(peLocaldWm); }
public static void validateDefaultInterfaceReference(final OperationContext context, final ModelNode bindingGroup) throws OperationFailedException { ModelNode defaultInterfaceNode = bindingGroup.get(DEFAULT_INTERFACE.getName()); if (defaultInterfaceNode.getType() == ModelType.STRING) { // ignore UNDEFINED and EXPRESSION String defaultInterface = defaultInterfaceNode.asString(); PathAddress interfaceAddress = PathAddress.pathAddress(PathElement.pathElement(INTERFACE, defaultInterface)); try { context.readResourceFromRoot(interfaceAddress, false); } catch (RuntimeException e) { throw ControllerMessages.MESSAGES.nonexistentInterface(defaultInterface, DEFAULT_INTERFACE.getName()); } } }
@Override public AttributeValueTranslator getReadTranslator() { return (context, value) -> { String poolName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { Resource resource = subsystem.getChild(PathElement.pathElement(type, poolName)); if (resource != null) { return resource.getModel().get("jndi-name"); } } throw InfinispanLogger.ROOT_LOGGER.dataSourceNotFound(poolName); }; }
@Override protected void describe(OrderedChildTypesAttachment orderedChildTypesAttachment, Resource resource, ModelNode addressModel, ModelNode result, ImmutableManagementResourceRegistration registration) { if (resource == null || registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime() || registration.isAlias()) return; result.add(createAddOperation(orderedChildTypesAttachment, addressModel, resource, registration.getChildAddresses(PathAddress.EMPTY_ADDRESS))); PathAddress address = PathAddress.pathAddress(addressModel); for (String type : resource.getChildTypes()) { for (Resource.ResourceEntry entry : resource.getChildren(type)) { PathElement path = entry.getPathElement(); ImmutableManagementResourceRegistration childRegistration = Optional.ofNullable(registration.getSubModel(PathAddress.pathAddress(path))).orElse(registration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(path.getKey())))); PathAddress childAddress = address.append(path); this.describe(orderedChildTypesAttachment, entry, childAddress.toModelNode(), result, childRegistration); } } }
@Override public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) { PathElement element = address.getLastElement(); element = PathElement.pathElement(Constants.ACL_MODULE, element.getValue()); return address.subAddress(0, address.size() -1).append(element); } });
@SuppressWarnings("deprecation") private static void registerPassivationStoreTransformers_1_2_1_and_1_3_0(ResourceTransformationDescriptionBuilder parent) { ResourceTransformationDescriptionBuilder child = parent.addChildRedirection(PassivationStoreResourceDefinition.INSTANCE.getPathElement(), PathElement.pathElement(EJB3SubsystemModel.CLUSTER_PASSIVATION_STORE)); child.getAttributeBuilder() .setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode(true), true), EJB3SubsystemModel.PASSIVATE_EVENTS_ON_REPLICATE) .setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode("default"), true), EJB3SubsystemModel.CLIENT_MAPPINGS_CACHE) .setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode().set(Long.valueOf(Integer.MAX_VALUE)), true), EJB3SubsystemModel.IDLE_TIMEOUT) .setValueConverter(AttributeConverter.Factory.createHardCoded(new ModelNode().set(TimeUnit.SECONDS.name()), true), EJB3SubsystemModel.IDLE_TIMEOUT_UNIT) ; }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final PathAddress serverAddress = PathAddress.EMPTY_ADDRESS.append(PathElement.pathElement(SERVER, serverName)); final ProxyController controller = context.getResourceRegistration().getProxyController(serverAddress); if (controller != null) { context.getFailureDescription().set(MESSAGES.serverStillRunning(serverName)); } context.stepCompleted(); } }, OperationContext.Stage.RUNTIME);
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired(); if (model.get(ARCHIVE.getName()).isDefined()) { archiveOrModuleName = model.get(ARCHIVE.getName()).asString(); } else { archiveOrModuleName = model.get(MODULE.getName()).asString(); .install(); PathElement peStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
private ModelNode createAddStrictMaxBeanInstancePoolOperation(final String name, final Integer maxPoolSize, final Long timeout, final String timeoutUnit) { // create /subsystem=ejb3/strict-max-bean-instance-pool=name:add(...) final ModelNode addStrictMaxPoolOperation = new ModelNode(); addStrictMaxPoolOperation.get(OP).set(ADD); // set the address for this operation final PathAddress address = this.getEJB3SubsystemAddress().append(PathElement.pathElement(STRICT_MAX_BEAN_INSTANCE_POOL, name)); addStrictMaxPoolOperation.get(OP_ADDR).set(address.toModelNode()); // set the params for the operation if (maxPoolSize != null) { addStrictMaxPoolOperation.get(MAX_POOL_SIZE).set(maxPoolSize); } if (timeout != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT).set(timeout); } if (timeoutUnit != null) { addStrictMaxPoolOperation.get(INSTANCE_ACQUISITION_TIMEOUT_UNIT).set(timeoutUnit); } return addStrictMaxPoolOperation; }
private static PathAddress getComponentAddress(EJBComponentType type, ComponentConfiguration configuration, DeploymentUnit deploymentUnit) { List<PathElement> elements = new ArrayList<PathElement>(); if (deploymentUnit.getParent() == null) { elements.add(PathElement.pathElement(ModelDescriptionConstants.DEPLOYMENT, deploymentUnit.getName())); } else { elements.add(PathElement.pathElement(ModelDescriptionConstants.DEPLOYMENT, deploymentUnit.getParent().getName())); elements.add(PathElement.pathElement(ModelDescriptionConstants.SUBDEPLOYMENT, deploymentUnit.getName())); } elements.add(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME)); elements.add(PathElement.pathElement(type.getResourceType(), configuration.getComponentName())); return PathAddress.pathAddress(elements); } }
void processManagement(final DeploymentUnit unit, JBossWebMetaData metaData) { final DeploymentResourceSupport deploymentResourceSupport = unit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); for (final JBossServletMetaData servlet : metaData.getServlets()) { try { final String name = servlet.getName(); final ModelNode node = deploymentResourceSupport.getDeploymentSubModel(UndertowExtension.SUBSYSTEM_NAME, PathElement.pathElement("servlet", name)); node.get("servlet-class").set(servlet.getServletClass()); node.get("servlet-name").set(servlet.getServletName()); } catch (Exception e) { // Should a failure in creating the mgmt view also make to the deployment to fail? continue; } } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); final ServiceBuilder<ManagedExecutorServiceAdapter> serviceBuilder = context.getServiceTarget().addService(ConcurrentServiceNames.getManagedExecutorServiceServiceName(name), service); boolean rcPresent = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).hasChild(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, RequestControllerExtension.SUBSYSTEM_NAME)); String contextService = null; if(model.hasDefined(ManagedExecutorServiceResourceDefinition.CONTEXT_SERVICE)) {
@Override public void stop(StopContext context) { PathElement peDistributedWm = PathElement.pathElement(Constants.STATISTICS_NAME, "distributed"); if (overrideRegistration.getSubModel(PathAddress.pathAddress(peDistributedWm)) != null) overrideRegistration.unregisterSubModel(peDistributedWm); }
public static void validateDefaultInterfaceReference(final OperationContext context, final ModelNode bindingGroup) throws OperationFailedException { ModelNode defaultInterfaceNode = bindingGroup.get(DEFAULT_INTERFACE.getName()); if (defaultInterfaceNode.getType() == ModelType.STRING) { // ignore UNDEFINED and EXPRESSION String defaultInterface = defaultInterfaceNode.asString(); PathAddress interfaceAddress = PathAddress.pathAddress(PathElement.pathElement(INTERFACE, defaultInterface)); try { context.readResourceFromRoot(interfaceAddress, false); } catch (RuntimeException e) { throw ControllerMessages.MESSAGES.nonexistentInterface(defaultInterface, DEFAULT_INTERFACE.getName()); } } }
@Override public AttributeValueTranslator getWriteTranslator() { return (context, value) -> { String jndiName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { ModelNode model = entry.getModel(); if (model.get("jndi-name").asString().equals(jndiName)) { return new ModelNode(entry.getName()); } } } } throw InfinispanLogger.ROOT_LOGGER.dataSourceJndiNameNotFound(jndiName); }; } };
ManagementResourceRegistration raReg = registration.getSubModel(RA_ADDRESS.getParent().append(Constants.RESOURCEADAPTER_NAME, deploymentName)); ManagementResourceRegistration cdefReg = raReg.getSubModel(PathAddress.pathAddress(PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME))); ManagementResourceRegistration aoReg = raReg.getSubModel(PathAddress.pathAddress(PathElement.pathElement(Constants.ADMIN_OBJECTS_NAME))); for (AdminObject ao : adminObjects) {