src.server
Interface Module

All Known Implementing Classes:
ModuleClass

public interface Module

Defines the interface for modules. A module is something that provides a service on the server. It can be queried and have event triggered. A simple module could for instance be a clock that returns the current time as a result of any query. Also it could register an event in EventHandler and send users messages at certain times.

Version:
2005-apr-19

Method Summary
 ModuleMeta getModuleMeta()
          Get the module meta data.
 boolean isValidCache(ModuleQuery query, java.lang.String cachedUserId, long cacheAge)
          Checks if a cached result is valid or not based on how long ago the result was cached.
 Package processQuery(ModuleQuery query)
          Process a user sent query.
 Package processSettingRequest(QueryPackage query)
          Handles a given setting request.
 void setModuleMeta(ModuleMeta m)
          Set the module meta data.
 

Method Detail

isValidCache

public boolean isValidCache(ModuleQuery query,
                            java.lang.String cachedUserId,
                            long cacheAge)
Checks if a cached result is valid or not based on how long ago the result was cached. Some services might work fine with returning very old cached results, for instance the result of a map service wont change (often at least) and most cache ages would then be valid. Other things like news services on the other hand should not allow a long cache age.

Parameters:
query - The user query that resulted in the cached result. The user's query parameters are identical to the cached query parameters.
cachedUserId - The userId of the query that is cached.
cacheAge - The number of seconds that has elapsed since the cached version was cached.
Returns:
True if the cache should be concidered to still be valid. False otherwise.

processQuery

public Package processQuery(ModuleQuery query)
Process a user sent query. This is very individual depending on the service provided by the module.

Parameters:
query - The user sent query.
Returns:
An ErrorPackage if an error occured while processing the query, an OutputPackage with the result otherwise.

processSettingRequest

public Package processSettingRequest(QueryPackage query)
Handles a given setting request. The setting request is required to have the parameters settingName and settingValue.

Parameters:
query - The setting request. Needs to have parameters settingName and settingValue.
Returns:
A package containing the result of the setting request.

getModuleMeta

public ModuleMeta getModuleMeta()
Get the module meta data.

Returns:
A module meta data structure.

setModuleMeta

public void setModuleMeta(ModuleMeta m)
Set the module meta data.