Database Management for Smalltalk

How to disconnect from a virtual space


Q:  “Our application kicks off with a menu where icons are clicked to invoke windows which have their own transaction to the database.  How does an application connect to a VOSS virtual space and automatically disconnect when the menu is closed?”

A:  To clarify terminology: “connecting” to a virtual space means making the image aware of its existence, requiring a pathname; “log-on” to a virtual space means opening the files in that image and registering that image’s log-on in the space’s dictionary of current accesses (using the ImageID set when VOSS is installed in the image) by the system’s private log-on transaction.  There’s no need to log-off after every transaction, but the two operations could be combined like this:

  | vom customers departments |
  [ [ vom := VOManager newForExistingSpace: ‘c:\vospaces\myspace’. “connect”
      vom isNil ifTrue: [^self].
      vom open ifFalse: [^self].                                   “log-on”
      [ customers := vom rootDictionary at: ‘customers’.
        departments := vom rootDictionary at: ‘departments’
      ] atomicReadOnly.
      …
      …
      …
    ] ensure:
      [ vom notNil ifTrue: [vom close; disconnect]]
  ] forkAt: (Processor userBackgroundPriority).

Leave a Reply