|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.as400.resource.Resource | +--com.ibm.as400.access.NetServerSession
The NetServerSession class represents a NetServer session.
Note: A session corresponds to a workstation. A workstation could be a Windows Terminal Server or it could be a single PC on someone's desktop. A connection corresponds to a specific user who has mapped a drive and has files opened or spooled output on a print queue. Since a session can have multiple users, a connection shows a particular user's statistics on that session.
NetServerSession objects are created and returned by NetServer.listSessions()
.
The following attribute IDs are supported:
Use any of the above attribute IDs with
getAttributeValue
to access the attribute values for a NetServerSession.
Note: For the above attributes, getAttributeValue() should never return null.
For String-valued attributes, if the current actual value of the corresponding property on the server is blank, getAttributeValue() will return "" (an empty String).
import com.ibm.as400.access.*;
import com.ibm.as400.resource.*;
// Create a NetServer object for a specific server system.
AS400 system = new AS400("MYSYSTEM", "MYUSERID", "MYPASSWORD");
NetServer ns = new NetServer(system);
try
{
// List all current sessions.
System.out.println("Sessions:");
ResourceList sessionList = ns.listSessions();
sessionList.waitForComplete();
for (int i=0; i<sessionList.getListLength(); i++)
{
NetServerSession session =
(NetServerSession)sessionList.resourceAt(i);
System.out.println(session.getName() + ": " +
(String)session.getAttributeValue(NetServerSession.USER) + "; " +
((Integer)session.getAttributeValue(NetServerSession.SESSION_TIME))
.intValue() + "; " +
((Boolean)session.getAttributeValue(NetServerSession.IS_GUEST))
.booleanValue() );
}
}
catch (ResourceException e) {
e.printStackTrace();
}
finally {
if (system != null) system.disconnectAllServices();
}
Field Summary | |
static java.lang.String |
CONNECTION_COUNT
Attribute ID for "connection count". |
static java.lang.String |
FILES_OPEN_COUNT
Attribute ID for "files open count". |
static java.lang.String |
IDLE_TIME
Attribute ID for "session idle time". |
static java.lang.String |
IS_ENCRYPT_PASSWORD
Attribute ID for "is encrypt password". |
static java.lang.String |
IS_GUEST
Attribute ID for "is guest". |
static java.lang.String |
SESSION_TIME
Attribute ID for "session time". |
static java.lang.String |
USER
Attribute ID for "user name". |
Method Summary | |
void |
end()
Ends the session. |
protected void |
establishConnection()
Establishes the connection to the server. |
protected void |
freezeProperties()
Freezes any property changes. |
java.lang.Object |
getAttributeValue(java.lang.Object attributeID)
Returns the current value of an attribute. |
java.lang.String |
getName()
Returns the name of the workstation from which the session to the server was established. |
ResourceList |
listConnections()
Lists the connections currently associated with this session. |
void |
refreshAttributeValues()
Refreshes the values for all attributes. |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String CONNECTION_COUNT
public static final java.lang.String SESSION_TIME
public static final java.lang.String FILES_OPEN_COUNT
public static final java.lang.String IDLE_TIME
public static final java.lang.String IS_ENCRYPT_PASSWORD
public static final java.lang.String IS_GUEST
public static final java.lang.String USER
Method Detail |
public void end() throws ResourceException
protected void establishConnection() throws ResourceException
The method is called by the resource framework automatically when the connection needs to be established.
protected void freezeProperties() throws ResourceException
The method is called by the resource framework automatically when the properties need to be frozen.
public java.lang.Object getAttributeValue(java.lang.Object attributeID) throws ResourceException
attributeID
- Identifies the attribute.public java.lang.String getName()
public ResourceList listConnections() throws ResourceException
NetServerConnection
public void refreshAttributeValues() throws ResourceException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |