private static Optional < Invocable > newInvocable ( final Object target , final Collection < Supplier < Reader > > scripts ) { Optional < Invocable > invocable ; if ( ! scripts . isEmpty ( ) ) { final ScriptEngine engine = new ScriptEngineManager ( ) . getEngineByName ( "javascript" ) ; engine . put ( "target" , target ) ; scripts . stream ( ) . forEach ( script -> loadScript ( engine , script ) ) ; invocable = Optional . of ( ( Invocable ) engine ) ; } else { invocable = Optional . empty ( ) ; } return invocable ; }
Creates a new invocable proxy . The proxy may be used to create interface implementations that are implemented in javascript .