@Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
        context.startSubsystemElement(InfinispanSchema.CURRENT.getNamespaceUri(), false);
        ModelNode model = context.getModelNode();
        if (model.isDefined()) {
            for (Property entry: model.get(ModelKeys.CACHE_CONTAINER).asPropertyList()) {

                String containerName = entry.getName();
                ModelNode container = entry.getValue();

                writer.writeStartElement(Element.CACHE_CONTAINER.getLocalName());
                writer.writeAttribute(Attribute.NAME.getLocalName(), containerName);
                // AS7-3488 make default-cache a non required attribute
                // this.writeRequired(writer, Attribute.DEFAULT_CACHE, container, ModelKeys.DEFAULT_CACHE);
                this.writeListAsAttribute(writer, Attribute.ALIASES, container, ModelKeys.ALIASES);
                this.writeOptional(writer, Attribute.DEFAULT_CACHE, container, ModelKeys.DEFAULT_CACHE);
                this.writeOptional(writer, Attribute.JNDI_NAME, container, ModelKeys.JNDI_NAME);
                this.writeOptional(writer, Attribute.START, container, ModelKeys.START);
                this.writeOptional(writer, Attribute.MODULE, container, ModelKeys.MODULE);
                this.writeOptional(writer, Attribute.STATISTICS, container, ModelKeys.STATISTICS);

                if (container.hasDefined(ModelKeys.TRANSPORT)) {
                    writer.writeStartElement(Element.TRANSPORT.getLocalName());
                    ModelNode transport = container.get(ModelKeys.TRANSPORT, ModelKeys.TRANSPORT_NAME);
                    this.writeOptional(writer, Attribute.CHANNEL, transport, ModelKeys.CHANNEL);
                    this.writeOptional(writer, Attribute.LOCK_TIMEOUT, transport, ModelKeys.LOCK_TIMEOUT);
                    this.writeOptional(writer, Attribute.STRICT_PEER_TO_PEER, transport, ModelKeys.STRICT_PEER_TO_PEER);
                    this.writeOptional(writer, Attribute.INITIAL_CLUSTER_SIZE, transport, ModelKeys.INITIAL_CLUSTER_SIZE);
                    this.writeOptional(writer, Attribute.INITIAL_CLUSTER_TIMEOUT, transport, ModelKeys.INITIAL_CLUSTER_TIMEOUT);
                    writer.writeEndElement();
                }

                if (container.hasDefined(ModelKeys.SECURITY)) {
                    writer.writeStartElement(Element.SECURITY.getLocalName());
                    ModelNode security = container.get(ModelKeys.SECURITY, ModelKeys.SECURITY_NAME);
                    if (security.hasDefined(ModelKeys.AUTHORIZATION)) {
                        writer.writeStartElement(Element.AUTHORIZATION.getLocalName());
                        ModelNode authorization = security.get(ModelKeys.AUTHORIZATION, ModelKeys.AUTHORIZATION_NAME);
                        if (authorization.hasDefined(ModelKeys.MAPPER)) {
                            String mapper = authorization.get(ModelKeys.MAPPER).asString();
                            if (CommonNameRoleMapper.class.getName().equals(mapper)) {
                                writer.writeEmptyElement(Element.COMMON_NAME_ROLE_MAPPER.getLocalName());
                            } else if (ClusterRoleMapper.class.getName().equals(mapper)) {
                                writer.writeEmptyElement(Element.CLUSTER_ROLE_MAPPER.getLocalName());
                            } else if (IdentityRoleMapper.class.getName().equals(mapper)) {
                                writer.writeEmptyElement(Element.IDENTITY_ROLE_MAPPER.getLocalName());
                            } else {
                                writer.writeStartElement(Element.CUSTOM_ROLE_MAPPER.getLocalName());
                                writer.writeAttribute(Attribute.CLASS.getLocalName(), mapper);
                                writer.writeEndElement();
                            }
                        }

                        ModelNode roles = authorization.get(ModelKeys.ROLE);
                        if (roles.isDefined()) {
                            for (ModelNode roleNode : roles.asList()) {
                                ModelNode role = roleNode.get(0);
                                writer.writeStartElement(Element.ROLE.getLocalName());
                                AuthorizationRoleResource.NAME.marshallAsAttribute(role, writer);
                                this.writeListAsAttribute(writer, Attribute.PERMISSIONS, role, ModelKeys.PERMISSIONS);
                                writer.writeEndElement();
                            }
                        }

                        writer.writeEndElement();
                    }

                    writer.writeEndElement();
                }

                if (container.hasDefined(ModelKeys.GLOBAL_STATE)) {
                    writer.writeStartElement(Element.GLOBAL_STATE.getLocalName());
                    ModelNode globalState = container.get(ModelKeys.GLOBAL_STATE, ModelKeys.GLOBAL_STATE_NAME);
                    writeStatePathElement(Element.PERSISTENT_LOCATION, ModelKeys.PERSISTENT_LOCATION, writer, globalState);
                    writeStatePathElement(Element.SHARED_PERSISTENT_LOCATION, ModelKeys.SHARED_PERSISTENT_LOCATION, writer, globalState);
                    writeStatePathElement(Element.TEMPORARY_LOCATION, ModelKeys.TEMPORARY_LOCATION, writer, globalState);
                    if (globalState.hasDefined(ModelKeys.CONFIGURATION_STORAGE)) {
                        ConfigurationStorage configurationStorage = ConfigurationStorage.valueOf(globalState.get(ModelKeys.CONFIGURATION_STORAGE).asString());
                        switch (configurationStorage) {
                            case IMMUTABLE:
                                writer.writeEmptyElement(Element.IMMUTABLE_CONFIGURATION_STORAGE.getLocalName());
                                break;
                            case VOLATILE:
                                writer.writeEmptyElement(Element.VOLATILE_CONFIGURATION_STORAGE.getLocalName());
                                break;
                            case OVERLAY:
                                writer.writeEmptyElement(Element.OVERLAY_CONFIGURATION_STORAGE.getLocalName());
                                break;
                            case MANAGED:
                                writer.writeEmptyElement(Element.MANAGED_CONFIGURATION_STORAGE.getLocalName());
                                break;
                            case CUSTOM:
                                writer.writeStartElement(Element.CUSTOM_CONFIGURATION_STORAGE.getLocalName());
                                writer.writeAttribute(Attribute.CLASS.getLocalName(), globalState.get(ModelKeys.CONFIGURATION_STORAGE_CLASS).asString());
                                writer.writeEndElement();
                                break;
                        }
                    }
                    writer.writeEndElement();
                }

                // write any configured thread pools
                if (container.hasDefined(ThreadPoolResource.WILDCARD_PATH.getKey())) {
                    writeThreadPoolElements(Element.ASYNC_OPERATIONS_THREAD_POOL, ThreadPoolResource.ASYNC_OPERATIONS, writer, container);
                    writeScheduledThreadPoolElements(Element.EXPIRATION_THREAD_POOL, ScheduledThreadPoolResource.EXPIRATION, writer, container);
                    writeThreadPoolElements(Element.LISTENER_THREAD_POOL, ThreadPoolResource.LISTENER, writer, container);
                    writeScheduledThreadPoolElements(Element.PERSISTENCE_THREAD_POOL, ScheduledThreadPoolResource.PERSISTENCE, writer, container);
                    writeThreadPoolElements(Element.REMOTE_COMMAND_THREAD_POOL, ThreadPoolResource.REMOTE_COMMAND, writer, container);
                    writeScheduledThreadPoolElements(Element.REPLICATION_QUEUE_THREAD_POOL, ScheduledThreadPoolResource.REPLICATION_QUEUE, writer, container);
                    writeThreadPoolElements(Element.STATE_TRANSFER_THREAD_POOL, ThreadPoolResource.STATE_TRANSFER, writer, container);
                    writeThreadPoolElements(Element.TRANSPORT_THREAD_POOL, ThreadPoolResource.TRANSPORT, writer, container);
                }

                // write modules
                if (container.hasDefined(ModelKeys.MODULES)) {
                   writer.writeStartElement(Element.MODULES.getLocalName());
                   ModelNode modules = container.get(ModelKeys.MODULES, ModelKeys.MODULES_NAME, ModelKeys.MODULE);
                   for (ModelNode moduleNode : modules.asList()) {
                      if (moduleNode.isDefined()) {
                         ModelNode modelNode = moduleNode.get(0);
                         writer.writeStartElement(Element.MODULE.getLocalName());
                         writeAttribute(writer, modelNode, CacheContainerModuleResource.NAME);
                         if (modelNode.hasDefined(ModelKeys.SLOT)) {
                            writeAttribute(writer, modelNode, CacheContainerModuleResource.SLOT);
                         }
                         writer.writeEndElement();
                      }
                   }
                   writer.writeEndElement();
                }

                ModelNode configurations = container.get(ModelKeys.CONFIGURATIONS, ModelKeys.CONFIGURATIONS_NAME);

                // write any existent cache types
                processCacheConfiguration(writer, container, configurations, ModelKeys.LOCAL_CACHE);
                processCacheConfiguration(writer, container, configurations, ModelKeys.INVALIDATION_CACHE);
                processCacheConfiguration(writer, container, configurations, ModelKeys.REPLICATED_CACHE);
                processCacheConfiguration(writer, container, configurations, ModelKeys.DISTRIBUTED_CACHE);

                // counters
                processCounterConfigurations(writer, container);

                writer.writeEndElement();
            }
        }
        writer.writeEndElement();
    }
@ Override public void writeContent ( XMLExtendedStreamWriter writer , SubsystemMarshallingContext context ) throws XMLStreamException { context . startSubsystemElement ( InfinispanSchema . CURRENT . getNamespaceUri ( ) , false ) ; ModelNode model = context . getModelNode ( ) ; if ( model . isDefined ( ) ) { for ( Property entry : model . get ( ModelKeys . CACHE_CONTAINER ) . asPropertyList ( ) ) { String containerName = entry . getName ( ) ; ModelNode container = entry . getValue ( ) ; writer . writeStartElement ( Element . CACHE_CONTAINER . getLocalName ( ) ) ; writer . writeAttribute ( Attribute . NAME . getLocalName ( ) , containerName ) ; this . writeListAsAttribute ( writer , Attribute . ALIASES , container , ModelKeys . ALIASES ) ; this . writeOptional ( writer , Attribute . DEFAULT_CACHE , container , ModelKeys . DEFAULT_CACHE ) ; this . writeOptional ( writer , Attribute . JNDI_NAME , container , ModelKeys . JNDI_NAME ) ; this . writeOptional ( writer , Attribute . START , container , ModelKeys . START ) ; this . writeOptional ( writer , Attribute . MODULE , container , ModelKeys . MODULE ) ; this . writeOptional ( writer , Attribute . STATISTICS , container , ModelKeys . STATISTICS ) ; if ( container . hasDefined ( ModelKeys . TRANSPORT ) ) { writer . writeStartElement ( Element . TRANSPORT . getLocalName ( ) ) ; ModelNode transport = container . get ( ModelKeys . TRANSPORT , ModelKeys . TRANSPORT_NAME ) ; this . writeOptional ( writer , Attribute . CHANNEL , transport , ModelKeys . CHANNEL ) ; this . writeOptional ( writer , Attribute . LOCK_TIMEOUT , transport , ModelKeys . LOCK_TIMEOUT ) ; this . writeOptional ( writer , Attribute . STRICT_PEER_TO_PEER , transport , ModelKeys . STRICT_PEER_TO_PEER ) ; this . writeOptional ( writer , Attribute . INITIAL_CLUSTER_SIZE , transport , ModelKeys . INITIAL_CLUSTER_SIZE ) ; this . writeOptional ( writer , Attribute . INITIAL_CLUSTER_TIMEOUT , transport , ModelKeys . INITIAL_CLUSTER_TIMEOUT ) ; writer . writeEndElement ( ) ; } if ( container . hasDefined ( ModelKeys . SECURITY ) ) { writer . writeStartElement ( Element . SECURITY . getLocalName ( ) ) ; ModelNode security = container . get ( ModelKeys . SECURITY , ModelKeys . SECURITY_NAME ) ; if ( security . hasDefined ( ModelKeys . AUTHORIZATION ) ) { writer . writeStartElement ( Element . AUTHORIZATION . getLocalName ( ) ) ; ModelNode authorization = security . get ( ModelKeys . AUTHORIZATION , ModelKeys . AUTHORIZATION_NAME ) ; if ( authorization . hasDefined ( ModelKeys . MAPPER ) ) { String mapper = authorization . get ( ModelKeys . MAPPER ) . asString ( ) ; if ( CommonNameRoleMapper . class . getName ( ) . equals ( mapper ) ) { writer . writeEmptyElement ( Element . COMMON_NAME_ROLE_MAPPER . getLocalName ( ) ) ; } else if ( ClusterRoleMapper . class . getName ( ) . equals ( mapper ) ) { writer . writeEmptyElement ( Element . CLUSTER_ROLE_MAPPER . getLocalName ( ) ) ; } else if ( IdentityRoleMapper . class . getName ( ) . equals ( mapper ) ) { writer . writeEmptyElement ( Element . IDENTITY_ROLE_MAPPER . getLocalName ( ) ) ; } else { writer . writeStartElement ( Element . CUSTOM_ROLE_MAPPER . getLocalName ( ) ) ; writer . writeAttribute ( Attribute . CLASS . getLocalName ( ) , mapper ) ; writer . writeEndElement ( ) ; } } ModelNode roles = authorization . get ( ModelKeys . ROLE ) ; if ( roles . isDefined ( ) ) { for ( ModelNode roleNode : roles . asList ( ) ) { ModelNode role = roleNode . get ( 0 ) ; writer . writeStartElement ( Element . ROLE . getLocalName ( ) ) ; AuthorizationRoleResource . NAME . marshallAsAttribute ( role , writer ) ; this . writeListAsAttribute ( writer , Attribute . PERMISSIONS , role , ModelKeys . PERMISSIONS ) ; writer . writeEndElement ( ) ; } } writer . writeEndElement ( ) ; } writer . writeEndElement ( ) ; } if ( container . hasDefined ( ModelKeys . GLOBAL_STATE ) ) { writer . writeStartElement ( Element . GLOBAL_STATE . getLocalName ( ) ) ; ModelNode globalState = container . get ( ModelKeys . GLOBAL_STATE , ModelKeys . GLOBAL_STATE_NAME ) ; writeStatePathElement ( Element . PERSISTENT_LOCATION , ModelKeys . PERSISTENT_LOCATION , writer , globalState ) ; writeStatePathElement ( Element . SHARED_PERSISTENT_LOCATION , ModelKeys . SHARED_PERSISTENT_LOCATION , writer , globalState ) ; writeStatePathElement ( Element . TEMPORARY_LOCATION , ModelKeys . TEMPORARY_LOCATION , writer , globalState ) ; if ( globalState . hasDefined ( ModelKeys . CONFIGURATION_STORAGE ) ) { ConfigurationStorage configurationStorage = ConfigurationStorage . valueOf ( globalState . get ( ModelKeys . CONFIGURATION_STORAGE ) . asString ( ) ) ; switch ( configurationStorage ) { case IMMUTABLE : writer . writeEmptyElement ( Element . IMMUTABLE_CONFIGURATION_STORAGE . getLocalName ( ) ) ; break ; case VOLATILE : writer . writeEmptyElement ( Element . VOLATILE_CONFIGURATION_STORAGE . getLocalName ( ) ) ; break ; case OVERLAY : writer . writeEmptyElement ( Element . OVERLAY_CONFIGURATION_STORAGE . getLocalName ( ) ) ; break ; case MANAGED : writer . writeEmptyElement ( Element . MANAGED_CONFIGURATION_STORAGE . getLocalName ( ) ) ; break ; case CUSTOM : writer . writeStartElement ( Element . CUSTOM_CONFIGURATION_STORAGE . getLocalName ( ) ) ; writer . writeAttribute ( Attribute . CLASS . getLocalName ( ) , globalState . get ( ModelKeys . CONFIGURATION_STORAGE_CLASS ) . asString ( ) ) ; writer . writeEndElement ( ) ; break ; } } writer . writeEndElement ( ) ; } if ( container . hasDefined ( ThreadPoolResource . WILDCARD_PATH . getKey ( ) ) ) { writeThreadPoolElements ( Element . ASYNC_OPERATIONS_THREAD_POOL , ThreadPoolResource . ASYNC_OPERATIONS , writer , container ) ; writeScheduledThreadPoolElements ( Element . EXPIRATION_THREAD_POOL , ScheduledThreadPoolResource . EXPIRATION , writer , container ) ; writeThreadPoolElements ( Element . LISTENER_THREAD_POOL , ThreadPoolResource . LISTENER , writer , container ) ; writeScheduledThreadPoolElements ( Element . PERSISTENCE_THREAD_POOL , ScheduledThreadPoolResource . PERSISTENCE , writer , container ) ; writeThreadPoolElements ( Element . REMOTE_COMMAND_THREAD_POOL , ThreadPoolResource . REMOTE_COMMAND , writer , container ) ; writeScheduledThreadPoolElements ( Element . REPLICATION_QUEUE_THREAD_POOL , ScheduledThreadPoolResource . REPLICATION_QUEUE , writer , container ) ; writeThreadPoolElements ( Element . STATE_TRANSFER_THREAD_POOL , ThreadPoolResource . STATE_TRANSFER , writer , container ) ; writeThreadPoolElements ( Element . TRANSPORT_THREAD_POOL , ThreadPoolResource . TRANSPORT , writer , container ) ; } if ( container . hasDefined ( ModelKeys . MODULES ) ) { writer . writeStartElement ( Element . MODULES . getLocalName ( ) ) ; ModelNode modules = container . get ( ModelKeys . MODULES , ModelKeys . MODULES_NAME , ModelKeys . MODULE ) ; for ( ModelNode moduleNode : modules . asList ( ) ) { if ( moduleNode . isDefined ( ) ) { ModelNode modelNode = moduleNode . get ( 0 ) ; writer . writeStartElement ( Element . MODULE . getLocalName ( ) ) ; writeAttribute ( writer , modelNode , CacheContainerModuleResource . NAME ) ; if ( modelNode . hasDefined ( ModelKeys . SLOT ) ) { writeAttribute ( writer , modelNode , CacheContainerModuleResource . SLOT ) ; } writer . writeEndElement ( ) ; } } writer . writeEndElement ( ) ; } ModelNode configurations = container . get ( ModelKeys . CONFIGURATIONS , ModelKeys . CONFIGURATIONS_NAME ) ; processCacheConfiguration ( writer , container , configurations , ModelKeys . LOCAL_CACHE ) ; processCacheConfiguration ( writer , container , configurations , ModelKeys . INVALIDATION_CACHE ) ; processCacheConfiguration ( writer , container , configurations , ModelKeys . REPLICATED_CACHE ) ; processCacheConfiguration ( writer , container , configurations , ModelKeys . DISTRIBUTED_CACHE ) ; processCounterConfigurations ( writer , container ) ; writer . writeEndElement ( ) ; } } writer . writeEndElement ( ) ; }
{@inheritDoc}
@see org.jboss.staxmapper.XMLElementWriter#writeContent(org.jboss.staxmapper.XMLExtendedStreamWriter, java.lang.Object)