Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.presumo.jms.selector
Class Parser  view Parser download Parser.java

java.lang.Object
  extended bycom.presumo.jms.selector.Parser

public final class Parser
extends java.lang.Object

Access point to the filter functionality for the rest of the JMS implementation. This class (along with every other class in this package) is on the critical path for message throughput performance. Thus it is, and must remain optimized. Parser is a singleton instead of a series of static methods because I read somewhere that instance methods are faster than static methods (never personally verified this). The class is thread safe, but to prevent the routing thread from having to obtain a lock for every evaluation, a thread can obtain the lock once and call several evaluations before releasing the lock.


Field Summary
private  java.lang.Thread lockOwner
           
private static com.presumo.util.log.Logger logger
           
private static Parser onlyInstance
           
 
Constructor Summary
protected Parser()
           
 
Method Summary
 JmsOperand andTogether(JmsOperand lv, JmsOperand rv)
          Logically and's together two trees.
 void delete(JmsOperand root)
           
 boolean evaluate(JmsOperand root, javax.jms.Message msg)
          Must be used in conjunction with resetEvaluateOnce().
static Parser getInstance()
           
 void obtainLock()
          Called to obtain the mutex lock for the current thread.
 JmsOperand orTogether(JmsOperand[] roots)
          Logically or's together the trees The returned expression tree must be deleted
 JmsOperand parseFilter(java.lang.String filter)
          Parse the filter and return a JmsOperand representing the root node of the filter's expression tree.
 void releaseLock()
          Called to release the mutex lock held for this parser instance
 void resetEvaluateOnce()
          The evaluate() method stores information about its last evaluation.
 java.lang.String unparse(JmsOperand root)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

onlyInstance

private static Parser onlyInstance

lockOwner

private java.lang.Thread lockOwner

logger

private static com.presumo.util.log.Logger logger
Constructor Detail

Parser

protected Parser()
Method Detail

getInstance

public static Parser getInstance()

obtainLock

public void obtainLock()
Called to obtain the mutex lock for the current thread. ReleaseLock() must be called by the same thread.


releaseLock

public void releaseLock()
Called to release the mutex lock held for this parser instance


resetEvaluateOnce

public void resetEvaluateOnce()
The evaluate() method stores information about its last evaluation. This is combined with the fact that all logically equivelant JMS filters in a JVM are represented by the same instance of JmsOperand represents a signficant optimization. The filtering is used by ONLY the routing thread for evaluation, and for every message the thread has to deliver this method is called. Then for every filter the routing thread needs to check the message against the evaluate() method is called. If any sql expressions (or subexpressions!!) are duplicated in the filters, they will only be evaluated once.


evaluate

public boolean evaluate(JmsOperand root,
                        javax.jms.Message msg)
Must be used in conjunction with resetEvaluateOnce().


parseFilter

public JmsOperand parseFilter(java.lang.String filter)
                       throws javax.jms.InvalidSelectorException
Parse the filter and return a JmsOperand representing the root node of the filter's expression tree.


unparse

public java.lang.String unparse(JmsOperand root)

andTogether

public JmsOperand andTogether(JmsOperand lv,
                              JmsOperand rv)
Logically and's together two trees. The returned expression tree must be deleted.


orTogether

public JmsOperand orTogether(JmsOperand[] roots)
Logically or's together the trees The returned expression tree must be deleted


delete

public void delete(JmsOperand root)