Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2013, Red Hat, Inc., and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.jboss.legacy.jnp;
 
 import  org.jboss.as.controller.persistence.SubsystemMarshallingContext;
 import  org.jboss.dmr.ModelNode;
 import static org.jboss.legacy.jnp.JNPSubsystemModel.SERVICE;
 import  org.jboss.staxmapper.XMLElementWriter;
 import  org.jboss.staxmapper.XMLExtendedStreamWriter;

Author(s):
baranowb
Emmanuel Hugonnet (c) 2013 Red Hat, inc.
 
 public class JNPSubsystemXMLPersister implements XMLElementWriter<SubsystemMarshallingContext> {
 
     public static final JNPSubsystemXMLPersister INSTANCE = new JNPSubsystemXMLPersister();
 
     @Override
     public void writeContent(XMLExtendedStreamWriter xmlExtendedStreamWriter,
             SubsystemMarshallingContext subsystemMarshallingContextthrows XMLStreamException {
         subsystemMarshallingContext.startSubsystemElement(..getUriString(), false);
         writeElements(xmlExtendedStreamWritersubsystemMarshallingContext);
         xmlExtendedStreamWriter.writeEndElement();
     }
 
     private void writeElements(XMLExtendedStreamWriter xmlExtendedStreamWriter,
             SubsystemMarshallingContext subsystemMarshallingContextthrows XMLStreamException {
         if (subsystemMarshallingContext.getModelNode().hasDefined())  {
             final ModelNode model = subsystemMarshallingContext.getModelNode().get();
 
             if (model.hasDefined(.)) {
                 writeJNPServer(xmlExtendedStreamWriter);
             }
 
             if (model.hasDefined(.)) {
                 writeConnector(xmlExtendedStreamWritersubsystemMarshallingContext);
             }
             if (model.hasDefined(.)) {
                 final ModelNode treeModel = model.get(.);
                 if (model.hasDefined(.) && treeModel.hasDefined(.)) {
                     writeDistributedCache(xmlExtendedStreamWritertreeModel);
                 }
             }
         }
 
     }

    

Parameters:
xmlExtendedStreamWriter
subsystemMarshallingContext
 
     private void writeConnector(XMLExtendedStreamWriter xmlExtendedStreamWriter,
             SubsystemMarshallingContext subsystemMarshallingContextthrows XMLStreamException {
         final ModelNode model = subsystemMarshallingContext.getModelNode().get().get(.);
 
         xmlExtendedStreamWriter.writeStartElement(..getLocalName());
         if (model.hasDefined(.)) {
             ..marshallAsAttribute(modeltruexmlExtendedStreamWriter);
         }
 
         if (model.hasDefined(.)) {
             ..marshallAsAttribute(modeltruexmlExtendedStreamWriter);
         }
 
         xmlExtendedStreamWriter.writeEndElement();
     }
 
     private void writeJNPServer(XMLExtendedStreamWriter xmlExtendedStreamWriterthrows XMLStreamException {
         xmlExtendedStreamWriter.writeStartElement(..getLocalName());
         xmlExtendedStreamWriter.writeEndElement();
     }
 
     private void writeDistributedCache(XMLExtendedStreamWriter xmlExtendedStreamWriter, ModelNode treeModelthrows XMLStreamException {
        xmlExtendedStreamWriter.writeStartElement(..getLocalName());
        ..marshallAsAttribute(treeModeltruexmlExtendedStreamWriter);
        ..marshallAsAttribute(treeModeltruexmlExtendedStreamWriter);
        xmlExtendedStreamWriter.writeEndElement();
    }
New to GrepCode? Check out our FAQ X