<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">

package ${PACKAGENAME};

import org.graalvm.visualvm.application.Application;
import org.graalvm.visualvm.application.jvm.Jvm;
import org.graalvm.visualvm.application.type.ApplicationType;
import org.graalvm.visualvm.application.type.ApplicationTypeFactory;
import org.graalvm.visualvm.application.type.MainClassApplicationTypeFactory;

public class ${TEMPLATENAME}ApplicationTypeProvider extends MainClassApplicationTypeFactory {
    private static class Singleton {
        final private static ${TEMPLATENAME}ApplicationTypeProvider INSTANCE = new ${TEMPLATENAME}ApplicationTypeProvider();
    }

    private ${TEMPLATENAME}ApplicationTypeProvider() {}

    /**
     * Call this method from the module Installer#restored()
     **/
    static public void install() {
        ApplicationTypeFactory.getDefault().registerProvider(Singleton.INSTANCE);
    }
    
    /**
     * Call this method from the module Installer#uninstalled()
     **/
    static public void uninstall() {
        ApplicationTypeFactory.getDefault().unregisterProvider(Singleton.INSTANCE);
    }

    @Override
    public ApplicationType createApplicationTypeFor(Application app, Jvm jvm, String mainClass) {

        //TODO: Specify the name of the application's main class here:
        if ("${DISPLAYNAME}".equals(mainClass)) {
            return new ${TEMPLATENAME}ApplicationType(app.getPid());
        }
        return null;

    }
    
}
