use of org.jboss.dmr.Property in project wildfly by wildfly.
the class OperationsTestCase method testDistributedCacheJDBCStoreReadWriteOperation.
/*
* Tests access to local cache attributes
*/
@SuppressWarnings("deprecation")
@Test
public void testDistributedCacheJDBCStoreReadWriteOperation() throws Exception {
ModelNode stringKeyedTable = createStringKeyedTable();
// Parse and install the XML into the controller
String subsystemXml = getSubsystemXml();
KernelServices servicesA = this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build();
// read the distributed cache mixed-keyed-jdbc-store datasource attribute
ModelNode result = servicesA.executeOperation(getJDBCCacheStoreReadOperation("maximal", DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(), "dist", JDBCStoreResourceDefinition.Attribute.DATA_SOURCE));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("ExampleDS", result.get(RESULT).asString());
// write the batching attribute
result = servicesA.executeOperation(getJDBCCacheStoreWriteOperation("maximal", DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(), "dist", JDBCStoreResourceDefinition.Attribute.DATA_SOURCE, "new-datasource"));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
// re-read the batching attribute
result = servicesA.executeOperation(getJDBCCacheStoreReadOperation("maximal", DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(), "dist", JDBCStoreResourceDefinition.Attribute.DATA_SOURCE));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals("new-datasource", result.get(RESULT).asString());
// read the string-keyed-table attribute
result = servicesA.executeOperation(getJDBCCacheStoreReadOperation("maximal", DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(), "dist", MixedKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.STRING_TABLE));
Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
Assert.assertEquals(stringKeyedTable.asPropertyList().size(), result.get(RESULT).asPropertyList().size());
for (Property property : stringKeyedTable.asPropertyList()) {
Assert.assertTrue(property.getName(), result.get(RESULT).hasDefined(property.getName()));
Assert.assertEquals(property.getValue(), result.get(RESULT).get(property.getName()));
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class InfinispanSubsystemXMLWriter method writeCacheElements.
@SuppressWarnings("deprecation")
private static void writeCacheElements(XMLExtendedStreamWriter writer, ModelNode cache) throws XMLStreamException {
if (cache.hasDefined(LockingResourceDefinition.PATH.getKeyValuePair())) {
ModelNode locking = cache.get(LockingResourceDefinition.PATH.getKeyValuePair());
Set<LockingResourceDefinition.Attribute> attributes = EnumSet.allOf(LockingResourceDefinition.Attribute.class);
if (hasDefined(locking, attributes)) {
writer.writeStartElement(XMLElement.LOCKING.getLocalName());
writeAttributes(writer, locking, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(TransactionResourceDefinition.PATH.getKeyValuePair())) {
ModelNode transaction = cache.get(TransactionResourceDefinition.PATH.getKeyValuePair());
Set<TransactionResourceDefinition.Attribute> attributes = EnumSet.allOf(TransactionResourceDefinition.Attribute.class);
if (hasDefined(transaction, attributes)) {
writer.writeStartElement(XMLElement.TRANSACTION.getLocalName());
writeAttributes(writer, transaction, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(HeapMemoryResourceDefinition.PATH.getKeyValuePair())) {
ModelNode memory = cache.get(HeapMemoryResourceDefinition.PATH.getKeyValuePair());
Iterable<Attribute> attributes = new CompositeIterable<>(EnumSet.allOf(MemoryResourceDefinition.Attribute.class), EnumSet.allOf(HeapMemoryResourceDefinition.Attribute.class));
if (hasDefined(memory, attributes)) {
writer.writeStartElement(XMLElement.HEAP_MEMORY.getLocalName());
writeAttributes(writer, memory, attributes);
writer.writeEndElement();
}
} else if (cache.hasDefined(OffHeapMemoryResourceDefinition.PATH.getKeyValuePair())) {
ModelNode memory = cache.get(OffHeapMemoryResourceDefinition.PATH.getKeyValuePair());
Iterable<Attribute> attributes = new CompositeIterable<>(EnumSet.allOf(MemoryResourceDefinition.Attribute.class), EnumSet.allOf(OffHeapMemoryResourceDefinition.Attribute.class));
if (hasDefined(memory, attributes)) {
writer.writeStartElement(XMLElement.OFF_HEAP_MEMORY.getLocalName());
writeAttributes(writer, memory, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(ExpirationResourceDefinition.PATH.getKeyValuePair())) {
ModelNode expiration = cache.get(ExpirationResourceDefinition.PATH.getKeyValuePair());
Set<ExpirationResourceDefinition.Attribute> attributes = EnumSet.allOf(ExpirationResourceDefinition.Attribute.class);
if (hasDefined(expiration, attributes)) {
writer.writeStartElement(XMLElement.EXPIRATION.getLocalName());
writeAttributes(writer, expiration, attributes);
writer.writeEndElement();
}
}
Set<StoreResourceDefinition.Attribute> storeAttributes = EnumSet.complementOf(EnumSet.of(StoreResourceDefinition.Attribute.PROPERTIES));
if (cache.hasDefined(CustomStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(CustomStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.STORE.getLocalName());
writeAttributes(writer, store, CustomStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(FileStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(FileStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.FILE_STORE.getLocalName());
writeAttributes(writer, store, FileStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(BinaryKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(BinaryKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.BINARY_KEYED_JDBC_STORE.getLocalName());
writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writeJDBCStoreTable(writer, XMLElement.BINARY_KEYED_TABLE, store, BinaryTableResourceDefinition.PATH, BinaryTableResourceDefinition.Attribute.PREFIX);
writer.writeEndElement();
}
if (cache.hasDefined(StringKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(StringKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.JDBC_STORE.getLocalName());
writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writeJDBCStoreTable(writer, XMLElement.TABLE, store, StringTableResourceDefinition.PATH, StringTableResourceDefinition.Attribute.PREFIX);
writer.writeEndElement();
}
if (cache.hasDefined(MixedKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(MixedKeyedJDBCStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.MIXED_KEYED_JDBC_STORE.getLocalName());
writeAttributes(writer, store, JDBCStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writeJDBCStoreTable(writer, XMLElement.BINARY_KEYED_TABLE, store, BinaryTableResourceDefinition.PATH, BinaryTableResourceDefinition.Attribute.PREFIX);
writeJDBCStoreTable(writer, XMLElement.STRING_KEYED_TABLE, store, StringTableResourceDefinition.PATH, StringTableResourceDefinition.Attribute.PREFIX);
writer.writeEndElement();
}
if (cache.hasDefined(RemoteStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(RemoteStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.REMOTE_STORE.getLocalName());
writeAttributes(writer, store, RemoteStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(HotRodStoreResourceDefinition.PATH.getKeyValuePair())) {
ModelNode store = cache.get(HotRodStoreResourceDefinition.PATH.getKeyValuePair());
writer.writeStartElement(XMLElement.HOTROD_STORE.getLocalName());
writeAttributes(writer, store, HotRodStoreResourceDefinition.Attribute.class);
writeAttributes(writer, store, storeAttributes);
writeAttributes(writer, store, StoreResourceDefinition.DeprecatedAttribute.class);
writeStoreElements(writer, store);
writer.writeEndElement();
}
if (cache.hasDefined(PartitionHandlingResourceDefinition.PATH.getKeyValuePair())) {
ModelNode partitionHandling = cache.get(PartitionHandlingResourceDefinition.PATH.getKeyValuePair());
EnumSet<PartitionHandlingResourceDefinition.Attribute> attributes = EnumSet.allOf(PartitionHandlingResourceDefinition.Attribute.class);
if (hasDefined(partitionHandling, attributes)) {
writer.writeStartElement(XMLElement.PARTITION_HANDLING.getLocalName());
writeAttributes(writer, partitionHandling, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(StateTransferResourceDefinition.PATH.getKeyValuePair())) {
ModelNode stateTransfer = cache.get(StateTransferResourceDefinition.PATH.getKeyValuePair());
EnumSet<StateTransferResourceDefinition.Attribute> attributes = EnumSet.allOf(StateTransferResourceDefinition.Attribute.class);
if (hasDefined(stateTransfer, attributes)) {
writer.writeStartElement(XMLElement.STATE_TRANSFER.getLocalName());
writeAttributes(writer, stateTransfer, attributes);
writer.writeEndElement();
}
}
if (cache.hasDefined(BackupsResourceDefinition.PATH.getKeyValuePair())) {
ModelNode backups = cache.get(BackupsResourceDefinition.PATH.getKeyValuePair());
if (backups.hasDefined(BackupResourceDefinition.WILDCARD_PATH.getKey())) {
writer.writeStartElement(XMLElement.BACKUPS.getLocalName());
for (Property property : backups.get(BackupResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
writer.writeStartElement(XMLElement.BACKUP.getLocalName());
writer.writeAttribute(XMLAttribute.SITE.getLocalName(), property.getName());
ModelNode backup = property.getValue();
writeAttributes(writer, backup, EnumSet.allOf(BackupResourceDefinition.Attribute.class));
EnumSet<BackupResourceDefinition.TakeOfflineAttribute> takeOfflineAttributes = EnumSet.allOf(BackupResourceDefinition.TakeOfflineAttribute.class);
if (hasDefined(backup, takeOfflineAttributes)) {
writer.writeStartElement(XMLElement.TAKE_OFFLINE.getLocalName());
writeAttributes(writer, backup, takeOfflineAttributes);
writer.writeEndElement();
}
writer.writeEndElement();
}
writer.writeEndElement();
}
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class StoreServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.passivation = PASSIVATION.resolveModelAttribute(context, model).asBoolean();
this.fetchState = FETCH_STATE.resolveModelAttribute(context, model).asBoolean();
this.preload = PRELOAD.resolveModelAttribute(context, model).asBoolean();
this.purge = PURGE.resolveModelAttribute(context, model).asBoolean();
this.shared = SHARED.resolveModelAttribute(context, model).asBoolean();
this.maxBatchSize = MAX_BATCH_SIZE.resolveModelAttribute(context, model).asInt();
this.properties.clear();
for (Property property : PROPERTIES.resolveModelAttribute(context, model).asPropertyListOrEmpty()) {
this.properties.setProperty(property.getName(), property.getValue().asString());
}
return this;
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class AppClientXml method parseServerProfile.
private void parseServerProfile(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException {
// Attributes
requireNoAttributes(reader);
// Content
final Set<String> configuredSubsystemTypes = new HashSet<String>();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
if (Element.forName(reader.getLocalName()) != Element.SUBSYSTEM) {
throw unexpectedElement(reader);
}
if (!configuredSubsystemTypes.add(reader.getNamespaceURI())) {
throw AppClientLogger.ROOT_LOGGER.duplicateSubsystemDeclaration(reader.getLocation());
}
// parse subsystem
final List<ModelNode> subsystems = new ArrayList<ModelNode>();
reader.handleAny(subsystems);
// Process subsystems
for (final ModelNode update : subsystems) {
// Process relative subsystem path address
final ModelNode subsystemAddress = address.clone();
for (final Property path : update.get(OP_ADDR).asPropertyList()) {
subsystemAddress.add(path.getName(), path.getValue().asString());
}
update.get(OP_ADDR).set(subsystemAddress);
list.add(update);
}
}
}
use of org.jboss.dmr.Property in project wildfly by wildfly.
the class BatchSubsystemWriter method writeContent.
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
final ThreadsParser threadsParser = ThreadsParser.getInstance();
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
final ModelNode model = context.getModelNode();
BatchSubsystemDefinition.DEFAULT_JOB_REPOSITORY.marshallAsElement(model, writer);
BatchSubsystemDefinition.DEFAULT_THREAD_POOL.marshallAsElement(model, writer);
BatchSubsystemDefinition.RESTART_JOBS_ON_RESUME.marshallAsElement(model, writer);
BatchSubsystemDefinition.SECURITY_DOMAIN.marshallAsElement(model, writer);
// Write the in-memory job repositories
if (model.hasDefined(InMemoryJobRepositoryDefinition.NAME)) {
final List<Property> repositories = model.get(InMemoryJobRepositoryDefinition.NAME).asPropertyList();
for (Property property : repositories) {
writer.writeStartElement(Element.JOB_REPOSITORY.getLocalName());
writeNameAttribute(writer, property.getName());
writer.writeEmptyElement(Element.IN_MEMORY.getLocalName());
// end job-repository
writer.writeEndElement();
}
}
// Write the JDBC job repositories
if (model.hasDefined(JdbcJobRepositoryDefinition.NAME)) {
final List<Property> repositories = model.get(JdbcJobRepositoryDefinition.NAME).asPropertyList();
for (Property property : repositories) {
writer.writeStartElement(Element.JOB_REPOSITORY.getLocalName());
writeNameAttribute(writer, property.getName());
writer.writeStartElement(Element.JDBC.getLocalName());
JdbcJobRepositoryDefinition.DATA_SOURCE.marshallAsAttribute(property.getValue(), writer);
writer.writeEndElement();
// end job-repository
writer.writeEndElement();
}
}
// Write the thread pool
if (model.hasDefined(BatchThreadPoolResourceDefinition.NAME)) {
final List<Property> threadPools = model.get(BatchThreadPoolResourceDefinition.NAME).asPropertyList();
for (Property threadPool : threadPools) {
threadsParser.writeUnboundedQueueThreadPool(writer, threadPool, Element.THREAD_POOL.getLocalName(), true);
}
}
// Write out the thread factory
if (model.hasDefined(BatchSubsystemDefinition.THREAD_FACTORY)) {
final List<Property> threadFactories = model.get(BatchSubsystemDefinition.THREAD_FACTORY).asPropertyList();
for (Property threadFactory : threadFactories) {
threadsParser.writeThreadFactory(writer, threadFactory);
}
}
writer.writeEndElement();
}
Aggregations