|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mockftpserver.core.session.DefaultSession
public class DefaultSession
Default implementation of the Session interface.
| Field Summary | |
|---|---|
protected static int |
DEFAULT_CLIENT_DATA_PORT
|
protected ServerSocketFactory |
serverSocketFactory
|
protected SocketFactory |
socketFactory
|
| Constructor Summary | |
|---|---|
DefaultSession(Socket controlSocket,
Map commandHandlers)
Create a new initialized instance |
|
| Method Summary | |
|---|---|
void |
close()
Close the session, closing the underlying sockets |
void |
closeDataConnection()
Close the data connection |
Object |
getAttribute(String name)
Return the attribute value for the specified name. |
Set |
getAttributeNames()
Return the Set of names under which attributes have been stored on this session. |
InetAddress |
getClientHost()
Return the InetAddress representing the client host for this session |
InetAddress |
getServerHost()
Return the InetAddress representing the server host for this session |
void |
openDataConnection()
Open the data connection, attaching to the predefined port number on the client |
byte[] |
readData()
Read data from the client across the data connection |
byte[] |
readData(int numBytes)
Read and return (up to) numBytes of data from the client across the data connection |
void |
removeAttribute(String name)
Remove the attribute value for the specified name. |
void |
run()
|
void |
sendData(byte[] data,
int numBytes)
Write the specified data using the data connection |
void |
sendReply(int code,
String text)
Send the specified reply code and text across the control connection. |
void |
setAttribute(String name,
Object value)
Store the value under the specified attribute name. |
void |
setClientDataHost(InetAddress clientHost)
|
void |
setClientDataPort(int dataPort)
|
int |
switchToPassiveMode()
Switch to passive mode |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final int DEFAULT_CLIENT_DATA_PORT
protected SocketFactory socketFactory
protected ServerSocketFactory serverSocketFactory
| Constructor Detail |
|---|
public DefaultSession(Socket controlSocket,
Map commandHandlers)
controlSocket - - the control connection socketcommandHandlers - - the Map of command name -> CommandHandler. It is assumed that the
command names are all normalized to upper case. See Command.normalizeName(String).| Method Detail |
|---|
public InetAddress getClientHost()
getClientHost in interface SessionSession.getClientHost()public InetAddress getServerHost()
getServerHost in interface SessionSession.getServerHost()
public void sendReply(int code,
String text)
sendReply in interface Sessioncode - - the reply codetext - - the reply text to send; may be nullpublic void openDataConnection()
Session
openDataConnection in interface SessionSession.openDataConnection()public int switchToPassiveMode()
switchToPassiveMode in interface SessionSession.switchToPassiveMode()public void closeDataConnection()
Session
closeDataConnection in interface SessionSession.closeDataConnection()public void close()
Session
close in interface SessionSession.close()
public void sendData(byte[] data,
int numBytes)
Session
sendData in interface Sessiondata - - the data to writenumBytes - - the number of bytes from data to sendSession.sendData(byte[], int)public byte[] readData()
Session
readData in interface SessionSession.readData()public byte[] readData(int numBytes)
Session
readData in interface SessionSession.readData()public void setClientDataHost(InetAddress clientHost)
setClientDataHost in interface SessionclientHost - - the client host for the data connectionSession.setClientDataHost(java.net.InetAddress)public void setClientDataPort(int dataPort)
setClientDataPort in interface SessiondataPort - - the port number on the client side for the data connectionSession.setClientDataPort(int)public void run()
run in interface RunnableRunnable.run()public Object getAttribute(String name)
getAttribute in interface Sessionname - - the attribute name; may not be null
Session.getAttribute(java.lang.String)
public void setAttribute(String name,
Object value)
setAttribute in interface Sessionname - - the attribute name; may not be nullvalue - - the attribute value; may be nullSession.setAttribute(java.lang.String, java.lang.Object)public Set getAttributeNames()
getAttributeNames in interface SessionSession.getAttributeNames()public void removeAttribute(String name)
removeAttribute in interface Sessionname - - the attribute name; may not be null
AssertFailedException - - if name is nullSession.removeAttribute(java.lang.String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||