cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/core WorkerEnv.java

2004-01-16 Thread billbarker
billbarker2004/01/16 19:24:51

  Modified:jk/java/org/apache/jk/core WorkerEnv.java
  Log:
  Fix the problem that every Handler was getting added twice.
  
  Also, fix the case where we are attempting to replace a Handler (only possible if 
you are using your own JMX code to control Jk).
  
  Revision  ChangesPath
  1.12  +13 -3 
jakarta-tomcat-connectors/jk/java/org/apache/jk/core/WorkerEnv.java
  
  Index: WorkerEnv.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/core/WorkerEnv.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WorkerEnv.java25 Sep 2003 15:24:44 -  1.11
  +++ WorkerEnv.java17 Jan 2004 03:24:51 -  1.12
  @@ -133,6 +133,11 @@
   }
   
   public void addHandler( String name, JkHandler w ) {
  +JkHandler oldH = getHandler(name);
  +if(oldH == w) {
  +// Already added
  +return;
  +}
   w.setWorkerEnv( this );
   w.setName( name );
   handlersMap.put( name, w );
  @@ -141,9 +146,14 @@
   System.arraycopy( handlersTable, 0, newT, 0, handlersTable.length );
   handlersTable=newT;
   }
  -handlersTable[handlerCount]=w;
  -w.setId( handlerCount );
  -handlerCount++;
  +if(oldH == null) {
  +handlersTable[handlerCount]=w;
  +w.setId( handlerCount );
  +handlerCount++;
  +} else {
  +handlersTable[oldH.getId()]=w;
  +w.setId(oldH.getId());
  +}
   
   // Notify all other handlers of the new one
   // XXX Could be a Coyote action ?
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/java/org/apache/jk/core WorkerEnv.java

2002-02-06 Thread costin

costin  02/02/06 09:36:07

  Modified:jk/java/org/apache/jk/core WorkerEnv.java
  Log:
  Moved the process() logic in the HandlerDispatch, it doesn't have to be hardcoded.
  Added a 'home' property.
  Added 'notes' for the workerenv ( for generic properties stored by handlers )
  Removed the channel, consolidate Handler as the main 'plugin' mechanism.
  
  Revision  ChangesPath
  1.4   +35 -76
jakarta-tomcat-connectors/jk/java/org/apache/jk/core/WorkerEnv.java
  
  Index: WorkerEnv.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/jk/core/WorkerEnv.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WorkerEnv.java26 Jan 2002 07:22:23 -  1.3
  +++ WorkerEnv.java6 Feb 2002 17:36:07 -   1.4
  @@ -79,26 +79,19 @@
   
   Hashtable properties;
   
  -Webapp webapps[]=new Webapp[20];
  +Object webapps[]=new Object[20];
   int webappCnt=0;
   
   public static final int ENDPOINT_NOTE=0;
   public static final int REQUEST_NOTE=1;
   int noteId[]=new int[4];
   String noteName[][]=new String[4][];
  +private Object notes[]=new Object[32];
   
  -static final int MAX_HANDLERS=32;
  -static final int RESERVED=16;  // reserved names, backward compat
  -
  -// Note that we don't make distinction between in and out
  -// messages ( i.e. one id is used only in one direction )
  -Handler handlers[]=new Handler[MAX_HANDLERS];
  -String handlerNames[]=new String[MAX_HANDLERS];
  -int currentId=RESERVED;
  -
  -Hashtable workers=new Hashtable();
  -Hashtable channels=new Hashtable();
  -
  +Hashtable handlersMap=new Hashtable();
  +// base dir for the jk webapp
  +String home;
  +
   public WorkerEnv() {
   for( int i=0; inoteId.length; i++ ) {
   noteId[i]=7;
  @@ -106,9 +99,9 @@
   }
   }
   
  -public int addWebapp( Webapp wa ) {
  +public int addWebapp( Object wa ) {
   if( webappCnt = webapps.length ) {
  -Webapp newWebapps[]=new Webapp[ webapps.length + 20 ];
  +Object newWebapps[]=new Object[ webapps.length + 20 ];
   System.arraycopy( webapps, 0, newWebapps, 0, webapps.length);
   webapps=newWebapps;
   }
  @@ -116,94 +109,60 @@
   return webappCnt++;
   }
   
  -public Webapp getWebapp( int i ) {
  +public void setJkHome( String s ) {
  +home=s;
  +}
  +
  +public String getJkHome() {
  +return home;
  +}
  +
  +public Object getWebapp( int i ) {
   return webapps[i];
   }
   
   public int getWebappCount() {
   return webappCnt;
   }
  +
  +public final Object getNote(int i ) {
  +return notes[i];
  +}
   
  -public void addHandler( Handler h ) {
  -h.setWorkerEnv( this );
  -h.init();
  +public final void setNote(int i, Object o ) {
  +notes[i]=o;
   }
   
   public int getNoteId( int type, String name ) {
  +for( int i=0; inoteId[type]; i++ ) {
  +if( name.equals( noteName[type][i] ))
  +return i;
  +}
   int id=noteId[type]++;
   noteName[type][id]=name;
   return id;
   }
   
  -public int registerMessageType( int id, String name, Handler h,
  - String sig[] )
  -{
  - if( id  0 ) {
  - // try to find it by name
  - for( int i=0; i handlerNames.length; i++ )
  - if( name.equals( handlerNames[i] ) ) return i;
  - handlerNames[currentId]=name;
  - handlers[currentId]=h;
  - currentId++;
  - return currentId;
  - }
  - // fixed id
  - handlerNames[id]=name;
  - handlers[id]=h;
  - return id;
  -}
  -
  -public int processCallbacks( Channel ch, Endpoint ep, Msg hBuf )
  -throws IOException
  -{
  -int type=hBuf.getByte();
  -
  -if( type  handlers.length ||
  -handlers[type]==null ) {
  - d( Invalid handler  + type );
  - return 500;
  - }
  -
  -if( dL  0 )
  -d( Received  + type +   + handlerNames[type]);
  -
  - Handler handler=handlers[type];
  -
  -return handler.callback( type, ch, ep, hBuf );
  -}
  -
  -public void addWorker( String name, Worker w ) {
  +public void addHandler( String name, JkHandler w ) {
   w.setWorkerEnv( this );
  -workers.put( name, w );
  -}
  -
  -public Worker getWorker( String name ) {
  -return (Worker)workers.get(name);
  +w.setName( name );
  +handlersMap.put( name, w );
   }
   
  -public void addChannel( String name, Channel c ) {
  -c.setWorkerEnv( this );
  -channels.put( name, c