1 16 17 package org.apache.jk.core; 18 19 import java.io.IOException ; 20 import java.util.Properties ; 21 22 import javax.management.MBeanRegistration ; 23 import javax.management.MBeanServer ; 24 import javax.management.Notification ; 25 import javax.management.NotificationListener ; 26 import javax.management.ObjectName ; 27 28 import org.apache.commons.modeler.Registry; 29 30 34 public class JkHandler implements MBeanRegistration , NotificationListener { 35 public static final int OK=0; 36 public static final int LAST=1; 37 public static final int ERROR=2; 38 39 protected Properties properties=new Properties (); 40 protected WorkerEnv wEnv; 41 protected JkHandler next; 42 protected String nextName=null; 43 protected String name; 44 protected int id; 45 46 public static final int HANDLE_RECEIVE_PACKET = 10; 50 public static final int HANDLE_SEND_PACKET = 11; 51 public static final int HANDLE_FLUSH = 12; 52 public static final int HANDLE_THREAD_END = 13; 53 54 public void setWorkerEnv( WorkerEnv we ) { 55 this.wEnv=we; 56 } 57 58 61 public void setName(String s ) { 62 name=s; 63 } 64 65 public String getName() { 66 return name; 67 } 68 69 74 public void setId( int id ) { 75 this.id=id; 76 } 77 78 public int getId() { 79 return id; 80 } 81 82 85 public void setNext( JkHandler h ) { 86 next=h; 87 } 88 89 public void setNext( String s ) { 90 nextName=s; 91 } 92 93 public String getNext() { 94 if( nextName==null ) { 95 if( next!=null) 96 nextName=next.getName(); 97 } 98 return nextName; 99 } 100 101 104 public void init() throws IOException { 105 } 106 107 109 public void destroy() throws IOException { 110 } 111 112 public MsgContext createMsgContext() { 113 return new MsgContext(); 114 } 115 116 public int invoke(Msg msg, MsgContext mc ) throws IOException { 117 return OK; 118 } 119 120 public void setProperty( String name, String value ) { 121 properties.put( name, value ); 122 } 123 124 public String getProperty( String name ) { 125 return properties.getProperty(name) ; 126 } 127 128 131 public void addHandlerCallback( JkHandler w ) { 132 133 } 134 135 public void handleNotification(Notification notification, Object handback) 136 { 137 142 143 } 144 145 protected String domain; 146 protected ObjectName oname; 147 protected MBeanServer mserver; 148 149 public ObjectName getObjectName() { 150 return oname; 151 } 152 153 public String getDomain() { 154 return domain; 155 } 156 157 public ObjectName preRegister(MBeanServer server, 158 ObjectName oname) throws Exception { 159 this.oname=oname; 160 mserver=server; 161 domain=oname.getDomain(); 162 if( name==null ) { 163 name=oname.getKeyProperty("name"); 164 } 165 166 ObjectName wEnvName=new ObjectName (domain + ":type=JkWorkerEnv"); 168 if ( wEnv == null ) { 169 wEnv=new WorkerEnv(); 170 } 171 if( ! mserver.isRegistered(wEnvName )) { 172 Registry.getRegistry(null, null).registerComponent(wEnv, wEnvName, null); 173 } 174 mserver.invoke( wEnvName, "addHandler", 175 new Object [] {name, this}, 176 new String [] {"java.lang.String", 177 "org.apache.jk.core.JkHandler"}); 178 return oname; 179 } 180 181 public void postRegister(Boolean registrationDone) { 182 } 183 184 public void preDeregister() throws Exception { 185 } 186 187 public void postDeregister() { 188 } 189 190 public void pause() throws Exception { 191 } 192 193 public void resume() throws Exception { 194 } 195 196 } 197 | Popular Tags |