org.apache.turbine.services.uniqueid

## Class TurbineUniqueIdService

- java.lang.Object
- - org.apache.turbine.services.BaseInitable
  - - org.apache.turbine.services.BaseService
    - - org.apache.turbine.services.TurbineBaseService
      - - org.apache.turbine.services.uniqueid.TurbineUniqueIdService

- All Implemented Interfaces:
    Initable, Service, UniqueIdService

      public class TurbineUniqueIdService
      extends TurbineBaseService
      implements UniqueIdService

  This is an implementation of `UniqueIdService`.

  Version:
    $Id: TurbineUniqueIdService.java 1706239 2015-10-01 13:18:35Z tv $
  Author:
    Rafal Krzewski, Henning P. Schmiedehausen

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `counter`
    `protected static String` | `turbineId` The identifier of this instance of turbine.
    `protected static String` | `turbineURL`

    - ### Fields inherited from class org.apache.turbine.services.BaseService

      `configuration, name, serviceBroker`

    - ### Fields inherited from class org.apache.turbine.services.BaseInitable

      `initableBroker, isInitialized`

    - ### Fields inherited from interface org.apache.turbine.services.uniqueid.UniqueIdService

      `SERVICE_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TurbineUniqueIdService()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getInstanceId()` Returns an identifier of this Turbine instance that is unique both on the server and worldwide.
    `String` | `getPseudorandomId()` Returns a unique identifier that looks like random data.
    `String` | `getUniqueId()` Returns an identifier that is unique within this turbine instance, but does not have random-like apearance.
    `void` | `init()` Initializes the service upon first Turbine.doGet() invocation.
    `void` | `shutdown()` Writes a message to the log upon system shutdown.

    - ### Methods inherited from class org.apache.turbine.services.TurbineBaseService

      `init, init`

    - ### Methods inherited from class org.apache.turbine.services.BaseService

      `getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker`

    - ### Methods inherited from class org.apache.turbine.services.BaseInitable

      `getInit, getInitableBroker, setInit, setInitableBroker`

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

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

    - ### Methods inherited from interface org.apache.turbine.services.Service

      `getConfiguration, getName, getProperties, setName, setServiceBroker`

    - ### Methods inherited from interface org.apache.turbine.services.Initable

      `getInit, init, setInitableBroker`

- - ### Field Detail

    - #### turbineId

          protected static String turbineId

      The identifier of this instance of turbine.

    - #### turbineURL

          protected static String turbineURL

    - #### counter

          protected static int counter

  - ### Constructor Detail

    - #### TurbineUniqueIdService

          public TurbineUniqueIdService()

  - ### Method Detail

    - #### init

          public void init()
                    throws InitializationException

      Initializes the service upon first Turbine.doGet() invocation.

      Specified by:
        `init` in interface `Initable`
      Overrides:
        `init` in class `TurbineBaseService`
      Throws:
        `InitializationException` - Initialization of this class was not successful.

    - #### shutdown

          public void shutdown()

      Writes a message to the log upon system shutdown.

      Specified by:
        `shutdown` in interface `Initable`
      Overrides:
        `shutdown` in class `TurbineBaseService`

    - #### getInstanceId

          public String getInstanceId()

      Returns an identifier of this Turbine instance that is unique both on the server and worldwide. This identifier is computed as an MD5 sum of the URL (including schema, address, port if different that 80/443 respecively, context and servlet name). There is an overwhelming probalility that this id will be different that all other Turbine instances online.

      Specified by:
        `getInstanceId` in interface `UniqueIdService`
      Returns:
        A String with the instance identifier.

    - #### getUniqueId

          public String getUniqueId()

      Returns an identifier that is unique within this turbine instance, but does not have random-like apearance.

      Specified by:
        `getUniqueId` in interface `UniqueIdService`
      Returns:
        A String with the non-random looking instance identifier.

    - #### getPseudorandomId

          public String getPseudorandomId()

      Returns a unique identifier that looks like random data.

      Specified by:
        `getPseudorandomId` in interface `UniqueIdService`
      Returns:
        A String with the random looking instance identifier.

Copyright © 2000-2015 The Apache Software Foundation. All Rights Reserved.