org.apache.jk.common

Class JniHandler

Implemented Interfaces:
MBeanRegistration, NotificationListener
Known Direct 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

static int
C2B_NOTE
static int
JK_HANDLE_JNI_DISPATCH
static int
JK_HANDLE_SHM_DISPATCH
static int
MB_NOTE
static int
MSG_NOTE
protected AprImpl
apr
protected String
jkHome
protected long
nativeJkHandlerP

Fields inherited from class org.apache.jk.core.JkHandler

ERROR, HANDLE_FLUSH, HANDLE_RECEIVE_PACKET, HANDLE_SEND_PACKET, HANDLE_THREAD_END, LAST, OK, domain, id, mserver, name, next, nextName, oname, properties, wEnv

Constructor Summary

JniHandler()

Method Summary

void
appendString(Msg msg, String s, C2BConverter charsetDecoder)
MsgContext
createMsgContext()
Create a msg context to be used with the shm channel
void
destroyJkComponent()
String
getJkHome()
void
init()
You must call initNative() inside the component init()
void
initJkComponent()
protected void
initNative(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(String s)
void
setNativeAttribute(String name, String val)
protected void
setNativeEndpoint(MsgContext msgCtx)

Methods inherited from class org.apache.jk.core.JkHandler

addHandlerCallback, createMsgContext, destroy, getDomain, getId, getName, getNext, getObjectName, getProperty, handleNotification, init, invoke, pause, postDeregister, postRegister, preDeregister, preRegister, resume, setId, setName, setNext, setNext, setProperty, setWorkerEnv

Field Details

C2B_NOTE

public static final int C2B_NOTE

Field Value:
1


JK_HANDLE_JNI_DISPATCH

public static final int JK_HANDLE_JNI_DISPATCH

Field Value:
21


JK_HANDLE_SHM_DISPATCH

public static final int JK_HANDLE_SHM_DISPATCH

Field Value:
22


MB_NOTE

public static final int MB_NOTE

Field Value:
2


MSG_NOTE

public static final int MSG_NOTE

Field Value:
0


apr

protected AprImpl apr


jkHome

protected String jkHome


nativeJkHandlerP

protected long nativeJkHandlerP

Constructor Details

JniHandler

public JniHandler()

Method Details

appendString

public void appendString(Msg msg,
                         String s,
                         C2BConverter charsetDecoder)
            throws IOException


createMsgContext

public MsgContext createMsgContext()
Create a msg context to be used with the shm channel
Overrides:
createMsgContext in interface JkHandler


destroyJkComponent

public void destroyJkComponent()
            throws IOException


getJkHome

public String getJkHome()


init

public void init()
            throws IOException
You must call initNative() inside the component init()
Overrides:
init in interface JkHandler


initJkComponent

public void initJkComponent()
            throws IOException


initNative

protected void initNative(String nativeComponentName)


invoke

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


nativeDispatch

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


pause

public void pause()
            throws Exception
Overrides:
pause in interface JkHandler


recycleNative

protected void recycleNative(MsgContext ep)


resume

public void resume()
            throws Exception
Overrides:
resume in interface JkHandler


setJkHome

public void setJkHome(String s)


setNativeAttribute

public void setNativeAttribute(String name,
                               String val)
            throws IOException


setNativeEndpoint

protected void setNativeEndpoint(MsgContext msgCtx)


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.