// TODO: this method could move to a more general place.
private static Adapter tryAdapter( Class adapterClass, Object externalContext )
{
try
{
Adapter sa = ( Adapter ) adapterClass.newInstance();
try
{
AdapterContext context = new AdapterContext( externalContext );
if ( sa.accept( context ) )
{
_log.info( "Adapter " + adapterClass.getName() + " accepted." );
sa.setContext( context );
return sa;
}
else
{
_log.info( "Adapter " + adapterClass.getName() + " is present but did not accept." );