More to my problem -
if I move database opening code into the custom WebsocketListener
implementation
https://github.com/afarber/jetty-newbie/blob/master/WebsocketHandler/src/main/java/de/afarber/MyListener.java
@Override
public void onWebSocketConnect(Session session) {
Properties props = new Properties();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try (
InputStream is =
loader.getResourceAsStream("database.properties");
) {
props.load(is);
} catch (IOException ex) {
return;
}
try {
mDatabase = DriverManager.getConnection("jdbc:postgresql://
127.0.0.1/", props);
} catch (SQLException ex) {
return;
}
mName = "Client-" + ThreadLocalRandom.current().nextInt(1, 1000 +
1);
mSession = session;
sClients.put(mName, mSession);
messageAll(mName + " has connected to " + getClass().getName());
}
then the code of reading database.properties is run again and again.
I wonder if it could be run once somewhere in WebSocketServletFactory
instead - and then passed to the registered class.
Would creating a custom WebsocketCreator help here?
https://www.eclipse.org/jetty/documentation/current/jetty-websocket-server-api.html
Regards
Alex
On Sun, Jun 5, 2016 at 8:54 AM, Alexander Farber <[email protected]
> wrote:
> But actually I already have a "pool manager" - in the form of pgbouncer in
> front of my PostgreSQL server
>
>
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users