Package org.apache.tomcat.util.xml

Examples of org.apache.tomcat.util.xml.XmlMapper


     * Create and configure the XmlMapper we will be using.
     */
    private XmlMapper createMapper() {

  // Initialize the mapper
  XmlMapper mapper = new XmlMapper();
  mapper.setDebug(999);

  // Configure the actions we will be using

  // FIXME -- Adapter or Connector or something!

  mapper.addRule("Engine", mapper.objectCreate("org.apache.tomcat.core.StandardEngine", "className"));
  mapper.addRule("Engine", mapper.setProperties());

  mapper.addRule("Engine/Host", mapper.objectCreate("org.apache.tomcat.core.StandardHost", "className"));
  mapper.addRule("Engine/Host", mapper.setProperties());
  mapper.addRule("Engine/Host", mapper.addChild("addChild", "org.apache.tomcat.Container"));

  mapper.addRule("Engine/Host/Context", mapper.objectCreate("org.apache.tomcat.core.StandardContext", "className"));
  mapper.addRule("Engine/Host/Context", mapper.setProperties());
  mapper.addRule("Engine/Host/Context", mapper.addChild("addChild", "org.apache.tomcat.Container"));
  ;  // FIXME -- Process web.xml as well!!!

  mapper.addRule("Engine/Host/Context/Loader", mapper.objectCreate("org.apache.tomcat.core.StandardLoader", "className"));
  mapper.addRule("Engine/Host/Context/Loader", mapper.setProperties());
  mapper.addRule("Engine/Host/Context/Loader", mapper.addChild("setLoader", "org.apache.tomcat.Loader"));

  mapper.addRule("Engine/Host/Context/Logger", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Host/Context/Logger", mapper.setProperties());
  mapper.addRule("Engine/Host/Context/Logger", mapper.addChild("setLogger", "org.apache.tomcat.Logger"));

  mapper.addRule("Engine/Host/Context/Manager", mapper.objectCreate("org.apache.tomcat.session.StandardManager", "className"));
  mapper.addRule("Engine/Host/Context/Manager", mapper.setProperties());
  mapper.addRule("Engine/Host/Context/Manager", mapper.addChild("setManager", "org.apache.tomcat.Manager"));

  mapper.addRule("Engine/Host/Context/Realm", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Host/Context/Realm", mapper.setProperties());
  mapper.addRule("Engine/Host/Context/Realm", mapper.addChild("setRealm", "org.apache.tomcat.Realm"));

  mapper.addRule("Engine/Host/Context/Resources", mapper.objectCreate("org.apache.tomcat.core.StandardResources", "className"));
  mapper.addRule("Engine/Host/Context/Resources", mapper.setProperties());
  mapper.addRule("Engine/Host/Context/Resources", mapper.addChild("setResources", "org.apache.tomcat.Resources"));

  mapper.addRule("Engine/Host/Context/Valve", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Host/Context/Valve", mapper.setProperties());
  mapper.addRule("Engine/Host/Context/Valve", mapper.addChild("addValve", "org.apache.tomcat.Valve"));

  mapper.addRule("Engine/Host/Loader", mapper.objectCreate("org.apache.tomcat.core.StandardLoader", "className"));
  mapper.addRule("Engine/Host/Loader", mapper.setProperties());
  mapper.addRule("Engine/Host/Loader", mapper.addChild("setLoader", "org.apache.tomcat.Loader"));

  mapper.addRule("Engine/Host/Logger", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Host/Logger", mapper.setProperties());
  mapper.addRule("Engine/Host/Logger", mapper.addChild("setLogger", "org.apache.tomcat.Logger"));

  mapper.addRule("Engine/Host/Manager", mapper.objectCreate("org.apache.tomcat.session.StandardManager", "className"));
  mapper.addRule("Engine/Host/Manager", mapper.setProperties());
  mapper.addRule("Engine/Host/Manager", mapper.addChild("setManager", "org.apache.tomcat.Manager"));

  mapper.addRule("Engine/Host/Realm", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Host/Realm", mapper.setProperties());
  mapper.addRule("Engine/Host/Realm", mapper.addChild("setRealm", "org.apache.tomcat.Realm"));

  mapper.addRule("Engine/Host/Resources", mapper.objectCreate("org.apache.tomcat.core.StandardResources", "className"));
  mapper.addRule("Engine/Host/Resources", mapper.setProperties());
  mapper.addRule("Engine/Host/Resources", mapper.addChild("setResources", "org.apache.tomcat.Resources"));

  mapper.addRule("Engine/Host/Valve", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Host/Valve", mapper.setProperties());
  mapper.addRule("Engine/Host/Valve", mapper.addChild("addValve", "org.apache.tomcat.Valve"));

  mapper.addRule("Engine/Loader", mapper.objectCreate("org.apache.tomcat.core.StandardLoader", "className"));
  mapper.addRule("Engine/Loader", mapper.setProperties());
  mapper.addRule("Engine/Loader", mapper.addChild("setLoader", "org.apache.tomcat.Loader"));

  mapper.addRule("Engine/Logger", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Logger", mapper.setProperties());
  mapper.addRule("Engine/Logger", mapper.addChild("setLogger", "org.apache.tomcat.Logger"));

  mapper.addRule("Engine/Manager", mapper.objectCreate("org.apache.tomcat.session.StandardManager", "className"));
  mapper.addRule("Engine/Manager", mapper.setProperties());
  mapper.addRule("Engine/Manager", mapper.addChild("setManager", "org.apache.tomcat.Manager"));

  mapper.addRule("Engine/Realm", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Realm", mapper.setProperties());
  mapper.addRule("Engine/Realm", mapper.addChild("setRealm", "org.apache.tomcat.Realm"));

  mapper.addRule("Engine/Resources", mapper.objectCreate("org.apache.tomcat.core.StandardResources", "className"));
  mapper.addRule("Engine/Resources", mapper.setProperties());
  mapper.addRule("Engine/Resources", mapper.addChild("setResources", "org.apache.tomcat.Resources"));

  mapper.addRule("Engine/Valve", mapper.objectCreate(null, "className"));
  mapper.addRule("Engine/Valve", mapper.setProperties());
  mapper.addRule("Engine/Valve", mapper.addChild("addValve", "org.apache.tomcat.Valve"));

  return (mapper);

  // FIXME - When do we call start() on all of these objects?

View Full Code Here


     * Execute the processing that has been configured from the command line.
     */
    private void execute() throws Exception {

  // Configure the XmlMapper we will be using
  XmlMapper mapper = createMapper();

  // Process the configuration file
  File file = new File(configFile);
  mapper.readXml(file, null);

  // Start or stop
  // FIXME

    }
View Full Code Here

  throws TomcatException
    {
        if( configFile==null )
      configFile=(String)cm.getNote("configFile");

  XmlMapper xh=new XmlMapper();
  xh.setDebug( debug );

  // use the same tags for context-local modules
  addTagRules(cm, xh);
  setContextRules( xh );
        setPropertiesRules( cm, xh );
View Full Code Here

    public void start(SaxContext ctx ) throws Exception {
        AttributeList attributes = ctx.getCurrentAttributes();
        String name=attributes.getValue("name");
        String value=attributes.getValue("value");
        if( name==null || value==null ) return;
        XmlMapper xm=ctx.getMapper();
       
        Context context=(Context)ctx.currentObject();
        // replace ${foo} in value
        value=xm.replaceProperties( value );
        if( context.getDebug() > 0 )
      context.log("Setting " + name + "=" + value);
        context.setProperty( name, value );
    }
      });
View Full Code Here

      });

        xh.addRule( "Context", new XmlAction() {
                public void start( SaxContext xctx) throws Exception {
                    Context tcCtx=(Context)xctx.currentObject();
                    XmlMapper xm=xctx.getMapper();
                    ContextPropertySource propS = (ContextPropertySource)xm.getPropertySource();
                    if( propS != null )
                        propS.setContext(tcCtx);
                }
            });

  xh.addRule( "Context", new XmlAction() {
    public void end( SaxContext xctx) throws Exception {
        Context tcCtx=(Context)xctx.currentObject();
                    XmlMapper xm=xctx.getMapper();
                    ContextPropertySource propS = (ContextPropertySource)xm.getPropertySource();
                    if( propS != null )
                        propS.setContext(null);
        String host=(String)xctx.getVariable("current_host");
        String address=(String)xctx.getVariable("current_address");
        Vector aliases=(Vector)xctx.getVariable( "host_aliases" );
View Full Code Here

  throws TomcatException
    {
  //  checkHooks(cm, ctx, module);
  if( this != module ) return;
  setupHookFinder();
  XmlMapper xh=new XmlMapper();
  xh.setDebug( debug );
  xh.addRule( "ContextManager", xh.setProperties() );
  setPropertiesRules( cm, xh );
  setTagRules( xh );
  addDefaultTags(cm, xh);
  //addTagRules( cm, xh );
  setBackward( xh );
View Full Code Here

                public void start(SaxContext ctx ) throws Exception {
                    AttributeList attributes = ctx.getCurrentAttributes();
                    String name=attributes.getValue("name");
                    String value=attributes.getValue("value");
                    if( name==null || value==null ) return;
                    XmlMapper xm=ctx.getMapper();

                    ContextManager cm1=(ContextManager)ctx.currentObject();
                    // replace ${foo} in value
                    value=xm.replaceProperties( value );
                    if( cm1.getDebug() > 0 )
                        cm1.log("Setting " + name + "=" + value);
                    cm1.setProperty( name, value );
                }
            });

        // for backward compatibility, keep old version
  xh.addRule( "ContextManager/property", new XmlAction() {
    public void start(SaxContext ctx ) throws Exception {
        AttributeList attributes = ctx.getCurrentAttributes();
        String name=attributes.getValue("name");
        String value=attributes.getValue("value");
        if( name==null || value==null ) return;
        XmlMapper xm=ctx.getMapper();
       
        ContextManager cm1=(ContextManager)ctx.currentObject();
        // replace ${foo} in value
        value=xm.replaceProperties( value );
        if( cm1.getDebug() > 0 )
      cm1.log("Setting " + name + "=" + value);
        cm1.setProperty( name, value );
    }
      });
View Full Code Here

            if( ! f.exists() ) {
                log( "File not found  " + f );
                return;
            }
            XmlMapper xh=new XmlMapper();
            if( getDebug() > 5 ) xh.setDebug( 2 );

            // call addUser using attributes as parameters
            xh.addRule("tomcat-users/user",
                       new XmlAction() {
                               public void start(SaxContext sctx) throws Exception {
                                   int top=sctx.getTagCount()-1;
                                   MemoryRealm mr=(MemoryRealm)sctx.getRoot();
                                   AttributeList attributes = sctx.getAttributeList( top );
                                   String user=attributes.getValue("name");
                                   String pass=attributes.getValue("password");
                                   String group=attributes.getValue("roles");

                                   mr.addUser( user, pass, group );
                               }
                           }
                       );

            xh.readXml( f, this );
        }
View Full Code Here

             BaseInterceptor module)
  throws TomcatException
    {
  if( this != module ) return;

  XmlMapper xh=new XmlMapper();
  xh.setDebug( debug );

  addProfileRules( xh );
  addTagRules( cm, ctx, xh );
 
  if (configFile == null)
      configFile=DEFAULT_CONFIG;
 
        File f=new File(configFile);
        if ( !f.isAbsolute())
      f=new File( cm.getHome(), File.separator + configFile);

  if( f.exists() ){
      try {
    xh.readXml(f, this );
      } catch( Exception ex ) {
    ex.printStackTrace();
    throw new TomcatException(ex);
      }
        }
View Full Code Here

    public void loadInterceptors( Context ctx, File modulesF, Vector modulesV )
  throws TomcatException
    {

  XmlMapper xh=new XmlMapper();
  xh.setClassLoader( ctx.getClassLoader());
  //xh.setDebug( debug );

  // no backward compat rules. The file must be self-contained,
  // with <module> definition and the module itself
  setTagRules( xh );
View Full Code Here

TOP

Related Classes of org.apache.tomcat.util.xml.XmlMapper

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.