org.apache.jk.common
Class ChannelJni

java.lang.Object
  extended byorg.apache.jk.core.JkHandler
      extended byorg.apache.jk.common.JniHandler
          extended byorg.apache.jk.common.ChannelJni
All Implemented Interfaces:
java.util.EventListener, JkChannel, javax.management.MBeanRegistration, javax.management.NotificationListener

public class ChannelJni
extends JniHandler
implements JkChannel

Pass messages using jni

Author:
Costin Manolache

Field Summary
 
Fields inherited from class org.apache.jk.common.JniHandler
apr, C2B_NOTE, JK_HANDLE_JNI_DISPATCH, JK_HANDLE_SHM_DISPATCH, jkHome, MB_NOTE, MSG_NOTE, nativeJkHandlerP
 
Fields inherited from class org.apache.jk.core.JkHandler
domain, ERROR, HANDLE_FLUSH, HANDLE_RECEIVE_PACKET, HANDLE_SEND_PACKET, HANDLE_THREAD_END, id, LAST, mserver, name, next, nextName, OK, oname, properties, wEnv
 
Constructor Summary
ChannelJni()
           
 
Method Summary
 int flush(Msg msg, MsgContext ep)
          Flush the data to the client.
 java.lang.String getChannelName()
          Return the identifying name of this Channel.
 void init()
          You must call initNative() inside the component init()
 int invoke(Msg msg, MsgContext ep)
          Receive a packet from the C side.
 boolean isSameAddress(MsgContext ep)
          Confirm that a shutdown request was recieved form us.
 int receive(Msg msg, MsgContext ep)
          Receives does nothing - send will put the response in the same buffer
 void registerRequest(Request req, MsgContext ep, int count)
          Register a new Request in the Request pool.
 int send(Msg msg, MsgContext ep)
          Send the packet.
 
Methods inherited from class org.apache.jk.common.JniHandler
appendString, createMsgContext, destroyJkComponent, getJkHome, initJkComponent, initNative, nativeDispatch, pause, recycleNative, resume, setJkHome, setNativeAttribute, setNativeEndpoint
 
Methods inherited from class org.apache.jk.core.JkHandler
addHandlerCallback, destroy, getDomain, getId, getName, getNext, getObjectName, getProperty, handleNotification, postDeregister, postRegister, preDeregister, preRegister, setId, setName, setNext, setNext, setProperty, setWorkerEnv
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jk.core.JkChannel
createMsgContext
 

Constructor Detail

ChannelJni

public ChannelJni()
Method Detail

init

public void init()
          throws java.io.IOException
Description copied from class: JniHandler
You must call initNative() inside the component init()

Overrides:
init in class JniHandler
Throws:
java.io.IOException

receive

public int receive(Msg msg,
                   MsgContext ep)
            throws java.io.IOException
Receives does nothing - send will put the response in the same buffer

Specified by:
receive in interface JkChannel
Parameters:
msg - The place to recieve the data into.
ep - The connection point for this request.
Throws:
java.io.IOException

send

public int send(Msg msg,
                MsgContext ep)
         throws java.io.IOException
Send the packet. XXX This will modify msg !!! We could use 2 packets, or sendAndReceive().

Specified by:
send in interface JkChannel
Parameters:
msg - The message to send.
ep - The connection point for this request.
Throws:
java.io.IOException

flush

public int flush(Msg msg,
                 MsgContext ep)
          throws java.io.IOException
Description copied from interface: JkChannel
Flush the data to the client.

Specified by:
flush in interface JkChannel
Throws:
java.io.IOException

isSameAddress

public boolean isSameAddress(MsgContext ep)
Description copied from interface: JkChannel
Confirm that a shutdown request was recieved form us.

Specified by:
isSameAddress in interface JkChannel

registerRequest

public void registerRequest(Request req,
                            MsgContext ep,
                            int count)
Description copied from interface: JkChannel
Register a new Request in the Request pool.

Specified by:
registerRequest in interface JkChannel

getChannelName

public java.lang.String getChannelName()
Description copied from interface: JkChannel
Return the identifying name of this Channel.

Specified by:
getChannelName in interface JkChannel

invoke

public int invoke(Msg msg,
                  MsgContext ep)
           throws java.io.IOException
Receive a packet from the C side. This is called from the C code using invocation, but only for the first packet - to avoid recursivity and thread problems. This may look strange, but seems the best solution for the problem ( the problem is that we don't have 'continuation' ). sendPacket will move the thread execution on the C side, and return when another packet is available. For packets that are one way it'll return after it is processed too ( having 2 threads is far more expensive ). Again, the goal is to be efficient and behave like all other Channels ( so the rest of the code can be shared ). Playing with java objects on C is extremely difficult to optimize and do right ( IMHO ), so we'll try to keep it simple - byte[] passing, the conversion done in java ( after we know the encoding and if anyone asks for it - same lazy behavior as in 3.3 ).

Specified by:
invoke in interface JkChannel
Overrides:
invoke in class JniHandler
Throws:
java.io.IOException


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.