@Override public ModelNode buildRequest(CommandContext ctx) throws OperationFormatException { ModelNode composite = new ModelNode(); composite.get("operation").set("composite"); composite.get("address").setEmptyList(); ModelNode steps = composite.get("steps"); final String name = this.name.getValue(ctx.getParsedArguments()); if (name == null) { throw new OperationFormatException("Required argument name are missing."); } DefaultOperationRequestBuilder builder; // undeploy builder = new DefaultOperationRequestBuilder(); builder.setOperationName("undeploy"); builder.addNode("deployment", name); steps.add(builder.buildRequest()); builder = new DefaultOperationRequestBuilder(); builder.setOperationName("remove"); builder.addNode("deployment", name); steps.add(builder.buildRequest()); return composite; }
private ModelNode getQueueOperation(String operationName) { final ModelNode address = new ModelNode(); address.add("subsystem", "messaging"); address.add("hornetq-server", "default"); address.add("jms-queue", getQueueName()); return org.jboss.as.controller.operations.common.Util.getEmptyOperation(operationName, address); }
private Map<ServerIdentity, ControlledProcessState.State> getServerStatuses() { Map<ServerIdentity, ControlledProcessState.State> result = new HashMap<ServerIdentity, ControlledProcessState.State>(); ModelNode op = new ModelNode(); op.get("operation").set("read-children-names"); op.get("child-type").set("server-config"); op.get("address").add("host", configuration.getHostName()); ModelNode opResult = executeForResult(new OperationBuilder(op).build()); Set<String> servers = new HashSet<String>(); for (ModelNode server : opResult.asList()) { servers.add(server.asString()); } for (String server : servers) { ModelNode address = new ModelNode(); address.add("host", configuration.getHostName()); address.add("server-config", server); String group = readAttribute("group", address).asString(); if (!readAttribute("auto-start", address).asBoolean()) continue; address = new ModelNode(); address.add("host", configuration.getHostName()); address.add("server", server); ControlledProcessState.State status = Enum.valueOf( ControlledProcessState.State.class, readAttribute("server-state", address).asString().toUpperCase(Locale.ENGLISH)); ServerIdentity id = new ServerIdentity(configuration.getHostName(), group, server); result.put(id, status); } return result; }
@Test public void testServerReadResource() throws IOException { DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient(); final ModelNode serverOp = new ModelNode(); serverOp.get(OP).set(READ_RESOURCE_OPERATION); ModelNode address = serverOp.get(OP_ADDR); address.add(HOST, "master"); address.add(SERVER, "main-one"); serverOp.get(RECURSIVE).set(true); serverOp.get(INCLUDE_RUNTIME).set(true); serverOp.get(PROXIES).set(false); ModelNode response = domainClient.execute(serverOp); validateResponse(response); // TODO make some more assertions about result content ModelNode result = response.get(RESULT); Assert.assertTrue(result.isDefined()); Assert.assertTrue(result.hasDefined(PROFILE_NAME)); address.setEmptyList(); address.add(HOST, "slave"); address.add(SERVER, "main-three"); response = domainClient.execute(serverOp); validateResponse(response); // TODO make some more assertions about result content result = response.get(RESULT); Assert.assertTrue(result.isDefined()); Assert.assertTrue(result.hasDefined(PROFILE_NAME)); }
public void setup(ManagementClient managementClient, String containerId) throws Exception { final ModelNode compositeOp = new ModelNode(); compositeOp.get(OP).set(COMPOSITE); compositeOp.get(OP_ADDR).setEmptyList(); ModelNode updates = compositeOp.get(STEPS); PathAddress address = PathAddress.pathAddress() .append(SUBSYSTEM, "security") .append(SECURITY_DOMAIN, getSecurityDomainName()); updates.add(Util.createAddOperation(address)); address = address.append(Constants.AUTHENTICATION, Constants.CLASSIC); updates.add(Util.createAddOperation(address)); ModelNode loginModule = Util.createAddOperation(address.append(LOGIN_MODULE, RunAsLoginModule.class.getName())); loginModule.get(CODE).set(RunAsLoginModule.class.getName()); loginModule.get(FLAG).set("optional"); ModelNode moduleOptions = loginModule.get("module-options"); moduleOptions.get("roleName").set("RunAsLoginModuleRole"); ModelNode loginModule2 = Util.createAddOperation( address.append(LOGIN_MODULE, CustomEjbAccessingLoginModule.class.getName())); loginModule2.get(CODE).set(CustomEjbAccessingLoginModule.class.getName()); loginModule2.get(FLAG).set("required"); loginModule.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true); loginModule2.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true); updates.add(loginModule); updates.add(loginModule2); applyUpdates(managementClient.getControllerClient(), Arrays.asList(compositeOp)); }
@Test public void testJsonObjectInList() throws Exception { ModelNode description = createDescription(ModelType.LIST, ModelType.OBJECT); TypeConverter converter = getConverter(description); ArrayType<String> arrayType = assertCast(ArrayType.class, converter.getOpenType()); Assert.assertEquals( SimpleType.STRING, assertCast(SimpleType.class, arrayType.getElementOpenType())); ModelNode list = new ModelNode(); ModelNode value1 = new ModelNode(); value1.get("long").set(5L); value1.get("string").set("Value"); value1.get("a", "b").set(true); value1.get("c", "d").set(40); list.add(value1); ModelNode value2 = new ModelNode(); value2.get("long").set(10L); list.add(value2); String json1 = value1.toJSONString(false); String json2 = value2.toJSONString(false); String[] data = assertCast(String[].class, converter.fromModelNode(list)); Assert.assertEquals(2, data.length); Assert.assertEquals(json1, data[0]); Assert.assertEquals(json2, data[1]); Assert.assertEquals( ModelNode.fromJSONString(list.toJSONString(false)), converter.toModelNode(data)); }
protected void describe( final Resource resource, final ModelNode address, ModelNode result, final ImmutableManagementResourceRegistration registration) { if (registration.isRemote() || registration.isRuntimeOnly() || resource.isProxy() || resource.isRuntime()) { return; } final Set<PathElement> children = registration.getChildAddresses(PathAddress.EMPTY_ADDRESS); result.add(createAddOperation(address, resource.getModel(), children)); for (final PathElement element : children) { if (element.isMultiTarget()) { final String childType = element.getKey(); for (final Resource.ResourceEntry entry : resource.getChildren(childType)) { final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel( PathAddress.pathAddress(PathElement.pathElement(childType, entry.getName()))); final ModelNode childAddress = address.clone(); childAddress.add(childType, entry.getName()); describe(entry, childAddress, result, childRegistration); } } else { final Resource child = resource.getChild(element); final ImmutableManagementResourceRegistration childRegistration = registration.getSubModel(PathAddress.pathAddress(element)); final ModelNode childAddress = address.clone(); childAddress.add(element.getKey(), element.getValue()); describe(child, childAddress, result, childRegistration); } } }
@Test public void test() throws Exception { final ModelController controller = getController(); final ModelNode address = new ModelNode(); address.add("host", "*"); address.add("server", "[one,two]"); address.add("subsystem", "web"); address.add("connector", "*"); final ModelNode read = new ModelNode(); read.get(OP).set("read-resource"); read.get(OP_ADDR).set(address); ModelNode result = controller.execute(read, null, null, null); System.out.println(result); result = result.get("result"); Assert.assertEquals(4, result.asInt()); // A,B one,two final ModelNode describe = new ModelNode(); describe.get(OP).set("describe"); describe.get(OP_ADDR).set(address); result = controller.execute(describe, null, null, null).get("result"); }
@Override public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception { final ModelNode address = new ModelNode(); address.add("subsystem", "resource-adapters"); address.add("resource-adapter", "pure.rar"); address.protect(); remove(address); }
@AfterClass public static void tearDown() throws Exception { final ModelNode address = new ModelNode(); address.add("subsystem", "resource-adapters"); address.add("resource-adapter", "as7_1452.rar"); address.protect(); remove(address); closeModelControllerClient(); }
@Test public void testValidPath() throws IOException, MgmtOperationException { ModelNode op = ModelUtil.createOpNode(null, ValidateAddressOperationHandler.OPERATION_NAME); final ModelNode addr = op.get(VALUE); addr.add("socket-binding-group", "standard-sockets"); addr.add("socket-binding", "http"); final ModelNode result = executeOperation(op); assertTrue(result.hasDefined(VALID)); final ModelNode value = result.get(VALID); assertTrue(value.asBoolean()); assertFalse(result.hasDefined(PROBLEM)); }
@Override public ServerStatus startServer(String hostControllerName, String serverName) { final ModelNode op = new ModelNode(); op.get("operation").set("start"); ModelNode address = op.get("address"); address.add("host", hostControllerName); address.add("server-config", serverName); ModelNode result = executeForResult(new OperationBuilder(op).build()); String status = result.asString(); return Enum.valueOf(ServerStatus.class, status); }
@Override public ModelNode buildRequest(CommandContext ctx) throws OperationFormatException { DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder(); ParsedArguments args = ctx.getParsedArguments(); if (ctx.isDomainMode()) { String profile = this.profile.getValue(args); if (profile == null) { throw new OperationFormatException("--profile argument value is missing."); } builder.addNode("profile", profile); } final String name; try { name = this.name.getValue(args); } catch (IllegalArgumentException e) { throw new OperationFormatException(e.getLocalizedMessage()); } builder.addNode("subsystem", "jms"); builder.addNode("queue", name); builder.setOperationName("add"); ModelNode entriesNode = builder.getModelNode().get("entries"); final String entriesStr = this.entries.getValue(args); if (entriesStr == null) { entriesNode.add(name); } else { String[] split = entriesStr.split(","); for (int i = 0; i < split.length; ++i) { String entry = split[i].trim(); if (!entry.isEmpty()) { entriesNode.add(entry); } } } final String selector = this.selector.getValue(args); if (selector != null) { builder.addProperty("selector", selector); } final String durable = this.durable.getValue(args); if (durable != null) { builder.addProperty("durable", durable); } return builder.buildRequest(); }
@Test public void testRunningServerReadResourceDescription() throws IOException { DomainClient domainClient = domainMasterLifecycleUtil.getDomainClient(); ModelNode request = new ModelNode(); request.get(OP).set("read-resource-description"); ModelNode address = request.get(OP_ADDR); address.add(HOST, "master"); address.add(RUNNING_SERVER, "reload-one"); // Check the stopped server has a resource description too ModelNode response = domainClient.execute(request); validateResponse(response); }
public ModelNode toModelNode() { ModelNode node = new ModelNode(); node.get(RESOURCE_CLASS.getName()).set(resourceClass.getCanonicalName()); ModelNode resPathNode = node.get(RESOURCE_PATHS.getName()); Collections.sort(methodsDescriptions); for (JaxrsResourceMethodDescription methodRes : methodsDescriptions) { resPathNode.add(methodRes.toModelNode()); } ModelNode subResNode = node.get(SUB_RESOURCE_LOCATORS.getName()); Collections.sort(subLocatorDescriptions); for (JaxrsResourceLocatorDescription subLocator : subLocatorDescriptions) { subResNode.add(subLocator.toModelNode()); } return node; }
/** * Parses the comma delimited address into model nodes. * * @param profileName the profile name for the domain or {@code null} if not a domain * @param inputAddress the address. * @return a collection of the address nodes. */ private ModelNode parseAddress(final String profileName, final String inputAddress) { final ModelNode result = new ModelNode(); if (profileName != null) { result.add(ServerOperations.PROFILE, profileName); } String[] parts = inputAddress.split(","); for (String part : parts) { String[] address = part.split("="); if (address.length != 2) { throw new RuntimeException(part + " is not a valid address segment"); } result.add(address[0], address[1]); } return result; }
private ModelNode createDeploymentOperation( ModelNode content, PathAddress... serverGroupAddressses) { ModelNode composite = createEmptyOperation(COMPOSITE, PathAddress.EMPTY_ADDRESS); ModelNode steps = composite.get(STEPS); ModelNode step1 = steps.add(); step1.set(createAddOperation(ROOT_DEPLOYMENT_ADDRESS)); step1.get(CONTENT).add(content); for (PathAddress serverGroup : serverGroupAddressses) { ModelNode sg = steps.add(); sg.set(createAddOperation(serverGroup)); sg.get(ENABLED).set(true); } return composite; }
protected boolean isAddressValid(CommandContext ctx) { final ModelNode request = new ModelNode(); final ModelNode address = request.get(Util.ADDRESS); address.setEmptyList(); request.get(Util.OPERATION).set(Util.VALIDATE_ADDRESS); final ModelNode addressValue = request.get(Util.VALUE); for (OperationRequestAddress.Node node : requiredAddress) { addressValue.add(node.getType(), node.getName()); } final ModelNode response; try { response = ctx.getModelControllerClient().execute(request); } catch (IOException e) { return false; } final ModelNode result = response.get(Util.RESULT); if (!result.isDefined()) { return false; } final ModelNode valid = result.get(Util.VALID); if (!valid.isDefined()) { return false; } return valid.asBoolean(); }
/** * Creates CliCommandAction for adding a Login-Module of the specific Security-Domain * * @param domain Security-Domain containing Login-Module * @param module Login-Module * @return created CliCommandAction for adding the Login-Module */ public static CliCommandAction createLoginModuleCliAction( SecurityDomainBean domain, LoginModuleAS7Bean module) { ModelNode request = new ModelNode(); request.get(ClientConstants.OP).set(ClientConstants.ADD); request.get(ClientConstants.OP_ADDR).add("subsystem", "security"); request.get(ClientConstants.OP_ADDR).add("security-domain", domain.getSecurityDomainName()); request.get(ClientConstants.OP_ADDR).add("authentication", "classic"); ModelNode moduleNode = new ModelNode(); ModelNode list = new ModelNode(); if (module.getModuleOptions() != null) { ModelNode optionNode = new ModelNode(); for (ModuleOptionAS7Bean option : module.getModuleOptions()) { optionNode.get(option.getModuleOptionName()).set(option.getModuleOptionValue()); } moduleNode.get("module-options").set(optionNode); } CliApiCommandBuilder builder = new CliApiCommandBuilder(moduleNode); builder.addProperty("flag", module.getLoginModuleFlag()); builder.addProperty("code", module.getLoginModuleCode()); // Needed for CLI because parameter login-modules requires LIST list.add(builder.getCommand()); request.get("login-modules").set(list); return new CliCommandAction( SecurityMigrator.class, createLoginModuleScript(domain, module), request); }
@Test public void testReadResourceResources() throws Exception { final ModelNode address = new ModelNode(); address.add("subsystem", "datasources"); address.protect(); final ModelNode operation = new ModelNode(); operation.get(OP).set("read-resource-description"); operation.get(OP_ADDR).set(address); final ModelNode result = executeOperation(operation); final Map<String, ModelNode> children = getChildren(result.get("attributes").get("installed-drivers").get("value-type")); Assert.assertFalse(children.isEmpty()); HashSet<String> keys = new HashSet<String>(); for (final Entry<String, ModelNode> child : children.entrySet()) { Assert.assertTrue(child.getKey() != null); keys.add(child.getKey()); } Assert.assertTrue(keys.contains("driver-xa-datasource-class-name")); Assert.assertTrue(keys.contains("module-slot")); Assert.assertTrue(keys.contains("driver-name")); }
@Test public void testServerReadResourceViaSlave() throws IOException { DomainClient domainClient = domainSlaveLifecycleUtil.getDomainClient(); final ModelNode serverOp = new ModelNode(); serverOp.get(OP).set(READ_RESOURCE_OPERATION); ModelNode address = serverOp.get(OP_ADDR); address.add(HOST, "slave"); address.add(SERVER, "main-three"); serverOp.get(RECURSIVE).set(true); serverOp.get(INCLUDE_RUNTIME).set(true); serverOp.get(PROXIES).set(false); ModelNode response = domainClient.execute(serverOp); validateResponse(response); // TODO make some more assertions about result content }
protected ModelNode buildWritePropertyRequest(CommandContext ctx) throws CommandFormatException { final String name = this.name.getValue(ctx.getParsedCommandLine(), true); ModelNode composite = new ModelNode(); composite.get(Util.OPERATION).set(Util.COMPOSITE); composite.get(Util.ADDRESS).setEmptyList(); ModelNode steps = composite.get(Util.STEPS); final ParsedCommandLine args = ctx.getParsedCommandLine(); final String profile; if (isDependsOnProfile() && ctx.isDomainMode()) { profile = this.profile.getValue(args); if (profile == null) { throw new OperationFormatException("--profile argument value is missing."); } } else { profile = null; } final Map<String, CommandArgument> nodeProps = loadArguments(ctx, null); for (String argName : args.getPropertyNames()) { if (isDependsOnProfile() && argName.equals("--profile") || this.name.getFullName().equals(argName)) { continue; } final ArgumentWithValue arg = (ArgumentWithValue) nodeProps.get(argName); if (arg == null) { throw new CommandFormatException("Unrecognized argument name '" + argName + "'"); } DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder(); if (profile != null) { builder.addNode(Util.PROFILE, profile); } for (OperationRequestAddress.Node node : getRequiredAddress()) { builder.addNode(node.getType(), node.getName()); } builder.addNode(getRequiredType(), name); builder.setOperationName(Util.WRITE_ATTRIBUTE); final String propName; if (argName.charAt(1) == '-') { propName = argName.substring(2); } else { propName = argName.substring(1); } builder.addProperty(Util.NAME, propName); final String valueString = args.getPropertyValue(argName); ModelNode nodeValue = arg.getValueConverter().fromString(valueString); builder.getModelNode().get(Util.VALUE).set(nodeValue); steps.add(builder.buildRequest()); } return composite; }
@Override public OperationResult execute( OperationContext context, ModelNode operation, ResultHandler resultHandler) { final ModelNode model = context.getSubModel(); PathAddress rootAddress = PathAddress.pathAddress( PathAddress.pathAddress(operation.require(OP_ADDR)).getLastElement()); final ModelNode result = new ModelNode(); final ModelNode subsystem = new ModelNode(); subsystem.get(OP).set(ADD); subsystem.get(OP_ADDR).set(rootAddress.toModelNode()); if (model.has(ACTIVATION)) { subsystem.get(ACTIVATION).set(model.get(ACTIVATION)); } if (model.has(CONFIGURATION)) { subsystem.get(CONFIGURATION).set(model.get(CONFIGURATION)); } if (model.has(PROPERTIES)) { subsystem.get(PROPERTIES).set(model.get(PROPERTIES)); } if (model.has(MODULES)) { subsystem.get(MODULES).set(model.get(MODULES)); } result.add(subsystem); resultHandler.handleResultFragment(Util.NO_LOCATION, result); resultHandler.handleResultComplete(); return new BasicOperationResult(); }
private void addManagementSecurityRealms(List<ModelNode> updates) { if (hostModel.get(CORE_SERVICE, MANAGEMENT, SECURITY_REALM).isDefined()) { ModelNode securityRealms = hostModel.get(CORE_SERVICE, MANAGEMENT, SECURITY_REALM); Set<String> keys = securityRealms.keys(); for (String current : keys) { ModelNode addOp = new ModelNode(); ModelNode realmAddress = new ModelNode(); realmAddress.add(CORE_SERVICE, MANAGEMENT).add(SECURITY_REALM, current); addOp.get(OP).set(ADD); addOp.get(OP_ADDR).set(realmAddress); updates.add(addOp); ModelNode currentRealm = securityRealms.get(current); if (currentRealm.hasDefined(SERVER_IDENTITY)) { addManagementComponentComponent(currentRealm, realmAddress, SERVER_IDENTITY, updates); } if (currentRealm.hasDefined(AUTHENTICATION)) { addManagementComponentComponent(currentRealm, realmAddress, AUTHENTICATION, updates); } if (currentRealm.hasDefined(AUTHORIZATION)) { addManagementComponentComponent(currentRealm, realmAddress, AUTHORIZATION, updates); } } } }
private void startServers() { ModelNode addr = new ModelNode(); addr.add(HOST, hostControllerInfo.getLocalHostName()); ModelNode op = Util.getEmptyOperation(StartServersHandler.OPERATION_NAME, addr); getValue().execute(op, null, null, null); }
@Override public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException { final ModelNode address = new ModelNode(); address.add(SUBSYSTEM, SUBSYSTEM_NAME); address.protect(); final ModelNode subsystem = new ModelNode(); subsystem.get(OP).set(ADD); subsystem.get(OP_ADDR).set(address); list.add(subsystem); // Handle elements while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { switch (Namespace.forUri(reader.getNamespaceURI())) { case THREADS_1_0: { final Element element = Element.forName(reader.getLocalName()); switch (element) { case BOUNDED_QUEUE_THREAD_POOL: { parseBoundedQueueThreadPool(reader, address, list); break; } case THREAD_FACTORY: { // Add connector updates parseThreadFactory(reader, address, list); break; } case QUEUELESS_THREAD_POOL: { parseQueuelessThreadPool(reader, address, list); break; } case SCHEDULED_THREAD_POOL: { parseScheduledThreadPool(reader, address, list); break; } case UNBOUNDED_QUEUE_THREAD_POOL: { parseUnboundedQueueThreadPool(reader, address, list); break; } default: { throw unexpectedElement(reader); } } break; } default: { throw unexpectedElement(reader); } } } }
private void addUnboundedQueueThreadPools(final ModelNode result, final ModelNode model) { if (model.hasDefined(UNBOUNDED_QUEUE_THREAD_POOL)) { ModelNode pools = model.get(UNBOUNDED_QUEUE_THREAD_POOL); for (Property poolProp : pools.asPropertyList()) { final ModelNode operation = Util.getEmptyOperation( ADD, pathAddress( PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME), PathElement.pathElement(UNBOUNDED_QUEUE_THREAD_POOL, poolProp.getName()))); final ModelNode pool = poolProp.getValue(); operation.get(NAME).set(pool.require(NAME)); if (pool.hasDefined(THREAD_FACTORY)) { operation.get(THREAD_FACTORY).set(pool.get(THREAD_FACTORY)); } if (pool.hasDefined(PROPERTIES)) { operation.get(PROPERTIES).set(pool.get(PROPERTIES)); } if (pool.hasDefined(MAX_THREADS)) { operation.get(MAX_THREADS).set(pool.get(MAX_THREADS)); } if (pool.hasDefined(KEEPALIVE_TIME)) { operation.get(KEEPALIVE_TIME).set(pool.get(KEEPALIVE_TIME)); } result.add(operation); } } }
private void addThreadFactories(final ModelNode result, final ModelNode model) { if (model.hasDefined(THREAD_FACTORY)) { ModelNode pools = model.get(THREAD_FACTORY); for (Property poolProp : pools.asPropertyList()) { final ModelNode operation = Util.getEmptyOperation( ADD, pathAddress( PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME), PathElement.pathElement(THREAD_FACTORY, poolProp.getName()))); final ModelNode pool = poolProp.getValue(); operation.get(NAME).set(pool.require(NAME)); if (pool.hasDefined(GROUP_NAME)) { operation.get(GROUP_NAME).set(pool.get(GROUP_NAME)); } if (pool.hasDefined(THREAD_NAME_PATTERN)) { operation.get(THREAD_NAME_PATTERN).set(pool.get(THREAD_NAME_PATTERN)); } if (pool.hasDefined(PRIORITY)) { operation.get(PRIORITY).set(pool.get(PRIORITY)); } if (pool.hasDefined(PROPERTIES)) { operation.get(PROPERTIES).set(pool.get(PROPERTIES)); } result.add(operation); } } }
@Override public Cancellable execute( final OperationContext context, final ModelNode operation, final ResultHandler resultHandler) { final ModelNode model = context.getSubModel(); final ModelNode subsystem = new ModelNode(); subsystem.get(OP).set(ADD); subsystem.get(OP_ADDR).add(SUBSYSTEM, SUBSYSTEM_NAME); if (model.hasDefined(AUTHENTICATION_MANAGER_CLASS_NAME)) { subsystem .get(AUTHENTICATION_MANAGER_CLASS_NAME) .set(model.get(AUTHENTICATION_MANAGER_CLASS_NAME)); } if (subsystem.hasDefined(DEEP_COPY_SUBJECT_MODE)) { subsystem.get(DEEP_COPY_SUBJECT_MODE).set(model.get(DEEP_COPY_SUBJECT_MODE)); } if (subsystem.hasDefined(DEFAULT_CALLBACK_HANDLER_CLASS_NAME)) { subsystem .get(DEFAULT_CALLBACK_HANDLER_CLASS_NAME) .set(model.get(DEFAULT_CALLBACK_HANDLER_CLASS_NAME)); } ModelNode result = new ModelNode(); result.add(subsystem); resultHandler.handleResultFragment(Util.NO_LOCATION, result); resultHandler.handleResultComplete(null); return Cancellable.NULL; }
/** * {@inheritDoc} * * @see * org.jboss.staxmapper.XMLElementReader#readElement(org.jboss.staxmapper.XMLExtendedStreamReader, * java.lang.Object) */ @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException { ModelNode subsystemAddress = new ModelNode(); subsystemAddress.add(ModelDescriptionConstants.SUBSYSTEM, InfinispanExtension.SUBSYSTEM_NAME); subsystemAddress.protect(); ModelNode subsystem = Util.getEmptyOperation(ModelDescriptionConstants.ADD, subsystemAddress); for (int i = 0; i < reader.getAttributeCount(); i++) { ParseUtils.requireNoNamespaceAttribute(reader, i); String value = reader.getAttributeValue(i); Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case DEFAULT_CACHE_CONTAINER: { subsystem.get(ModelKeys.DEFAULT_CACHE_CONTAINER).set(value); break; } default: { throw ParseUtils.unexpectedAttribute(reader, i); } } } if (!subsystem.hasDefined(ModelKeys.DEFAULT_CACHE_CONTAINER)) { throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.DEFAULT_CACHE_CONTAINER)); } // command to add the subsystem operations.add(subsystem); while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) { switch (Namespace.forUri(reader.getNamespaceURI())) { case INFINISPAN_1_0: case INFINISPAN_1_1: { Element element = Element.forName(reader.getLocalName()); switch (element) { case CACHE_CONTAINER: { parseContainer(reader, subsystemAddress, operations); break; } default: { throw ParseUtils.unexpectedElement(reader); } } break; } default: { throw ParseUtils.unexpectedElement(reader); } } } }