Methods Summary |
---|
protected org.apache.axis.session.Session | createSession(java.lang.String cooky)demand create a session if there is not already one for the string
// is there a session already?
Session session = null;
if (sessions.containsKey(cooky)) {
session = (Session) sessions.get(cooky);
} else {
// no session for this cooky, bummer
session = new SimpleSession();
// ADD CLEANUP LOGIC HERE if needed
sessions.put(cooky, session);
}
return session;
|
protected void | finalize()stop the server if not already told to.
stop();
super.finalize();
|
public synchronized org.apache.axis.server.AxisServer | getAxisServer()demand create an axis server; return an existing one if one exists.
The configuration for the axis server is derived from #myConfig if not null,
the default config otherwise.
if (myAxisServer == null) {
if (myConfig == null) {
myConfig = EngineConfigurationFactoryFinder.newFactory().getServerEngineConfig();
}
myAxisServer = new AxisServer(myConfig);
ServiceAdmin.setEngine(myAxisServer, NetworkUtils.getLocalHostname() + "@" + serverSocket.getLocalPort());
}
return myAxisServer;
|
private java.lang.String | getCurrentDirectory()Gets the current directory
return System.getProperty("user.dir");
|
public boolean | getDoThreads()
return doThreads ;
|
public int | getMaxSessions()get max session count
return maxSessions;
|
public org.apache.axis.EngineConfiguration | getMyConfig()
return myConfig;
|
public static org.apache.axis.components.threadpool.ThreadPool | getPool()get the thread pool
return pool;
|
public java.net.ServerSocket | getServerSocket()Obtain the serverSocket that that SimpleAxisServer is listening on.
return serverSocket;
|
protected boolean | isSessionUsed()
return doSessions;
|
public static void | main(java.lang.String[] args)Server process.
Options opts = null;
try {
opts = new Options(args);
} catch (MalformedURLException e) {
log.error(Messages.getMessage("malformedURLException00"), e);
return;
}
String maxPoolSize = opts.isValueSet('t");
if (maxPoolSize==null) maxPoolSize = ThreadPool.DEFAULT_MAX_THREADS + "";
String maxSessions = opts.isValueSet('m");
if (maxSessions==null) maxSessions = MAX_SESSIONS_DEFAULT + "";
SimpleAxisServer sas = new SimpleAxisServer(Integer.parseInt(maxPoolSize),
Integer.parseInt(maxSessions));
try {
doThreads = (opts.isFlagSet('t") > 0);
int port = opts.getPort();
ServerSocket ss = null;
// Try five times
final int retries = 5;
for (int i = 0; i < retries; i++) {
try {
ss = new ServerSocket(port);
break;
} catch (java.net.BindException be){
log.debug(Messages.getMessage("exception00"), be);
if (i < (retries-1)) {
// At 3 second intervals.
Thread.sleep(3000);
} else {
throw new Exception(Messages.getMessage("unableToStartServer00",
Integer.toString(port)));
}
}
}
sas.setServerSocket(ss);
sas.start();
} catch (Exception e) {
log.error(Messages.getMessage("exception00"), e);
return;
}
|
public void | run()Accept requests from a given TCP port and send them through the
Axis engine for processing.
log.info(Messages.getMessage("start01", "SimpleAxisServer",
new Integer(getServerSocket().getLocalPort()).toString(),getCurrentDirectory()));
// Accept and process requests from the socket
while (!stopped) {
Socket socket = null;
try {
socket = serverSocket.accept();
} catch (java.io.InterruptedIOException iie) {
} catch (Exception e) {
log.debug(Messages.getMessage("exception00"), e);
break;
}
if (socket != null) {
SimpleAxisWorker worker = new SimpleAxisWorker(this, socket);
if (doThreads) {
pool.addWorker(worker);
} else {
worker.run();
}
}
}
log.info(Messages.getMessage("quit00", "SimpleAxisServer"));
|
public void | setDoThreads(boolean value)turn threading on or off. This sets a static value
doThreads = value ;
|
public void | setMaxSessions(int maxSessions)Resize the session map
this.maxSessions = maxSessions;
((LRUMap)sessions).setMaximumSize(maxSessions);
|
public void | setMyConfig(org.apache.axis.EngineConfiguration myConfig)
this.myConfig = myConfig;
|
public void | setServerSocket(java.net.ServerSocket serverSocket)Set the serverSocket this server should listen on.
(note : changing this will not affect a running server, but if you
stop() and then start() the server, the new socket will be used).
this.serverSocket = serverSocket;
|
public void | start(boolean daemon)Start this server.
Spawns a worker thread to listen for HTTP requests.
stopped=false;
if (doThreads) {
Thread thread = new Thread(this);
thread.setDaemon(daemon);
thread.start();
} else {
run();
}
|
public void | start()Start this server as a NON-daemon.
start(false);
|
public void | stop()Stop this server. Can be called safely if the system is already stopped,
or if it was never started.
This will interrupt any pending accept().
//recognise use before we are live
if(stopped ) {
return;
}
/*
* Close the server socket cleanly, but avoid fresh accepts while
* the socket is closing.
*/
stopped = true;
try {
if(serverSocket != null) {
serverSocket.close();
}
} catch (IOException e) {
log.info(Messages.getMessage("exception00"), e);
} finally {
serverSocket=null;
}
log.info(Messages.getMessage("quit00", "SimpleAxisServer"));
//shut down the pool
pool.shutdown();
|