Search in sources :

Example 1 with PluginClassLoader

use of org.jivesoftware.openfire.container.PluginClassLoader in project Openfire by igniterealtime.

the class ClusterClassLoader method getResources.

public Enumeration<URL> getResources(String name) throws IOException {
    Enumeration<URL> answer = null;
    try {
        answer = enterpriseClassloader.getResources(name);
    } catch (IOException e) {
    // Ignore
    }
    if (answer == null || !answer.hasMoreElements()) {
        PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
        for (Plugin plugin : pluginManager.getPlugins()) {
            String pluginName = pluginManager.getPluginDirectory(plugin).getName();
            if ("clustering".equals(pluginName) || "admin".equals(pluginName)) {
                continue;
            }
            PluginClassLoader pluginClassloader = pluginManager.getPluginClassloader(plugin);
            try {
                answer = pluginClassloader.getResources(name);
            } catch (IOException e) {
            // Ignore
            }
            if (answer != null && answer.hasMoreElements()) {
                return answer;
            }
        }
    }
    return answer;
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) IOException(java.io.IOException) URL(java.net.URL) Plugin(org.jivesoftware.openfire.container.Plugin) PluginClassLoader(org.jivesoftware.openfire.container.PluginClassLoader)

Example 2 with PluginClassLoader

use of org.jivesoftware.openfire.container.PluginClassLoader in project Openfire by igniterealtime.

the class ClusterClassLoader method getResource.

public URL getResource(String name) {
    URL resource = hazelcastClassloader.getResource(name);
    if (resource == null) {
        PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
        for (Plugin plugin : pluginManager.getPlugins()) {
            String pluginName = pluginManager.getPluginDirectory(plugin).getName();
            if ("hazelcast".equals(pluginName) || "admin".equals(pluginName)) {
                continue;
            }
            PluginClassLoader pluginClassloader = pluginManager.getPluginClassloader(plugin);
            resource = pluginClassloader.getResource(name);
            if (resource != null) {
                return resource;
            }
        }
    }
    return resource;
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) URL(java.net.URL) Plugin(org.jivesoftware.openfire.container.Plugin) PluginClassLoader(org.jivesoftware.openfire.container.PluginClassLoader)

Example 3 with PluginClassLoader

use of org.jivesoftware.openfire.container.PluginClassLoader in project Openfire by igniterealtime.

the class ClusterClassLoader method getResources.

public Enumeration<URL> getResources(String name) throws IOException {
    Enumeration<URL> answer = null;
    try {
        answer = hazelcastClassloader.getResources(name);
    } catch (IOException e) {
    // Ignore
    }
    if (answer == null || !answer.hasMoreElements()) {
        PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
        for (Plugin plugin : pluginManager.getPlugins()) {
            String pluginName = pluginManager.getPluginDirectory(plugin).getName();
            if ("hazelcast".equals(pluginName) || "admin".equals(pluginName)) {
                continue;
            }
            PluginClassLoader pluginClassloader = pluginManager.getPluginClassloader(plugin);
            try {
                answer = pluginClassloader.getResources(name);
            } catch (IOException e) {
            // Ignore
            }
            if (answer != null && answer.hasMoreElements()) {
                return answer;
            }
        }
    }
    return answer;
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) IOException(java.io.IOException) URL(java.net.URL) Plugin(org.jivesoftware.openfire.container.Plugin) PluginClassLoader(org.jivesoftware.openfire.container.PluginClassLoader)

Example 4 with PluginClassLoader

use of org.jivesoftware.openfire.container.PluginClassLoader in project Openfire by igniterealtime.

the class CacheFactory method getClusteredCacheStrategyClassLoader.

private static ClassLoader getClusteredCacheStrategyClassLoader() {
    PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
    Plugin plugin = pluginManager.getPlugin("hazelcast");
    if (plugin == null) {
        plugin = pluginManager.getPlugin("clustering");
        if (plugin == null) {
            plugin = pluginManager.getPlugin("enterprise");
        }
    }
    PluginClassLoader pluginLoader = pluginManager.getPluginClassloader(plugin);
    if (pluginLoader != null) {
        if (log.isDebugEnabled()) {
            StringBuffer pluginLoaderDetails = new StringBuffer("Clustering plugin class loader: ");
            pluginLoaderDetails.append(pluginLoader.getClass().getName());
            for (URL url : pluginLoader.getURLs()) {
                pluginLoaderDetails.append("\n\t").append(url.toExternalForm());
            }
            log.debug(pluginLoaderDetails.toString());
        }
        return pluginLoader;
    } else {
        log.warn("CacheFactory - Unable to find a Plugin that provides clustering support.");
        return Thread.currentThread().getContextClassLoader();
    }
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) URL(java.net.URL) Plugin(org.jivesoftware.openfire.container.Plugin) PluginClassLoader(org.jivesoftware.openfire.container.PluginClassLoader)

Example 5 with PluginClassLoader

use of org.jivesoftware.openfire.container.PluginClassLoader in project Openfire by igniterealtime.

the class ClusterClassLoader method getResource.

public URL getResource(String name) {
    URL resource = enterpriseClassloader.getResource(name);
    if (resource == null) {
        PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
        for (Plugin plugin : pluginManager.getPlugins()) {
            String pluginName = pluginManager.getPluginDirectory(plugin).getName();
            if ("clustering".equals(pluginName) || "admin".equals(pluginName)) {
                continue;
            }
            PluginClassLoader pluginClassloader = pluginManager.getPluginClassloader(plugin);
            resource = pluginClassloader.getResource(name);
            if (resource != null) {
                return resource;
            }
        }
    }
    return resource;
}
Also used : PluginManager(org.jivesoftware.openfire.container.PluginManager) URL(java.net.URL) Plugin(org.jivesoftware.openfire.container.Plugin) PluginClassLoader(org.jivesoftware.openfire.container.PluginClassLoader)

Aggregations

URL (java.net.URL)5 Plugin (org.jivesoftware.openfire.container.Plugin)5 PluginClassLoader (org.jivesoftware.openfire.container.PluginClassLoader)5 PluginManager (org.jivesoftware.openfire.container.PluginManager)5 IOException (java.io.IOException)2