org.szegedi.spring.web.jsflow.codec
Class PooledCodec

java.lang.Object
  extended by org.szegedi.spring.web.jsflow.codec.PooledCodec
All Implemented Interfaces:
BinaryStateCodec

public class PooledCodec
extends java.lang.Object
implements BinaryStateCodec

A codec that can pool and reuse OneWayCodec instances of another codec it wraps. The pool uses soft references, and therefore plays nicely with regard to memory. It is recommended with codecs that can have high initialization overhead, i.e. a ConfidentialityCodec using password-based encryption, or a IntegrityCodec. When more than one of these are combined into a CompositeCodec, it is a good idea to wrap the composite codec with a pooled codec, instead of wrapping the individual component codecs.

Version:
$Id: PooledCodec.java 10 2006-05-16 09:49:48Z szegedia $
Author:
Attila Szegedi

Constructor Summary
PooledCodec()
           
 
Method Summary
 OneWayCodec createDecoder()
          Create a one-way single-threaded, nonshared codec instance able to decode a state as received from the client or from an upstream codec.
 OneWayCodec createEncoder()
          Create a one-way single-threaded, nonshared codec instance able to encode a state as should be sent to a client or a downstream codec.
 void setBinaryStateCodec(BinaryStateCodec binaryStateCodec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PooledCodec

public PooledCodec()
Method Detail

setBinaryStateCodec

public void setBinaryStateCodec(BinaryStateCodec binaryStateCodec)

createDecoder

public OneWayCodec createDecoder()
                          throws java.lang.Exception
Description copied from interface: BinaryStateCodec
Create a one-way single-threaded, nonshared codec instance able to decode a state as received from the client or from an upstream codec.

Specified by:
createDecoder in interface BinaryStateCodec
Returns:
the codec for decoding
Throws:
java.lang.Exception

createEncoder

public OneWayCodec createEncoder()
                          throws java.lang.Exception
Description copied from interface: BinaryStateCodec
Create a one-way single-threaded, nonshared codec instance able to encode a state as should be sent to a client or a downstream codec.

Specified by:
createEncoder in interface BinaryStateCodec
Returns:
the codec for encoding
Throws:
java.lang.Exception