tigase.server.ssender

## Class FileTask

- java.lang.Object
- - java.util.TimerTask
  - - tigase.server.ssender.SenderTask
    - - tigase.server.ssender.FileTask

- All Implemented Interfaces:
    Runnable

      public class FileTask
      extends SenderTask

  `FileTask` implements tasks for cyclic retrieving stanzas from a directory and sending them to the StanzaHandler object.
  It looks for any new stanza to send. Any single file can contain only single stanza to send and any entry in database table can also contain only single stanza to send. File on hard disk and record in database is deleted after it is read.
  Any file in given directory is treated the same way - Tigase assumes it contains valid XML data with XMPP stanza to send. You can however set in configuration, using wildchars which files contain stanzas. All stanzas must contain complete data including correct "from" and "to" attributes.
  By default it looks for `*.stanza` files in `/var/spool/jabber/` folder but you can specify different directory name in initialization string. Sample initialization strings:

      /var/spool/jabber/*.stanza

      /var/spool/jabber/*

  The last is equal to:

      /var/spool/jabber/

  Note the last forward slash '/' is required in such case if the last element of the path is a directory.
  Please note! Tigase must have writing permissions for this directory, otherwise it may not function properly.
  Created: Fri Apr 20 12:10:55 2007
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileTask()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getInitString()` `getInitString` method returns initialization string passed to it in `init()` method.
    `void` | `init(StanzaHandler handler, String initString)` `init` method is a task specific initialization rountine.
    `void` | `run()` `run` method is where all task work is done.

    - ### Methods inherited from class tigase.server.ssender.SenderTask

      `getName, setName`

    - ### Methods inherited from class java.util.TimerTask

      `cancel, scheduledExecutionTime`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileTask

          public FileTask()

  - ### Method Detail

    - #### init

          public void init(StanzaHandler handler,
                           String initString)
                    throws IOException

      `init` method is a task specific initialization rountine.
      Specified by:
        `init` in class `SenderTask`
      Parameters:
        `handler` - a `StanzaHandler` value is a reference to object which handles all stanza retrieved from data source. The handler is responsible for delivering stanza to destination address.
        `initString` - a `String` value is an initialization string for this task. For example database tasks would expect database connection string here, filesystem task would expect directory here.
      Throws:
        `IOException` - if an error occurs during task or data storage initialization.

    - #### getInitString

          public String getInitString()

      `getInitString` method returns initialization string passed to it in `init()` method.
      Specified by:
        `getInitString` in class `SenderTask`
      Returns:
        a `String` value of initialization string.

    - #### run

          public void run()

      `run` method is where all task work is done.
      Specified by:
        `run` in interface `Runnable`
      Specified by:
        `run` in class `TimerTask`

Copyright © 2022 "Tigase, Inc.". All rights reserved.