Implement event dispatch on the java side.