com.ca.jcs.processor.script
Class ScriptStyleOpProxyHandler

java.lang.Object
  extended by com.ca.jcs.processor.script.ScriptStyleOpProxyHandler

public class ScriptStyleOpProxyHandler
extends Object

Delegated to by MetaOpBindingsProxyHandler to take care of script-style op bindings. Note that use of script-style bindings with either OP or POST timings removes the possibility of streaming search results to the client piece-meal, but instead forces all results accumulated in memory at the same time.


Field Summary
static String SCRIPT_NAME_CONNECTOR
          Name by which scripts can access parent connector which they are wrapping.
static String SCRIPT_NAME_CURR_ATTRS
          Name which scripts can use to access the current (pre-modify) attribute values for the target object during modify requests.
static String SCRIPT_NAME_LOOKUP_ATTRS_RESULTS
          Name which should be used by scripts to record results of lookup request.
static String SCRIPT_NAME_SEARCH_RESULTS
          Name which should be used by scripts to record results of search request.
static String SCRIPT_NAME_SEARCH_RESULTS_BLOCKING_QUEUE
          Name which should be used by scripts to queue results from asynchronously processed search requests.
static String SCRIPT_NAME_STATUS_ARRAY
          Name by which scripts can access status array, where element [0] should be filled with a description when an error is encountered.
static String SCRIPT_TERMINATE_STATUS
          Value which may be put into element [0] of SCRIPT_NAME_STATUS_ARRAY in which case script should periodically check it and exit.
static String SEARCH_RESULTS_COMPLETE
           
 
Constructor Summary
ScriptStyleOpProxyHandler(MetaConnector metaConnector, Opbindings metaData, ScriptStyleOpProcessor scriptStyleOpProcessor, Logger log)
          Creates a proxy handler for executing scripts around operations targeting metaConnector.
 
Method Summary
static void debug(String message, boolean dumpStack)
          Calls debug(String, Object, boolean, int) with null Object argument.
static void debug(String message, boolean dumpStack, int pos)
          A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack and simply debug(String, Object, boolean, int) underneath.
static void debug(String message, int pos)
          A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack and simply calls debug(String, Object, boolean, int) underneath.
static void debug(String message, Object obj, boolean dumpStack)
          A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack.
static void debug(String message, Object obj, boolean dumpStack, int pos)
          A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack and simply calls debug(String, Object, boolean) underneath.
 Object invokeQueryWithOpTiming(Method method, Operation op, Object[] args, ObjectInfo objInfo, OpBindingType binding, List<String> argNames)
          Execute a single query script as a timing=OP binding.
 Object invokeQueryWithPostTiming(Method method, OpBindingMethodInfo methodInfo, Object[] args, ObjectInfo objInfo, List<OpBindingType> bindings, List<String> argNames, Object ret)
          Execute one or more bindings with timing=POST after query operations, namely POST doLookUp/Assocs() and doSearch/Assocs() make sense.
 void invokeUpdateWithTiming(Method method, Operation op, Object[] args, ObjectInfo objInfo, AttributesProxy currAttrs, Timing timing, OpBindingType binding, List<String> argNames)
           
static boolean isExecutedDirectly(OpBindingType binding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCRIPT_NAME_CONNECTOR

public static final String SCRIPT_NAME_CONNECTOR
Name by which scripts can access parent connector which they are wrapping.

See Also:
Constant Field Values

SCRIPT_NAME_STATUS_ARRAY

public static final String SCRIPT_NAME_STATUS_ARRAY
Name by which scripts can access status array, where element [0] should be filled with a description when an error is encountered.

See Also:
Constant Field Values

SCRIPT_NAME_SEARCH_RESULTS

public static final String SCRIPT_NAME_SEARCH_RESULTS
Name which should be used by scripts to record results of search request.

See Also:
Constant Field Values

SCRIPT_NAME_LOOKUP_ATTRS_RESULTS

public static final String SCRIPT_NAME_LOOKUP_ATTRS_RESULTS
Name which should be used by scripts to record results of lookup request.

See Also:
Constant Field Values

SCRIPT_NAME_SEARCH_RESULTS_BLOCKING_QUEUE

public static final String SCRIPT_NAME_SEARCH_RESULTS_BLOCKING_QUEUE
Name which should be used by scripts to queue results from asynchronously processed search requests.

See Also:
Constant Field Values

SCRIPT_NAME_CURR_ATTRS

public static final String SCRIPT_NAME_CURR_ATTRS
Name which scripts can use to access the current (pre-modify) attribute values for the target object during modify requests.

See Also:
Constant Field Values

SCRIPT_TERMINATE_STATUS

public static final String SCRIPT_TERMINATE_STATUS
Value which may be put into element [0] of SCRIPT_NAME_STATUS_ARRAY in which case script should periodically check it and exit.

See Also:
Constant Field Values

SEARCH_RESULTS_COMPLETE

public static final String SEARCH_RESULTS_COMPLETE
See Also:
Constant Field Values
Constructor Detail

ScriptStyleOpProxyHandler

public ScriptStyleOpProxyHandler(MetaConnector metaConnector,
                                 Opbindings metaData,
                                 ScriptStyleOpProcessor scriptStyleOpProcessor,
                                 Logger log)
Creates a proxy handler for executing scripts around operations targeting metaConnector.

Method Detail

debug

public static void debug(String message,
                         Object obj,
                         boolean dumpStack)
A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack.

Parameters:
message - Printed out to stderr.
obj - - obj.toString() is printed to stderr (may an object whose state you want to inspect in Java debugger).
dumpStack - - if true then stack trace is written to stderr.

debug

public static void debug(String message,
                         boolean dumpStack)
Calls debug(String, Object, boolean, int) with null Object argument.


debug

public static void debug(String message,
                         int pos)
A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack and simply calls debug(String, Object, boolean, int) underneath.

Parameters:
pos - is to make it easy to add a conditional method breakpoint at particular point of interest during execution of a script, by giving each such point of interest an identifying "pos" value.

debug

public static void debug(String message,
                         boolean dumpStack,
                         int pos)
A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack and simply debug(String, Object, boolean, int) underneath.

Parameters:
pos - is to make it easy to add a conditional method breakpoint at particular point of interest during execution of a script, by giving each such point of interest an identifying "pos" value.

debug

public static void debug(String message,
                         Object obj,
                         boolean dumpStack,
                         int pos)
A method which exists simply so it can be called from scripts and provide an easy anchor point for examining the Java stack and simply calls debug(String, Object, boolean) underneath.

Parameters:
pos - is to make it easy to add a conditional method breakpoint at particular point of interest during execution of a script, by giving each such point of interest an identifying "pos" value.

isExecutedDirectly

public static boolean isExecutedDirectly(OpBindingType binding)

invokeUpdateWithTiming

public void invokeUpdateWithTiming(Method method,
                                   Operation op,
                                   Object[] args,
                                   ObjectInfo objInfo,
                                   AttributesProxy currAttrs,
                                   Timing timing,
                                   OpBindingType binding,
                                   List<String> argNames)
                            throws NamingException
Throws:
NamingException - If entire operation associated with op binding should be terminated (got non-null error status and strict completion is true).

invokeQueryWithOpTiming

public Object invokeQueryWithOpTiming(Method method,
                                      Operation op,
                                      Object[] args,
                                      ObjectInfo objInfo,
                                      OpBindingType binding,
                                      List<String> argNames)
                               throws NamingException
Execute a single query script as a timing=OP binding. The script may choose to to return:
  1. For ease: a Map (doLookUp()) / collection of Maps (doList() and doSearch()). If maps are used then the attributes !name! and !objectclass are special.
  2. For efficiency: the script will return the exact JNDI objects returned by the do*() Java methods.
In the first case this method is responsible for converting the returned Maps to JNDI objects so that any scripts with timing=POST always see the standard object types (whether OP is implemented in Java or using script-style).

Throws:
NamingException

invokeQueryWithPostTiming

public Object invokeQueryWithPostTiming(Method method,
                                        OpBindingMethodInfo methodInfo,
                                        Object[] args,
                                        ObjectInfo objInfo,
                                        List<OpBindingType> bindings,
                                        List<String> argNames,
                                        Object ret)
                                 throws NamingException
Execute one or more bindings with timing=POST after query operations, namely POST doLookUp/Assocs() and doSearch/Assocs() make sense.

The POST doLookUp/Assocs() scripts have beans declared matching all arguments for the target methods, most importantly including an Attributes object bound to the name attrs, which they can update.

POST doSearch() scripts are given a NamingEnumeration<SearchResult> object bound to the name searchResults and can update these SearchResults and return one of:

  1. Collection<Map> (all results are "relative")
  2. Collection<SearchResult>
  3. NamingEnumeration<SearchResult>
POST handling for doSearch/Assocs() requires all the search results to be broken up into separate collections targeting each each script, so that each one is only executed once on its entire target collection instead of once per search result.

Note that use of script-style search bindings immediately removes the possibility of streamed search results.

Returns:
Original return from doLookUp() / doSearch() methods after script has optionally updated values referenced by it.
Throws:
NamingException


Created 2011-07-14 13:27 EST