org.locomotive.loco
Class Cloudscape

java.lang.Object
  |
  +--org.locomotive.loco.Cloudscape

public class Cloudscape
extends java.lang.Object

This class provides integration of the Locomotive with Cloudscape. Each of the methods here are to be called via Cloudscape's database-side method invocation. For example, to call insertNewSession(), use the following:

      "select (CLASS org.locomotive.loco.Cloudscape).createSession(...)"
 
 

Note that the methods in this class have been abstracted from their more logical location in the User, Session, and RequestManager classes because there is some hope that someday cloudscape will be able to run in a seperate server JVM. If this is the case, then this will be the only loco class which have to be in the cloudscape server's classpath.


Constructor Summary
Cloudscape()
           
 
Method Summary
static long createSession(java.sql.Connection conn, int srid, int userid, java.sql.Timestamp expire)
          use this to create a new session.
static int createUser(java.sql.Connection conn, java.lang.String username, java.lang.String password, int loco_flags)
          use this to create a new user.
static long getNextBStampID(java.sql.Connection conn)
          gets a unique bstamp_id.
static long getNextGraffitiTagID(java.sql.Connection conn)
          gets a unique graffiti tag id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cloudscape

public Cloudscape()
Method Detail

getNextBStampID

public static long getNextBStampID(java.sql.Connection conn)
                            throws java.sql.SQLException
gets a unique bstamp_id. All this does is get the last number out of the loco_bstamp_sq table, increment by 1, update the table. and return the value. We shouldn't need to synchronize this method becauase everything is handled within a transaction, which will lock the table we're worried about. To invoke with SQL, use the following:
   SELECT (CLASS org.locomotive.loco.Cloudscape).getNextBStampID(
          GETCURRENTCONNECTION()) from LOCO_BSTAMP_SQ;
 
Returns:
a unique bstamp id

createSession

public static long createSession(java.sql.Connection conn,
                                 int srid,
                                 int userid,
                                 java.sql.Timestamp expire)
                          throws java.sql.SQLException
use this to create a new session. This shouldn't need to be synchronized because it does everything within a transaction, which will lock the LOCO_SESSIONS table anyway handles three JDBC calls:
 1. get the last session_id from session_id_sq  
 2. increment the session_id_sq
 3. insert the new session
 
Here's a sample invocation:
   SELECT (CLASS org.locomotive.loco.Cloudscape).createSession(
          GETCURRENTCONNECTION(), 12121, 1010, CURRENT_TIMESTAMP) 
          from LOCO_SESSION_SQ
 
Throws:
java.sql.SQLException - if there problems accessing or updating the data

createUser

public static int createUser(java.sql.Connection conn,
                             java.lang.String username,
                             java.lang.String password,
                             int loco_flags)
                      throws java.sql.SQLException
use this to create a new user. This shouldn't need to be synchronized because it does everything within a transaction, which will lock the LOCO_USERS table anyway handles three JDBC calls:
 1. get the last user_id from user_id_sq  
 2. increment the user_id_sq
 3. insert the new user
 
Here's an example SQL invocation:
   SELECT (CLASS org.locomotive.loco.Cloudscape).createUser(
           GETCURRENTCONNECTION(), 'username', 'password', 0)
           from LOCO_USER_SQ
 
Returns:
the user_id of the created user
Throws:
java.sql.SQLException - if there problems accessing or updating the data

getNextGraffitiTagID

public static long getNextGraffitiTagID(java.sql.Connection conn)
                                 throws java.sql.SQLException
gets a unique graffiti tag id. All this does is get the last number out of the loco_graffiti_tag_sq table, increment by 1, update the table. and return the value. We shouldn't need to synchronize this method becauase everything is handled within a transaction, which will lock the table we're worried about. To invoke with SQL, use the following:
   SELECT (CLASS org.locomotive.loco.Cloudscape).getNextGraffitiTagID(
          GETCURRENTCONNECTION()) from LOCO_GRAFFITI_TAG_SQ;
 
Returns:
a unique bstamp id