public interface SessionListener
The following events generate notifications:
SessionListener
instances are registered with the Persistence
class. They are not explicitly deregistered, but rather are
implicitly deregistered at the end of a specific scope (or possibly
earlier -- see below). A listener's scope is determined at registration
time using one of the following Scope
types.
execute
). This is meant to support listener objects
which are constructed as instance members of the business logic
object. We can get into trouble if some other, external scope is
opened between the construction of our business logic object and the
invocation of its execute()
method. This will not
happen in converted code, but it is possible in hand-written code.
There are two ways a session listener may be deregistered earlier than at end of the scopes described above:
sessionEvent(com.goldencode.p2j.persist.event.SessionListener.Event)
method returns
true
, the listener is deregistered immediately after
this method returns.
Modifier and Type | Interface and Description |
---|---|
static class |
SessionListener.Event
Type of session event
|
static class |
SessionListener.Scope
Scope of listener registration
|
Modifier and Type | Method and Description |
---|---|
void |
deregisteredSessionListener()
Invoked when a session listener is removed from the list of registered
session listeners.
|
boolean |
sessionEvent(SessionListener.Event event)
Invoked when a significant event occurs related to the current Hibernate
session or transaction.
|
boolean sessionEvent(SessionListener.Event event) throws PersistenceException
event
- Type of event.true
if this listener should be removed from the
current set of registered listeners; false
to
remain registered.PersistenceException
- if any error occurs during the implementor's processing of the
given event. If this exception is thrown, the listener will be
deregistered as if true
had been returned.void deregisteredSessionListener()
sessionEvent(com.goldencode.p2j.persist.event.SessionListener.Event)
is invoked and returns true
. It is not invoked when
deregistration occurs due to garbage collection, since the listener is
not in a position to do anything useful at that point anyway, and is no
longer referenced by business logic.