|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.boylesoftware.cb2.BLOContainer
As its name suggests, BLO container contains BLOs. BLOs never exist out of
BLO container context and the only way to access a BLO is to find first the
BLO container and then lookup the BLO in it by the BLO's deployment name.
The BL Manager creates, maintains and destroys BLO containers as user
sessions are created and destroyed. Since there is always one dedicated BLO
container corresponding to every user session, in a sense, a BLO container
is a representation of a user session in the Business Level. There is one
exception to that though - the Shared BLO Container, which is an instance of
BLOContainer
class which contains shared BLOs and does not
correspond to any particular user session. The instance of the Shared BLO
Container is maintained by the BL Manager as well.
The only way to get a BLO container for the application code is through
the BL Manager's getBLOContainer
method. The
getBLOContainer
method also locks the BLO container so no other
thread can access it until it is release by the current owner via
release
method call (or BL Manager's
releaseBLOContainer
). Because of that, all methods of this
class are absolutely not thread-safe, counting on
proper usage, which is never store references to BLO containers in your
application. Instead, you should always call BLO container's methods between
getBLOContainer
and release
calls, that is while
it is locked.
This class logs messages related to its operation under "com.boylesoftware.cb2.BLOCNR" log channel.
BLManager
,
BLObject
,
Serialized FormMethod Summary | |
BLManager |
getBLManager()
Gets the BL Manager. |
BLObject |
getBLO(java.lang.String bloName)
Gets a BLO from this container or the Shared BLO Container. |
java.lang.Object |
getSessionId()
Gets id of the user session, to which this container corresponds. |
java.security.Principal |
getUserPrincipal()
Gets currently authenticated for the session user principal set earlier by the processUserLogin call. |
boolean |
hasBLO(java.lang.String bloName)
Checks if there is a BLO under the specified name in this container or in the Shared BLO Container. |
boolean |
isShared()
Tells if this is the Shared BLO Container. |
void |
processUserLogin(java.security.Principal principal)
Notifies the BLO container about a user login event for the session. |
void |
processUserLogout()
Notifies the BLO container about a user logout event for the session. |
void |
release()
Releases this BLO container after it has been locked by the BL Manager's getBLOContainer method. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public BLObject getBLO(java.lang.String bloName)
null
instead.
bloName
- case-insensitive deployment name of a BLO.
null
if there is no
such BLO and this is the Shared BLO Container.
java.lang.IllegalArgumentException
- if there is no BLO with the specified
name and this container is not the Shared BLO Container.public boolean hasBLO(java.lang.String bloName)
bloName
- BLO's deployment name as specified in the
blo-config.xml
file.
true
if the specified BLO exists and can be
retrieved via getBLO
method.public void release() throws BLException
getBLOContainer
method. This is a convenience method, which
calls releaseBLOContainer
on the BL Manager internally. It
is often more convenient to call this method rather than the
BL Manager's, because it does not require the session id.
BLException
- if an error happens in a BLO implementing
BLOContainerStateListener
interface and it throws an
exception. Note, that the BLO container gets unlocked anyway.
java.lang.UnsupportedOperationException
- if called on the Shared BLO
Container.BLManager.releaseBLOContainer(java.lang.String)
public void processUserLogin(java.security.Principal principal) throws BLException
processUserLogin
method on all its
BLOs that implement AuthenticationListener
interface. A
transaction is started for this operation and all BLOs are called within
that one single transaction. This method checks if it has been already
successfully called earlier and no user logout happened since then. If
so, an IllegalStateException
is thrown.
Standard CB2 Presentation Level implementations, such as the one
located in com.boylesoftware.cb2.presentation.servlet
package, call this method automatically when appropriate. But if you are
implementing the presentation level yourself, you should take care of
calling this method upon each successful user login (if you care about
the notification at all).
Note also, that this method is never called on the Shared BLO
Container, because the Shared BLO Container does not correspond to any
user session. It makes impractical for shared BLOs to implement
AuthenticationListener
interface.
principal
- the pricipal, who logged in. Should not be
null
, or a IllegalArgumentException
is thrown.
BLException
- if one of the BLOs implementing
AuthenticationListener
interface threw an exception. It may
also mean that not all listeners have been notified, and it certainly
means that the trasnaction got rolled back.
java.lang.IllegalStateException
- if there is already a logged in user.AuthenticationListener
public void processUserLogout() throws BLException
processUserLogin
method, with the difference that processUserLogout
method
is called on the BLOs implementing AuthenticationListener
interface, and that it does nothing if processUserLogin
has
not been successfully called earlier.
BLException
- if one of the BLOs implementing
AuthenticationListener
interface threw an exception. It may
also mean that not all listeners have been notified, and it certainly
means that the trasnaction got rolled back.AuthenticationListener
,
processUserLogin(java.security.Principal)
public BLManager getBLManager()
public java.lang.Object getSessionId()
null
if it is the Shared BLO
Container.public java.security.Principal getUserPrincipal()
processUserLogin
call.
null
if the session is not
authenticated.public boolean isShared()
true
if this is the Shared BLO Container.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |