Quantcast
Channel: Planet Apache
Viewing all articles
Browse latest Browse all 9364

Simone Tripodi: Async Apache Commons Digester

$
0
0
Java people familiar with Push/Comet and Websocket probably know the Atmosphere freamork and his author, Jeanfrançois Arcand that is the original author of another great piece of software: the AsycHttpClient.
I had a love at first sight with the AHC that I won't ever change it, I really like the innovation introduced by this library.

Then, taking inspiration from those concurrent APIs, I just introduced a small feature to Apache Commons Digester to support asynchronous parse operation, that will be available from release 3.1.
Once plugged their preferred java.util.concurrent.ExecutorService instance, users will be able to invoke the Digester#parse() method asynchronously:

final DigesterLoader digesterLoader = newLoader( new AbstractRulesModule()
{

    @Override
    protected void configure()
    {
        forPattern( "root" ).createObject().ofType( MyPOJO.class );
        ...
    }

} ).setExecutorService( Executors.newFixedThreadPool( 10 ) );
...
Digester digester = digesterLoader.newDigester();
Future<MyPOJO> future = digester.asyncParse( getClass().getResource( "mydoc.xml" ) );
MyPOJO myPojo = future.get();

Not at the same smart level of the AHC, but a useful small feature that users will - hopefully - enjoy :)

Viewing all articles
Browse latest Browse all 9364

Trending Articles