-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide a session listener callback interface (#3460)
Fixes #3457
- Loading branch information
Showing
7 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
server/src/main/java/io/deephaven/server/session/DelegatingSessionListener.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,30 @@ | ||
package io.deephaven.server.session; | ||
|
||
import io.deephaven.internal.log.LoggerFactory; | ||
import io.deephaven.io.logger.Logger; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Utility class to fan out session events to multiple handlers. | ||
*/ | ||
public class DelegatingSessionListener implements SessionListener { | ||
private static final Logger log = LoggerFactory.getLogger(DelegatingSessionListener.class); | ||
private final Collection<SessionListener> sessionListeners; | ||
|
||
public DelegatingSessionListener(Collection<SessionListener> sessionListeners) { | ||
this.sessionListeners = sessionListeners; | ||
} | ||
|
||
@Override | ||
public void onSessionCreate(SessionState session) { | ||
for (SessionListener listener : sessionListeners) { | ||
try { | ||
listener.onSessionCreate(session); | ||
} catch (Exception e) { | ||
log.error().append("Error invoking session listener ").append(listener.getClass().getName()).append(e) | ||
.endl(); | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
server/src/main/java/io/deephaven/server/session/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,16 @@ | ||
package io.deephaven.server.session; | ||
|
||
/** | ||
* Callbacks for the SessionService, to observe session lifecycles. | ||
*/ | ||
public interface SessionListener { | ||
/** | ||
* When a new session is created and has been given a refresh token, this will be invoked. | ||
* <p> | ||
* </p> | ||
* To track a session closing, use {@link SessionState#addOnCloseCallback(java.io.Closeable)}. | ||
* | ||
* @param session the newly created session | ||
*/ | ||
void onSessionCreate(SessionState session); | ||
} |
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
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
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
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
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