Package org.codehaus.plexus.util.xml

Examples of org.codehaus.plexus.util.xml.XMLWriter


        }
    }

    private XMLWriter initializeRootElementOneDotThree( Writer w )
    {
        XMLWriter writer = initializeXmlWriter( w, DOCTYPE_1_3 );
        writer.startElement( APPLICATION_ELEMENT );
        return writer;
    }
View Full Code Here


        return writer;
    }

    private XMLWriter initializeRootElementOneDotFour( Writer w )
    {
        XMLWriter writer = initializeXmlWriter( w, null );
        writer.startElement( APPLICATION_ELEMENT );
        writer.addAttribute( "xmlns", "http://java.sun.com/xml/ns/j2ee" );
        writer.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
        writer.addAttribute( "xsi:schemaLocation",
                             "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" );
        writer.addAttribute( "version", "1.4" );
        return writer;
    }
View Full Code Here

        return writer;
    }

    private XMLWriter initializeRootElementFive( Writer w )
    {
        XMLWriter writer = initializeXmlWriter( w, null );
        writer.startElement( APPLICATION_ELEMENT );
        writer.addAttribute( "xmlns", "http://java.sun.com/xml/ns/javaee" );
        writer.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
        writer.addAttribute( "xsi:schemaLocation",
                             "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" );
        writer.addAttribute( "version", "5" );
        return writer;
    }
View Full Code Here

        return writer;
    }

    private XMLWriter initializeRootElementSix( Writer w )
    {
        XMLWriter writer = initializeXmlWriter( w, null );
        writer.startElement( APPLICATION_ELEMENT );
        writer.addAttribute( "xmlns", "http://java.sun.com/xml/ns/javaee" );
        writer.addAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
        writer.addAttribute( "xsi:schemaLocation",
                             "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" );
        writer.addAttribute( "version", "6" );
        return writer;
    }
View Full Code Here

    public void write( File destinationFile, JbossConfiguration jbossConfiguration, List<EarModule> earModules )
        throws EarPluginException
    {
        final Writer w = initializeWriter( destinationFile );

        XMLWriter writer;
        if ( jbossConfiguration.isJbossThreeDotTwo() )
        {
            writer = initializeXmlWriter( w, DOCTYPE_3_2 );
        }
        else if ( jbossConfiguration.isJbossFour() )
        {
            writer = initializeXmlWriter( w, DOCTYPE_4 );
        }
        else if ( jbossConfiguration.isJbossFourDotTwo() )
        {
            writer = initializeXmlWriter( w, DOCTYPE_4_2 );
        }
        else
        {
            writer = initializeXmlWriter( w, DOCTYPE_5 );
        }
        writer.startElement( JBOSS_APP_ELEMENT );

        // Make sure to write the things in the right order so that the DTD validates

        // module-order (only available as from 4.2)
        if ( jbossConfiguration.isJbossFourDotTwoOrHigher() && jbossConfiguration.getModuleOrder() != null )
        {
            writer.startElement( JbossConfiguration.MODULE_ORDER );
            writer.writeText( jbossConfiguration.getModuleOrder() );
            writer.endElement();
        }

        // If JBoss 4, write the jboss4 specific stuff
        if ( jbossConfiguration.isJbossFourOrHigher() )
        {
            if ( jbossConfiguration.getSecurityDomain() != null )
            {
                writer.startElement( JbossConfiguration.SECURITY_DOMAIN );
                writer.writeText( jbossConfiguration.getSecurityDomain() );
                writer.endElement();
            }
            if ( jbossConfiguration.getUnauthenticatedPrincipal() != null )
            {
                writer.startElement( JbossConfiguration.UNAUHTHENTICTED_PRINCIPAL );
                writer.writeText( jbossConfiguration.getUnauthenticatedPrincipal() );
                writer.endElement();
            }
        }

        // classloader repository
        if ( jbossConfiguration.getLoaderRepository() != null
            || jbossConfiguration.getLoaderRepositoryConfig() != null )
        {
            writer.startElement( JbossConfiguration.LOADER_REPOSITORY );

            // classloader repository class
            if ( jbossConfiguration.getLoaderRepositoryClass() != null )
            {
                writer.addAttribute( JbossConfiguration.LOADER_REPOSITORY_CLASS_ATTRIBUTE,
                                     jbossConfiguration.getLoaderRepositoryClass() );
            }

            // we don't need to write any text if only the loader repo configuration is changed
            if ( jbossConfiguration.getLoaderRepository() != null )
            {
                writer.writeText( jbossConfiguration.getLoaderRepository() );
            }

            // classloader configuration
            if ( jbossConfiguration.getLoaderRepositoryConfig() != null )
            {
                writer.startElement( JbossConfiguration.LOADER_REPOSITORY_CONFIG );

                // classloader configuration parser
                if ( jbossConfiguration.getConfigParserClass() != null )
                {
                    writer.addAttribute( JbossConfiguration.CONFIG_PARSER_CLASS_ATTRIBUTE,
                                         jbossConfiguration.getConfigParserClass() );
                }
                writer.writeText( jbossConfiguration.getLoaderRepositoryConfig() );
                writer.endElement();
            }

            writer.endElement();
        }

        // jmx name
        if ( jbossConfiguration.getJmxName() != null )
        {
            writer.startElement( JbossConfiguration.JMX_NAME );
            writer.writeText( jbossConfiguration.getJmxName() );
            writer.endElement();
        }

        // library-directory (only available as from 4.2)
        if ( jbossConfiguration.isJbossFourDotTwoOrHigher() && jbossConfiguration.getLibraryDirectory() != null )
        {
            writer.startElement( JbossConfiguration.LIBRARY_DIRECTORY );
            writer.writeText( jbossConfiguration.getLibraryDirectory() );
            writer.endElement();
        }

        // Modules

        List<String> dataSources = jbossConfiguration.getDataSources();
        // Write out data source modules first
        if ( dataSources != null )
        {
            for ( String dsPath : dataSources )
            {
                writer.startElement( MODULE_ELEMENT );
                writer.startElement( SERVICE_ELEMENT );
                writer.writeText( dsPath );
                writer.endElement();
                writer.endElement();
            }
        }

        // Write the JBoss specific modules
        for ( EarModule earModule : earModules )
        {
            if ( JbossEarModule.class.isInstance( earModule ) )
            {
                JbossEarModule jbossEarModule = (JbossEarModule) earModule;
                jbossEarModule.appendJbossModule( writer, jbossConfiguration.getVersion() );
            }
        }
        writer.endElement();

        close( w );
    }
View Full Code Here

        Writer writer = null;
        try
        {
            writer = new OutputStreamWriter( new FileOutputStream( f ), encoding );

            XMLWriter w = new PrettyPrintXMLWriter( writer, encoding, null );

            w.startElement( "plugin" );

            PluginUtils.element( w, "name", pluginDescriptor.getName() );

            PluginUtils.element( w, "description", pluginDescriptor.getDescription() );

            PluginUtils.element( w, "groupId", pluginDescriptor.getGroupId() );

            PluginUtils.element( w, "artifactId", pluginDescriptor.getArtifactId() );

            PluginUtils.element( w, "version", pluginDescriptor.getVersion() );

            PluginUtils.element( w, "goalPrefix", pluginDescriptor.getGoalPrefix() );

            PluginUtils.element( w, "isolatedRealm", "" + pluginDescriptor.isIsolatedRealm() );

            PluginUtils.element( w, "inheritedByDefault", "" + pluginDescriptor.isInheritedByDefault() );

            w.startElement( "mojos" );

            if ( pluginDescriptor.getMojos() != null )
            {
                for ( @SuppressWarnings( "unchecked" )
                Iterator<MojoDescriptor> it = pluginDescriptor.getMojos().iterator(); it.hasNext(); )
                {
                    MojoDescriptor descriptor = it.next();
                    processMojoDescriptor( descriptor, w );
                }
            }

            w.endElement();

            PluginUtils.writeDependencies( w, pluginDescriptor );

            w.endElement();

            writer.flush();
        }
        finally
        {
View Full Code Here

        Writer writer = null;
        try
        {
            writer = new OutputStreamWriter( new FileOutputStream( outputFile ), encoding );

            XMLWriter w = new PrettyPrintXMLWriter( new PrintWriter( writer ), encoding, null );
            writeBody( mojoDescriptor, w );

            writer.flush();
        }
        finally
View Full Code Here

        PluginDescriptor descriptor = new PluginDescriptor();
        descriptor.setDependencies( Collections.singletonList( dependency ) );

        StringWriter sWriter = new StringWriter();
        XMLWriter writer = new CompactXMLWriter( sWriter );

        PluginUtils.writeDependencies( writer, descriptor );

        String output = sWriter.toString();
View Full Code Here

    return new PrettyPrintXMLWriter(writer, encoding, docType);
  }

  protected void write(Workflow workflow) throws MojoExecutionException {
    Writer w = initializeWriter(workflow.getDestinationFile());
    XMLWriter writer = initializeRootElement(w, workflow.getSchemaVersion(),
        workflow.getName());

    appendStart(writer);
    appendJavaAction(writer, workflow);
    appendKill(writer);
    appendEnd(writer);

    writer.endElement();
    close(w);
  }
View Full Code Here

    close(w);
  }

  private XMLWriter initializeRootElement(Writer w, String schemaVersion,
      String workflowName) {
    XMLWriter writer = initializeXmlWriter(w, null);
    writer.startElement(WORKFLOW_ELEMENT);
    writer.addAttribute("xmlns", "uri:oozie:workflow:" + schemaVersion);
    writer.addAttribute("name", workflowName);
    return writer;
  }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.util.xml.XMLWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.