SosDesign

Even if there are more packages, like the utilities or unit tests, the Tideland Smalltalk Object Store has four major parts which are described here.

Core

The developer as the user of the SOS needs just three classes for his work with the system:

SosDatabase

The class SosDatabase is the single interface to the database. The instance is created with

db := SosDatabase open.

and has to be maintained at a central place if the application is multithreaded. An example would be an own application class inside a Seaside web application.

db close.

will close the database, also a shutdown of the system will close it.

SosTransaction

Transactions are handled by the class SosTransaction which is created through the command

tx := db newTransaction: userName.

.

The transaction itself will be controlled through the messages begin, commit and abort. After one of the last both the transaction is invalid, no further cleanup is necessary.

The named roots have got two keys, the first one for grouping. Be aware: both will allways be converted into their string representation. So '4711' is the same as 4711.

The messages are:

"Add an instance."

tx root: 'AllCustomers' at: customer id put: customer.

"Retrieve an instance, ifAbsent and ifAbsentPut also exist."

customer := tx root: 'AllCustomers' at: anId.

"Search instances by string pattern."

customers := tx root: 'AllCustomers' selectMatching: 'f*'.

"Enumerate."

tx root: 'AllCustomers' do: [:eachCustomer | ...].
tx root: 'AllCustomers' keysAndValuesDo: [:eachKey :eachCustomer | ...].

result := tx root: 'AllCustomers' collect: [:eachCustomer | ...].
result := tx root: 'AllCustomers' detect: [:eachCustomer | ...].
result := tx root: 'AllCustomers' select: [:eachCustomer | ...].

"Remove."

tx root: 'AllCustomers' removeAt: anId.

For simple transactions theres also a single command with an automatic commit:

noOfOrders := db
                transaction: [:tx | (tx root: 'AllCustomers' at: id) orders size]
                onError: [...].

Like for the database there's the tiny component SosTransactionTico which is the only interface to other components. The user name will be detected automaticly from other components and transactions can be nested with commit and abort for the current, all or all but the top one.

Strategies

Analyzer

Entities

last edited 2007-03-03 19:17:09 by FrankMueller