Skip to content

Commit

Permalink
Adding cleanUp for MolAnnouncements
Browse files Browse the repository at this point in the history
  • Loading branch information
ELePors committed Jun 25, 2024
1 parent 5c324a0 commit c5e77e6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Molecule-Tests/MolComponentManagerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ MolComponentManagerTest >> testCleanUp [

]

{ #category : #tests }
MolComponentManagerTest >> testCleanUpAnnouncements [
| announcement list selection |
announcement := nil.
SystemAnnouncer uniqueInstance when: MolComponentInstanciated do:[ :a | announcement := a ].
SystemAnnouncer uniqueInstance when: MolComponentPassivated do:[ :a | announcement := a ].
SystemAnnouncer uniqueInstance when: MolComponentInstanciated do:[ :a | announcement := a ].
list := MolAnnouncement withAllSubclasses.
selection := SystemAnnouncer uniqueInstance subscriptions subscriptions select: [ :e | list includes: e announcementClass] .
self assert: (selection size > 0).
MolComponentManager cleanupMolAnnouncements.
selection := SystemAnnouncer uniqueInstance subscriptions subscriptions select: [ :e | list includes: e announcementClass] .
self assert: (selection size = 0).

]

{ #category : #'tests - general' }
MolComponentManagerTest >> testCleanUpIgnoreErrors [
"Start a manuel tree of components and clean up, components are removed during the cleanUp but some componentRemove methods should remove again an already removed component : a error is reach but ignored during a cleanUp"
Expand Down
18 changes: 18 additions & 0 deletions src/Molecule/MolComponentManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ MolComponentManager class >> cleanUp [
notifiers do: [ :n | n release ].
subscribers do: [ :n | n release ].

self cleanupMolAnnouncements.

MolUtils log: 'End of the cleanUp.'
]

Expand All @@ -57,6 +59,14 @@ MolComponentManager class >> cleanUp: aBoolean [
self deepCleanUp.
]

{ #category : #cleanup }
MolComponentManager class >> cleanupMolAnnouncements [
<script>
| registeredList |
registeredList := SystemAnnouncer uniqueInstance subscriptions subscriptions select: [ :e | self isMolAnnoucement: e announcementClass ].
registeredList do: [ :r | SystemAnnouncer uniqueInstance subscriptions remove: r].
]

{ #category : #cleanup }
MolComponentManager class >> deepCleanUp [

Expand Down Expand Up @@ -142,6 +152,14 @@ MolComponentManager class >> isInitialized [
^ Default notNil
]

{ #category : #cleanup }
MolComponentManager class >> isMolAnnoucement: aClass [

MolAnnouncement withAllSubclasses do: [ :a |
a = aClass ifTrue: [ ^ true ] ].
^ false
]

{ #category : #'initialize-release' }
MolComponentManager class >> isRunningComponents [
<script:'self isRunningComponents inspect'>
Expand Down

0 comments on commit c5e77e6

Please sign in to comment.