net.jetrix.services
Class PublishingService

java.lang.Object
  extended by net.jetrix.services.AbstractService
      extended by net.jetrix.services.ScheduledService
          extended by net.jetrix.services.PublishingService
All Implemented Interfaces:
Service

public class PublishingService
extends ScheduledService

A service publishing the address of the server on public server lists (tetrinet.org, tfast.org and tsrv.com). The host parameter can be specified if not explicitely defined in the config.xml file (with the host attribute on the tetrinet-server element), if no hostname is provided the service will try to guess the address automatically. The name of the server is used as the description. The address is published once a day by default.

Since:
0.2
Version:
$Revision: 732 $, $Date: 2008-08-22 15:13:53 +0200 (ven., 22 août 2008) $
Author:
Emmanuel Bourg

Field Summary
 
Fields inherited from class net.jetrix.services.AbstractService
autoStart
 
Constructor Summary
PublishingService()
           
 
Method Summary
protected  InetAddress findInetAddress()
          Search through the available network interfaces and return the first global internet address found.
 String getHost()
           
 String getName()
          Return the name of the service.
protected  String getPublishedAddress()
          Find the address to publish by looking at the service host parameter, the server host attribute in the config.xml file, and the IP associated to the network interfaces.
protected  void post(String url, Map<String,String> parameters)
          Send a POST http request to the specified URL.
protected  void run()
          Execute the task
 void setHost(String host)
           
 
Methods inherited from class net.jetrix.services.ScheduledService
getDelay, getPeriod, init, isRunning, setDelay, setPeriod, start, stop
 
Methods inherited from class net.jetrix.services.AbstractService
isAutoStart, setAutoStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PublishingService

public PublishingService()
Method Detail

setHost

public void setHost(String host)

getHost

public String getHost()

getName

public String getName()
Description copied from interface: Service
Return the name of the service.


run

protected void run()
Description copied from class: ScheduledService
Execute the task

Specified by:
run in class ScheduledService

post

protected void post(String url,
                    Map<String,String> parameters)
             throws IOException
Send a POST http request to the specified URL.

Parameters:
url - the URL
parameters - the parameters of the request
Throws:
IOException

getPublishedAddress

protected String getPublishedAddress()
Find the address to publish by looking at the service host parameter, the server host attribute in the config.xml file, and the IP associated to the network interfaces.


findInetAddress

protected InetAddress findInetAddress()
Search through the available network interfaces and return the first global internet address found.



Copyright © 2001-2008 Emmanuel Bourg. All Rights Reserved.