use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class OperationSequencesTestCase method testProtocolStackAddRemoveAddSequence.
@Test
public void testProtocolStackAddRemoveAddSequence() throws Exception {
KernelServices services = buildKernelServices();
ModelNode operation = Operations.createCompositeOperation(addStackOp, addTransportOp, addProtocolOp);
// add a protocol stack, its transport and a protocol as a batch
ModelNode result = services.executeOperation(operation);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// remove the stack
result = services.executeOperation(removeStackOp);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// add the same stack
result = services.executeOperation(operation);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class OperationSequencesTestCase method testProtocolStackAddRemoveSequenceWithParameters.
/**
* Tests the ability of the /subsystem=jgroups/stack=X:add() operation
* to correctly process the optional TRANSPORT and PROTOCOLS parameters.
*/
@Test
public void testProtocolStackAddRemoveSequenceWithParameters() throws Exception {
KernelServices services = buildKernelServices();
// add a protocol stack specifying TRANSPORT and PROTOCOLS parameters
ModelNode result = services.executeOperation(addStackOpWithParams);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// check some random values
// remove the protocol stack
result = services.executeOperation(removeStackOp);
Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
// remove the protocol stack again
result = services.executeOperation(removeStackOp);
Assert.assertEquals(FAILED, result.get(OUTCOME).asString());
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class OperationTestCaseBase method getLegacyTransportAddOperation.
@SuppressWarnings("deprecation")
protected static ModelNode getLegacyTransportAddOperation(String stackName, String protocol) {
ModelNode op = Util.createAddOperation(getLegacyTransportAddress(stackName));
op.get(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).set(protocol);
op.get(SocketBindingProtocolResourceDefinition.Attribute.SOCKET_BINDING.getName()).set("some-binding");
return op;
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class OperationTestCaseBase method getProtocolPropertyAddOperation.
@SuppressWarnings("deprecation")
protected static ModelNode getProtocolPropertyAddOperation(String stackName, String protocolName, String propertyName, String propertyValue) {
ModelNode operation = Util.createAddOperation(getProtocolPropertyAddress(stackName, protocolName, propertyName));
operation.get(PropertyResourceDefinition.VALUE.getName()).set(propertyValue);
return operation;
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class ResourceAdapterParser method parseResourceAdapter.
private void parseResourceAdapter(final XMLExtendedStreamReader reader, final List<ModelNode> list, ModelNode parentAddress) throws XMLStreamException, ParserException, ValidateException {
final ModelNode raAddress = parentAddress.clone();
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
String archiveOrModuleName = null;
HashMap<String, ModelNode> configPropertiesOperations = new HashMap<String, ModelNode>();
HashMap<String, ModelNode> connectionDefinitionsOperations = new HashMap<String, ModelNode>();
HashMap<String, HashMap<String, ModelNode>> cfConfigPropertiesOperations = new HashMap<String, HashMap<String, ModelNode>>();
HashMap<String, ModelNode> adminObjectsOperations = new HashMap<String, ModelNode>();
HashMap<String, HashMap<String, ModelNode>> aoConfigPropertiesOperations = new HashMap<String, HashMap<String, ModelNode>>();
boolean archiveOrModuleMatched = false;
boolean txSupportMatched = false;
boolean isXa = false;
String id = null;
int attributeSize = reader.getAttributeCount();
for (int i = 0; i < attributeSize; i++) {
Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
String value = reader.getAttributeValue(i);
switch(attribute) {
case ID:
{
id = value;
break;
}
case STATISTICS_ENABLED:
STATISTICS_ENABLED.parseAndSetParameter(value, operation, reader);
break;
default:
break;
}
}
while (reader.hasNext()) {
switch(reader.nextTag()) {
case END_ELEMENT:
{
if (Activations.Tag.forName(reader.getLocalName()) == Activations.Tag.RESOURCE_ADAPTER) {
if (!archiveOrModuleMatched) {
throw new ParserException(bundle.requiredElementMissing(ARCHIVE.getName(), RESOURCEADAPTER_NAME));
}
if (id != null) {
raAddress.add(RESOURCEADAPTER_NAME, id);
} else {
raAddress.add(RESOURCEADAPTER_NAME, archiveOrModuleName);
}
raAddress.protect();
operation.get(OP_ADDR).set(raAddress);
list.add(operation);
for (Map.Entry<String, ModelNode> entry : configPropertiesOperations.entrySet()) {
final ModelNode env = raAddress.clone();
env.add(CONFIG_PROPERTIES.getName(), entry.getKey());
env.protect();
entry.getValue().get(OP_ADDR).set(env);
list.add(entry.getValue());
}
for (Map.Entry<String, ModelNode> entry : connectionDefinitionsOperations.entrySet()) {
final ModelNode env = raAddress.clone();
env.add(CONNECTIONDEFINITIONS_NAME, entry.getKey());
env.protect();
entry.getValue().get(OP_ADDR).set(env);
list.add(entry.getValue());
final HashMap<String, ModelNode> properties = cfConfigPropertiesOperations.get(entry.getKey());
if (properties != null) {
for (Map.Entry<String, ModelNode> configEntry : properties.entrySet()) {
final ModelNode configEnv = env.clone();
configEnv.add(CONFIG_PROPERTIES.getName(), configEntry.getKey());
configEnv.protect();
configEntry.getValue().get(OP_ADDR).set(configEnv);
list.add(configEntry.getValue());
}
}
}
for (Map.Entry<String, ModelNode> entry : adminObjectsOperations.entrySet()) {
final ModelNode env = raAddress.clone();
env.add(ADMIN_OBJECTS_NAME, entry.getKey());
env.protect();
entry.getValue().get(OP_ADDR).set(env);
list.add(entry.getValue());
final HashMap<String, ModelNode> aoProperties = aoConfigPropertiesOperations.get(entry.getKey());
if (aoProperties != null) {
for (Map.Entry<String, ModelNode> configEntry : aoProperties.entrySet()) {
final ModelNode configEnv = env.clone();
configEnv.add(CONFIG_PROPERTIES.getName(), configEntry.getKey());
configEnv.protect();
configEntry.getValue().get(OP_ADDR).set(configEnv);
list.add(configEntry.getValue());
}
}
}
return;
} else {
if (AS7ResourceAdapterTags.forName(reader.getLocalName()) == AS7ResourceAdapterTags.UNKNOWN) {
throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
}
}
break;
}
case START_ELEMENT:
{
switch(AS7ResourceAdapterTags.forName(reader.getLocalName())) {
case ADMIN_OBJECTS:
case CONNECTION_DEFINITIONS:
case BEAN_VALIDATION_GROUPS:
{
//ignore it,we will parse bean-validation-group,admin_object and connection_definition directly
break;
}
case ADMIN_OBJECT:
{
parseAdminObjects(reader, adminObjectsOperations, aoConfigPropertiesOperations);
break;
}
case CONNECTION_DEFINITION:
{
switch(org.jboss.as.connector.subsystems.resourceadapters.Namespace.forUri(reader.getNamespaceURI())) {
case RESOURCEADAPTERS_1_0:
case RESOURCEADAPTERS_1_1:
case RESOURCEADAPTERS_2_0:
parseConnectionDefinitions_1_0(reader, connectionDefinitionsOperations, cfConfigPropertiesOperations, isXa);
break;
case RESOURCEADAPTERS_3_0:
parseConnectionDefinitions_3_0(reader, connectionDefinitionsOperations, cfConfigPropertiesOperations, isXa);
break;
case RESOURCEADAPTERS_4_0:
parseConnectionDefinitions_4_0(reader, connectionDefinitionsOperations, cfConfigPropertiesOperations, isXa);
break;
default:
parseConnectionDefinitions_5_0(reader, connectionDefinitionsOperations, cfConfigPropertiesOperations, isXa);
break;
}
break;
}
case BEAN_VALIDATION_GROUP:
{
String value = rawElementText(reader);
operation.get(BEANVALIDATION_GROUPS.getName()).add(BEANVALIDATIONGROUP.parse(value, reader));
break;
}
case BOOTSTRAP_CONTEXT:
{
String value = rawElementText(reader);
BOOTSTRAP_CONTEXT.parseAndSetParameter(value, operation, reader);
break;
}
case CONFIG_PROPERTY:
{
parseConfigProperties(reader, configPropertiesOperations);
break;
}
case TRANSACTION_SUPPORT:
{
if (txSupportMatched) {
throw new ParserException(bundle.unexpectedElement(TRANSACTION_SUPPORT.getXmlName()));
}
String value = rawElementText(reader);
TRANSACTION_SUPPORT.parseAndSetParameter(value, operation, reader);
isXa = value != null && TransactionSupportEnum.valueOf(value) == TransactionSupportEnum.XATransaction;
txSupportMatched = true;
break;
}
case WORKMANAGER:
{
parseWorkManager(operation, reader);
break;
}
case ARCHIVE:
{
if (archiveOrModuleMatched) {
throw new ParserException(bundle.unexpectedElement(ARCHIVE.getXmlName()));
}
archiveOrModuleName = rawElementText(reader);
ARCHIVE.parseAndSetParameter(archiveOrModuleName, operation, reader);
archiveOrModuleMatched = true;
break;
}
case MODULE:
{
if (archiveOrModuleMatched) {
throw new ParserException(bundle.unexpectedElement(MODULE.getXmlName()));
}
String moduleId = rawAttributeText(reader, "id");
String moduleSlot = rawAttributeText(reader, "slot", "main");
archiveOrModuleName = moduleId + ":" + moduleSlot;
MODULE.parseAndSetParameter(archiveOrModuleName, operation, reader);
archiveOrModuleMatched = true;
break;
}
default:
throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
}
break;
}
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
}
Aggregations