org.compass.core.converter.basic.format
Class ThreadSafeFormat

java.lang.Object
  extended by org.compass.core.converter.basic.format.ThreadSafeFormat
All Implemented Interfaces:
Formatter

public class ThreadSafeFormat
extends Object
implements Formatter

Wrapper around Formatter that can be called by multiple threads concurrently.

Format has a high overhead in creating and is not thread safe. To make best use of resources, the ThreadSafeFormat provides a dynamically sizing pool of instances, each of which will only be called by a single thread at a time.

The pool has a maximum capacity, to limit overhead. If all instances in the pool are in use and another is required, it shall block until one becomes available.

Author:
kimchy

Constructor Summary
ThreadSafeFormat(int initialPoolSize, int maxPoolSize, FormatterFactory formatterFactory)
           
 
Method Summary
 String format(Object obj)
          Formats the given object to String.
 boolean isThreadSafe()
          Returns true if this formatter is thread safe, false otherwise.
 Object parse(String str)
          Parse the given string to an Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadSafeFormat

public ThreadSafeFormat(int initialPoolSize,
                        int maxPoolSize,
                        FormatterFactory formatterFactory)
Method Detail

isThreadSafe

public boolean isThreadSafe()
Description copied from interface: Formatter
Returns true if this formatter is thread safe, false otherwise.

Specified by:
isThreadSafe in interface Formatter

format

public String format(Object obj)
Description copied from interface: Formatter
Formats the given object to String.

Specified by:
format in interface Formatter

parse

public Object parse(String str)
             throws ParseException
Description copied from interface: Formatter
Parse the given string to an Object.

Specified by:
parse in interface Formatter
Throws:
ParseException


Copyright (c) 2004-2008 The Compass Project.