public class GbjSession extends GbjGciSession implements GbjObservable
GbjObject[ ] notifyObjs = new GbjObject[10];
notifyObjs[0] = [object I want to be notified about];
notifyObjs[1] = [object I want to be notified about];
...
notifyObjs[9] = [object I want to be notified about];
session.perform(session.kernel.System, "addToNotifySet:", notifyObjs, 10);
Set up a session observer to process notified objects when a notificationMessage of "ObjChg" is received.
Modifier and Type | Field and Description |
---|---|
GbjKernelObjects |
kernel
A collection of frequently accessed objects from the server
Globals dictionary.
|
GbjException |
lastError
lastError holds the last GbjException received from the server.
|
boolean |
monitorSessionSignals
Flag used to control if session signals should be monitored
|
boolean |
objChgNotify
Flag used to control if object change notification should be active
|
int |
pollInterval
The polling interval used to check for asynchronous signals
(sigAbort, gem-to-gem signals, changed objects).
|
Object |
toolData
toolData is for GemStone internal use
|
Object |
userData
userData is for customer use.
|
static String |
version
The version of the interface
|
gbjGciInterface, monitorChangedObjects
Constructor and Description |
---|
GbjSession() |
GbjSession(GbjParameters sessionParameters)
GbjSession() requires a sessionParameters object, which tells the
session the host and port for the connection as well as the type
of session requested
|
Modifier and Type | Method and Description |
---|---|
void |
abortTransaction()
abortTransaction() rolls back the current transaction in the database.
|
void |
addObserver(GbjObserver obs)
add an observer to the receiver
|
void |
beginTransaction()
beginTransaction() starts a new transaction in the database.
|
void |
checkConnected()
checkConnected() will throw a GbjException if the session is not in
a connected state.
|
GbjObject |
clientObject(Object o) |
void |
close()
close() closes the connection.
|
boolean |
commitAndReleaseLocks()
commitAndReleaseLocks() is like commitTransaction but any locks held
are released if the commit succeeds.
|
boolean |
commitTransaction()
commitTransaction() commits the current transaction in the database.
|
void |
connect()
connect() is usually sent soon after instantiating a session to connect
to the remote system.
|
GbjObject |
doit(String smalltalkCode)
doit() sends the given @param smalltalkCode string to the server for
compilation and execution.
|
GbjObject |
execute(String smalltalkCode)
Execute smalltalk code on the server.
|
static int |
format() |
byte[] |
getBytes(GbjObject obj,
long startIndex,
int numBytes)
Retrieve the designated bytes from this byte-based GS object.
|
String |
getName()
getName() will return an identifying description of a session.
|
GbjObject[] |
getNamedObjs(GbjObject obj,
long startIndex,
int numOops)
Retrieve the designated GS objects from the named instvars for this GS object.
|
GbjObject[] |
getObjs(GbjObject obj,
long startIndex,
int numOops)
Retrieve the designated GS objects from this indexable GS object
|
String |
getShortName()
getShortName() will return a short identifying description of a
session.
|
String |
getTransactionMode()
getTransactionMode() returns a string describing the current
transaction mode.
|
static void |
initialize(boolean useLinked,
String appName,
int bufSize,
int preloadSize,
int maxSessions)
Initializes the GbjGciInterface environment.
|
boolean |
inTransaction()
Returns true if the GemStone server has started a transaction
and false if not.
|
boolean |
isAutomaticTransactionModeSet()
isAutomaticTransactionModeSet() will return true if the server is
in automatic transaction mode and false if not.
|
boolean |
isConnected()
isConnected indicates whether the session is able to communicate with
its server.
|
void |
notifyObservers(String notificationMessage,
Object argument)
notify observers of a change
|
GbjObject |
objectNamed(String smalltalkObjectName)
objectNamed() is a name lookup service.
|
GbjObject |
perform(GbjObject receiver,
String selector,
GbjObject[] args,
int argCount)
Perform a particular smalltalk method against a particular object.
|
String |
printit(String smalltalkCode)
printit() is the same as doit(), but the message "printString" is
sent to the result and the answer of this message is returned.
|
GbjObject |
putInServer(Object obj)
Deprecated.
use GbjObject constructor
|
void |
registerAdapter(String className,
GbjClientAdapter adapter)
registerAdapter specifies an object to be used in forwarding messages
for the given Java class.
|
static void |
registerStaticAdapter(String className,
GbjClientAdapter adapter)
registerStaticAdapter specifies an object to be used in forwarding
messages for the given Java class.
|
static void |
registerStaticStub(GbjObject stubInstance,
String gemstoneClassName)
registerStaticStub allows building of a GemStone@lt-@gtJava class
correspondence at static initialization time.
|
void |
registerStub(GbjObject stubInstance,
GbjObject classStub)
registerStub allows building of a GemStone<->Java class
correspondence
at run time.
|
void |
registerStub(GbjObject stubInstance,
String gemstoneClassName)
registerStub allows building of a GemStone@lt-@gtJava class
correspondence
at run time.
|
void |
removeObserver(GbjObserver obs)
remove an observer
|
void |
rollbackTransaction()
rollbackTransaction() rolls back the current transaction in the
database.
|
void |
setAutomaticTransactionMode()
setAutomaticTransactionMode() will set the GemStone transaction mode
to automatic (chained transactions, with an implicit begin after a
commit or abort).
|
void |
setDebugOptions(boolean verboseClient,
boolean verboseServer)
Set debugging options.
|
void |
setManualTransactionMode()
setManualTransactionMode() will set the GemStone transaction mode
to manual (explicit beginTransaction required).
|
void |
setName(String newName)
setName() will assign an identifying description to a session.
|
void |
setTransactionlessMode()
setTransactionlessMode() will set the GemStone transaction mode to
transactionless transaction mode.
|
void |
setTransactionMode(String mode)
setTransactionMode() sets the transaction mode of the session.
|
void |
setupExceptionHandler(int errCode,
Object handlerObject,
String handlerMethodName)
Specify an object and method to execute when a particular
GbjException is received.
|
String |
toString()
return a description of this session.
|
checkErrors, execute, getBytes, getNamedObjs, getNamedObjs, getObjs, getObjs, getSessionId, hashCode, isKindOf, isLoggedIn, login, logout, mapGsToJavaClass, mapGsToJavaClass, objWithOop, perform, putBytes, putNamedObjs, putObjs
public GbjKernelObjects kernel
public GbjException lastError
public Object toolData
public Object userData
public boolean monitorSessionSignals
public boolean objChgNotify
public static String version
public int pollInterval
public GbjSession()
public GbjSession(GbjParameters sessionParameters)
sessionParameters
- a configured instance of GbjParameterspublic static int format()
public boolean isConnected()
public static void registerStaticStub(GbjObject stubInstance, String gemstoneClassName)
stubInstance
- an instance of the stub class
(must currently be a GbjObject)gemstoneClassName
- the name of the GemStone class,
which is found at session initialization timepublic void registerStub(GbjObject stubInstance, String gemstoneClassName) throws GbjException
stubInstance
- an instance of the stub class
(must currently be a GbjObject)gemstoneClassName
- the name of the GemStone classGbjException
- thrown if the session is not connected
or there is a server exceptionpublic void registerStub(GbjObject stubInstance, GbjObject classStub) throws GbjException
stubInstance
- an instance of the stub class
(must currently be a GbjObject)classStub
- a GbjObject stub for the server class objectGbjException
- thrown if the session is not connected
or there is a server exceptionpublic static void registerStaticAdapter(String className, GbjClientAdapter adapter)
className
- A fully qualified class name. E.g., java.util.Stackadapter
- The object that will forward messagesregisterAdapter(java.lang.String, com.gemstone.gbj.GbjClientAdapter)
public void registerAdapter(String className, GbjClientAdapter adapter)
className
- A fully qualified class name. E.g., java.util.Stackadapter
- The object that will forward messagesregisterStaticAdapter(java.lang.String, com.gemstone.gbj.GbjClientAdapter)
public static void initialize(boolean useLinked, String appName, int bufSize, int preloadSize, int maxSessions)
Calls GbjGciInterface.initialize().
useLinked
- If true, first session login is linked.
Normally, GCI sessions are logged in RPC. If the useLinked
flag is set to true, the first session will be Linked (refer to GS/S
documentation for further details on RPC/linked sessions). Default is false.appName
- Optional application name.
The name that is displayed in the GS/S session cache statistics
and statmonitor/VSD output for this gem process. For Android, the appName
is also used to help locate the GemStone libssl library, and should match
the Android application name, but with all lower-case letters.
Default is "GbjApplication".bufSize
- Maximum size (in bytes) for internal byte/oop buffers.
The maximum number of bytes that can be transfered in a single
getOops()/getNamedOops()/getBytes() operation. Exceeding this value will
trigger a GbjGciException. The value is used to allocate internal buffers
for storage during transfer.
Default is 100000.preloadSize
- Maximum size (in bytes) for initial preload of objects
When an object is initially fetched from the server, this
parameter specifies how many bytes are preloaded with the initial fetch.
These are cached, and subsequent getOops()/getNamedOops()/getBytes()
calls can retrieve their results from this cache if available. Application
developers can tune performance by sizing this as appropriate -- larger
sizes will improve the performance of subsequent getX operations at the
expense of a slower initial object fetch. 1000 bytes is a good starting value.
Default is 1000.maxSessions
- Maximum number of sessions that will be run on this Stone.
This should be equal to or greater than the setting of the stone configuration
file parameter STN_MAX_SESSIONS.
Default is 1000.for additional details.
public byte[] getBytes(GbjObject obj, long startIndex, int numBytes)
obj
- The GS object to retrieve the bytes from.startIndex
- The starting index (1-based)numBytes
- The number of bytes to retrieveGbjGciException
- thrown on any errorspublic GbjObject[] getObjs(GbjObject obj, long startIndex, int numOops)
obj
- The GS object to retrieve the GS objects from.startIndex
- The starting index (1-based)numOops
- The number of objects to retrieveGbjGciException
- thrown on any errorspublic GbjObject[] getNamedObjs(GbjObject obj, long startIndex, int numOops)
obj
- The GS object to retrieve the GS objects from.startIndex
- The starting index (1-based)numOops
- The number of objects to retrieveGbjGciException
- thrown on any errorspublic void setDebugOptions(boolean verboseClient, boolean verboseServer)
verboseClient
- display debugging information on System.out,
and notify observersverboseServer
- write debugging information to
gbj<sessionId>.log on serverpublic void connect() throws GbjException
GbjException
- thrown if there is a server exception
while connectingclose()
public void close()
connect()
public void abortTransaction() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionbeginTransaction()
,
commitTransaction()
,
commitAndReleaseLocks()
public void rollbackTransaction() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionabortTransaction()
,
beginTransaction()
,
commitTransaction()
,
commitAndReleaseLocks()
public void beginTransaction() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionabortTransaction()
,
commitTransaction()
,
commitAndReleaseLocks()
public boolean commitTransaction() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionabortTransaction()
,
beginTransaction()
,
commitAndReleaseLocks()
public boolean commitAndReleaseLocks() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionabortTransaction()
,
beginTransaction()
,
commitTransaction()
public boolean inTransaction() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionbeginTransaction()
,
setAutomaticTransactionMode()
,
setManualTransactionMode()
public void setManualTransactionMode() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionGbjParameters.transactionMode
,
setAutomaticTransactionMode()
,
setTransactionlessMode()
public void setAutomaticTransactionMode() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionGbjParameters.transactionMode
,
setManualTransactionMode()
,
setTransactionlessMode()
public void setTransactionlessMode() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionGbjParameters.transactionMode
,
setAutomaticTransactionMode()
,
setManualTransactionMode()
public boolean isAutomaticTransactionModeSet() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionpublic String getTransactionMode() throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionpublic void setTransactionMode(String mode) throws GbjException
mode
- StringGbjException
- thrown if passed an invalid transaction mode,
if the session is not connected or there is a server exception.public GbjObject objectNamed(String smalltalkObjectName) throws GbjException
objectNamed
in class GbjGciSession
smalltalkObjectName
- StringGbjException
- thrown if the session is not connected
or there is a server exceptionpublic GbjObject execute(String smalltalkCode) throws GbjException
execute
in class GbjGciSession
smalltalkCode
- String containing codeGbjException
public GbjObject perform(GbjObject receiver, String selector, GbjObject[] args, int argCount)
receiver
- GbjObject to send message againstselector
- string with method nameargs
- GbjObject array containing argumentsargCount
- number of arguments in args arraypublic GbjObject doit(String smalltalkCode) throws GbjException
smalltalkCode
- String containing codeGbjException
- thrown if the session is not connected
or there is a server exceptionpublic String printit(String smalltalkCode) throws GbjException
smalltalkCode
- String containg codeGbjException
- thrown if the session is not connected
or there is a server exceptionpublic GbjObject putInServer(Object obj) throws GbjException
obj
- Object to put on serverGbjException
- thrown if the session is not connected
or there is a server exceptionpublic String getName()
setName(java.lang.String)
public String getShortName()
public void setName(String newName)
newName
- String for namegetName()
public String toString()
public void checkConnected() throws GbjException
GbjException
- thrown if this session is not connectedpublic void addObserver(GbjObserver obs)
addObserver
in interface GbjObservable
public void removeObserver(GbjObserver obs)
removeObserver
in interface GbjObservable
public void notifyObservers(String notificationMessage, Object argument)
notifyObservers
in interface GbjObservable
public void setupExceptionHandler(int errCode, Object handlerObject, String handlerMethodName) throws NoSuchMethodException
errCode
- The int error code to be handledhandlerObject
- The designated object to handle the exceptionhandlerMethodName
- The name of the method to be called when
the exception is raisedNoSuchMethodException
- thrown if method doesn't exist