org.hd.d.pg2k.webSvr.util
Class StatsSink.AbstractStatsListener

java.lang.Object
  extended by org.hd.d.pg2k.webSvr.util.StatsSink.AbstractStatsListener
All Implemented Interfaces:
java.io.ObjectInputValidation
Direct Known Subclasses:
AdUtils.ClickThruHandler, WebUtils.VoteHandler
Enclosing class:
StatsSink

public abstract static class StatsSink.AbstractStatsListener
extends java.lang.Object
implements java.io.ObjectInputValidation

Abstract/base listener object waiting for stats to arrive. This has an embedded unique listener ID, cryptographically generated, and pure-alphanumeric-ASCII suitable for embedding in URLs, etc.


Field Summary
private  long expireBy
          Date/time that we expire by (ms).
 java.lang.String uniqueDataPointID
          Unique data-point identifier: not more than one listener with given ID can exist at once; never null nor empty.
 java.lang.String uniqueListenerID
          Unique listener ID: unique-for-all-time pure-alphanumeric-ASCII identifier for this listener.
 
Constructor Summary
StatsSink.AbstractStatsListener(java.lang.String uniqueDataPointID, long expireBy)
          Construct an instance.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality is on just the data point ID.
abstract  java.lang.String handle(java.util.Map<java.lang.String,java.lang.String[]> parameters)
          Handle a (non-null) Map of input parameters (String name to String[] value array).
 int hashCode()
          The hash is based on the data point ID.
 boolean isExpired()
          Returns true if this listener has expired.
 void validateObject()
          Check state is valid; complain if not.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uniqueListenerID

public final java.lang.String uniqueListenerID
Unique listener ID: unique-for-all-time pure-alphanumeric-ASCII identifier for this listener. This ID ends up in external URLs and identifies this listener until it expires or removes itself.

Generated from a cryptographically-secure source, so should not be possible to guess in advance.

The use of this may make creation of instances of this class expensive.


uniqueDataPointID

public final java.lang.String uniqueDataPointID
Unique data-point identifier: not more than one listener with given ID can exist at once; never null nor empty. Can be used to contain, for example, something like VOTE-214.21.39, eg a combination of a stats purpose and a unique identifier for a user such as part of their IP address, such that we never ask them (or accept responses) for more than one vote per user.

Note therefore that this is not a unique-for-all-time identifier, but rather a unique-data-point-to-collect identifier.


expireBy

private final long expireBy
Date/time that we expire by (ms). Once this time has passed this listener will disappear.

Constructor Detail

StatsSink.AbstractStatsListener

public StatsSink.AbstractStatsListener(java.lang.String uniqueDataPointID,
                                       long expireBy)
Construct an instance.

Parameters:
uniqueDataPointID - unique data-point identifier for a data point to collect, only one data point with this name can be requested at any one time any previous one being ignored for example; never null nor empty
expireBy - time by which this listener should expire regardless of whether the listened-for data point has arrived; strictly positive
Method Detail

isExpired

public boolean isExpired()
Returns true if this listener has expired.


handle

public abstract java.lang.String handle(java.util.Map<java.lang.String,java.lang.String[]> parameters)
Handle a (non-null) Map of input parameters (String name to String[] value array). Return a redirection URL (or null for no redirection).

The ID string will generally be amongst the properties in its external form.

As a side-effect, this should so what ever processing it needs in order to record the data point.

By default, this listener instance is removed once this routine has been called.

The ID (and thus this data point) has already been validated by the time that this call is made.


hashCode

public int hashCode()
The hash is based on the data point ID.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Equality is on just the data point ID.

Overrides:
equals in class java.lang.Object

validateObject

public void validateObject()
                    throws java.io.InvalidObjectException
Check state is valid; complain if not.

Specified by:
validateObject in interface java.io.ObjectInputValidation
Throws:
java.io.InvalidObjectException

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.