net.sf.uadetector.service
Class UADetectorServiceFactory

java.lang.Object
  extended by net.sf.uadetector.service.UADetectorServiceFactory

public final class UADetectorServiceFactory
extends java.lang.Object

Service factory to get preconfigured instances of UserAgentStringParser implementations.

Author:
André Rouél

Nested Class Summary
static class UADetectorServiceFactory.ResourceModuleXmlDataStore
          A simple implementation to store UAS data delivered in this module (called uadetector-resource) only in the heap space.
 
Field Summary
static UADetectorServiceFactory.ResourceModuleXmlDataStore RESOURCE_MODULE
          Data store filled with the UAS data that are shipped with this module (JAR)
static UserAgentStringParser RESOURCE_MODULE_PARSER
          UserAgentStringParser filled with the UAS data that are shipped with this module (JAR)
 
Method Summary
static UserAgentStringParser getCachingAndUpdatingParser()
          Returns an implementation of UserAgentStringParser which checks at regular intervals for new versions of UAS data (also known as database).
static UserAgentStringParser getOnlineUpdatingParser()
          Returns an implementation of UserAgentStringParser which checks at regular intervals for new versions of UAS data (also known as database).
static UserAgentStringParser getResourceModuleParser()
          Returns an implementation of UserAgentStringParser with no updating functions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_MODULE

public static final UADetectorServiceFactory.ResourceModuleXmlDataStore RESOURCE_MODULE
Data store filled with the UAS data that are shipped with this module (JAR)


RESOURCE_MODULE_PARSER

public static final UserAgentStringParser RESOURCE_MODULE_PARSER
UserAgentStringParser filled with the UAS data that are shipped with this module (JAR)

Method Detail

getCachingAndUpdatingParser

public static UserAgentStringParser getCachingAndUpdatingParser()
Returns an implementation of UserAgentStringParser which checks at regular intervals for new versions of UAS data (also known as database). When newer data available, it automatically loads and updates it. Additionally the loaded data are stored in a cache file.

At initialization time the returned parser will be loaded with the UAS data of the cache file. If the cache file doesn't exist or is empty the data of this module will be loaded. The initialization is started only when this method is called the first time.

The update of the data store runs as background task. With this feature we try to reduce the initialization time of this UserAgentStringParser, because a network connection is involved and the remote system can be not available or slow.

The static class definition CachingAndUpdatingParserHolder within this factory class is not initialized until the JVM determines that CachingAndUpdatingParserHolder must be executed. The static class CachingAndUpdatingParserHolder is only executed when the static method getOnlineUserAgentStringParser is invoked on the class UADetectorServiceFactory, and the first time this happens the JVM will load and initialize the CachingAndUpdatingParserHolder class.

If during the operation the Internet connection gets lost, then this instance continues to work properly (and under correct log level settings you will get an corresponding log messages).

Returns:
an user agent string parser with updating service

getOnlineUpdatingParser

public static UserAgentStringParser getOnlineUpdatingParser()
Returns an implementation of UserAgentStringParser which checks at regular intervals for new versions of UAS data (also known as database). When newer data available, it automatically loads and updates it.

At initialization time the returned parser will be loaded with the UAS data of this module (the shipped one within the uadetector-resources JAR) and tries to update it. The initialization is started only when this method is called the first time.

The update of the data store runs as background task. With this feature we try to reduce the initialization time of this UserAgentStringParser, because a network connection is involved and the remote system can be not available or slow.

The static class definition OnlineUpdatingParserHolder within this factory class is not initialized until the JVM determines that OnlineUpdatingParserHolder must be executed. The static class OnlineUpdatingParserHolder is only executed when the static method getOnlineUserAgentStringParser is invoked on the class UADetectorServiceFactory, and the first time this happens the JVM will load and initialize the OnlineUpdatingParserHolder class.

If during the operation the Internet connection gets lost, then this instance continues to work properly (and under correct log level settings you will get an corresponding log messages).

Returns:
an user agent string parser with updating service

getResourceModuleParser

public static UserAgentStringParser getResourceModuleParser()
Returns an implementation of UserAgentStringParser with no updating functions. It will be loaded by using the shipped UAS data (also known as database) of this module. The database is loaded once during initialization. The initialization is started at class loading of this class (UADetectorServiceFactory).

Returns:
an user agent string parser without updating service


Copyright © 2011-2014. All Rights Reserved.