Please see examples at
Bean Shell Programming