org.apache.jk.common
Class JniHandler

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

public class JniHandler
extends JkHandler

Base class for components using native code ( libjkjni.so ). It allows to access the jk_env and wrap ( 'box' ? ) a native jk component, and call it's methods. Note that get/setAttribute are expensive ( Strings, etc ), invoke() is were all optimizations are done. We do recycle all memory on both C and java sides ( the only exception is when we attempt pinning but the VM doesn't support it ). The low level optimizations from ByteBuffer, etc are used to reduce the overhead of passing strings.

Author:
Costin Manolache

Field Summary
protected  AprImpl apr
           
static int C2B_NOTE
           
static int JK_HANDLE_JNI_DISPATCH
           
static int JK_HANDLE_SHM_DISPATCH
           
protected  java.lang.String jkHome
           
static int MB_NOTE
           
static int MSG_NOTE
           
protected  long 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
JniHandler()
           
 
Method Summary
 void appendString(Msg msg, java.lang.String s, C2BConverter charsetDecoder)
           
 MsgContext createMsgContext()
          Create a msg context to be used with the shm channel
 void destroyJkComponent()
           
 java.lang.String getJkHome()
           
 void init()
          You must call initNative() inside the component init()
 void initJkComponent()
           
protected  void initNative(java.lang.String nativeComponentName)
           
 int invoke(Msg msg, MsgContext ep)
          Base implementation for invoke.
protected  int nativeDispatch(Msg msg, MsgContext ep, int code, int raw)
          send and get the response in the same buffer.
 void pause()
           
protected  void recycleNative(MsgContext ep)
           
 void resume()
           
 void setJkHome(java.lang.String s)
           
 void setNativeAttribute(java.lang.String name, java.lang.String val)
           
protected  void setNativeEndpoint(MsgContext msgCtx)
           
 
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
 

Field Detail

apr

protected AprImpl apr

nativeJkHandlerP

protected long nativeJkHandlerP

jkHome

protected java.lang.String jkHome

JK_HANDLE_JNI_DISPATCH

public static final int JK_HANDLE_JNI_DISPATCH
See Also:
Constant Field Values

JK_HANDLE_SHM_DISPATCH

public static final int JK_HANDLE_SHM_DISPATCH
See Also:
Constant Field Values

MSG_NOTE

public static final int MSG_NOTE
See Also:
Constant Field Values

C2B_NOTE

public static final int C2B_NOTE
See Also:
Constant Field Values

MB_NOTE

public static final int MB_NOTE
See Also:
Constant Field Values
Constructor Detail

JniHandler

public JniHandler()
Method Detail

setJkHome

public void setJkHome(java.lang.String s)

getJkHome

public java.lang.String getJkHome()

init

public void init()
          throws java.io.IOException
You must call initNative() inside the component init()

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

initNative

protected void initNative(java.lang.String nativeComponentName)

appendString

public void appendString(Msg msg,
                         java.lang.String s,
                         C2BConverter charsetDecoder)
                  throws java.io.IOException
Throws:
java.io.IOException

pause

public void pause()
           throws java.lang.Exception
Overrides:
pause in class JkHandler
Throws:
java.lang.Exception

resume

public void resume()
            throws java.lang.Exception
Overrides:
resume in class JkHandler
Throws:
java.lang.Exception

createMsgContext

public MsgContext createMsgContext()
Create a msg context to be used with the shm channel

Overrides:
createMsgContext in class JkHandler

setNativeAttribute

public void setNativeAttribute(java.lang.String name,
                               java.lang.String val)
                        throws java.io.IOException
Throws:
java.io.IOException

initJkComponent

public void initJkComponent()
                     throws java.io.IOException
Throws:
java.io.IOException

destroyJkComponent

public void destroyJkComponent()
                        throws java.io.IOException
Throws:
java.io.IOException

setNativeEndpoint

protected void setNativeEndpoint(MsgContext msgCtx)

recycleNative

protected void recycleNative(MsgContext ep)

nativeDispatch

protected int nativeDispatch(Msg msg,
                             MsgContext ep,
                             int code,
                             int raw)
                      throws java.io.IOException
send and get the response in the same buffer. This calls the method on the wrapped jk_bean object.

Throws:
java.io.IOException

invoke

public int invoke(Msg msg,
                  MsgContext ep)
           throws java.io.IOException
Base implementation for invoke. Dispatch the action to the native code, where invoke() is called on the wrapped jk_bean.

Overrides:
invoke in class JkHandler
Throws:
java.io.IOException


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