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

package ${PACKAGENAME};

import com.sun.tools.visualvm.application.Application;
import com.sun.tools.visualvm.application.jvm.Jvm;
import com.sun.tools.visualvm.application.type.ApplicationType;
import com.sun.tools.visualvm.application.type.ApplicationTypeFactory;
import com.sun.tools.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;

    }
    
}
