private void write( final ExecutionContext executionContext )
{
Object bean = executionContext.getBeanContext().getBean( beanId );
if ( bean == null )
{
throw new SmooksException( "A bean with id [" + beanId + "] was not found in the executionContext");
}
OutputStream out = AbstractOutputStreamResource.getOutputStream( resourceName, executionContext );
try
{
if ( bean instanceof String )
{
out.write( ( (String)bean).getBytes(encoding ) );
}
else if ( bean instanceof byte[] )
{
out.write( new String( (byte[]) bean, encoding ).getBytes() ) ;
}
else
{
out = new ObjectOutputStream( out );
((ObjectOutputStream)out).writeObject( bean );
}
out.flush();
}
catch (IOException e)
{
final String errorMsg = "IOException while trying to append to file";
throw new SmooksException( errorMsg, e );
}
}