Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## php.java.bridge.http
Class ContextRunner

    java.lang.Object
      php.java.bridge.http.ContextRunner

All Implemented Interfaces:
  java.lang.Runnable

    public class ContextRunner

extends java.lang.Object
implements java.lang.Runnable

The ContextRunner manages the "high speed" communication link. It pulls a context and executes it. After execution the context is destroyed.

ContextRunners are kept in a per-loader map and each client may refer to its runner by passing X_JAVARIDGE_CONTEXT_DEFAULT. The ContextRunner may ignore this hint and prepare for a new physical connection, if the ID does not exist in its map. This usually happens when there are two separate bridges installed in context A and context B and the client uses a persistent connection to context A. An attempt to re-use the same connection for B fails because the classes are loaded via two separate class loaders. A client must check the returned X_JAVABRIDGE_CONTEXT_DEFAULT value. If it is not set, the client must create a new physical connection. For named pipes this means that the connection should have been prepared and sent via X_JAVABRIDGE_CHANNEL, as usual. Otherwise the bridge will use the SocketContextServer instead. -- The client may destroy the new pipe, if the server has accepted X_JAVABRIDGE_CONTEXT_DEFAULT, of course.

See http://php-java-bridge.sourceforge.net#global-servlet for details how to install the bridge globally.

Method Summary
`static java.lang.String` | `checkRunner(IContextServer.ChannelName channelName, ContextServer contextServer)` May be called to recycle the runner from the pool of ContextRunners for a new contextServer.
`void` | `recycle(IContextFactory ctx, ContextServer contextServer)` Recycle the runner for a different web context.
`void` | `run()`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### checkRunner

    public static java.lang.String checkRunner(IContextServer.ChannelName channelName,
                                               ContextServer contextServer)

  May be called to recycle the runner from the pool of ContextRunners for a new contextServer. Reduces the # of physical connections when there is only one ContextFactory factory but several ContextServer instances per ClassLoader, for example when the PhpCGIServlet is used globally, see ABOUT.HTM#global-servlet". In this setup we have n PHP childs using n physical connections (n ContextRunner instances), k web contexts (k contextServers) and up to k*n ContextFactory and JavaBridge instances.

  Parameters:
    `channelName` - the channelName. This procedure sets the runner into channelName as a side effect.
    `contextServer` - the current contextServer or null
  Returns:
    the ContextRunner, if found, otherwise null.

### recycle

    public void recycle(IContextFactory ctx,
                        ContextServer contextServer)

  Recycle the runner for a different web context.

  Parameters:
    `ctx` - the old contextFacory belonging to a different contextServer
    `contextServer` - the new ContextServer

### run

    public void run()

  Specified by:
    `run` in interface `java.lang.Runnable`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD