php.java.script
Class PhpSimpleHttpScriptContext

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

public class PhpSimpleHttpScriptContext
extends SimpleScriptContext
implements IContext, IPhpScriptContext

A simple ScriptContext which can be used in servlet environments.

Author:
jostb

Field Summary
static int APPLICATION_SCOPE
          Integer value for the level of APPLICATION_SCOPE
static int REQUEST_SCOPE
          Integer value for the level of SCRIPT_SCOPE
static int SESSION_SCOPE
          Integer value for the level of SESSION_SCOPE
 
Fields inherited from interface javax.script.ScriptContext
ENGINE_SCOPE, GLOBAL_SCOPE
 
Constructor Summary
PhpSimpleHttpScriptContext()
           
 
Method Summary
 boolean call(PhpProcedureProxy kont)
          Call the java continuation with the current continuation kont as its argument.
 java.lang.Object getAttribute(java.lang.String name)
          Retrieves the value for getAttribute(String, int) for the lowest scope in which it returns a non-null value.
 java.lang.Object getAttribute(java.lang.String key, int scope)
          Retrieves the value associated with specified name in the specified level of scope.
 javax.servlet.ServletContext getContext()
          Get the ServletContext
 HttpProxy getContinuation()
          Get the php continuation
 javax.servlet.http.HttpServletRequest getRequest()
          Get the HttpServletRequest
 javax.servlet.http.HttpServletResponse getResponse()
          Get the servlet response
 java.io.Writer getWriter()
          Retrieves an instance of java.io.Writer which can be used by scripts to display their output.
 void initialize(javax.servlet.ServletContext ctx, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, PhpScriptWriter writer)
          Initialize the context.
 void setAttribute(java.lang.String key, java.lang.Object value, int scope)
          Sets an attribute specified by the name in specified level of scope.
 void setContinuation(HttpProxy kont)
          Set the php continuation
 void setWriter(java.io.Writer writer)
          Set the Writer
 
Methods inherited from class javax.script.SimpleScriptContext
getAttributesScope, getBindings, removeAttribute, setBindings
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_SCOPE

public static final int REQUEST_SCOPE
Integer value for the level of SCRIPT_SCOPE

See Also:
Constant Field Values

SESSION_SCOPE

public static final int SESSION_SCOPE
Integer value for the level of SESSION_SCOPE

See Also:
Constant Field Values

APPLICATION_SCOPE

public static final int APPLICATION_SCOPE
Integer value for the level of APPLICATION_SCOPE

See Also:
Constant Field Values
Constructor Detail

PhpSimpleHttpScriptContext

public PhpSimpleHttpScriptContext()
Method Detail

initialize

public void initialize(javax.servlet.ServletContext ctx,
                       javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse res,
                       PhpScriptWriter writer)
                throws javax.servlet.ServletException
Initialize the context.

Parameters:
ctx - The ServletContext
req - The HttpServletRequest
res - The HttpServletResponse
writer - The PhpScriptWriter
Throws:
javax.servlet.ServletException

getAttribute

public java.lang.Object getAttribute(java.lang.String key,
                                     int scope)
Description copied from class: SimpleScriptContext
Retrieves the value associated with specified name in the specified level of scope. Returns null if no value is associated with specified key in specified level of scope.

Specified by:
getAttribute in interface ScriptContext
Specified by:
getAttribute in interface IContext
Overrides:
getAttribute in class SimpleScriptContext
Parameters:
key - the name of the attribute
scope - the level of scope
Returns:
the value value associated with the specified name in specified level of scope

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
                              throws java.lang.IllegalArgumentException
Description copied from class: SimpleScriptContext
Retrieves the value for getAttribute(String, int) for the lowest scope in which it returns a non-null value.

Specified by:
getAttribute in interface ScriptContext
Specified by:
getAttribute in interface IContext
Overrides:
getAttribute in class SimpleScriptContext
Parameters:
name - the name of the attribute
Returns:
the value of the attribute
Throws:
java.lang.IllegalArgumentException - if the name is null

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value,
                         int scope)
                  throws java.lang.IllegalArgumentException
Description copied from class: SimpleScriptContext
Sets an attribute specified by the name in specified level of scope.

Specified by:
setAttribute in interface ScriptContext
Specified by:
setAttribute in interface IContext
Overrides:
setAttribute in class SimpleScriptContext
Parameters:
key - the name of the attribute
value - the value of the attribute
scope - the level of the scope
Throws:
java.lang.IllegalArgumentException - if the name is null or the scope is invalid

getWriter

public java.io.Writer getWriter()
Description copied from class: SimpleScriptContext
Retrieves an instance of java.io.Writer which can be used by scripts to display their output.

Specified by:
getWriter in interface ScriptContext
Specified by:
getWriter in interface IContext
Specified by:
getWriter in interface IPhpScriptContext
Overrides:
getWriter in class SimpleScriptContext
Returns:
an instance of java.io.Writer

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Get the servlet response

Returns:
The HttpServletResponse

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Get the HttpServletRequest

Returns:
The HttpServletRequest

getContext

public javax.servlet.ServletContext getContext()
Get the ServletContext

Returns:
The current ServletContext

setContinuation

public void setContinuation(HttpProxy kont)
Description copied from interface: IPhpScriptContext
Set the php continuation

Specified by:
setContinuation in interface IPhpScriptContext
Parameters:
kont - The continuation.

call

public boolean call(PhpProcedureProxy kont)
             throws java.lang.Exception
Description copied from interface: Invocable
Call the java continuation with the current continuation kont as its argument.

Specified by:
call in interface Invocable
Parameters:
kont - The continuation.
Returns:
True on success, false otherwise.
Throws:
java.lang.Exception

setWriter

public void setWriter(java.io.Writer writer)
Description copied from interface: IPhpScriptContext
Set the Writer

Specified by:
setWriter in interface IPhpScriptContext
Parameters:
writer - The writer

getContinuation

public HttpProxy getContinuation()
Description copied from interface: IPhpScriptContext
Get the php continuation

Specified by:
getContinuation in interface IPhpScriptContext
Returns:
The HttpProxy