public class SessionPool extends Object
Constructor and Description |
---|
SessionPool(SessionFactory factory,
int size) |
Modifier and Type | Method and Description |
---|---|
Session |
acquire()
Take a session from the pool.
|
void |
close()
Close the pool and all sessions associated with it.
|
void |
release(Session s)
Release a session back to the pool.
|
int |
size()
Returns the amount of sessions currently on the pool.
|
public SessionPool(SessionFactory factory, int size)
factory
- SessionFactory instance used to create new sessions.size
- Amount of sessions to pre-allocate.public Session acquire() throws InterruptedException, IOException
InterruptedException
IOException
public void release(Session s) throws InterruptedException
s
- Session previously acquired from the poolInterruptedException
public int size()
public void close() throws IOException
IOException
Copyright © 2021. All rights reserved.