Package org.apache.tomcat.core

Examples of org.apache.tomcat.core.Context


      cm=(ContextManager)pageContext.getAttribute("cm");
      if( cm==null )
    throw new JspException( "Can't find context manager" );

      Context ctx=null;
      if( ctxPath==null && ctxPathParam!=null ) {
    ctxPath=req.getParameter( ctxPathParam );
      }

      if( docBase==null &&  docBaseParam!=null) {
    docBase=req.getParameter( docBaseParam );
      }
     
      if( ctxPath != null ) {
    if( debug>0 ) log("Finding " + ctxPath );
    Enumeration en=cm.getContexts();
    while( en.hasMoreElements() ) {
        ctx=(Context)en.nextElement();
        // XXX virtual host
        if( ctxPath.equals( ctx.getPath())) {
      pageContext.setAttribute("ctx", ctx);
      break;
        }
    }
      }
View Full Code Here


  if( ! docBase.startsWith("/") ) {
      docBase=cm.getHome() + "/" + docBase;
  }
  if( debug > 0 )
      log("Adding " + path + " " + docBase);
  Context context = new Context();
  context.setContextManager(cm);
  context.setPath(path);
  context.setDocBase(docBase);

  cm.addContext(context);
  context.init();
    }
View Full Code Here

      init(req);
      if( cm==null ) {
    return SKIP_BODY;
      }
      pageContext.setAttribute("cm", cm);
      Context ctx=null;
      if( ctxHost == null && ctxHostParam != null) {
    ctxHost=req.getParameter( ctxHostParam );
    if( "".equals(ctxHost) )
        ctxHost=null;
      }
      if( ctxPath==null && ctxPathParam!=null ) {
    ctxPath=req.getParameter( ctxPathParam );
      }
      if( docBase==null &&  docBaseParam!=null) {
    docBase=req.getParameter( docBaseParam );
      }

      boolean found = false;
      if( ctxPath != null ) {
    System.out.println("Finding host: "+ ctxHost + ",path=" + ctxPath );
    if( ! ctxPath.startsWith("/") )
        ctxPath = "/" + ctxPath;
    if( ctxPath.equals("/") )
        ctxPath="";
    Enumeration en=cm.getContexts();
    while( en.hasMoreElements() ) {
        ctx=(Context)en.nextElement();
        // XXX virtual host
        if( ctxPath.equals( ctx.getPath())) {
      if( (ctxHost == null && ctx.getHost() == null ) ||
          (ctxHost != null && ctxHost.equals(ctx.getHost()))){
          found=true;
          pageContext.setAttribute("ctx", ctx);
          System.out.println("Found " + ctx );
          break;
      }
View Full Code Here

      for(int i=0; i < eI.length ; i++)
    if(ctx == eI[i].getContext()) sI.addElement(eI[i]);
       
      Enumeration e;
  
      Context ctx1=cm.createContext();
      ctx1.setContextManager( cm );
      ctx1.setPath(ctx.getPath());
      ctx1.setDocBase(ctx.getDocBase());
      ctx1.setReloadable( ctx.getReloadable());
      ctx1.setDebug( ctx.getDebug());
      ctx1.setHost( ctx.getHost());
      ctx1.setTrusted( ctx.isTrusted());
      e=ctx.getHostAliases();
      while( e.hasMoreElements())
    ctx1.addHostAlias( (String)e.nextElement());
     
      BaseInterceptor ri[] =
    cm.getContainer().getInterceptors(Container.H_copyContext);
      int i;
      for( i=0; i < ri.length; i++) {
    ri[i].copyContext(request, ctx, ctx1);
      }
      cm.removeContext( ctx );
       
      cm.addContext( ctx1 );
     
      // put back saved local interceptors
      e=sI.elements();
      while(e.hasMoreElements()){
    BaseInterceptor savedI=(BaseInterceptor)e.nextElement();
   
    ctx1.addInterceptor(savedI);
    savedI.setContext(ctx1);
    savedI.reload(request,ctx1);
      }

      ctx1.init();
  }
    }
View Full Code Here

    {
  if( ! docBase.startsWith("/") ) {
      docBase=cm.getHome() + "/" + docBase;
  }
  System.out.println("Adding " + path + " " + docBase);
  Context context = new Context();
  context.setContextManager(cm);
  context.setHost(host);
  context.setPath(path);
  context.setDocBase(docBase);

  cm.addContext(context);
  context.init();
    }
View Full Code Here

  try {
      cm=(ContextManager)pageContext.getAttribute("cm");
      if( cm==null )
    throw new JspException( "Can't find context manager" );

      Context ctx=(Context)pageContext.getAttribute("ctx");

      Container ct=(ctx==null)? cm.getContainer():ctx.getContainer();
      BaseInterceptor bi[]=ct.getInterceptors();
      BaseInterceptor found=null;
      for( int i=0; i<bi.length; i++ ) {
    String cn=bi[i].getClass().getName();
    if( cn.equals( moduleName )) {
View Full Code Here

      dateHeader.setTime( System.currentTimeMillis(), dateFormat);
  }

  // return server name (or the reported one)
  if (reportedname == null) {
      Context ctx = request.getContext();
      String server = ctx != null ? ctx.getEngineHeader() :
                ContextManager.TOMCAT_NAME + "/" + ContextManager.TOMCAT_VERSION;   
      getMimeHeaders().setValue"Server" ).setString(server);
  } else {
      if (reportedname.length() != 0)
    getMimeHeaders().setValue"Server" ).setString(reportedname);
View Full Code Here

  // Now we need to fix path info and servlet path
  if( servletPath == null ||
      ! servletPath.startsWith( prefix ))
      return 0;

  Context ctx=req.getContext();
  // Set the wrapper, and add a new mapping - next time
  // we'll not have to do that ( the simple mapper is
  // supposed to be faster )
 
  String servletName = null;
  String newPathInfo = null;
 
  if( debug>0 )
      log( "Original ServletPath=" +servletPath +
     " PathInfo=" + pathInfo);

  int secondSlash=servletPath.indexOf("/", prefixLen );
  if ( secondSlash > -1) {
      servletName = servletPath.substring(prefixLen, secondSlash );
      newPathInfo = servletPath.substring( secondSlash );
  } else {
      servletName = servletPath.substring( prefixLen );
  }
 
  String newServletPath = prefix + servletName;

  if( debug > 0)
      log( "After pathfix SN=" + servletName +
     " SP=" + newServletPath +
     " PI=" + newPathInfo);
 
   req.servletPath().setString(newServletPath);
  req.pathInfo().setString(newPathInfo);
 
  Handler wrapper = ctx.getServletByName(servletName);
  if (wrapper != null) {
      req.setHandler( wrapper );
      return 0;
  }
     
  // Dynamic add for the wrapper
 
  // even if the server doesn't supports dynamic mappings,
  // we'll avoid the interceptor for include() and
  // it's a much cleaner way to construct the servlet and
  // make sure all interceptors are up to date.
  try {
      ctx.addServletMapping( newServletPath + "/*" ,
           servletName );
      // The facade should create the servlet name
     
      Handler sw=ctx.getServletByName( servletName );
      //       sw.setContext(ctx);
      //       sw.setServletName(servletName);
      //      ctx.addServlet( sw );
      //      sw.setServletClass( servletName );
      //sw.setOrigin( Handler.ORIGIN_INVOKER );
View Full Code Here

        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" );
       
        if( host!=null && ! "DEFAULT".equals( host )) {
          tcCtx.setHost( host );
          tcCtx.setHostAddress( address );
          if( aliases!=null ) {
        Enumeration alE=aliases.elements();
        while( alE.hasMoreElements() ) {
            String alias=(String)alE.nextElement();
            tcCtx.addHostAlias( alias );
            if( tcCtx.getDebug() > 0 )
          tcCtx.log( "Alias " + host  + " " + alias );
        }
          }
        }
    }
      });
View Full Code Here

TOP

Related Classes of org.apache.tomcat.core.Context

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.