|
A session in Nirvana represents a logical
connection to a Nirvana Realm. It consists of
a set of session attributes, such as the protocol
and authentication mechanism to be used, the host
and port the message server is running on and
a reconnect handler object. The following figures
illustrate the class structure and the logical
steps involved in creating a session to a Nirvana
Realm.
Most of the session parameters are defined in
a string that is called RNAME and resembles a
URL. All the sample applications provided use
an RNAME Java system property to obtain the necessary
session attributes. The following section discusses
this in further detail. The RNAME takes the following
format.
<wire protocol> :// <hostname>
:< port>, <wire protocol> :// <hostname>
: <port>
The RNAME entry can contain an
unlimited number of comma-separated values each
one representing an interface on a Nirvana Realm.
Click here for more information on RNAME.
The current version of the Nirvana
Realm and the Nirvana client API supports 4 TCP
wire protocols. These are the Nirvana Socket Protocol
(nsp), the Nirvana HTTP Protocol (nhp), the Nirvana
SSL Protocol (nsps) and the Nirvana HTTPS protocol
(nhps). These wire protocols are available wherever
a connection is required, i.e. client to Realm
and Realm to Realm. Click here for more information
on wire protocols
supported.
Creating a Nirvana session
To create a Nirvana Session follow the steps below:
1. Create a nSessionAttrib object with the RNAME
value of your choice
String[] RNAME=({“nsp://127.0.0.1:9000”});
nSessionAttributes nsa=new nSessionAttributes(RNAME);
2. Call the create method on nSessionFactory
to create your session
nSession mySession=nSessionFactory.create(nsa);
Alternatively, if you require the use of a session
reconnect handler to intercept the automatic reconnection
attempts, pass an instance of that class too in
the create method:
Public class myReconnectHandler implements
nReconnectHandler{
…
}
myReconnectHandler rhandler=new myReconnectHandler();
nSession mySession=nSessionFactory.create(nsa,
rhandler);
3. Initialise the session object to open the
connection to the Nirvana Realm
mySession.init();
After initialising your Nirvana session, you will
be connected to the Nirvana Realm. From that point,
all functionality is subject to a Realm ACL check.
If you call a method that requires a permission
your credential does not have, you will receive
an nSecurityException. Click here for more information
on Nirvana ACLs.
|