net.anotheria.net.shared.server
Class AbstractServer

java.lang.Object
  extended by net.anotheria.net.shared.server.AbstractServer
All Implemented Interfaces:
IServer
Direct Known Subclasses:
BasicTCPServer

public abstract class AbstractServer
extends Object
implements IServer

Base class for all different kinds of servers


Constructor Summary
protected AbstractServer()
          Creates a new server
protected AbstractServer(IConnectionFactory aConnectionFactory)
          Creates a new server with specified connection factory.
 
Method Summary
 void addServerListener(IServerListener listener)
          Adds a listener to this server
 IConnectionFactory getConnectionFactory()
          Returns the connection factory
protected  void notifyConnectionCreated(IConnection con)
          Calls the connectionCreated method in all listeners
protected  void notifyConnectionRemoved(IConnection con)
          Calls the connectionRemoved method in all listeners
 void removeServerListener(IServerListener listener)
          Removes a listener from this server.
 void setConnectionFactory(IConnectionFactory connectionFactory)
          Sets a new connection factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.anotheria.net.shared.server.IServer
startServer, stopServer
 

Constructor Detail

AbstractServer

protected AbstractServer()
Creates a new server


AbstractServer

protected AbstractServer(IConnectionFactory aConnectionFactory)
Creates a new server with specified connection factory.

Parameters:
aConnectionFactory - the connection factor to use for incoming connections
Method Detail

addServerListener

public void addServerListener(IServerListener listener)
Description copied from interface: IServer
Adds a listener to this server

Specified by:
addServerListener in interface IServer
Parameters:
listener - listener to add

removeServerListener

public void removeServerListener(IServerListener listener)
Description copied from interface: IServer
Removes a listener from this server.

Specified by:
removeServerListener in interface IServer
Parameters:
listener - listener to remove

notifyConnectionCreated

protected void notifyConnectionCreated(IConnection con)
Calls the connectionCreated method in all listeners

Parameters:
con - the newly created connection

notifyConnectionRemoved

protected void notifyConnectionRemoved(IConnection con)
Calls the connectionRemoved method in all listeners

Parameters:
con - the removed connection

getConnectionFactory

public IConnectionFactory getConnectionFactory()
Returns the connection factory

Returns:
the connection factory object

setConnectionFactory

public void setConnectionFactory(IConnectionFactory connectionFactory)
Sets a new connection factory

Parameters:
connectionFactory - connection factory to use for new incoming connections


Copyright © 2010-2013 anotheria.net. All Rights Reserved.