org.aselect.agent.ticket
Class TicketManager

java.lang.Object
  extended by org.aselect.agent.ticket.TicketManager

public class TicketManager
extends java.lang.Object

Manages A-Select Agent tickets.

Description:
Provides methods for managing ticket:

The ticket contexts are stored using a StorageManager.

Note: This manager is implemented as a Singleton.

Concurrency issues:
-

Author:
Alfa & Ariss

Field Summary
static java.lang.String MODULE
          The module name
 
Method Summary
 java.lang.String createTicket(java.util.Hashtable htTicketContext)
          Create a Agent ticket.
static TicketManager getHandle()
          Get a static handle to the TicketManager instance.
 java.util.Hashtable getTicketContext(java.lang.String sTicket)
          Get Agent ticket context.
 java.util.Hashtable getTicketContexts()
          Get all ticket context.
 long getTicketsCounter()
          Get the number of issued tickets since startup.
 long getTicketStartTime(java.lang.String sTicket)
          Returns the ticket start time.
 long getTicketTimeout(java.lang.String sTicket)
          Returns the ticket timeout.
 boolean init()
          Initializes the TicketManager.
 void killAllTickets()
          Kill all Agent tickets.
 boolean killTicket(java.lang.String sTicket)
          Kill Agent ticket.
 void stop()
          Stop the TicketManager.
 void updateTicketContext(java.lang.String sTicket, java.util.Hashtable htTicketContext)
          Update a ticket.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULE

public static final java.lang.String MODULE
The module name

See Also:
Constant Field Values
Method Detail

getHandle

public static TicketManager getHandle()
Get a static handle to the TicketManager instance.

Description:
Checks if a static instance exists, otherwise it is created. This instance is returned.

Concurrency issues:
-

Preconditions:
-

Postconditions:
A static instance of the TicketManager exists.

Returns:
A static handle to the TicketManager

init

public boolean init()
Initializes the TicketManager.

Description:
Read configuration settings and initializes the components.

Concurrency issues:
-

Preconditions:
-

Postconditions:
The instance variables and components are initialized.

Returns:
true if initialization succeeds, otherwise false.

stop

public void stop()
Stop the TicketManager.

Description:
Destroys all current tickets.

Concurrency issues:
After this method is finished, no methods may be called in other threads.

Preconditions:
-

Postconditions:
The TicketManager has stopped.


createTicket

public java.lang.String createTicket(java.util.Hashtable htTicketContext)
Create a Agent ticket.

Description:
Create a new Agent ticket which is used as a ID for the given ticket context. Adds the given ticket context to the storage.

Concurrency issues:
-

Preconditions:
htTicketContext != null

Postconditions:
The ticket context is added to the storage.

Parameters:
htTicketContext - The ccontext to be add.
Returns:
The created ticket.

updateTicketContext

public void updateTicketContext(java.lang.String sTicket,
                                java.util.Hashtable htTicketContext)
Update a ticket.

Description:
Overwrites the new ticket context in the storage.

Concurrency issues:
-

Preconditions:
Postconditions:
The given ticket is updated with the new context.

Parameters:
sTicket - The ticket to be updated.
htTicketContext - The new ticket context.

killTicket

public boolean killTicket(java.lang.String sTicket)
Kill Agent ticket.

Description:
Remove the context of a given ticket from the storage.

Concurrency issues:
-

Preconditions:
sTicket != null

Postconditions:
The ticket context is removed from storage.

Parameters:
sTicket - The ticket to be removed.
Returns:
True if removal succeeds, otherwise false.

killAllTickets

public void killAllTickets()
Kill all Agent tickets.

Description:
Remove all ticket contexts from the storage.

Concurrency issues:
-

Preconditions:
-

Postconditions:
The ticket storage is empty.


getTicketContext

public java.util.Hashtable getTicketContext(java.lang.String sTicket)
Get Agent ticket context.

Description:
Retrieve Agent ticket context from the storage.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Parameters:
sTicket - The ticket to retrieve.
Returns:
The ticket context.

getTicketTimeout

public long getTicketTimeout(java.lang.String sTicket)
                      throws ASelectStorageException
Returns the ticket timeout.

Description:
Return the ticket timeout from the given ticket.

Concurrency issues:
-

Preconditions:
sTicket != null

Postconditions:
-

Parameters:
sTicket - the ticket.
Returns:
The expiration time of the ticket.
Throws:
ASelectStorageException - If retrieving ticket timeout fails.

getTicketStartTime

public long getTicketStartTime(java.lang.String sTicket)
                        throws ASelectStorageException
Returns the ticket start time.

Description:
Return the ticket timestamp form the given ticket.

Concurrency issues:
-

Preconditions:
sTicket != null

Postconditions:
-

Parameters:
sTicket - the ticket.
Returns:
The start time of the ticket.
Throws:
ASelectStorageException - If retrieving ticket start time fails.

getTicketContexts

public java.util.Hashtable getTicketContexts()
Get all ticket context.

Description:
Retrieve all Agent ticket contexts from the storage.

Concurrency issues:
-

Preconditions:
-

Postconditions:
-

Returns:
all Agent ticket contexts in a Hashtable.

getTicketsCounter

public long getTicketsCounter()
Get the number of issued tickets since startup.

Returns:
The number of issued Agent tickets.


Copyright © 2008 SURFnet BV. All Rights Reserved.