All Downloads are FREE. Search and download functionalities are using the official Maven repository.

play.modules.gtengineplugin.gt_integration.GTJavaExtensionMethodResolver1x Maven / Gradle / Ivy

Go to download

RePlay is a fork of the Play1 framework, made and maintained by Codeborne.

The newest version!
package play.modules.gtengineplugin.gt_integration;

import play.Play;
import play.template2.compile.GTJavaExtensionMethodResolver;
import play.templates.JavaExtensions;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GTJavaExtensionMethodResolver1x implements GTJavaExtensionMethodResolver {

    private static final Object lock = new Object();
    private static Map methodName2ClassMapping;

    @Override 
    public Class findClassWithMethod(String methodName) {
        synchronized (lock) {
            if (methodName2ClassMapping == null) {
                List extensionsClassnames = new ArrayList<>(5);
                extensionsClassnames.add(JavaExtensions.class);
                extensionsClassnames.addAll(Play.classes.getAssignableClasses(JavaExtensions.class));

                methodName2ClassMapping = new HashMap<>();
                for ( Class clazz : extensionsClassnames) {
                    for ( Method method : clazz.getDeclaredMethods()) {
                        methodName2ClassMapping.put(method.getName(), clazz);
                    }
                }
            }
        }

        return methodName2ClassMapping.get(methodName);

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy