1 16 17 package org.apache.jk.core; 18 19 import java.util.Hashtable ; 20 import javax.management.ObjectName ; 21 22 33 public class WorkerEnv { 34 35 Hashtable properties; 36 37 public static final int ENDPOINT_NOTE=0; 38 public static final int REQUEST_NOTE=1; 39 public static final int SSL_CERT_NOTE=16; 40 int noteId[]=new int[4]; 41 String noteName[][]=new String [4][]; 42 private Object notes[]=new Object [32]; 43 44 Hashtable handlersMap=new Hashtable (); 45 JkHandler handlersTable[]=new JkHandler[20]; 46 int handlerCount=0; 47 48 String home; 50 int localId=0; 51 52 public WorkerEnv() { 53 for( int i=0; i<noteId.length; i++ ) { 54 noteId[i]=7; 55 noteName[i]=new String [20]; 56 } 57 } 58 59 public void setLocalId(int id) { 60 localId=id; 61 } 62 63 public int getLocalId() { 64 return localId; 65 } 66 67 public void setJkHome( String s ) { 68 home=s; 69 } 70 71 public String getJkHome() { 72 return home; 73 } 74 75 public final Object getNote(int i ) { 76 return notes[i]; 77 } 78 79 public final void setNote(int i, Object o ) { 80 notes[i]=o; 81 } 82 83 public int getNoteId( int type, String name ) { 84 for( int i=0; i<noteId[type]; i++ ) { 85 if( name.equals( noteName[type][i] )) 86 return i; 87 } 88 int id=noteId[type]++; 89 noteName[type][id]=name; 90 return id; 91 } 92 93 public void addHandler( String name, JkHandler w ) { 94 JkHandler oldH = getHandler(name); 95 if(oldH == w) { 96 return; 98 } 99 w.setWorkerEnv( this ); 100 w.setName( name ); 101 handlersMap.put( name, w ); 102 if( handlerCount > handlersTable.length ) { 103 JkHandler newT[]=new JkHandler[ 2 * handlersTable.length ]; 104 System.arraycopy( handlersTable, 0, newT, 0, handlersTable.length ); 105 handlersTable=newT; 106 } 107 if(oldH == null) { 108 handlersTable[handlerCount]=w; 109 w.setId( handlerCount ); 110 handlerCount++; 111 } else { 112 handlersTable[oldH.getId()]=w; 113 w.setId(oldH.getId()); 114 } 115 116 for( int i=0; i< handlerCount ; i++ ) { 119 handlersTable[i].addHandlerCallback( w ); 120 } 121 } 122 123 public final JkHandler getHandler( String name ) { 124 return (JkHandler)handlersMap.get(name); 125 } 126 127 public final JkHandler getHandler( int id ) { 128 return handlersTable[id]; 129 } 130 131 public final int getHandlerCount() { 132 return handlerCount; 133 } 134 135 public ObjectName [] getHandlersObjectName() { 136 137 ObjectName onames[]=new ObjectName [ handlerCount ]; 138 for( int i=0; i<handlerCount; i++ ) { 139 onames[i]=handlersTable[i].getObjectName(); 140 } 141 return onames; 142 } 143 144 } 145 | Popular Tags |