php.java.script
Class HttpProxy

java.lang.Object
  extended by java.lang.Thread
      extended by php.java.script.HttpProxy
All Implemented Interfaces:
java.lang.Runnable

public class HttpProxy
extends java.lang.Thread

Represents the script continuation. This class can be used to allocate php scripts on a HTTP server. Although this class accidentally inherits from CGIRunner it doesn't necessarily run CGI binaries. If you pass a URLReader, it calls its read method which opens a URLConnection to the remote server and holds the allocated remote script instance hostage until release is called.

Author:
jostb

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
HttpProxy(java.io.Reader reader, java.util.Map env, java.io.OutputStream out, java.io.OutputStream err, Util.HeaderParser headerParser, ResultProxy resultProxy)
          Create a HTTP proxy which can be used to allocate a php script from a HTTP server
HttpProxy(java.io.Reader reader, java.lang.String ctx, java.io.OutputStream out, java.io.OutputStream err, Util.HeaderParser headerParser, ResultProxy resultProxy)
          Create a HTTP proxy which can be used to allocate a php script from a HTTP server
 
Method Summary
 void call(PhpProcedureProxy script)
          The PHP script must call this function with the current continuation as an argument.
 PhpProcedureProxy getPhpScript()
          One must call this function if one is interested in the php continuation.
 void release()
          This function must be called to release the allocated php continuation.
 void run()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpProxy

public HttpProxy(java.io.Reader reader,
                 java.util.Map env,
                 java.io.OutputStream out,
                 java.io.OutputStream err,
                 Util.HeaderParser headerParser,
                 ResultProxy resultProxy)
Create a HTTP proxy which can be used to allocate a php script from a HTTP server

Parameters:
reader - - The reader, for example a URLReader
env - - The environment, must contain values for X_JAVABRIDGE_CONTEXT. It may contain X_JAVABRIDGE_OVERRIDE_HOSTS.
out - - The OutputStream
err - The error stream
headerParser - The header parser
resultProxy - The return value proxy

HttpProxy

public HttpProxy(java.io.Reader reader,
                 java.lang.String ctx,
                 java.io.OutputStream out,
                 java.io.OutputStream err,
                 Util.HeaderParser headerParser,
                 ResultProxy resultProxy)
Create a HTTP proxy which can be used to allocate a php script from a HTTP server

Parameters:
reader - - The reader, for example a URLReader
ctx - - The context
out - The output stream
err - The error stream
headerParser - The header parser
resultProxy - The return code proxy
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

call

public void call(PhpProcedureProxy script)
          throws java.lang.InterruptedException
The PHP script must call this function with the current continuation as an argument.

Example:

java_context()->call(java_closure());

Parameters:
script - - The php continuation
Throws:
java.lang.InterruptedException

getPhpScript

public PhpProcedureProxy getPhpScript()
                               throws java.lang.Exception
One must call this function if one is interested in the php continuation.

Returns:
The php continuation.
Throws:
java.lang.Exception

release

public void release()
             throws java.lang.InterruptedException
This function must be called to release the allocated php continuation. Note that simply calling this method does not guarantee that the script is finished, as the ContextRunner may still produce output. Use contextFactory.waitFor() to wait for the script to terminate.

Throws:
java.lang.InterruptedException