public class GbjSession extends GbjGciSession implements GbjObservable
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
|
static 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) |
String |
getName()
getName() will return an identifying description of a session.
|
GbjObject[] |
getNamedObjs(GbjObject obj,
long startIndex,
int numOops) |
GbjObject[] |
getObjs(GbjObject obj,
long startIndex,
int numOops) |
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)
Calls GbjGciInterface.initialize().
|
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<->Java 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<->Java 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 static String version
public static 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)
for details.
public byte[] getBytes(GbjObject obj, long startIndex, int numBytes)
public void setDebugOptions(boolean verboseClient, boolean verboseServer)
verboseClient
- display debugging information on System.out,
and notify observersverboseServer
- write debugging information to
gbjpublic 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
GbjException
- 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
GbjException
- thrown if the session is not connected
or there is a server exceptionpublic GbjObject execute(String smalltalkCode) throws GbjException
execute
in class GbjGciSession
smalltalkCode
- The Smalltalk string to execute.GbjException
public GbjObject perform(GbjObject receiver, String selector, GbjObject[] args, int argCount)
public GbjObject doit(String smalltalkCode) throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionpublic String printit(String smalltalkCode) throws GbjException
GbjException
- thrown if the session is not connected
or there is a server exceptionpublic GbjObject putInServer(Object obj) throws GbjException
GbjException
- 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)
getName()
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