Class Connection
- All Implemented Interfaces:
Runnable
It is derived from java.lang.Thread, which reflects the architecture constraint of one thread per connection. This might seem a waste of resources, but as a matter of fact sharing threads would require a far more complex imlementation, due to the fact that telnet is not a stateless protocol (i.e. alive throughout a session of multiple requests and responses).
Each Connection instance is created by the listeners ConnectionManager instance, making it part of a threadgroup and passing in an associated ConnectionData instance, that holds vital information about the connection. Be sure to take a look at their documention.
Once the thread has started and is running, it will get a login shell instance from the ShellManager and run passing its own reference.
- Version:
- 2.0 (16/07/2006)
- Author:
- Dieter Wimberger
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorDescriptionConnection
(ThreadGroup tcg, ConnectionData cd) Constructs a TelnetConnection by invoking its parent constructor and setting of various members.
Subsequently instantiates the whole i/o subsystem, negotiating telnet protocol level options etc. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Method that registers a ConnectionListener with the Connection instance.void
close()
Closes the connection and its underlying i/o and network resources.protected abstract void
doClose()
protected abstract void
doRun()
Method to access the associated connection data.boolean
isActive()
Returns if a connection has been closed.void
Method called by the io subsystem to pass on a "low-level" event.void
Method that removes a ConnectionListener from the Connection instance.void
run()
Method overloaded to implement following behaviour: On first entry, retrieve an instance of the configured login shell from the ShellManager and run it.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
Connection
Constructs a TelnetConnection by invoking its parent constructor and setting of various members.
Subsequently instantiates the whole i/o subsystem, negotiating telnet protocol level options etc.- Parameters:
tcg
- ThreadGroup that this instance is running in.cd
- ConnectionData instance containing all vital information of this connection.- See Also:
-
-
Method Details
-
run
public void run()Method overloaded to implement following behaviour:- On first entry, retrieve an instance of the configured login shell from the ShellManager and run it.
- Handle a shell switch or close down disgracefully when problems (i.e. unhandled unchecked exceptions) occur in the running shell.
-
doRun
- Throws:
Exception
-
doClose
- Throws:
Exception
-
getConnectionData
Method to access the associated connection data.- Returns:
- ConnectionData associated with the Connection instance.
- See Also:
-
close
public void close()Closes the connection and its underlying i/o and network resources. -
isActive
public boolean isActive()Returns if a connection has been closed.- Returns:
- the state of the connection.
-
addConnectionListener
Method that registers a ConnectionListener with the Connection instance.- Parameters:
cl
- ConnectionListener to be registered.- See Also:
-
removeConnectionListener
Method that removes a ConnectionListener from the Connection instance.- Parameters:
cl
- ConnectionListener to be removed.- See Also:
-
processConnectionEvent
Method called by the io subsystem to pass on a "low-level" event. It will be properly delegated to all registered listeners.- Parameters:
ce
- ConnectionEvent to be processed.- See Also:
-