jklustor-overlap-0.0.2-20140619012940 (ChemAxon)


com.chemaxon.overlap.io
Class StandardizerWrappers

Object
  extended by com.chemaxon.overlap.io.StandardizerWrappers

@Beta
public final class StandardizerWrappers
extends Object

Provide utility methods for StandardizerWrapper.

Please note that the ThreadLocal based thread safety fix might lead to unexpected memory leaks when worker threads invoking the provided wrappers are pooled. To mitigate this problem make the reference to the wrapper inacessable allowing the garbage collector to free the thread local copies up.

Note that an alternative approach would be to implement a Closeable semantics to allow explicitly freeing up the copies, however this is currently considered not viable.

TODO: investigate the possibility to implement some expiring cache to drop (and if necessary, re-inti) ThreadLocals. TODO: Maybe ExpiringThreadLocal(timeout)? to mitigate this issue?

Author:
Gabor Imre
See Also:
http://www.javacodegeeks.com/2013/01/how-to-shoot-yourself-in-foot-with-threadlocals.html, http://stackoverflow.com/questions/817856/when-and-how-should-i-use-a-threadlocal-variable

Method Summary
static StandardizerWrapper fromStandardizerCfgLocation(String cfglocation)
          Wrap a Standardizer with config file location.
static StandardizerWrapper fromStandardizerConfigXml(String configXml)
          Wrap a Standardizer with config XML location.
static StandardizerWrapper identityStandardizer()
          Identity standardization.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fromStandardizerCfgLocation

public static StandardizerWrapper fromStandardizerCfgLocation(String cfglocation)
Wrap a Standardizer with config file location.

The returned wrapper uses ThreadLocal clones of the supplied Standardizers. For details see #fromStandardizer(chemaxon.standardizer.Standardizer)

Parameters:
cfglocation - Config file location
Returns:
Wrapped and initialzied Standardizer
Throws:
IllegalArgumentException - upon initialization proble,

fromStandardizerConfigXml

public static StandardizerWrapper fromStandardizerConfigXml(String configXml)
Wrap a Standardizer with config XML location.

The returned wrapper uses ThreadLocal clones of the supplied Standardizers. For details see #fromStandardizer(chemaxon.standardizer.Standardizer)

The returned wrapper is serializable and thread safe. Apart from the ThreadLocal storage state it is immutable.

Parameters:
configXml - Configuration file location
Returns:
Wrapped and initialzied Standardizer
Throws:
IllegalArgumentException - upon initialization proble,

identityStandardizer

public static StandardizerWrapper identityStandardizer()
Identity standardization.

Returns:
Wrapper doing nothing

jklustor-overlap-0.0.2-20140619012940 (ChemAxon)