php.java.script
Class PhpScriptContext

java.lang.Object
  extended by javax.script.SimpleScriptContext
      extended by php.java.script.AbstractPhpScriptContext
          extended by php.java.script.PhpScriptContext
All Implemented Interfaces:
ScriptContext, IContext, IManaged, Invocable, IPhpScriptContext

public class PhpScriptContext
extends AbstractPhpScriptContext
implements IPhpScriptContext

This class implements a simple script context for PHP. It starts a standalone JavaBridgeRunner which listens for requests from php instances.

In a servlet environment please use a php.java.script.PhpSimpleHttpScriptContext instead.

Author:
jostb
See Also:
PhpScriptContext, JavaBridgeRunner

Field Summary
 
Fields inherited from class php.java.script.AbstractPhpScriptContext
APPLICATION_SCOPE, REQUEST_SCOPE, SESSION_SCOPE
 
Fields inherited from interface php.java.bridge.http.IContext
ENGINE_SCOPE, GLOBAL_SCOPE, JAVA_BRIDGE, SERVLET, SERVLET_CONFIG, SERVLET_CONTEXT, SERVLET_REQUEST, SERVLET_RESPONSE
 
Fields inherited from interface javax.script.ScriptContext
ENGINE_SCOPE, GLOBAL_SCOPE
 
Constructor Summary
PhpScriptContext()
          Create a standalone PHP script context.
 
Method Summary
 java.io.Writer getErrorWriter()
          Returns the Writer used to display error output.
 java.lang.Object getHttpServletRequest()
          Throws IllegalStateException
 java.lang.Object getHttpServletResponse()
          Throws IllegalStateException
 java.lang.String getRealPath(java.lang.String path)
          Get the full file system path for the given resource.
 java.lang.Object getServlet()
          Throws IllegalStateException
 java.lang.Object getServletConfig()
          Throws IllegalStateException
 java.lang.Object getServletContext()
          Throws IllegalStateException
 java.io.Writer getWriter()
          Returns the Writer for scripts to use when displaying output.
 java.lang.Object init(java.lang.Object callable)
          Initialize a library.
 void onShutdown(java.lang.Object closeable)
          Register a shutdown hook for the library.
 
Methods inherited from class php.java.script.AbstractPhpScriptContext
call, getContinuation, setContinuation, setErrorWriter, setWriter
 
Methods inherited from class javax.script.SimpleScriptContext
getAttribute, getAttribute, getAttributesScope, getBindings, getReader, getScopes, removeAttribute, setAttribute, setBindings, setReader
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface php.java.script.IPhpScriptContext
getContinuation, setContinuation, setWriter
 
Methods inherited from interface php.java.bridge.Invocable
call
 
Methods inherited from interface php.java.bridge.http.IContext
getAttribute, getAttribute, getAttributesScope, removeAttribute, setAttribute
 

Constructor Detail

PhpScriptContext

public PhpScriptContext()
Create a standalone PHP script context.

Method Detail

getWriter

public java.io.Writer getWriter()
Returns the Writer for scripts to use when displaying output.

Specified by:
getWriter in interface ScriptContext
Specified by:
getWriter in interface IContext
Specified by:
getWriter in interface IPhpScriptContext
Overrides:
getWriter in class AbstractPhpScriptContext
Returns:
The Writer.

getErrorWriter

public java.io.Writer getErrorWriter()
Returns the Writer used to display error output.

Specified by:
getErrorWriter in interface ScriptContext
Overrides:
getErrorWriter in class AbstractPhpScriptContext
Returns:
The Writer

init

public java.lang.Object init(java.lang.Object callable)
                      throws java.lang.Exception
Initialize a library. This method may be called via java_context()->init(...) to initialize a library. Within init() onShutdown() may be called to register a shutdown hook for the library.

Specified by:
init in interface IManaged
Parameters:
callable - Its call() method will be called synchronized.
Returns:
The result of the call() invocation.
Throws:
java.lang.Exception - The result of the call() invocation.

onShutdown

public void onShutdown(java.lang.Object closeable)
Register a shutdown hook for the library. This method may be called via java_context()->onShutdown(...) to register a shutdown hook during init().

Specified by:
onShutdown in interface IManaged
Parameters:
closeable - Its close() method will be called before the context or the VM terminates.

getHttpServletRequest

public java.lang.Object getHttpServletRequest()
Throws IllegalStateException

Specified by:
getHttpServletRequest in interface IContext
Returns:
none

getServletContext

public java.lang.Object getServletContext()
Throws IllegalStateException

Specified by:
getServletContext in interface IContext
Returns:
none

getHttpServletResponse

public java.lang.Object getHttpServletResponse()
Throws IllegalStateException

Specified by:
getHttpServletResponse in interface IContext
Returns:
none

getServlet

public java.lang.Object getServlet()
Throws IllegalStateException

Specified by:
getServlet in interface IContext
Returns:
none

getServletConfig

public java.lang.Object getServletConfig()
Throws IllegalStateException

Specified by:
getServletConfig in interface IContext
Returns:
none

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Get the full file system path for the given resource.

Specified by:
getRealPath in interface IContext
Parameters:
path - the relative path to an existing resource
Returns:
the file system path