protected AbstractScriptEngineFactory()

in src/main/java/org/apache/sling/scripting/api/AbstractScriptEngineFactory.java [54:95]


    protected AbstractScriptEngineFactory() {
        String name = null;
        String version = null;

        // try to get the manifest
        Manifest manifest = null;
        InputStream ins = null;
        try {
            ins = getClass().getResourceAsStream("/META-INF/MANIFEST.MF");
            if (ins != null) {
                manifest = new Manifest(ins);
                Attributes attrs = manifest.getMainAttributes();
                name = attrs.getValue("ScriptEngine-Name");
                version = attrs.getValue("ScriptEngine-Version");
            }
        } catch (IOException ioe) {
            // might want to log ?
        } finally {
            if (ins != null) {
                try {
                    ins.close();
                } catch (IOException ignore) {
                }
            }
        }

        // fall back to class name and version zero
        if (name == null) {
            String className = getClass().getName();
            name = className.substring(className.lastIndexOf('.') + 1);
        }
        if (version == null) {
            version = "0";
        }

        setEngineName(name);
        setEngineVersion(version);

        setExtensions((String[]) null);
        setMimeTypes((String[]) null);
        setNames((String[]) null);
    }