use of org.wildfly.clustering.ee.CompositeIterable 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.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.
the class InfinispanRoutingProvider method getServiceConfigurators.
@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(String serverName, SupplierDependency<String> route) {
String containerName = this.config.getContainerName();
String cacheName = this.config.getCacheName();
CapabilityServiceConfigurator localRouteConfigurator = new LocalRouteServiceConfigurator(serverName, route);
CapabilityServiceConfigurator registryEntryConfigurator = new RouteRegistryEntryProviderServiceConfigurator(containerName, serverName);
CapabilityServiceConfigurator configurationConfigurator = new TemplateConfigurationServiceConfigurator(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CONFIGURATION.getName()).append(containerName, serverName), containerName, serverName, cacheName, this.config);
CapabilityServiceConfigurator cacheConfigurator = new CacheServiceConfigurator<>(ServiceNameFactory.parseServiceName(InfinispanCacheRequirement.CACHE.getName()).append(containerName, serverName), containerName, serverName);
List<Iterable<CapabilityServiceConfigurator>> configurators = new LinkedList<>();
configurators.add(Arrays.asList(localRouteConfigurator, registryEntryConfigurator, configurationConfigurator, cacheConfigurator));
ServiceNameRegistry<ClusteringCacheRequirement> registry = new ServiceNameRegistry<ClusteringCacheRequirement>() {
@Override
public ServiceName getServiceName(ClusteringCacheRequirement requirement) {
return REGISTRY_REQUIREMENTS.contains(requirement) ? ServiceNameFactory.parseServiceName(requirement.getName()).append(containerName, serverName) : null;
}
};
for (CacheServiceConfiguratorProvider provider : ServiceLoader.load(DistributedCacheServiceConfiguratorProvider.class, DistributedCacheServiceConfiguratorProvider.class.getClassLoader())) {
configurators.add(provider.getServiceConfigurators(registry, containerName, serverName));
}
return new CompositeIterable<>(configurators);
}
use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.
the class SingletonServiceConfiguratorFactoryServiceConfiguratorProvider method getServiceConfigurators.
@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String cacheName) {
Iterable<CapabilityServiceConfigurator> configurators = super.getServiceConfigurators(registry, containerName, cacheName);
@SuppressWarnings("deprecation") ServiceName name = registry.getServiceName(ClusteringCacheRequirement.SINGLETON_SERVICE_BUILDER_FACTORY);
if (name == null)
return configurators;
// Add configurator for deprecated capability
CapabilityServiceConfigurator deprecatedConfigurator = new IdentityCapabilityServiceConfigurator<>(name, ClusteringCacheRequirement.SINGLETON_SERVICE_CONFIGURATOR_FACTORY, containerName, cacheName);
return new CompositeIterable<>(configurators, Collections.singleton(deprecatedConfigurator));
}
use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.
the class IdentityRegistryFactoryServiceConfiguratorProvider method getServiceConfigurators.
@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String aliasCacheName, String targetCacheName) {
Iterable<CapabilityServiceConfigurator> configurators = super.getServiceConfigurators(registry, containerName, aliasCacheName, targetCacheName);
ServiceName registryServiceName = registry.getServiceName(ClusteringCacheRequirement.REGISTRY);
ServiceName registryEntryServiceName = registry.getServiceName(ClusteringCacheRequirement.REGISTRY_ENTRY);
if ((registryServiceName == null) && (registryEntryServiceName == null))
return configurators;
List<CapabilityServiceConfigurator> registryConfigurators = new ArrayList<>(2);
if (registryServiceName != null) {
registryConfigurators.add(new IdentityCapabilityServiceConfigurator<>(registryServiceName, ClusteringCacheRequirement.REGISTRY, containerName, targetCacheName));
}
if (registryEntryServiceName != null) {
registryConfigurators.add(new IdentityCapabilityServiceConfigurator<>(registryEntryServiceName, ClusteringCacheRequirement.REGISTRY_ENTRY, containerName, targetCacheName));
}
return new CompositeIterable<>(configurators, registryConfigurators);
}
use of org.wildfly.clustering.ee.CompositeIterable in project wildfly by wildfly.
the class RegistryFactoryServiceConfiguratorProvider method getServiceConfigurators.
@Override
public Iterable<CapabilityServiceConfigurator> getServiceConfigurators(ServiceNameRegistry<ClusteringCacheRequirement> registry, String containerName, String cacheName) {
Iterable<CapabilityServiceConfigurator> configurators = super.getServiceConfigurators(registry, containerName, cacheName);
ServiceName registryServiceName = registry.getServiceName(ClusteringCacheRequirement.REGISTRY);
if (registryServiceName == null)
return configurators;
CapabilityServiceConfigurator configurator = new RegistryServiceConfigurator<>(registryServiceName, containerName, cacheName);
return new CompositeIterable<>(configurators, Collections.singleton(configurator));
}
Aggregations