PageBoxLib
Class DynDns

java.lang.Object
  extended byjava.lang.Thread
      extended byPageBoxLib.DynDns
All Implemented Interfaces:
java.lang.Runnable

public class DynDns
extends java.lang.Thread

PageBox DNS registration using DynDNS protocol.

Changes:

alexis.grandemange@pagebox.net

Copyright (c) 2002-2004 Alexis Grandemange

This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public License
 as published by the Free Software Foundation; version 2.1 of the
 License.
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU Lesser General Public License for more details.
 A copy of the GNU Lesser General Public License lesser.txt should be
 included in the distribution.

Version:
0, 1, 1
Author:
Alexis Grandemange

Field Summary
(package private)  java.util.TreeMap archives
          Archives currently installed Key: archive name Value: Archive object
(package private)  ServletContext ctx
          Unique to the Web application
(package private)  java.lang.String dnshost
          Already used DynDNS registration service URL (from dyndns.txt)
(package private)  java.io.File f
          Points on DynDNS.txt
(package private)  java.io.File fif
          Points on fileinfo.xml
(package private)  java.lang.String host
          DNS name to register
(package private)  java.lang.String inter
          Network interface registered on DynDNS
(package private)  ListenerIF listener
          Non-HTTP listener instance
 Log log
          Logging object.
(package private)  java.lang.String myaddr
          Already used IP address (from dyndns.txt)
(package private)  java.lang.String myhost
          Already used host name (from dyndns.txt)
(package private)  java.lang.String name
          Name of the host to register on DynDNS
(package private)  java.lang.String PageBoxURL
          URL of the DeployIF Web service of this PageBox
(package private)  java.lang.String password
          Password used to connect to DynDNS
(package private)  long period
          Period between two retries = 1/4 hour
(package private)  java.util.HashMap repositories
          Key: Repository URL Value: FixInfo object
 Reinstall ri
          Instance used to reinstal archives on startup
(package private)  RepoTest rt
          Used to test repNotifyFix.
(package private)  RuleHandler.Rule rule
          Memory representation of rules.xml
 TokenCallbackImpl tcbi
          Token callback instance
(package private)  boolean toRegister
          If true register the PageBox
private  boolean toStop
          If true ends the thread
(package private)  java.lang.String url
          DynDNS registration service URL
(package private)  java.lang.String user
          User used to connect to DynDNS
(package private)  java.lang.String workDir
          Directory where dyndns.txt is defined
(package private)  java.lang.String ws
          Web service URL
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DynDns(java.lang.String workDir, Log log, ServletContext ctx)
          Constructor.
 
Method Summary
private  void checkArchives()
          Notify fix to the repository if the archive still exists and if its status has not changed.
 java.lang.String computeURL(HttpServletRequest request)
          Compute the URL of the DeployIF Web service of this PageBox.
 void end()
          Requires the thread termination
private  void initialize()
          Check Dynamic DNS parameters and restores dyndns.txt.
 void notifyFix(java.lang.String repURL, java.lang.String repUser, java.lang.String repPassword, java.lang.String arch, int status, java.lang.String subscriber)
          Notify a fix of a PageBox setting problem.
private  void register()
          Retrieves the IP address and calls register2..
(package private)  void register2(java.lang.String addr)
          Calls the registration page and updates dyndns.txt if needed.
private  boolean repNotifyFix(java.lang.String repURL, FixInfo fixInfo, java.lang.String subscriber)
          Notify a fix of a PageBox setting problem.
private  java.lang.String restorePbArchs()
          Parse PbArchives.xml and set the archives HashMap.
 void run()
          Main method of the Retry thread.
private  void saveFixInfo()
          Save pending notifications of PageBox fixes in fixinfo.xml.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

workDir

java.lang.String workDir
Directory where dyndns.txt is defined


log

public Log log
Logging object. Used by EventHandler


url

java.lang.String url
DynDNS registration service URL


user

java.lang.String user
User used to connect to DynDNS


password

java.lang.String password
Password used to connect to DynDNS


host

java.lang.String host
DNS name to register


inter

java.lang.String inter
Network interface registered on DynDNS


name

java.lang.String name
Name of the host to register on DynDNS


dnshost

java.lang.String dnshost
Already used DynDNS registration service URL (from dyndns.txt)


myhost

java.lang.String myhost
Already used host name (from dyndns.txt)


myaddr

java.lang.String myaddr
Already used IP address (from dyndns.txt)


f

java.io.File f
Points on DynDNS.txt


fif

java.io.File fif
Points on fileinfo.xml


period

long period
Period between two retries = 1/4 hour


toStop

private boolean toStop
If true ends the thread


repositories

java.util.HashMap repositories


PageBoxURL

java.lang.String PageBoxURL
URL of the DeployIF Web service of this PageBox


rt

RepoTest rt
Used to test repNotifyFix.


archives

java.util.TreeMap archives
Archives currently installed


ctx

ServletContext ctx
Unique to the Web application


toRegister

boolean toRegister
If true register the PageBox


rule

RuleHandler.Rule rule
Memory representation of rules.xml


tcbi

public TokenCallbackImpl tcbi
Token callback instance


listener

ListenerIF listener
Non-HTTP listener instance


ws

java.lang.String ws
Web service URL


ri

public Reinstall ri
Instance used to reinstal archives on startup

Constructor Detail

DynDns

public DynDns(java.lang.String workDir,
              Log log,
              ServletContext ctx)
Constructor. Called by the Update class.

Parameters:
workDir - Directory where to record the registration
log - logging object
ctx - used to retrieve DynDNS parameters
Method Detail

initialize

private void initialize()
Check Dynamic DNS parameters and restores dyndns.txt.


run

public void run()
Main method of the Retry thread.


end

public void end()
Requires the thread termination


checkArchives

private void checkArchives()
Notify fix to the repository if the archive still exists and if its status has not changed.


restorePbArchs

private java.lang.String restorePbArchs()
Parse PbArchives.xml and set the archives HashMap.

Returns:
status.

register

private void register()
Retrieves the IP address and calls register2..


register2

void register2(java.lang.String addr)
Calls the registration page and updates dyndns.txt if needed.


notifyFix

public void notifyFix(java.lang.String repURL,
                      java.lang.String repUser,
                      java.lang.String repPassword,
                      java.lang.String arch,
                      int status,
                      java.lang.String subscriber)
Notify a fix of a PageBox setting problem. Called by Update.

Parameters:
repURL - URL of the Repository
repUser - Repository subscriber name
repPassword - Repository subscriber password
arch - archive name
status - archive installation status
subscriber - subscribed PageBox that was fixed
Returns:
true in case of success

saveFixInfo

private void saveFixInfo()
Save pending notifications of PageBox fixes in fixinfo.xml.


repNotifyFix

private boolean repNotifyFix(java.lang.String repURL,
                             FixInfo fixInfo,
                             java.lang.String subscriber)
Notify a fix of a PageBox setting problem.

Parameters:
repURL - URL of the repository
fixInfo - notification information
subscriber - subscribed PageBox that was fixed
Returns:
true in case of success

computeURL

public java.lang.String computeURL(HttpServletRequest request)
Compute the URL of the DeployIF Web service of this PageBox.

Parameters:
request - HttpServletRequest.
Returns:
URL of the DepoyIF Web service of this pageBox