-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add listener for session changes to ensure the cache is updated as th…
…e scope entries change
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/ortus/boxlang/runtime/types/listeners/SessionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ortus.boxlang.runtime.types.listeners; | ||
|
||
import ortus.boxlang.runtime.application.Session; | ||
import ortus.boxlang.runtime.scopes.Key; | ||
|
||
public class SessionListener { | ||
|
||
private final Session session; | ||
|
||
public SessionListener( Session session ) { | ||
this.session = session; | ||
} | ||
|
||
/** | ||
* Call when a value is being changed in an IListenable | ||
* | ||
* @param key The key of the value being changed. For arrays, the key will be 1-based | ||
* @param newValue The new value (null if being removed) | ||
* @param oldValue The old value (null if being added) | ||
* | ||
* @return The new value to be set (you can override) | ||
*/ | ||
public Object notify( Key key, Object newValue, Object oldValue ) { | ||
this.session.getApplication().getSessionsCache().set( this.session.getID().getName(), this.session ); | ||
return null; | ||
} | ||
|
||
} |