snifos.application.test
Class DummyApplication

java.lang.Object
  extended bysnifos.application.test.DummyApplication
All Implemented Interfaces:
Application, java.lang.Runnable

public class DummyApplication
extends java.lang.Object
implements Application

This is simple implementation of Application interface. It's configuration should contain only one property named "userId" which value should be integer number. This application accepts user only when user id in user's communication module can be divided by "userId" without remainder.

Version:
$Id: DummyApplication.java,v 1.2 2004/05/08 21:55:30 mwerla Exp $

Constructor Summary
DummyApplication()
          Just dummy constructor - does nothing.
 
Method Summary
 void configure(java.util.Properties configuration, boolean isUnique)
          Configures instance of Application with given parameters.
 void receiveMessage(UserId userId, org.dom4j.Document message)
          Called by server to pass message from user to this instance of application.
 void registerUser(UserId userId, org.dom4j.Document message)
          This application accepts user only when user id in user's communication module can be divided by "userId" configuration parameter without remainder.
 void run()
          Method not implemented.
 void setServer(Server server)
          Sets instance of server which will be used to communicate with to users.
 void unregisterUser(UserId userId)
          Unregisters user with given id (for example after user disconnects).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DummyApplication

public DummyApplication()
Just dummy constructor - does nothing.

Method Detail

configure

public void configure(java.util.Properties configuration,
                      boolean isUnique)
Description copied from interface: Application
Configures instance of Application with given parameters.

Specified by:
configure in interface Application
Parameters:
configuration - Configuration which will be used.
isUnique - True if application is uniqe.
See Also:
Application.configure(Properties, boolean)

setServer

public void setServer(Server server)
Description copied from interface: Application
Sets instance of server which will be used to communicate with to users.

Specified by:
setServer in interface Application
Parameters:
server - Server instance.
See Also:
Application.setServer(Server)

unregisterUser

public void unregisterUser(UserId userId)
Description copied from interface: Application
Unregisters user with given id (for example after user disconnects).

Specified by:
unregisterUser in interface Application
Parameters:
userId - Id of user.
See Also:
Application.unregisterUser(UserId)

receiveMessage

public void receiveMessage(UserId userId,
                           org.dom4j.Document message)
Description copied from interface: Application
Called by server to pass message from user to this instance of application. If message is invalid for some reason, application should send message to the user with proper information - throwing an exception is not advised.

Specified by:
receiveMessage in interface Application
Parameters:
userId - Id of user which sends message.
message - Received message.
See Also:
Application.receiveMessage(UserId, Document)
To Do:
This method should be rewritten in some flexible way...

run

public void run()
Method not implemented.

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

registerUser

public void registerUser(UserId userId,
                         org.dom4j.Document message)
                  throws InvalidUserException
This application accepts user only when user id in user's communication module can be divided by "userId" configuration parameter without remainder.

Specified by:
registerUser in interface Application
Parameters:
userId - Id of user to register.
message - First message sent by user (can contain some user specific informations)
Throws:
InvalidUserException - Thrown when user cannot be registered by given application instance
See Also:
Application.registerUser(UserId, Document)


Copyright © 2001-2004 MoMaT & MWe Team. All Rights Reserved.