## 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 usually represents the physical connection, it manages the "high speed" communication link. It pulls a ContextFactory 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 ContextRunner` `checkRunner(IContextServer.ChannelName channelName)` May be called to recycle the runner from the pool of ContextRunners for a new contextServer.
`IContextServer.Channel` `getChannel()` Return the channel of the current runner.
`void` `recycle(IContextFactory ctx)` 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 ContextRunner checkRunner(IContextServer.ChannelName channelName)

  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.
  Returns:
    the ContextRunner, if found, otherwise null.

### recycle

    public void recycle(IContextFactory ctx)

  Recycle the runner for a different web context.

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

### getChannel

    public IContextServer.Channel getChannel()

  Return the channel of the current runner.

  Returns:
    The Channel

### run

    public void run()

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