GemStone code synchronisation

Automatic code synchronisation from GT to GemStone can be configured by setting the codeSync in the GtGemStoneSessionRegistry Object subclass: #GtGemStoneSessionRegistry uses: TGtUniqueInstance instanceVariableNames: 'propertiesFile sessions announcer connectors lastSessionId defaultName defaultSession keepAlive codeSync' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-Registry' .

Currently code synchronisation must be configured manually, typically in a user startup script.

A simple configuration is:

GtGemStoneSessionRegistry default codeSync:
	(GtGemStoneCodeSync new
		defaultClassStrategy: (GtGemStoneCodeSyncSubclassClassStrategy new superclass: #GemStoneObject asClass)) start.
  

GtGemStoneCodeSync Object subclass: #GtGemStoneCodeSync uses: TGtAnnouncer instanceVariableNames: 'log events announcer sessionStrategy defaultClassStrategy subscription registry flusher' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' listens to the Epicea monitor (EpMonitor Object subclass: #EpMonitor instanceVariableNames: 'systemAnnouncer log entryReferenceByEvent jobAnnouncer announcer debugMode' classVariableNames: '' package: 'Epicea-Monitor' ) for code changes and filters by attributes of the changed class using the classStrategy, in this example any subclass of the hyperthetical GemStoneObject class. The default session strategy (GtGemStoneCodeSyncSessionStrategy Object subclass: #GtGemStoneCodeSyncSessionStrategy instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' ) forwards the changes to any session that has the codeSyncEnabled flag set in the session, which can be done through the session inspector.

An example that sets the session strategy explicitly:

GtGemStoneSessionRegistry default codeSync:
	(GtGemStoneCodeSync new
		sessionStrategy: GtGemStoneCodeSyncDefaultSessionStrategy new;
		defaultClassStrategy: (GtGemStoneCodeSyncCategoriesStrategy new categories: { 'MyGemStone*' })) start.
  

will sync changes to any class in categories (package + tag) that begin with MyGemStone to the default session.

The class strategy can be overridden for an individual session by supplying the session with its own class strategy (GtGemStoneSessionCodeSync>>#classStrategy: classStrategy: anObject classStrategy := anObject ).

Further information on the available class and session strategies is available below.

Event Strategy

After a change is made to the code and sent to the session to be synchronised with the GemStone database, the event strategy (GtGemStoneCodeSyncEpEventStrategy Object subclass: #GtGemStoneCodeSyncEpEventStrategy instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' ) determines what to do with the change.

Currently there are two event strategies:

GtGemStoneCodeSyncEpEventStrategy Object subclass: #GtGemStoneCodeSyncEpEventStrategy instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' :

synchronises method additions, modifications and removals

synchronises class additions, modifications and removals

synchronises class comments and category changes

renaming a class creates the new class but leaves the class with the old name untouched

ignores all other changes

GtGemStoneCodeSyncBasicEpEventStrategy GtGemStoneCodeSyncEpEventStrategy subclass: #GtGemStoneCodeSyncBasicEpEventStrategy instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' :

synchronises method additions, modifications and removals

ignores all other changes

Class Strategy

GtGemStoneCodeSyncCategoriesStrategy GtGemStoneCodeSyncClassStrategy subclass: #GtGemStoneCodeSyncCategoriesStrategy instanceVariableNames: 'categories' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' will sync any class that is in one of the listed categories. Categories are matched using wild card strings, e.g. GemStone-classes-* would match any category beginning with GemStone-classes-*.

GtGemStoneCodeSyncCategoriesStrategy new categories: #('GemStone-classes-*')
  

GtGemStoneCodeSyncCustomClassStrategy GtGemStoneCodeSyncClassStrategy subclass: #GtGemStoneCodeSyncCustomClassStrategy instanceVariableNames: 'valuable' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' matches the class and session using the supplied valuable, e.g. a BlockClosure Object variableSubclass: #BlockClosure instanceVariableNames: 'outerContext startpc numArgs' classVariableNames: '' package: 'Kernel-Methods' .

GtGemStoneCodeSyncCustomClassStrategy new valuable:
	[ :aClass :aGtGemStoneSessionRegistry | aClass isKindOf: #PersistentObject asClass ]
  

GtGemStoneCodeSyncExplicitClassStrategy GtGemStoneCodeSyncClassStrategy subclass: #GtGemStoneCodeSyncExplicitClassStrategy instanceVariableNames: 'classes' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' syncs only the classes in the configure list. Note that this should be used with care since renaming the class to something outside the list will cause it to no longer be synced.

GtGemStoneCodeSyncExplicitClassStrategy new classes: { #CommonClass1. #CommonClass2. }.
  

GtGemStoneCodeSyncSubclassClassStrategy GtGemStoneCodeSyncClassStrategy subclass: #GtGemStoneCodeSyncSubclassClassStrategy instanceVariableNames: 'superclass' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' syncs all subclasses of the supplied class. E.g:

GtGemStoneCodeSyncSubclassClassStrategy new superclass: #PersistentObject asClass
  

Session Strategy

GtGemStoneCodeSyncDefaultSessionStrategy GtGemStoneCodeSyncSessionStrategy subclass: #GtGemStoneCodeSyncDefaultSessionStrategy instanceVariableNames: '' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' will only sync changes to the default session in the registry.

GtGemStoneCodeSyncDefaultSessionStrategy new
  

GtGemStoneCodeSyncExplicitSessionStrategy GtGemStoneCodeSyncSessionStrategy subclass: #GtGemStoneCodeSyncExplicitSessionStrategy instanceVariableNames: 'sessions' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' will sync to all of the configured GemStone sessions.

GtGemStoneCodeSyncExplicitSessionStrategy new sessions:
	{ GtGemStoneSessionRegistry default defaultSession }
  

Committing changes

GtGemStoneCodeSync Object subclass: #GtGemStoneCodeSync uses: TGtAnnouncer instanceVariableNames: 'log events announcer sessionStrategy defaultClassStrategy subscription registry flusher' classVariableNames: '' package: 'GToolkit-GemStone-Pharo-CodeSync' never commits a transaction.