|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.ldap.Connection
final class Connection
The class that creates a connection to the LDAP server. After the connection is made, a thread is created that reads data from the connection.
The application's thread sends a request to the MessageAgent class, which creates a Message class. The Message class calls the writeMessage method of this class to send the request to the server. The application thread will then query the MessageAgent class for a response.
The reader thread multiplexes response messages received from the server to the appropriate Message class. Each Message class has its own message queue.
Unsolicited messages are process separately, and if the application has registered a handler, a separate thread is created for that application's handler to process the message.
Note: the reader thread must not be a "selfish" thread, since some operating systems do not time slice.
Nested Class Summary | |
---|---|
class |
Connection.ReaderThread
|
private class |
Connection.UnsolicitedListenerThread
Inner class defined so that we can spawn off each unsolicited listener as a seperate thread. |
Field Summary | |
---|---|
private ReferralInfo |
activeReferral
|
private BindProperties |
bindProperties
|
private int |
bindSemaphoreId
|
private boolean |
clientActive
|
private int |
cloneCount
|
private static int |
connNum
|
private static int |
CONTINUE_READING
|
private java.lang.Thread |
deadReader
|
private java.io.IOException |
deadReaderException
|
private LBERDecoder |
decoder
|
private LBEREncoder |
encoder
|
private int |
ephemeralId
|
private java.lang.String |
host
|
private java.io.InputStream |
in
|
private MessageVector |
messages
|
private LDAPSocketFactory |
mySocketFactory
|
private int |
myTimeOut
|
private java.lang.String |
name
|
private static java.lang.Object |
nameLock
|
private java.net.Socket |
nonTLSBackup
|
private java.io.OutputStream |
out
|
private int |
port
|
(package private) static java.lang.Integer |
protocol
|
private java.lang.Thread |
reader
|
(package private) static java.lang.String |
sdk
|
(package private) static java.lang.String |
security
|
private java.net.Socket |
socket
|
private static LDAPSocketFactory |
socketFactory
|
private static int |
STOP_READING
|
private int |
stopReaderMessageID
|
private java.util.Vector |
unsolicitedListeners
|
private boolean |
unsolSvrShutDnNotification
|
private java.lang.Object |
writeSemaphore
|
private int |
writeSemaphoreCount
|
private int |
writeSemaphoreOwner
|
Constructor Summary | |
---|---|
Connection(int timeout)
Create a new Connection object |
|
Connection(LDAPSocketFactory factory)
Create a new Connection object |
Method Summary | |
---|---|
(package private) int |
acquireWriteSemaphore()
Acquire a simple counting semaphore that synchronizes state affecting bind. |
(package private) int |
acquireWriteSemaphore(int msgId)
Acquire a simple counting semaphore that synchronizes state affecting bind. |
(package private) void |
addUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
Add the specific object to the list of listeners that want to be notified when an unsolicited notification is received. |
(package private) boolean |
areMessagesComplete()
This tests to see if there are any outstanding messages. |
(package private) void |
clearBindSemId()
clears the writeSemaphore id used for active bind operation |
(package private) void |
connect(java.lang.String host,
int port)
Constructs a TCP/IP connection to a server specified in host and port. |
private void |
connect(java.lang.String host,
int port,
int semaphoreId)
Constructs a TCP/IP connection to a server specified in host and port. |
(package private) java.lang.Object |
copy_timeout()
Copy this Connection object. |
(package private) java.lang.Object |
copy()
Copy this Connection object. |
(package private) Connection |
destroyClone(boolean apiCall)
Destroys a clone of LDAPConnection . |
protected void |
finalize()
Cleans up resources associated with this connection. |
(package private) void |
freeWriteSemaphore(int msgId)
Release a simple counting semaphore that synchronizes state affecting bind. |
(package private) ReferralInfo |
getActiveReferral()
Gets the current referral active on this connection if created to follow referrals. |
(package private) BindProperties |
getBindProperties()
Sets the authentication credentials in the object and set flag indicating successful bind. |
(package private) int |
getBindSemId()
gets the writeSemaphore id used for active bind operation |
(package private) java.lang.String |
getConnectionName()
Returns the name of this Connection, used for debug only |
(package private) java.lang.String |
getHost()
gets the host used for this connection |
(package private) MessageAgent |
getMessageAgent(int msgId)
Returns the message agent for this msg ID |
(package private) int |
getPort()
gets the port used for this connection |
(package private) LDAPSocketFactory |
getSocketFactory()
gets the socket factory used for this connection |
(package private) int |
getSocketTimeOut()
Gets SocketTimeOut value set. |
(package private) void |
incrCloneCount()
Increments the count of cloned connections |
(package private) boolean |
isBindSemIdClear()
checks if the writeSemaphore id used for active bind operation is clear |
(package private) boolean |
isBound()
Return whether the application is bound to this connection. |
(package private) boolean |
isCloned()
Indicates whether clones exist for LDAPConnection |
(package private) boolean |
isConnected()
Return whether a connection has been made |
(package private) boolean |
isConnectionAlive()
Checks whether a connection is still alive or not by sending data to the server on this connection's socket.If the connection is not alive the send will generate an IOException and the function will return false. |
(package private) boolean |
isTLS()
Indicates if the connection is using TLS protection. |
private void |
notifyAllUnsolicitedListeners(RfcLDAPMessage message)
|
(package private) void |
removeMessage(Message info)
Removes a Message class from the Connection's list |
(package private) void |
removeUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
Remove the specific object from current list of listeners |
(package private) void |
setActiveReferral(ReferralInfo referral)
Sets the current referral active on this connection if created to follow referrals. |
(package private) void |
setBindProperties(BindProperties bindProps)
Sets the authentication credentials in the object and set flag indicating successful bind. |
(package private) void |
setBindSemId(int id)
sets the writeSemaphore id used for active bind operation |
(package private) static void |
setSocketFactory(LDAPSocketFactory factory)
sets the default socket factory |
(package private) void |
setSocketTimeOut(int timeout)
Sets the SocketTimeOut value. |
private void |
shutdown(java.lang.String reason,
int semaphoreId,
InterThreadException notifyUser)
Cleans up resources associated with this connection. |
(package private) void |
startReader()
startReader startReader should be called when socket and io streams have been set or changed. |
(package private) void |
startTLS()
StartsTLS, in this package, assumes the caller has: 1) Acquired the writeSemaphore 2) Stopped the reader thread 3) checked that no messages are outstanding on this connection. |
(package private) void |
stopReaderOnReply(int messageID)
The reader thread will stop when a reply is read with an ID equal to the messageID passed in to this method. |
(package private) void |
stopTLS()
|
private void |
waitForReader(java.lang.Thread thread)
|
(package private) void |
writeMessage(LDAPMessage msg)
Writes an LDAPMessage to the LDAP server over a socket. |
(package private) void |
writeMessage(Message info)
Writes an LDAPMessage to the LDAP server over a socket. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.Object writeSemaphore
private int writeSemaphoreOwner
private int writeSemaphoreCount
private int ephemeralId
private BindProperties bindProperties
private int bindSemaphoreId
private java.lang.Thread reader
private java.lang.Thread deadReader
private java.io.IOException deadReaderException
private LBEREncoder encoder
private LBERDecoder decoder
private java.net.Socket socket
private java.net.Socket nonTLSBackup
private java.io.InputStream in
private java.io.OutputStream out
private boolean clientActive
private boolean unsolSvrShutDnNotification
private static final int CONTINUE_READING
private static final int STOP_READING
private int stopReaderMessageID
private MessageVector messages
private ReferralInfo activeReferral
private java.util.Vector unsolicitedListeners
private static LDAPSocketFactory socketFactory
private LDAPSocketFactory mySocketFactory
private int myTimeOut
private java.lang.String host
private int port
private int cloneCount
private java.lang.String name
private static java.lang.Object nameLock
private static int connNum
static java.lang.String sdk
static java.lang.Integer protocol
static java.lang.String security
Constructor Detail |
---|
Connection(LDAPSocketFactory factory)
factory
- specifies the factory to use to produce SSL sockets.Connection(int timeout)
timeout
- specifies the socket timeout to be used when the server is stalled.Method Detail |
---|
java.lang.Object copy()
This is not a true clone, but creates a new object encapsulating part of the connection information from the original object. The new object will have the same default socket factory, designated socket factory, host, port, and protocol version as the original object. The new object is NOT be connected to the host.
java.lang.Object copy_timeout()
This is not a true clone, but creates a new object encapsulating part of the connection information from the original object. The new object will have the same default socket factory, designated socket factory, host, port, and protocol version as the original object. The new object is NOT be connected to the host.
final int acquireWriteSemaphore()
final int acquireWriteSemaphore(int msgId)
msgId
- a value that identifies the owner of this semaphore. A
value of zero means assign a unique semaphore value.
final void freeWriteSemaphore(int msgId)
msgId
- a value that identifies the owner of this semaphoreprivate void waitForReader(java.lang.Thread thread) throws LDAPException
LDAPException
void connect(java.lang.String host, int port) throws LDAPException
host
- The host to connect to.
port
- The port on the host to connect to.
LDAPException
private void connect(java.lang.String host, int port, int semaphoreId) throws LDAPException
host
- The host to connect to.
port
- The port on the host to connect to.
semaphoreId
- The write semaphore ID to use for the connect
LDAPException
final boolean isCloned()
final void incrCloneCount()
final Connection destroyClone(boolean apiCall)
LDAPConnection
.
This method first determines if only one LDAPConnection
object is associated with this connection, i.e. if no clone exists.
If no clone exists, the socket is closed, and the current
Connection
object is returned.
If multiple LDAPConnection
objects are associated
with this connection, i.e. clones exist, a copy()
of the
this object is made, but is not connected to any host. This
disassociates that clone from the original connection. The new
Connection
object is returned.
Only one destroyClone instance is allowed to run at any one time.
If the connection is closed, any threads waiting for operations on that connection will wake with an LDAPException indicating the connection is closed.
apiCall
- true
indicates the application is closing the
connection or or creating a new one by calling either the
connect
or disconnect
methods
of LDAPConnection
. false
indicates that LDAPConnection
is being finalized.
static final void setSocketFactory(LDAPSocketFactory factory)
factory
- the default factory to setfinal LDAPSocketFactory getSocketFactory()
final java.lang.String getHost()
final int getPort()
int getBindSemId()
void setBindSemId(int id)
void clearBindSemId()
final int getSocketTimeOut()
final void setSocketTimeOut(int timeout)
boolean isBindSemIdClear()
void writeMessage(Message info) throws LDAPException
info
- the Message containing the message to write.
LDAPException
void writeMessage(LDAPMessage msg) throws LDAPException
msg
- the message to write.
LDAPException
final MessageAgent getMessageAgent(int msgId) throws java.lang.NoSuchFieldException
java.lang.NoSuchFieldException
final boolean isBound()
final boolean isConnected()
final boolean isConnectionAlive()
final void removeMessage(Message info)
info
- the Message class to remove from the listprotected void finalize()
finalize
in class java.lang.Object
private void shutdown(java.lang.String reason, int semaphoreId, InterThreadException notifyUser)
final void setBindProperties(BindProperties bindProps)
bindProps
- The BindProperties object to set.final BindProperties getBindProperties()
final boolean areMessagesComplete()
final void stopReaderOnReply(int messageID)
final void startReader() throws LDAPException
LDAPException
final boolean isTLS()
final void startTLS() throws LDAPException
LDAPException
final void stopTLS() throws LDAPException
LDAPException
final void setActiveReferral(ReferralInfo referral)
final ReferralInfo getActiveReferral()
final void addUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
final void removeUnsolicitedNotificationListener(LDAPUnsolicitedNotificationListener listener)
private void notifyAllUnsolicitedListeners(RfcLDAPMessage message)
java.lang.String getConnectionName()
|
All LDAP Classes Internal LDAP Classes |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |