com.ibm.redback.redbeans
Class RedObject

java.lang.Object
  |
  +--com.ibm.redback.redbeans.RedObject

public class RedObject
extends java.lang.Object

The RedObject class is the main manager class and is created to represent a RBO class instance on the client. It calls RBO Server methods on behalf of it's client and may store all state for that RBO class. Note that if used within a J2EE server and accessed using stateless beans, the RedObject could be reused from a pool and the state will therefore need to be passed in.


Field Summary
static java.lang.String GETALLDELIM
           
static java.lang.String RBSRVREL
           
static java.lang.String RECDELIM
           
 
Constructor Summary
RedObject()
          Creates instance without reference to connection or RBOClass.
RedObject(Connection activeConnection, java.lang.String RBOClass)
          Creates instance and associates current connection details and RBOClass
RedObject(java.lang.String RBOAccount, java.lang.String RBOClass)
          Creates instance and associates current connection details and RBOClass
 
Method Summary
 void addDebugListener(RbEventListener l)
          Register an objects interest in receiving debug events
 RecordSet callMethod(java.lang.String methodName)
          Will call the specified method for the current RBO.
 RecordSet callRPC(java.lang.String methodName, java.lang.String param1, java.lang.String param2)
          calls RPC method within the RBO server
protected  void fireRbDebugEvent(java.lang.String sval)
          Fire off a new RbEvent to notify listeners of a new 'debug' string message.
 Connection getActiveConnection()
           
static char getAM()
           
protected  java.util.Vector getDispFields()
          Gets all the display fileds
protected  java.lang.String getEncode(java.lang.String val)
          get query strings with "+" for a " " don't get encoded in redback app server
 java.lang.String getHiddenField(java.lang.String fldName)
           
 java.lang.String getHidFields()
          Get non-null hidden-field values and return as a string in the format 'name=value&name=value ..etc'
 RbException getLastRbe()
          used by Servlets and Threadpools as exception cannot be thrown by runnable run() set and get via RBRunnable, API routines, not set by RedObject
 java.lang.String getModule()
          Gets the module name.
 java.util.Hashtable getMonitorData()
          Gets 'shallow clone' of the contents of monitor data.
 java.lang.String getPassword()
          Gets current password.
 java.lang.String getPostedReply()
          Get the last posted repaly.
 java.lang.String getPostedString()
          Gets the last posted String.
protected  java.lang.String getPostURL(java.lang.String methodName)
           
 java.lang.String getProperty(java.lang.String propertyName)
          Get current value for a given property name.
 java.util.Vector getPropertyNames()
          Gets the current RBO property names.
 java.util.Vector getPropertyValues()
           
 java.lang.String getRBOAccount()
           
 java.lang.String getRBOClass()
           
 java.lang.String getRBOHandle()
           
 RecordSet getRecordSet()
           
 java.lang.String getRPCResponse()
           
 java.lang.String getServerAlert()
           
 java.lang.String getSessionId()
           
 java.lang.String getSessionUserId()
          Deprecated. no longer required. You should either use getSessionId() or getRBOHandle()
static char getSVM()
           
 java.lang.String getURLAccountName()
           
 java.lang.String getUserId()
           
static char getVM()
           
 boolean hasIsHttp()
           
 boolean isDebugOn()
           
 boolean isInApplet()
          Deprecated. will now always return false
 boolean isMonitorOn()
           
 void open()
          Open the RBOClass, which will create an instance for it.
 void open(java.lang.String urlAccount)
          calls open method and does not require a connection object to be created
 void open(java.lang.String userId, java.lang.String password)
          Will create RPLOGIN and check user id and password.
protected  java.lang.String postRequest(java.lang.String urlString, java.lang.String postString)
          used to perform a POST
 java.util.Vector refresh(java.lang.String handle)
          Will refresh this instance with RBO Server state for the required session as determined by the handle passed.
 java.util.Vector refresh(java.lang.String sessionId, java.lang.String sessionUserId)
          Deprecated. as refresh now only requires the RBOHandle
 void removeDebugListener(RbEventListener l)
          Remove an object from list of those interested in receiving debug events
 void setActiveConnection(Connection activeConnection)
          Sets the current connection instance
static void setAM(char newAM)
          sets the AM character, only really required if the AM character is not the default 254
 void setDebugOn(boolean flag)
          Determines whether debug is on or off
protected  void setDispFields(java.lang.String newValue)
          Set the internal dispFields class attribute to the passed in value
protected  void setHiddenField(java.lang.String fldname, java.lang.String value)
          Set a hidden-field value for a specified 'name'.
protected  void setHidFields(java.lang.String serverReply)
          sets Hidden fields from a Server reply
 void setInApplet(boolean flag)
          Deprecated.  
 void setLastRbe(RbException rbe)
           
 void setMonitorOn(boolean flag)
           
 void setProperty(java.lang.String propertyName, java.lang.String value)
          Set current value for a given property name.
 void setPropertyNames(java.util.Vector propNames)
          sets the current property names
 void setPropertyValues(java.util.Vector propVals)
          sets the current property values, values must match position dictated by the property names
 void setRBOAccount(java.lang.String RBOAccount)
          Sets RBO Account to connect to.
 void setRBOClass(java.lang.String RBOClass)
          Sets the current RBO class name, can also be set when creating instance of this class
 void setRBOHandle(java.lang.String handle)
          Sets the current RBOHandle details for the current RBO.
 void setRecordSet(RecordSet recordSet)
           
 void setSessionId(java.lang.String sessionId)
          If this RedObject is to pick up an existing session id then you can set it using this method.
 void setSessionUserId(java.lang.String userId)
          Deprecated. no longer required.
static void setSVM(char newSVM)
          sets the current SVM character, only required of not the default of 252
 void setURLAccount(java.lang.String urlAccountName)
          sets the URL/accountname or account name (if using jni gateway) for this rbo instance
static void setVM(char newVM)
          sets the current VM character, only required of not the default of 253
 java.lang.String URLDecode(java.lang.String str)
          This method decodes the given urlencoded string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GETALLDELIM

public static final java.lang.String GETALLDELIM

RECDELIM

public static final java.lang.String RECDELIM

RBSRVREL

public static final java.lang.String RBSRVREL
Constructor Detail

RedObject

public RedObject()
Creates instance without reference to connection or RBOClass.

RedObject

public RedObject(Connection activeConnection,
                 java.lang.String RBOClass)
Creates instance and associates current connection details and RBOClass
Parameters:
activeConnection - the Connection class that contains the URL to connect
RBOClass - the class (module:classname) to create an instance of that RBOClass

RedObject

public RedObject(java.lang.String RBOAccount,
                 java.lang.String RBOClass)
Creates instance and associates current connection details and RBOClass
Parameters:
RBOAccount - the RBO Account to connect to
RBOClass - the class (module:classname) to create an instance of that RBOClass
Method Detail

setRBOAccount

public void setRBOAccount(java.lang.String RBOAccount)
Sets RBO Account to connect to. This is an alternative to creating a connection object and using setActiveConnection method
Parameters:
RBO - account to connect to

getRBOAccount

public java.lang.String getRBOAccount()

addDebugListener

public void addDebugListener(RbEventListener l)
Register an objects interest in receiving debug events

callMethod

public RecordSet callMethod(java.lang.String methodName)
                     throws RbException
Will call the specified method for the current RBO. The method call takes place on the RBO Server

callRPC

public RecordSet callRPC(java.lang.String methodName,
                         java.lang.String param1,
                         java.lang.String param2)
                  throws RbException
calls RPC method within the RBO server
Parameters:
methodName - is the method to call
param1 - is first parameter
param2 - is the second parameter

fireRbDebugEvent

protected void fireRbDebugEvent(java.lang.String sval)
Fire off a new RbEvent to notify listeners of a new 'debug' string message.

getActiveConnection

public Connection getActiveConnection()

getAM

public static char getAM()

getDispFields

protected java.util.Vector getDispFields()
Gets all the display fileds

getEncode

protected java.lang.String getEncode(java.lang.String val)
get query strings with "+" for a " " don't get encoded in redback app server

getHiddenField

public java.lang.String getHiddenField(java.lang.String fldName)
Parameters:
fldName - the hidden field name

getHidFields

public java.lang.String getHidFields()
Get non-null hidden-field values and return as a string in the format 'name=value&name=value ..etc'

getLastRbe

public RbException getLastRbe()
used by Servlets and Threadpools as exception cannot be thrown by runnable run() set and get via RBRunnable, API routines, not set by RedObject

getModule

public java.lang.String getModule()
Gets the module name.

getMonitorData

public java.util.Hashtable getMonitorData()
Gets 'shallow clone' of the contents of monitor data.

getPassword

public java.lang.String getPassword()
Gets current password.

getPostedReply

public java.lang.String getPostedReply()
Get the last posted repaly.

getPostedString

public java.lang.String getPostedString()
Gets the last posted String.

getPostURL

protected java.lang.String getPostURL(java.lang.String methodName)

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
Get current value for a given property name. This is the value as set by the last server call - not the value that may be held in a redbean associated with the specified propertyName
Parameters:
propertyname - the name of the property whose value should be returned

getPropertyNames

public java.util.Vector getPropertyNames()
Gets the current RBO property names.

getPropertyValues

public java.util.Vector getPropertyValues()

getRBOClass

public java.lang.String getRBOClass()

getRecordSet

public RecordSet getRecordSet()

getRPCResponse

public java.lang.String getRPCResponse()

getServerAlert

public java.lang.String getServerAlert()

getRBOHandle

public java.lang.String getRBOHandle()

setRBOHandle

public void setRBOHandle(java.lang.String handle)
Sets the current RBOHandle details for the current RBO. This is the handle generated by the RBO server and can be used later to refresh a RedObject with data from the RBO Server and to also associate other RedObjects with the current session
Parameters:
handle - the current handle, as returned by a previous call to getRBOHandle()

getSessionId

public java.lang.String getSessionId()

getSessionUserId

public java.lang.String getSessionUserId()
Deprecated. no longer required. You should either use getSessionId() or getRBOHandle()


getSVM

public static char getSVM()

getURLAccountName

public java.lang.String getURLAccountName()

getUserId

public java.lang.String getUserId()

getVM

public static char getVM()

hasIsHttp

public boolean hasIsHttp()

isDebugOn

public boolean isDebugOn()

isInApplet

public boolean isInApplet()
Deprecated. will now always return false


isMonitorOn

public boolean isMonitorOn()

open

public void open()
          throws RbException
Open the RBOClass, which will create an instance for it. Initial values for the RBOClass will be passed back to this RedObject instance
Throws:
RbException - thrown if open cannot take place. Can be a connection error, redbeans error or server error

open

public void open(java.lang.String urlAccount)
          throws RbException
calls open method and does not require a connection object to be created
Parameters:
urlAccount - the URL/accountname or account name (if using jni gateway) to connect to rbo class

open

public void open(java.lang.String userId,
                 java.lang.String password)
          throws RbException
Will create RPLOGIN and check user id and password. Used by RBOScope when accessing rboexplorer class Not used by applications other than the RedBack RBOScope

postRequest

protected java.lang.String postRequest(java.lang.String urlString,
                                       java.lang.String postString)
                                throws RbException
used to perform a POST
Parameters:
urlString - the url to POST to
postString - the string to POST

refresh

public java.util.Vector refresh(java.lang.String handle)
                         throws RbException
Will refresh this instance with RBO Server state for the required session as determined by the handle passed. The session details are passed in to identify the specific session. If the current session details are the same as the ones passed in then the object will just return the current property values. If the session details are different then a request will made to the RBO server to get the requested information
Parameters:
handle - which would have been objtained using the getRBOHandle() method

refresh

public java.util.Vector refresh(java.lang.String sessionId,
                                java.lang.String sessionUserId)
                         throws RbException
Deprecated. as refresh now only requires the RBOHandle

USED PRIOR TO RELEASE 4.1 RedBack!! Will refresh this instance with state information for the required session details The session details are passed in to identify the specific session. If the current session details are the same as the ones passed in then the object will just return the current property values. If the session details are different then a request will made to the RBO server to get the requested information
Parameters:
session - ID
session - User ID
See Also:
refresh(String RBOHandle)

removeDebugListener

public void removeDebugListener(RbEventListener l)
Remove an object from list of those interested in receiving debug events

setActiveConnection

public void setActiveConnection(Connection activeConnection)
Sets the current connection instance
Parameters:
activeConnection - the current Connection instance

setAM

public static void setAM(char newAM)
sets the AM character, only really required if the AM character is not the default 254
Parameters:
newAM - the AM character

setDebugOn

public void setDebugOn(boolean flag)
Determines whether debug is on or off
Parameters:
flag - if true then RbEvent will be fired each time debug information is available.

setDispFields

protected void setDispFields(java.lang.String newValue)
Set the internal dispFields class attribute to the passed in value
Parameters:
newValue - - list of display fields names, each separated by a space.

setHiddenField

protected void setHiddenField(java.lang.String fldname,
                              java.lang.String value)
                       throws RbException
Set a hidden-field value for a specified 'name'. Used by RedBeans so care should be taken if setting a hidden field within an application
Parameters:
fldName - the name of the hidden field
value - the value to set
Throws:
RbException - thrown if the hidden field is not found

setHidFields

protected void setHidFields(java.lang.String serverReply)
                     throws RbException
sets Hidden fields from a Server reply

setInApplet

public void setInApplet(boolean flag)
Deprecated.  


setLastRbe

public void setLastRbe(RbException rbe)
Parameters:
last - RbException thrown used by Servlets and Threadpools as exception cannot be thrown by runnable run() set and get via RBRunnable, API routines, not set by RedObject

setMonitorOn

public void setMonitorOn(boolean flag)
Parameters:
flag - to specify whether or not the performance monitor should be switched on/off

setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.String value)
Set current value for a given property name.
Parameters:
propertyName - relates to a property defined in the RBO
value - the current value of the property

setPropertyNames

public void setPropertyNames(java.util.Vector propNames)
sets the current property names
Parameters:
propNames - the property names

setPropertyValues

public void setPropertyValues(java.util.Vector propVals)
sets the current property values, values must match position dictated by the property names
Parameters:
propVals, - the property values to set

setRBOClass

public void setRBOClass(java.lang.String RBOClass)
Sets the current RBO class name, can also be set when creating instance of this class
Parameters:
RBOClass - the RBO class (module:classname)

setRecordSet

public void setRecordSet(RecordSet recordSet)
Parameters:
recordSet - sets the current recordset (can be null)

setSessionId

public void setSessionId(java.lang.String sessionId)
If this RedObject is to pick up an existing session id then you can set it using this method. If the client maintains a handle to this instance and the instance is not shared by other clients, then the session details will be stored and active within this instance. You would not therefore need to store session details and pass them in using this method. If your client does not store this instance and either recreates the RedObject when required, or the object instance is shared by clients, then you will need to set the session id (and session user id). In this way, previous state for the session will be maintained.

setSessionUserId

public void setSessionUserId(java.lang.String userId)
Deprecated. no longer required.


setSVM

public static void setSVM(char newSVM)
sets the current SVM character, only required of not the default of 252
Parameters:
the - current SVM characger

setURLAccount

public void setURLAccount(java.lang.String urlAccountName)
sets the URL/accountname or account name (if using jni gateway) for this rbo instance

setVM

public static void setVM(char newVM)
sets the current VM character, only required of not the default of 253
Parameters:
the - current VM characger

URLDecode

public java.lang.String URLDecode(java.lang.String str)
                           throws RbException
This method decodes the given urlencoded string.
Parameters:
str - the url-encoded string
Returns:
the decoded string
Throws:
ParseException - If a '%' is not followed by a valid 2-digit hex number.