Package net.visualillusionsent.utils

Examples of net.visualillusionsent.utils.PropertiesFile


     */
    private final void buildDepTree(HashMap<String, PropertiesFile> knownJars, LinkedList<DependencyNode> loadOrder) {
        HashMap<String, DependencyNode> nodes = new HashMap<String, DependencyNode>();
        // Make the flat dep tree
        for (String jar : knownJars.keySet()) {
            PropertiesFile inf = knownJars.get(jar);
            nodes.put(inf.getString("name"), new DependencyNode(inf.getString("name"), jar, inf));
        }
        // Create the basic dependency list
        Iterator<String> itr = nodes.keySet().iterator();
        while (itr.hasNext()) {
            String jar = itr.next();
            DependencyNode node = nodes.get(jar);
            PropertiesFile inf = node.getInf();

            if (inf.containsKey("dependencies")) {
                String[] dependencies = inf.getStringArray("dependencies", "[,;]+");
                for (String dependency : dependencies) {
                    dependency = dependency.trim();
                    // Remove empty entries
                    if (dependency.length() == 0) {
                        continue;
                    }
                    if (!nodes.containsKey(dependency)) {
                        Canary.logServerMessage("Cannot find dependency " + dependency + " but " + jar + " depends on it. Removing.");
                        itr.remove();
                        continue;
                    }
                    if (!node.edges.contains(nodes.get(dependency))) {
                        node.edges.add(nodes.get(dependency));
                    }
                }
            }

            if (inf.containsKey("optional-dependencies")) {
                String[] softDependencies = inf.getStringArray("optional-dependencies", "[,;]+");
                for (String dependency : softDependencies) {
                    dependency = dependency.trim();
                    // Remove empty entries
                    if (dependency.length() == 0) {
                        continue;
View Full Code Here


        try {
            if (!file.isFile()) {
                return false;
            }

            PropertiesFile inf = new PropertiesFile(file.getAbsolutePath(), "Canary.inf");
            // Get the main class, or use the plugin name as class
            if (!inf.containsKey("main-class")) {
                Canary.logSevere("Failed to read main-class for '" + file.getName() + "' in Canary.inf Please specify a main-class entry in Canary.inf");
                return false;
            }

            if (!inf.containsKey("name")) {
                inf.setString("name", simpleMain(inf.getString("main-class")));
            }
            inf.setString("jarPath", "plugins/".concat(file.getName()));
            inf.setString("jarName", file.getName().replace(".jar", ""));

            return load(file.getName(), inf);
        }
        catch (Throwable ex) {
            Canary.logStacktrace("Exception while loading plugin", ex);
View Full Code Here

        File test = new File(path);

        if (!test.exists()) {
            Canary.logInfo("Could not find the database configuration at " + path + ", creating default.");
        }
        this.cfg = new PropertiesFile(path);
        verifyConfig();
    }
View Full Code Here

            }
        }
        if (needNewInstance) {
            try {
                File file = new File(plugin.getJarPath());
                PropertiesFile inf = new PropertiesFile(file.getAbsolutePath(), "Canary.inf");
                pluginInf.put(plugin.getClass().getSimpleName(), inf);
                if (testDependencies(plugin)) { // Test for changes
                    CanaryClassLoader ploader = new CanaryClassLoader(new File(inf.getString("jarPath")).toURI().toURL(), getClass().getClassLoader());
                    Class<?> cls = ploader.loadClass(inf.getString("main-class"));
                    plugin = (Plugin) cls.newInstance();
                    enabled = plugin.enable();
                    plugins.put(plugin.getName(), plugin);
                }
            }
View Full Code Here

            return false;
        }

        // Disable the plugin
        disablePlugin(plugin);
        PropertiesFile orgInf;
        synchronized (lock) {
            plugins.remove(plugin.getName());
            ((CanaryClassLoader) plugin.getClass().getClassLoader()).close(); // close loader
            /* Remove INF reference */
            orgInf = pluginInf.remove(plugin.getClass().getSimpleName());
        }
        plugin.markClosed();
        // Reload the plugin by loading its package again
        boolean test = load(new File(orgInf.getString("jarPath")));
        if (test) {
            test = enablePlugin(plugin.getName()); // We have a name, not the new instance. Don't pass the plugin directly.

            // Check for dependents and reload them as well
            if (plugin.hasDependents()) {
View Full Code Here

        File test = new File(path);

        if (!test.exists()) {
            Canary.logInfo("Could not find the server configuration at " + path + ", creating default.");
        }
        this.cfg = new PropertiesFile("config" + File.separatorChar + "server.cfg");
        verifyConfig();
    }
View Full Code Here

TOP

Related Classes of net.visualillusionsent.utils.PropertiesFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.