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

Quick Search    Search Deep

proxy.protocol
Class ProxyRequestManager  view ProxyRequestManager download ProxyRequestManager.java

java.lang.Object
  extended byjava.lang.Thread
      extended byproxy.protocol.ProxyRequestManager
All Implemented Interfaces:
mobile.bearer.http.Protocol, java.lang.Runnable

public class ProxyRequestManager
extends java.lang.Thread
implements mobile.bearer.http.Protocol

This class provides an implementation of a thread which manages requests comming from mobile devices. The request are received in the order of their ids. The receipt protocol ensures that no request is lost and that they come in the desired order.

The requests are stored in a queue and processed sequentially. For each request the appropriate action associated with this request is executed and a reply is generated. The reply is then added to the reply queue. The reply queue is emptied by the replier thread which send the replies to the mobile device using the bearer layer.


Nested Class Summary
private  class ProxyRequestManager.Receiver
           
private  class ProxyRequestManager.Replier
           
 
Nested classes inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.util.Hashtable currentIds
           For each mobile contains a hash table mapping the id of the last request which was received from an application.
private  proxy.jmsapi.JMSObjectManager manager
          
private static int MESSAGES_PER_PACK
           
private  ProxyRequestManager.Replier replier
           
private  java.util.LinkedList replyQueue
          
private  java.util.LinkedList requestQueue
          
private  proxy.bearer.http.TalkingWithMobiles talking
          
private  java.util.Hashtable waiting
           For each mobile contains a sorted collection of waiting requests which couldn't have been processed because a previous request was missing
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface mobile.bearer.http.Protocol
ACKNOWLEDGE_MESSAGE, CLOSE_CONNECTION, CLOSE_MESSAGE_CONSUMER, CLOSE_MESSAGE_PRODUCER, COMMIT, CREATE_CONNECTION, CREATE_DURABLE_CONSUMER, CREATE_DURABLE_TOPIC_SUBSCRIBER, CREATE_QUEUE_CONNECTION, CREATE_QUEUE_RECEIVER, CREATE_QUEUE_SENDER, CREATE_QUEUE_SESSION, CREATE_RECEIVER, CREATE_SENDER, CREATE_SESSION, CREATE_TEMPORARY_DESTINATION, CREATE_TEMPORARY_QUEUE, CREATE_TEMPORARY_TOPIC, CREATE_TOPIC_CONNECTION, CREATE_TOPIC_PUBLISHER, CREATE_TOPIC_SESSION, CREATE_TOPIC_SUBSCRIBER, DELETE_TEMPORARY_DESTINATION, DELETE_TEMPORARY_QUEUE, DELETE_TEMPORARY_TOPIC, EXC_INVALID_DESTINATION, EXC_NAMING, EXC_OTHER, EXC_RESOURCE_ALLOCATION, INT_LEN, LONG_LEN, LOOKUP, MAX_BYTES_LEN, PUBLISH_BYTES_MESSAGE, PUBLISH_TEXT_MESSAGE, QUEUE, RECEIVE_MESSAGE, RECEIVE_MESSAGE_FROM_QUEUE, RECEIVE_MESSAGE_FROM_TOPIC, RECEIVE_MESSAGE_TIMEOUT, REP_BYTES_MESSAGE, REP_BYTES_MESSAGE_FROM_QUEUE, REP_BYTES_MESSAGE_FROM_TOPIC, REP_CONNECTION, REP_CONNECTION_FACTORY, REP_DURABLE_TOPIC_SUBSCRIBER, REP_QUEUE, REP_QUEUE_CONNECTION, REP_QUEUE_CONNECTION_FACTORY, REP_QUEUE_RECEIVER, REP_QUEUE_SENDER, REP_QUEUE_SESSION, REP_RECEIVER, REP_SENDER, REP_SESSION, REP_TEMPORARY_DESTINATION, REP_TEMPORARY_QUEUE, REP_TEMPORARY_TOPIC, REP_TEXT_MESSAGE, REP_TEXT_MESSAGE_FROM_QUEUE, REP_TEXT_MESSAGE_FROM_TOPIC, REP_TOPIC, REP_TOPIC_CONNECTION, REP_TOPIC_CONNECTION_FACTORY, REP_TOPIC_PUBLISHER, REP_TOPIC_SESSION, REP_TOPIC_SUBSCRIBER, ROLLBACK, SEND_BYTES_MESSAGE, SEND_TEXT_MESSAGE, START_CONNECTION, STOP_CONNECTION, TEMPRORARY, TOPIC
 
Constructor Summary
ProxyRequestManager()
           Initializes the queues and starts the main thread.
 
Method Summary
private  Reply handleExc(Request req, int type, java.lang.String name)
           
private  Reply handleRequest(Request req)
           
private  void log(java.lang.String msg)
          adds the message to the server logs - for debugging
 void processReply(Reply rep)
           Adds the reply to the reply queue.
 void processRequest(Request req)
           Receives the next request, acknowledges its receipt and adds it to the request queue.
 void run()
           The main thread.
 void setObjectManager(proxy.jmsapi.JMSObjectManager _om)
           
 void setTalkingWithMobiles(proxy.bearer.http.TalkingWithMobiles _twm)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentIds

private java.util.Hashtable currentIds

For each mobile contains a hash table mapping the id of the last request which was received from an application. Thus the hash table has two levels - the first one mapping the mobile nr to the second hash table and the second mapping the owner id to the last request id.


waiting

private java.util.Hashtable waiting

For each mobile contains a sorted collection of waiting requests which couldn't have been processed because a previous request was missing


talking

private proxy.bearer.http.TalkingWithMobiles talking


manager

private proxy.jmsapi.JMSObjectManager manager


MESSAGES_PER_PACK

private static final int MESSAGES_PER_PACK
See Also:
Constant Field Values

replier

private ProxyRequestManager.Replier replier

requestQueue

private java.util.LinkedList requestQueue


replyQueue

private java.util.LinkedList replyQueue

Constructor Detail

ProxyRequestManager

public ProxyRequestManager()

Initializes the queues and starts the main thread.

Method Detail

setTalkingWithMobiles

public void setTalkingWithMobiles(proxy.bearer.http.TalkingWithMobiles _twm)

setObjectManager

public void setObjectManager(proxy.jmsapi.JMSObjectManager _om)

log

private void log(java.lang.String msg)
adds the message to the server logs - for debugging


processRequest

public void processRequest(Request req)

Receives the next request, acknowledges its receipt and adds it to the request queue. Provides that the requests are added to the queue in the desired order and that no request is lost.


processReply

public void processReply(Reply rep)

Adds the reply to the reply queue.


handleExc

private Reply handleExc(Request req,
                        int type,
                        java.lang.String name)

handleRequest

private Reply handleRequest(Request req)

run

public void run()

The main thread. It takes the next request from the request queue and executes the action associated with it. The action generates a reply, which is handled by the processReply method.

Specified by:
run in interface java.lang.Runnable