com.ebmwebsourcing.easycommons.xml
Class TransformerResourcePool

java.lang.Object
  extended by com.ebmwebsourcing.easycommons.xml.TransformerResourcePool

public class TransformerResourcePool
extends java.lang.Object

This class represent a Transformer pool, which provided Transformer object as resource.

Author:
aruffie, Nicolas Oddoux - EBM WebSourcing

Constructor Summary
TransformerResourcePool(int minPoolSize, int maxPoolSize, PoolPolicy poolPolicy)
          Allowing to instantiate a new TransformerResourcePool containing Transformer resources.
 
Method Summary
 void release(javax.xml.transform.Transformer transformer)
          Release the specified Transformer After putting back the Transformer in the pool, the method onRelease() of the Transformer resource handler is called.
 javax.xml.transform.Transformer take()
          Take one unused Transformer in the current pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformerResourcePool

public TransformerResourcePool(int minPoolSize,
                               int maxPoolSize,
                               PoolPolicy poolPolicy)
Allowing to instantiate a new TransformerResourcePool containing Transformer resources.

Parameters:
minPoolSize - The minimum number of Transformer instances in the pool (created at the initialization).
maxPoolSize - the maximum number of Transformer instances in the current pool (limit of the pool). It must be greater or equals to the specified minSize. The maximum value is Integer.MAX_VALUE
poolPolicy - the PoolPolicy to adopt when the maximum size is reached. it must not be null.
Method Detail

take

public javax.xml.transform.Transformer take()
Take one unused Transformer in the current pool. After getting a Transformer from the pool and before returning a Transformer, the method onTake() of the Transformer resource handler is called.

Returns:
one Transformer
Throws:
PoolException - if the current thread is interrupted for the pool policy WAIT or if there is no more available resource in the pool for the pool policy REJECT

release

public final void release(javax.xml.transform.Transformer transformer)
Release the specified Transformer After putting back the Transformer in the pool, the method onRelease() of the Transformer resource handler is called.

Parameters:
transformer - The Transformer to release


Copyright © 2012 Petals Link. All Rights Reserved.