cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2001-12-22 Thread keith

keith   01/12/22 10:58:30

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  Cut-paste error.
  
  Revision  ChangesPath
  1.150 +0 -1  jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.149
  retrieving revision 1.150
  diff -u -r1.149 -r1.150
  --- Context.java  2001/08/21 04:55:39 1.149
  +++ Context.java  2001/12/22 18:58:30 1.150
  @@ -980,7 +980,6 @@
* Add a servlet. Servlets are mapped by name.
* This method is used to maintain the list of declared
* servlets, that can be used for mappings.
  - * @deprecated. Use addHandler() 
*/
   public void addHandler(Handler wrapper)
throws TomcatException
  
  
  

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java ContextManager.java

2001-08-20 Thread costin

costin  01/08/20 21:55:39

  Modified:src/share/org/apache/tomcat/core Context.java
ContextManager.java
  Log:
  2 small changes. In Context, avoid the creation of a log that will be thrown away
  a bit later ( which is usefull only to log messages before the context is 
initialized)
  
  In context manager make sure we set the tomcat.home property, which is required
  in reading the policy file. The shell script is setting it, but if EmbededTomcat
  is used we have no way to insure that.
  
  Revision  ChangesPath
  1.149 +2 -1  jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.148
  retrieving revision 1.149
  diff -u -r1.148 -r1.149
  --- Context.java  2001/08/17 03:59:48 1.148
  +++ Context.java  2001/08/21 04:55:39 1.149
  @@ -231,8 +231,9 @@
   // are servlets allowed to access internal objects? 
   private boolean trusted=false;
   
  +private static Log defaultContextLog=Log.getLog("org/apache/tomcat/core", 
"Context");
   // log channels for context and servlets 
  -private Log loghelper = Log.getLog("org/apache/tomcat/core", this);
  +private Log loghelper = defaultContextLog;
   private Log loghelperServlet;
   
   // servlet API implemented by this Context
  
  
  
  1.189 +1 -0  
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.188
  retrieving revision 1.189
  diff -u -r1.188 -r1.189
  --- ContextManager.java   2001/08/17 03:59:48 1.188
  +++ ContextManager.java   2001/08/21 04:55:39 1.189
  @@ -250,6 +250,7 @@
*/
   public void setHome(String home) {
this.home=home;
  + System.getProperties().put(TOMCAT_HOME, home );
   }
   
   public String getHome() {
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java ContextManager.java

2001-08-16 Thread costin

costin  01/08/16 20:59:48

  Modified:src/share/org/apache/tomcat/core Context.java
ContextManager.java
  Log:
  Small changes ( but the diff is big ). I tried to put in order all the
  package/protected/final stuff.
  
  Having final methods and classes hava a tiny impact on performance but may
  affect our ability to do "hot fixes" via add-on modules, and to extend
  tomcat or tune it for special configurations.
  
  Let me know if this creates a problem for anyone - I believe removing the final
  doesn't affect in any way the code stability but provides a lot of flexibility.
  
  I also added few factory methods in CM, to completely allow specialized
  extensions to control the whole thing.
  
  Revision  ChangesPath
  1.148 +111 -98   jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.147
  retrieving revision 1.148
  diff -u -r1.147 -r1.148
  --- Context.java  2001/08/16 04:50:30 1.147
  +++ Context.java  2001/08/17 03:59:48 1.148
  @@ -97,7 +97,7 @@
* @author [EMAIL PROTECTED]
* @author Gal Shachor [EMAIL PROTECTED]
*/
  -public final class Context {
  +public class Context {
   //  Constants 
   
   // Proprietary attribute names for contexts - defined
  @@ -147,6 +147,8 @@
   public static final int STATE_READY=3;
   
   //  internal properties
  +private String name;
  +
   // context "id"
   private String path = "";
   
  @@ -278,7 +280,7 @@
   /** Add a new container. Container define special properties for
a set of urls.
   */
  -public final void addContainer( Container ct )
  +public void addContainer( Container ct )
throws TomcatException
   {
// Notify interceptors that a new container is added
  @@ -300,7 +302,7 @@
* mapping.
* @deprecated Use addContainer
*/
  -public final  void addServletMapping(String path, String servletName)
  +public void addServletMapping(String path, String servletName)
throws TomcatException
   {
if( mappings.get( path )!= null) {
  @@ -314,7 +316,7 @@
// set it 
   Handler sw = getServletByName(servletName);

  - Container map=new Container();
  + Container map=contextM.createContainer();
map.setContext( this );
map.setHandlerName( servletName );
map.setHandler( sw );
  @@ -352,12 +354,12 @@
the request will have to pass the security constraints.
@deprecated Use addContainer
   */
  -public final  void addSecurityConstraint( String path[], String methods[],
  +public void addSecurityConstraint( String path[], String methods[],
   String roles[], String transport)
throws TomcatException
   {
for( int i=0; i< path.length; i++ ) {
  - Container ct=new Container();
  + Container ct=contextM.createContainer();
ct.setContext( this );
ct.setTransport( transport );
ct.setRoles( roles );
  @@ -380,7 +382,7 @@
*   user application. Only trusted apps can get 
*   access to the implementation object.
*/
  -public final  boolean allowAttribute( String name ) {
  +public boolean allowAttribute( String name ) {
// check if we can access this attribute.
if( isTrusted() ) return true;
log( "Attempt to access internal attribute in untrusted app",
  @@ -399,11 +401,11 @@
type of the facade, as a Context can be associated with a 2.2 ...
ServletContext.
*/
  -public final  Object getFacade() {
  +public Object getFacade() {
return contextFacade;
   }
   
  -public final  void setFacade(Object obj) {
  +public void setFacade(Object obj) {
   if(contextFacade!=null ) {
log( "Changing facade " + contextFacade + " " +obj);
}
  @@ -424,21 +426,30 @@
depend on the ContextManager, and will be adjusted
by interceptors ( DefaultCMSetter )
   */
  -public final  void setContextManager(ContextManager cm) {
  +public void setContextManager(ContextManager cm) {
if( contextM != null ) return;
contextM=cm;
  + if( defaultContainer==null ) {
  + defaultContainer=contextM.createContainer();
  + defaultContainer.setContext( this );
  + defaultContainer.setPath( null ); // default container
  + }
try {
attributeInfo=cm.getNoteId(ContextManager.REQUEST_NOTE,
   "req.attribute");
} catch( TomcatException ex ) {
ex.printStackTrace();
}
  -
   }
   
  

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2001-08-15 Thread larryi

larryi  01/08/15 21:50:30

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  Still figurine out virtual hosts, but I think virtual host ip address will be
  needed for writing config files should the host name not be an ip address.
  
  Revision  ChangesPath
  1.147 +16 -0 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.146
  retrieving revision 1.147
  diff -u -r1.146 -r1.147
  --- Context.java  2001/08/03 02:44:24 1.146
  +++ Context.java  2001/08/16 04:50:30 1.147
  @@ -221,6 +221,8 @@
   
   // Virtual host name ( null if default )
   private String vhost=null;
  +// Virtual host ip address (if vhost isn't an address)
  +private String vhostip=null;
   // vhost aliases 
   private Vector vhostAliases=new Vector();
   
  @@ -605,6 +607,20 @@
*/
   public final  String getHost() {
return vhost;
  +}
  +
  +/**
  + * Set the virtual host ip address.
  + */
  +public final void setHostAddress( String ip ) {
  +vhostip=ip;
  +}
  +
  +/**
  + * Return the virtual host ip address.
  + */
  +public final String getHostAddress() {
  +return vhostip;
   }
   
   /** DocBase points to the web application files.
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2001-08-02 Thread costin

costin  01/08/02 19:44:24

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  Added the missing callback calls on setState ( they are defined in BaseInterceptor,
  but I forgot to actually call them )
  
  Added "addContainer" helper, as a general form for the addServletMapping,
  addSecurityConstraint.
  
  Added the better named addHandler() ( addServlet is very confused, not all
  handlers are servlets - some are internal handlers ). Also, make sure removeHandler
  calls all the hooks.
  
  Revision  ChangesPath
  1.146 +58 -5 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.145
  retrieving revision 1.146
  diff -u -r1.145 -r1.146
  --- Context.java  2001/07/13 06:04:28 1.145
  +++ Context.java  2001/08/03 02:44:24 1.146
  @@ -273,6 +273,19 @@
   // ( and we try to keep the object "passive" - it is already
   // full of properties, no need to make it to complicated.
   
  +/** Add a new container. Container define special properties for
  + a set of urls.
  +*/
  +public final void addContainer( Container ct )
  + throws TomcatException
  +{
  + // Notify interceptors that a new container is added
  + BaseInterceptor cI[]=defaultContainer.getInterceptors();
  + for( int i=0; i< cI.length; i++ ) {
  + cI[i].addContainer( ct );
  + }
  +}
  +
   
   /**
* Maps a named servlet to a particular path or extension.
  @@ -283,6 +296,7 @@
*
* If the mapping already exists it will be replaced by the new
* mapping.
  + * @deprecated Use addContainer
*/
   public final  void addServletMapping(String path, String servletName)
throws TomcatException
  @@ -334,7 +348,7 @@
This is equivalent with adding a Container with the path,
method and transport. If the container will be matched,
the request will have to pass the security constraints.
  - 
  + @deprecated Use addContainer
   */
   public final  void addSecurityConstraint( String path[], String methods[],
   String roles[], String transport)
  @@ -388,8 +402,9 @@
   }
   
   public final  void setFacade(Object obj) {
  -if(contextFacade!=null )
  +if(contextFacade!=null ) {
log( "Changing facade " + contextFacade + " " +obj);
  + }
contextFacade=obj;
   }
   
  @@ -436,6 +451,14 @@
   void setState( int state )
throws TomcatException
   {
  + // call state callback
  + BaseInterceptor csI[]=getContainer().getInterceptors();
  + for( int i=0; i< csI.length; i++ ) {
  + csI[i].contextState( this, state ); 
  + }
  +
  + // transition from NEW to ADDED. The system is stable, we
  + // can init our own local modules
if(this.state==STATE_NEW && state==STATE_ADDED ) {
// we are just beeing added
BaseInterceptor cI[]=getContainer().getInterceptors();
  @@ -915,13 +938,27 @@
* Add a servlet. Servlets are mapped by name.
* This method is used to maintain the list of declared
* servlets, that can be used for mappings.
  + * @deprecated. Use addHandler() 
*/
   public final  void addServlet(Handler wrapper)
throws TomcatException
   {
  + addHandler( wrapper );
  +}
  +
  +/**
  + * Add a servlet. Servlets are mapped by name.
  + * This method is used to maintain the list of declared
  + * servlets, that can be used for mappings.
  + * @deprecated. Use addHandler() 
  + */
  +public final  void addHandler(Handler wrapper)
  + throws TomcatException
  +{
//  wrapper.setContext( this );
wrapper.setState( Handler.STATE_ADDED );
String name=wrapper.getName();
  + wrapper.setContextManager( contextM );
   
   // check for duplicates
   if (getServletByName(name) != null) {
  @@ -930,18 +967,34 @@
   }
if( debug>5 ) log( "Adding servlet=" + name + "-> "
   + wrapper);
  + BaseInterceptor cI[]=defaultContainer.getInterceptors();
  + for( int i=0; i< cI.length; i++ ) {
  + cI[i].addHandler( wrapper );
  + }
  + 
servlets.put(name, wrapper);
   }
   
  +public void removeHandler( Handler handler )
  + throws TomcatException
  +{
  + if( handler==null ) return;
  + BaseInterceptor cI[]=defaultContainer.getInterceptors();
  + for( int i=0; i< cI.length; i++ ) {
  + cI[i].removeHandler( handler );
  + }
  +
  + servlets.remove( handler.getName());
  + handler.setState( Handler.STATE_NEW );
  +}
  +
   /** Remove the servlet wit

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java ContextManager.java

2001-07-12 Thread costin

costin  01/07/12 23:04:35

  Modified:src/share/org/apache/tomcat/core Context.java
ContextManager.java
  Log:
  Added back the context's name. It was removed during the initial refactoring,
  as many apps used it in a wrong way ( it was not unique, but based only
  on the path - and that created problems with virtual hosts ).
  
  Now all internal apps (admin, etc ) are cleaned and know how to deal with
  virtual hosts, and it is usefull to add back the method ( with a correct
  behavior ).
  
  Thanks  Leong Mun Wai for reminding me that.
  
  Revision  ChangesPath
  1.145 +18 -2 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.144
  retrieving revision 1.145
  diff -u -r1.144 -r1.145
  --- Context.java  2001/06/16 22:05:04 1.144
  +++ Context.java  2001/07/13 06:04:28 1.145
  @@ -532,7 +532,22 @@
   
   
   //  Basic properties 
  +String name;
  +
  +/** Return a name ( id ) for this context. Currently it's composed
  + from the virtual host and path, or set explicitely by the app.
  +*/
  +public String getName() {
  + if(name!=null ) return name;
  + name=(vhost==null ? "DEFAULT:" : vhost + ":" )  +
  + ("".equals(path)  ? "/ROOT" :  path);
  + return name;
  +}
   
  +public void setName( String s ) {
  + name=s;
  +}
  +
   /** Base URL for this context
*/
   public final  String getPath() {
  @@ -549,6 +564,7 @@
this.path = path;
loghelper=Log.getLog("org/apache/tomcat/core",
 "Ctx("+ getId() +") ");
  + name=null;
   }
   
   /**
  @@ -557,6 +573,7 @@
*/
   public final  void setHost( String h ) {
vhost=h;
  + name=null;
   }
   
   /**
  @@ -992,8 +1009,7 @@
   }
   
   public final  String toString() {
  - return (vhost==null ? "DEFAULT:" : vhost + ":" )  +
  -("".equals(path)  ? "/ROOT" :  path);
  + return getName();
   }
   
   // --- Logging ---
  
  
  
  1.183 +11 -0 
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.182
  retrieving revision 1.183
  diff -u -r1.182 -r1.183
  --- ContextManager.java   2001/06/28 07:43:05 1.182
  +++ ContextManager.java   2001/07/13 06:04:30 1.183
  @@ -190,6 +190,7 @@
   // All contexts managed by the server ( can belong to different
   // virtual hosts )
   private Vector contextsV=new Vector();
  +private Hashtable contexts=new Hashtable();
   
   private int debug=0;
   
  @@ -673,6 +674,14 @@
return contextsV.elements();
   }
   
  +public final Enumeration getContextNames() {
  + return contexts.keys();
  +}
  +
  +public Context getContext(String name ) {
  + return (Context)contexts.get( name );
  +}
  +
   /**
* Adds a new Context to the set managed by this ContextManager.
* It'll also init the server if it hasn't been already.
  @@ -689,6 +698,7 @@
ctx.setState( Context.STATE_NEW );
   
contextsV.addElement( ctx );
  + contexts.put( ctx.getName(), ctx );
   
if( getState() == STATE_NEW )
return;
  @@ -718,6 +728,7 @@
log( "Removing context " + context.toString());
   
contextsV.removeElement(context);
  + contexts.remove( context.getName());
   
if( getState() == STATE_NEW )
return; // we are not even initialized
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2001-06-16 Thread costin

costin  01/06/16 13:17:54

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  Fix for JspServlet support.
  
  Tomcat must return a classpath that can be used to compile JSPs ( if
  JspInterceptor is not used ).
  
  The problem is that we want to allow the loader to be customized - the loader
  interceptor has the class path ( context.getClassPath() returns the local
  classpath, not including parent loader's path ).
  
  The soltuion is to use the provided hooks to let modules provide the
  required information. This will also alow more customization in the attribute
  name, and in enabling/disabling the feature ( if JspInterceptor is used there
  is no need to expose this non-standard information ).
  
  This also cleans up "getSpecialAttribute" ( we might want to move the other
  special attribute - facade - to a special module ).
  
  Revision  ChangesPath
  1.143 +33 -53jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.142
  retrieving revision 1.143
  diff -u -r1.142 -r1.143
  --- Context.java  2001/06/09 03:20:51 1.142
  +++ Context.java  2001/06/16 20:17:54 1.143
  @@ -114,12 +114,9 @@
   */
   public static final String ATTRIB_PROTECTION_DOMAIN=
"org.apache.tomcat.protection_domain";
  -
  -/** Workdir - a place where the servlets are allowed to write
  - */
  -public static final String ATTRIB_WORKDIR="org.apache.tomcat.workdir";
  -public static final String ATTRIB_WORKDIR1 = "javax.servlet.context.tempdir";
  -public static final String ATTRIB_WORKDIR2 = "sun.servlet.workdir";
  +
  +// public static final String ATTRIB_WORKDIR1 = "javax.servlet.context.tempdir";
  +// public static final String ATTRIB_WORKDIR2 = "sun.servlet.workdir";
   
   
   /** This attribute will return the real context (
  @@ -261,6 +258,7 @@
   private Hashtable envEntryTypes=new Hashtable();
   private Hashtable envEntryValues=new Hashtable();
   
  +private int attributeInfo;
   //  Constructor 
   
   public Context() {
  @@ -366,49 +364,6 @@
}
   }
   
  -/** getAttribute( "org.apache.tomcat.*" ) may return something
  - special
  -*/
  -private Object getSpecialAttribute( String name ) {
  - // deprecated - invalid and wrong prefix
  - if( name.equals( ATTRIB_WORKDIR1 ) ) 
  - return getWorkDir();
  - if( name.equals( ATTRIB_WORKDIR2 ) ) 
  - return getWorkDir();
  -
  - // this saves 5 compare for non-special attributes
  - if (name.startsWith( ATTRIB_PREFIX )) {
  - // XXX XXX XXX XXX Security - servlets may get too much access !!!
  - // right now we don't check because we need JspServlet to
  - // be able to access classloader and classpath
  - if( name.equals( ATTRIB_WORKDIR ) ) 
  - return getWorkDir();
  - 
  - if (name.equals("org.apache.tomcat.jsp_classpath")) {
  - String separator = System.getProperty("path.separator", ":");
  - StringBuffer cpath=new StringBuffer();
  - URL classPaths[]=getClassPath();
  - for(int i=0; i< classPaths.length ; i++ ) {
  - URL cp = classPaths[i];
  - if (cpath.length()>0) cpath.append( separator );
  - cpath.append(cp.getFile());
  - }
  - if( debug>9 ) log("Getting classpath " + cpath);
  - return cpath.toString();
  - }
  - if(name.equals("org.apache.tomcat.classloader")) {
  - return this.getClassLoader();
  - }
  - if(name.equals(ATTRIB_REAL_CONTEXT)) {
  - if( ! allowAttribute(name) ) {
  - return null;
  - }
  - return this;
  - }
  - }
  - return null; 
  -}
  -
   /** Check if "special" attributes can be used by
*   user application. Only trusted apps can get 
*   access to the implementation object.
  @@ -459,6 +414,13 @@
   public final  void setContextManager(ContextManager cm) {
if( contextM != null ) return;
contextM=cm;
  + try {
  + attributeInfo=cm.getNoteId(ContextManager.REQUEST_NOTE,
  +"req.attribute");
  + } catch( TomcatException ex ) {
  + ex.printStackTrace();
  + }
  +
   }
   
   /** Default container for this context.
  @@ -730,18 +692,36 @@
*  "Special" attributes ( defined org.apache.tomcat )
*  are computed
* 
  - *  XXX Use callbacks !!
*/
   public final  Object getAttribute(String name) {
  - Object o=getSpecialAttribute( name );
  -

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java ContextManager.java

2001-06-08 Thread costin

costin  01/06/08 20:20:52

  Modified:src/share/org/apache/tomcat/core Context.java
ContextManager.java
  Log:
  Extra checks for errors on adding the modules.
  
  Added fields and accessors for the other 3 class loaders used in tomcat,
  to allow modules to start using it.
  
  Revision  ChangesPath
  1.142 +16 -10jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.141
  retrieving revision 1.142
  diff -u -r1.141 -r1.142
  --- Context.java  2001/03/02 04:49:06 1.141
  +++ Context.java  2001/06/09 03:20:51 1.142
  @@ -484,17 +484,23 @@
for( int i=0; i< cI.length; i++ ) {
if( cI[i].getContext() != this )
continue; // not ours, don't have to initialize it.
  - cI[i].addInterceptor( contextM, this , cI[i] ); 
  - BaseInterceptor existingI[]=defaultContainer.getInterceptors();
  - for( int j=0; j


cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2001-03-17 Thread arieh

arieh   01/03/16 15:43:56

  Modified:src/share/org/apache/tomcat/core Tag: tomcat_32 Context.java
  Log:
  Add support for 'docbase' localization lookup to the getRealPath() method.
  Preserve backwards compatibility on the getRealPath(path, loc, loc) call.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.100.2.5 +48 -3 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.100.2.4
  retrieving revision 1.100.2.5
  diff -u -r1.100.2.4 -r1.100.2.5
  --- Context.java  2000/11/18 00:09:42 1.100.2.4
  +++ Context.java  2001/03/16 23:43:53 1.100.2.5
  @@ -807,7 +807,8 @@
   }
   
   /**  method to return the Localized version of the file whose
  - *   name is passed as an argument.
  + *   name is passed as an argument. This corresponds to "file" type
  + *   localization resource lookup mechanism.
*
*  The method performs a resource lookup in a manner similar to the
*  one specified by java.util.ResourceBundle.
  @@ -854,11 +855,55 @@
*/
   public String getRealPath (String path, Locale reqLocale, Locale fbLocale)
   {
  + return getRealPath (path, reqLocale, fbLocale, "file");
  +}
  +
  +/**  method to return the Localized version of the file whose
  + *   name is passed as an argument. The localization is done based
  + *   on localization subdirectories under the docBase.
  + *
  + *  The method performs a resource lookup in a manner similar to the
  + *  one used for JavaHelp resources.
  + *
  + *  Search for localized versions of the file are looked for:
  + *
  + *+ "/" + language1 + "_" + country1 + "_" + variant1 + file
  + *+ "/" + language1 + "_" + country1 + file
  + *+ "/" + language1 + file
  + *+ "/" + language2 + "_" + country2 + "_" + variant1 + file
  + *+ "/" + language2 + "_" + country2 + file
  + *+ "/" + language2 + file
  + *+ file
  + *
  + *  Where language1, country1, variant1 are associated with the Locale
  + *  passed as an argument and language2, country2, variant are associated
  + *  with the fallback Locale passed as argument.
  + *
  + *
  + *  @param path the pathname for the resource whose localized version
  + *  we are seeking
  + *  @param loc the Locale we are interested in.
  + *  @param fbLoc the fallback Locale to use if unsuccessful
  + *  @param locType the type of localization required "file", "docbase"
  + *
  + *  @return a String with the path of the "best localized match" for
  + *  the file whose path has been passed as argument.
  + */
  +public String getRealPath (String path, Locale reqLocale, Locale fbLocale,
  +String locType)
  +{
   String base = getAbsolutePath();
   if (path == null) path = "";
  +
  +String realPath = null;
  +
  + if ("file".equals (locType))
  + realPath = FileUtil.getLocalizedFile (base, path,
  +   reqLocale, fbLocale);
  + else if ("docbase".equals (locType))
  + realPath = FileUtil.getDocBaseLocalizedFile (base, path,
  +   reqLocale, fbLocale);
   
  -String realPath = FileUtil.getLocalizedFile (base, path,
  -  reqLocale, fbLocale);
if( debug>5) {
log("Get real path " + path + " " + realPath + " " + base
 + reqLocale.toString() + " " + fbLocale.toString() );
  
  
  



cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java Request.java

2001-02-27 Thread costin

costin  01/02/27 08:54:05

  Modified:src/share/org/apache/tomcat/core Context.java Request.java
  Log:
  Another change related with the profiles/lib reorg - remove the
  dependency between core and DependManager.
  
  As with the previous changes, DependManager is just an implementation
  choice made by the Reload module ( and few other modules adding dependencies).
  There are other ways to implement reloading ( modified class loaders, etc ),
  and there is no reason to "force" one way in the core APIs.
  
  DependManager is specific to a module ( or few ), but not required
  for normal tomcat operation ( other choices are possible as well ).
  
  Revision  ChangesPath
  1.140 +0 -24 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.139
  retrieving revision 1.140
  diff -u -r1.139 -r1.140
  --- Context.java  2001/02/20 03:17:56 1.139
  +++ Context.java  2001/02/27 16:54:01 1.140
  @@ -60,7 +60,6 @@
   
   package org.apache.tomcat.core;
   
  -import org.apache.tomcat.util.depend.*;
   import org.apache.tomcat.util.http.MimeMap;
   import org.apache.tomcat.util.log.Log;
   
  @@ -250,8 +249,6 @@
   // true if a change was detected and this context
   // needs reload
   private boolean reload;
  -// Tool used to control reloading
  -private DependManager dependM=new DependManager();
   
   //  from web.xml 
   // Those properties are not directly used in context
  @@ -976,17 +973,6 @@
classLoader=cl;
   }
   
  -// temp. properties until reloading is separated.
  -public final  boolean shouldReload() {
  - if( !reload && dependM != null )
  - return dependM.shouldReload();
  - return reload;
  -}
  -
  -public final  void setReload( boolean b ) {
  - reload=b;
  -}
  -
   //  ClassPath 
   
   public final  void addClassPath( URL url ) {
  @@ -1011,16 +997,6 @@
return urls;
   }
   
  -//  Depend manager ( used for reloading ) ---
  -
  -public final  void setDependManager(DependManager dm ) {
  - dependM=dm;
  -}
  -
  -public final  DependManager getDependManager( ) {
  - return dependM;
  -}
  -
   /*  Utils   */
   public final  void setDebug( int level ) {
if (level!=debug)
  
  
  
  1.94  +0 -4  jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java
  
  Index: Request.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Request.java,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- Request.java  2001/02/27 16:24:22 1.93
  +++ Request.java  2001/02/27 16:54:02 1.94
  @@ -305,10 +305,6 @@
return remoteHostMB;
   }
   
  -public void setRemoteHost(String remoteHost) {
  - this.remoteHost=remoteHost;
  -}
  -
   public String getLocalHost() {
return localHost;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java ContextManager.java

2001-02-05 Thread costin

costin  01/02/05 22:41:08

  Modified:src/share/org/apache/tomcat/core Context.java
ContextManager.java
  Log:
  Estetic change in the way Contexts are displayed: use host:/path
  instead of Ctx (  )
  
  Revision  ChangesPath
  1.138 +2 -2  jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.137
  retrieving revision 1.138
  diff -u -r1.137 -r1.138
  --- Context.java  2001/02/03 07:34:41 1.137
  +++ Context.java  2001/02/06 06:41:07 1.138
  @@ -1033,8 +1033,8 @@
   }
   
   public final  String toString() {
  - return "Ctx( " +  (vhost==null ? "" :
  - vhost + ":" )  +  path +  ")";
  + return (vhost==null ? "DEFAULT:" : vhost + ":" )  +
  +("".equals(path)  ? "/ROOT" :  path);
   }
   
   // --- Logging ---
  
  
  
  1.166 +1 -2  
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.165
  retrieving revision 1.166
  diff -u -r1.165 -r1.166
  --- ContextManager.java   2001/02/03 05:43:18 1.165
  +++ ContextManager.java   2001/02/06 06:41:07 1.166
  @@ -512,7 +512,7 @@
existingI[i].addContext( this, ctx );
}
ctx.setState( Context.STATE_ADDED );
  - log("Adding context " +  ctx.toString());
  + log("Adding  " +  ctx.toString());
} catch( TomcatException ex ) {
log( "Error adding context " + ctx , ex );
continue; 
  @@ -927,7 +927,6 @@
BaseInterceptor ri[];
int status;
ri=req.getContainer().getInterceptors( Container.H_handleError );
  - 
for( int i=0; i< ri.length; i++ ) {
status=ri[i].handleError( req, res, t );
if( status!=0 ) return;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2001-02-02 Thread costin

costin  01/02/02 23:08:01

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  Few changes in Context to make sure the state and rules defined in
  ContextManager are respected. ( i.e. no add/initContext before
  all modules are initialized, etc ).
  
  Note that per-Context modules have less power than global modules,
  i.e. engineInit is called only when the Context is added, contextMap
  is never called, etc.
  
  That means that "configuration" modules and "context mappers" need to
  be "global". It would be a good idea to make all modules that can be
  context-local part of a "profile" to simplify the configuration
  ( for example a set of contexts that may share common authentication
  style, logging, etc - right now you have to set it on each module )
  Global modules are bad because it's hard to tune them for individual
  contexts.
  
  Revision  ChangesPath
  1.136 +46 -43jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.135
  retrieving revision 1.136
  diff -u -r1.135 -r1.136
  --- Context.java  2001/02/03 05:43:18 1.135
  +++ Context.java  2001/02/03 07:08:00 1.136
  @@ -478,7 +478,18 @@
Can be called only from tomcat.core.ContextManager.
( package access )
   */
  -void setState( int state ) {
  +void setState( int state )
  + throws TomcatException
  +{
  + if(this.state==STATE_NEW && state==STATE_ADDED ) {
  + BaseInterceptor cI[]=getContainer().getInterceptors();
  + for( int i=0; i< cI.length; i++ ) {
  + // set all local interceptors 
  + cI[i].setContextManager( contextM );
  + cI[i].engineInit( contextM );
  + cI[i].addContext( contextM, this );
  + }
  + }
this.state=state;
   }
   
  @@ -503,40 +514,18 @@
log( "Already initialized " );
return;
}
  +
// make sure we see all interceptors added so far
getContainer().resetInterceptorCache(Container.H_engineInit);
   
  - // initialize all local-interceptors
  - BaseInterceptor cI[]=getContainer().getInterceptors();
  - for( int i=0; i


cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java ContextManager.java

2001-01-31 Thread costin

costin  01/01/31 21:06:05

  Modified:src/share/org/apache/tomcat/core Context.java
ContextManager.java
  Log:
  The first significant change in core for this year :-)
  
  The startup rules for tomcat were almost undefined in tomcat 3.2 and before,
  and defining a clear state was one of the biggest issues for 3.3.
  Things has improved ( thanks to Larry and Nacho for all the feedback),
  but I don't think they are perfect yet
  
  This is one of the biggest things that need review and attention.
  
  This fix tightens up a bit more the startup process:
  
  - no addContext or initContext hook can be called before the server is
  fully configure ( i.e. in STATE_CONFIG ). Because the server.xml reader
  adds both modules and contexts, calling addContext is delayed until
  init()
  
  - make clear that after init(), the server is fully configured and initialized
  engineStart is mostly for connectors.
  
  - reorganized a bit the documentation - runtime configuration is a different
  issue.
  
  Please read at least the ContextManager comments on the top, and send
  any feedback.
  
  ( ContextManager has 1 very important role - call the hooks that
  compose tomcat. It also stores global config, modules and contexts -
  but that's easy )
  
  Revision  ChangesPath
  1.134 +1 -1  jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.133
  retrieving revision 1.134
  diff -u -r1.133 -r1.134
  --- Context.java  2001/01/28 19:49:19 1.133
  +++ Context.java  2001/02/01 05:06:04 1.134
  @@ -525,7 +525,7 @@

// no action if ContextManager is not initialized
if( contextM==null ||
  - contextM.getState() == ContextManager.STATE_CONFIG ) {
  + contextM.getState() == ContextManager.STATE_NEW ) {
log( "ContextManager is not yet initialized ");
return;
}
  
  
  
  1.164 +193 -116  
jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.163
  retrieving revision 1.164
  diff -u -r1.163 -r1.164
  --- ContextManager.java   2001/01/01 00:17:23 1.163
  +++ ContextManager.java   2001/02/01 05:06:04 1.164
  @@ -67,65 +67,78 @@
   
   
   /**
  -  ContextManager is the entry point and "controler" of the servlet execution.
  +  ContextManager controls requests processing and server configuration.
 It maintains a list of Contexts ( web applications )  and a list of
  -  interceptors (hooks) that are set up to handle the actual execution.
  +  global modules that deal with server configuration and request processing,
  +  and global properties ( directories, general settings, etc ).
   
  -  The execution is modeled after Apache2.0 and other web servers, with
  -  interceptors serving the same role as modules.
  -
  -  The "core" is composed of representation of "Request", "Response",
  -  "Container" ( a set of URLs with shared properties - like a Location
  -  in Apache), "Context" ( web application - the deployment unit ).
  -
  -  "ContextManager" will  store properties that are global to the servlet
  -  container - like root directory, install dir, work dir and act as the
  -  top level controler.
  +  The request processing is similar with Apache and other servers, with the
  +  addition of a "contextMap" chain that will select a tomcat-specific.

  -  The server functionality is implemented in modules ( "BaseInterceptor" ).
  -
  -  Hooks are provided for request parsing and mapping, auth, autorization,
  -  pre/post service, actual invocation and logging - similar with Apache and all
  -  other web servers.
  -
  -  Using tomcat
  +  Configuration and startup
   
  +  Starting tomcat involves a number of actions and states. In order to
  +  start tomcat:
  +  
 
  -   Create ContextManager.
  +   Create ContextManager. The server state is STATE_NEW
   
  Set properties for ContextManager ( home, debug, etc).
   
  -   Add the initial set of modules. Modules can also be added and removed
  - after the server is started. ( engineInit() and addInterceptor() hooks
  - will be called ). An interceptor can add/remove other interceptors
  - during the engineInit  hook, or change/set server properties.
  - XXX web applications should be added at a later stage.
  - 
  -   Add the initial set of web applications ( Contexts ). Applications can
  - be added and removed after the server is started. ( addContext() hook
  - will be called )
  -
  -  init(). All contexts will be ready to run ( contextInit() h

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2001-01-23 Thread larryi

larryi  01/01/23 05:02:01

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  If reaload is true, don't defer to DependManager.
  
  Revision  ChangesPath
  1.132 +1 -1  jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.131
  retrieving revision 1.132
  diff -u -r1.131 -r1.132
  --- Context.java  2000/12/29 20:31:27 1.131
  +++ Context.java  2001/01/23 13:02:01 1.132
  @@ -979,7 +979,7 @@
   
   // temp. properties until reloading is separated.
   public final  boolean shouldReload() {
  - if( dependM != null )
  + if( !reload && dependM != null )
return dependM.shouldReload();
return reload;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2000-12-26 Thread costin

costin  00/12/26 15:13:57

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  Refactoring - moved init/shutdown from ContextManager to Context ( better OO :-)
  
  Added the setProperty/getProperty - to reduce the pressure of adding
  new methods needed by various modules. XmlMapper will automatically call
  setProperty if no explicit setter is found.
  That would allow people to better develop modules, without asking for
  changes in the core ( that should  be frozen after 3.3dev is finished )
  
  Revision  ChangesPath
  1.130 +124 -6jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- Context.java  2000/12/13 19:58:01 1.129
  +++ Context.java  2000/12/26 23:13:55 1.130
  @@ -160,7 +160,8 @@
   
   // Absolute path to docBase if file-system based
   private String absPath;
  -
  +private Hashtable properties=new Hashtable();
  +
   private int state=STATE_NEW;
   
   // internal state / related objects
  @@ -310,7 +311,7 @@
map.setPath( path );
   
// Notify interceptors that a new container is added
  - BaseInterceptor cI[]=map.getInterceptors();
  + BaseInterceptor cI[]=defaultContainer.getInterceptors();
for( int i=0; i< cI.length; i++ ) {
cI[i].addContainer( map );
}
  @@ -456,6 +457,7 @@
by interceptors ( DefaultCMSetter )
   */
   public final  void setContextManager(ContextManager cm) {
  + if( contextM != null ) return;
contextM=cm;
   }
   
  @@ -476,6 +478,95 @@
   void setState( int state ) {
this.state=state;
   }
  +
  +/**
  + * Initializes this context to be able to accept requests. This action
  + * will cause the context to load it's configuration information
  + * from the webapp directory in the docbase.
  + *
  + * This method must be called
  + * before any requests are handled by this context. It will be called
  + * after the context was added, typically when the engine starts
  + * or after the admin adds a new context.
  + *
  + * After this call, the context will be in READY state and will
  + * be able to server requests.
  + * 
  + * @exception if any interceptor throws an exception the error
  + *   will prevent the context from becoming READY
  + */
  +public final void init() throws TomcatException {
  + if( state==STATE_READY ) {
  + log( "Already initialized " );
  + return;
  + }
  + // make sure we see all interceptors added so far
  + getContainer().resetInterceptorCache(Container.H_engineInit);
  +
  + // initialize all local-interceptors
  + BaseInterceptor cI[]=getContainer().getInterceptors();
  + for( int i=0; i


cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core Context.java

2000-11-02 Thread costin

costin  00/11/02 13:27:09

  Modified:src/share/org/apache/tomcat/core Context.java
  Log:
  More work on defining Context "state".
  
  Call directly the container to get the interceptors.
  
  Revision  ChangesPath
  1.126 +31 -12jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
  
  Index: Context.java
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- Context.java  2000/10/01 22:21:44 1.125
  +++ Context.java  2000/11/02 21:27:07 1.126
  @@ -128,18 +128,29 @@
*/
   public static final String ATTRIB_REAL_CONTEXT="org.apache.tomcat.context";
   
  -/** Context is new, not even added to server. ContextManager is not
  - set, and most of the paths are not fixed
  +/** Context is new, possibly not even added to server.
  + ContextManager is not set, and most of the paths are not fixed
   */
  -public static final int STATE_PRE_ADD=0;
  -/** Context was added to the server. Relative paths are fixed, based
  - on server base, and CM is set.
  +public static final int STATE_NEW=0;
  +
  +/** Context was added to the server, but contextInit() is not
  + called. Paths are not set yet, the only valid information is
  + the contextURI.
  + */
  +public static final int STATE_ADDED=1;
  +
  +/**
  +   Relative paths are fixed, based
  +   on server base, and CM is set.
  +   If a request arives for this context, an error message should be
  +   displayed ( "application is temporary disabled" )
*/
  -public static final int STATE_ADD=1;
  +public static final int STATE_DISABLED=2;
  +
   /** Context is initialized and ready to serve. We have all mappings
and configs from web.xml.
   */
  -public static final int STATE_INIT=2;
  +public static final int STATE_READY=3;
   
   //  internal properties
   // context "id"
  @@ -151,7 +162,7 @@
   // Absolute path to docBase if file-system based
   private String absPath;
   
  -private int state=STATE_PRE_ADD;
  +private int state=STATE_NEW;
   
   // internal state / related objects
   private ContextManager contextM;
  @@ -300,7 +311,7 @@
map.setPath( path );
   
// Notify interceptors that a new container is added
  - BaseInterceptor cI[]=contextM.getInterceptors(map);
  + BaseInterceptor cI[]=map.getInterceptors();
for( int i=0; i< cI.length; i++ ) {
cI[i].addContainer( map );
}
  @@ -347,7 +358,7 @@
//contextM.addSecurityConstraint( this, path[i], ct);
   
// Notify interceptors that a new container is added
  - BaseInterceptor cI[]=contextM.getInterceptors(ct);
  + BaseInterceptor cI[]=ct.getInterceptors();
for( int j=0; j< cI.length; j++ ) {
cI[j].addContainer( ct );
}
  @@ -457,6 +468,14 @@
   public final int getState() {
return state;
   }
  +
  +/** Move the context in a different state.
  + Can be called only from tomcat.core.ContextManager.
  + ( package access )
  +*/
  +void setState( int state ) {
  + this.state=state;
  +}
   
   //  Basic properties 
   
  @@ -786,7 +805,7 @@
containers.remove(ct.getPath());
   
// notify modules that a container was removed
  - BaseInterceptor cI[]=contextM.getInterceptors(ct);
  + BaseInterceptor cI[]=ct.getInterceptors();
for( int i=0; i< cI.length; i++ ) {
cI[i].removeContainer( ct );
}
  @@ -872,7 +891,7 @@
   */
   public final  URL[] getClassPath() {
if( classPath==null ) return new URL[0];
  - URL serverCP[]=contextM.getServerClassPath();
  + URL serverCP[]=new URL[0]; //contextM.getServerClassPath();
URL urls[]=new URL[classPath.size() + serverCP.length];
int pos=0;
for( int i=0; i