Here you can find the source of invokeCallback(String callbackName, String callbackParam)
public static void invokeCallback(String callbackName, String callbackParam)
//package com.java2s; /*//www .j a v a 2s .c o m * * * Copyright 2011 Baptiste Wicht & Fr?d?ric Bapst * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import java.lang.reflect.Method; import java.util.regex.Pattern; public class Main { private static final Class<?>[] CALLBACK_PARAM_TYPES = { String.class }; private static final Pattern METHOD_SEPARATOR = Pattern.compile("/"); public static void invokeCallback(String callbackName, String callbackParam) { int a = callbackName.lastIndexOf('/'); if (a < 0) { throw new IllegalStateException("bad callback format (should be ab/cd/className/methName)"); } String className = METHOD_SEPARATOR.matcher(callbackName.substring(0, a)).replaceAll("."); String methodName = callbackName.substring(a + 1); try { Class<?> clazz = Class.forName(className); Method method = clazz.getMethod(methodName, CALLBACK_PARAM_TYPES); method.invoke(null, callbackParam); } catch (Exception e) { throw new IllegalStateException(e); } } }