FTP-Server API

server
Class Server

java.lang.Object
  |
  +--server.Server

public class Server
extends Object

JQ-Data FTP-Server must be started though this class. When started all clients can connect to the server on the running port (typically 21). All standard setups are in the setup.xml, that are generated the first time the server runs.
If you want to change the port to fx. 3000, you can do it by doing:
getConfiguration().getRoot().setQuickOptionValue("Server.port","3000");
The one that makes an instance of this class will often be ServerObserver, because it thereby gets all newcommers on the server send to it though ServerObservers interface! The Object UserSession represents a client's session.


Field Summary
static String version
          The Servers version.
 
Method Summary
 void addServerObserver(ServerObserver serverObserver)
          Adds an observer.
 boolean deleteLogFileSessions(LogFileSession[] ses)
          Deletes a group of LogFileSession from the logfiles.
 boolean doesAutoSave()
          Checks whether autoSave is on or off.
 Conf getConfiguration()
          Returns the configuration class.
 LogFileReader[] getLogFiles()
          Gets all logfiles on the FTP-Server.
 UserSession[] getOnlineUsers()
          Returns an array containing all online clients.
 int getServerPort()
          The port the server will run on.
static Server instanceOf()
          Creates a singleton server, with a version name of ''.
static Server instanceOf(String version)
          Creates a singleton server
 boolean isRunning()
          Wether the server is running or not.
 void removeServerObserver(ServerObserver serverObserver)
          Removes an observer
 void setAutoSave(boolean on)
          Sets the server to auto-save.
 void start()
          Tries to start the FTP-Server as a thread.
 boolean stop()
          Stops the FTP-Server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static String version
The Servers version. Used by the two commands 'Welcome' og 'Help'

Method Detail

instanceOf

public static Server instanceOf(String version)
Creates a singleton server

Parameters:
version - a name that is used in GUI, help and in commandline (java -jar JQData-FTP.jar -version). Only the first one to call this method gets the version name through,
Returns:
instance

instanceOf

public static Server instanceOf()
Creates a singleton server, with a version name of ''.

Returns:
instance

start

public void start()
Tries to start the FTP-Server as a thread. The server calls back through the interface 'ServerObserver', and states whether it was successfull or not.


stop

public boolean stop()
Stops the FTP-Server.


addServerObserver

public void addServerObserver(ServerObserver serverObserver)
Adds an observer.

Parameters:
serverObserver - observer

removeServerObserver

public void removeServerObserver(ServerObserver serverObserver)
Removes an observer

Parameters:
serverObserver - observer

getConfiguration

public Conf getConfiguration()
Returns the configuration class. Can also be obtained by Conf.getInstance();

Returns:
The configuration classen.

isRunning

public boolean isRunning()
Wether the server is running or not.

Returns:
true/false

getServerPort

public int getServerPort()
The port the server will run on.

Returns:
portnummer

setAutoSave

public void setAutoSave(boolean on)
Sets the server to auto-save. This will save setup.conf every time a client goes offline This is fx. necessary when running without graphics, as
sessioner 1
must be saved before the server are closed...

This option is by default set to OFF!

Parameters:
on -

doesAutoSave

public boolean doesAutoSave()
Checks whether autoSave is on or off.

Returns:
true/false

getOnlineUsers

public UserSession[] getOnlineUsers()
Returns an array containing all online clients.

Returns:
all online clients.

getLogFiles

public LogFileReader[] getLogFiles()
Gets all logfiles on the FTP-Server.

Returns:
LogFileReader[]

deleteLogFileSessions

public boolean deleteLogFileSessions(LogFileSession[] ses)
Deletes a group of LogFileSession from the logfiles. The array of LogFileSessions can consist of objects from severel different users. If there are errors in one or some of the logfiles, the method returns false, but this is not a guarrantee, that some logfiles were not deleted!

Parameters:
ses - an array consisting of LogFileSession objects to be deleted
Returns:
true if the logs were successfully deleted!

FTP-Server API