org.jivesoftware.openfire.container.PluginManager Java Examples

The following examples show how to use org.jivesoftware.openfire.container.PluginManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JigasiWrapper.java    From openfire-ofmeet-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize( final PluginManager manager, final File pluginDirectory )
{
    this.pluginDirectory = pluginDirectory;

    try
    {
        checkNatives();
    }
    catch ( Exception e )
    {
        Log.warn( "An unexpected error occurred while checking the native libraries.", e );
    }

    // The CallControlComponent implementation depends on OSGI-based loading of
    // Components, which is prepared for here.
    if ( OSGi.class.getClassLoader() != Thread.currentThread().getContextClassLoader() )
    {
        // the OSGi class should not be present in Openfire itself, or in the parent plugin of these modules. The OSGi implementation does not allow for more than one bundle to be configured/started, which leads to undesired re-used of
        // configuration of one bundle while starting another bundle.
        Log.warn( "The OSGi class is loaded by a class loader different from the one that's loading this module. This suggests that residual configuration is in the OSGi class instance, which is likely to prevent Jigasi from functioning correctly." );
    }

    reloadConfiguration();
}
 
Example #2
Source File: JvbPluginWrapper.java    From openfire-ofmeet-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the wrapped component.
 */
@Override
public synchronized void initialize( final PluginManager manager, final File pluginDirectory )
{
    Log.debug( "Initializing Jitsi Videobridge..." );

    if ( jitsiPlugin != null )
    {
        Log.warn( "Another Jitsi Videobridge appears to have been initialized earlier! Unexpected behavior might be the result of this new initialization!" );
    }

    reloadConfiguration();

    // Disable health check. Our JVB is not an external component, so there's no need to check for its connectivity.
    System.setProperty( "org.jitsi.videobridge.PING_INTERVAL", "-1" );

    jitsiPlugin = new PluginImpl();
    jitsiPlugin.initializePlugin( manager, pluginDirectory );

    Log.trace( "Successfully initialized Jitsi Videobridge." );
}
 
Example #3
Source File: LocaleUtils.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * <p>Returns an internationalized string loaded from a plugins resource bundle using
 * the Jive Locale. The name of resource bundle will be the lower-case word characters of the plugin name, with an
 * {@code _18n} suffix.</p>
 * <p>As a special case, if the plugin name is {@link #OPENFIRE_PLUGIN_NAME} then the standard Openfire i18n
 * resource bundle is used.</p>
 *
 * @param pluginName The name of the plugin - as defined in plugin.xml
 * @param key        The key to use for retrieving the string from the
 *                   appropriate resource bundle
 * @return the localized string.
 */
public static String getLocalizedPluginString(final String pluginName, final String key) {
    if (pluginName.equals(OPENFIRE_PLUGIN_NAME)) {
        return getLocalizedString(key);
    }
    final Locale locale = JiveGlobals.getLocale();
    final String bundleName = pluginName.replaceAll("\\W", "").toLowerCase() + "_i18n";
    final PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
    final ClassLoader bundleClassLoader = pluginManager.getPluginByName(pluginName)
        .map(pluginManager::getPluginClassloader)
        .map(pluginClassLoader -> (ClassLoader) pluginClassLoader)
        .orElseGet(() -> Thread.currentThread().getContextClassLoader());
    try {
        final ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale, bundleClassLoader);
        return getLocalizedString(key, locale, null, bundle);
    } catch (final MissingResourceException mre) {
        Log.error("Unable to load bundle {} from the {} class loader", bundleName, pluginName, mre);
        return getDefaultLocalizedString(key);
    }
}
 
Example #4
Source File: LocaleUtils.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve the <code>ResourceBundle</code> that is used with this plugin.
 *
 * @param pluginName the name of the plugin.
 * @return the ResourceBundle used with this plugin.
 * @throws Exception thrown if an exception occurs.
 */
public static ResourceBundle getPluginResourceBundle(String pluginName) throws Exception {
    final Locale locale = JiveGlobals.getLocale();

    String i18nFile = getI18nFile(pluginName);

    // Retrieve classloader from pluginName.
    final XMPPServer xmppServer = XMPPServer.getInstance();
    PluginManager pluginManager = xmppServer.getPluginManager();
    Plugin plugin = pluginManager.getPlugin(pluginName);
    if (plugin == null) {
        throw new NullPointerException("Plugin could not be located.");
    }

    ClassLoader pluginClassLoader = pluginManager.getPluginClassloader(plugin);
    return ResourceBundle.getBundle(i18nFile, locale, pluginClassLoader);
}
 
Example #5
Source File: CacheFactory.java    From Openfire with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example #6
Source File: ModuleManager.java    From openfire-ofmeet-plugin with Apache License 2.0 5 votes vote down vote up
public synchronized void start( final ClassLoader parent, final PluginManager manager, final File pluginDirectory )
{
    Log.debug( "Starting manager." );
    modulesByClassName = new ConcurrentHashMap<>();
    classLoaderByModule = new ConcurrentHashMap<>();

    this.parent = parent;
    this.manager = manager;
    this.pluginDirectory = pluginDirectory;
}
 
Example #7
Source File: GcmPlugin.java    From Openfire-GCM with Apache License 2.0 5 votes vote down vote up
public void initializePlugin(PluginManager manager, File pluginDirectory) {
	Log.info("GCM Plugin started");
	
	initConf();
	mServer = XMPPServer.getInstance();
	mPresenceManager = mServer.getPresenceManager();
	mUserManager = mServer.getUserManager();
	mGson = new Gson();
	
	interceptorManager.addInterceptor(this);
}
 
Example #8
Source File: UpdateManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the list of available plugins, sorted alphabetically, to install as reported by igniterealtime.org.
 *
 * Currently downloaded plugins will not be included, nor will plugins that require a newer or older server version.
 *
 * @return the list of available plugins to install as reported by igniterealtime.org.
 */
public List<AvailablePlugin> getNotInstalledPlugins()
{
    final List<AvailablePlugin> result = new ArrayList<>( availablePlugins.values() );
    final PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
    final Version currentServerVersion = XMPPServer.getInstance().getServerInfo().getVersion();

    // Iterate over the plugins, remove those that are of no interest.
    final Iterator<AvailablePlugin> iterator = result.iterator();
    while ( iterator.hasNext() )
    {
        final AvailablePlugin availablePlugin = iterator.next();

        // Remove plugins that are already downloaded from the list of available plugins.
        if ( pluginManager.isInstalled( availablePlugin.getCanonicalName() ) )
        {
            iterator.remove();
            continue;
        }

        // Remove plugins that require a newer server version.
        if ( availablePlugin.getMinServerVersion() != null && availablePlugin.getMinServerVersion().isNewerThan( currentServerVersion ) )
        {
            iterator.remove();
        }

        // Remove plugins that require an older server version.
        if ( availablePlugin.getPriorToServerVersion() != null && !availablePlugin.getPriorToServerVersion().isNewerThan( currentServerVersion ) )
        {
            iterator.remove();
        }
    }

    // Sort alphabetically.
    result.sort((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));

    return result;
}
 
Example #9
Source File: LocaleUtils.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an internationalized string loaded from a resource bundle from
 * the passed in plugin, using the passed in Locale.
 * 
 * If the plugin name is {@code null}, the key will be looked up using the
 * standard resource bundle.
 * 
 * If the locale is {@code null}, the Jive Global locale will be used.
 * 
 * @param key
 *            the key to use for retrieving the string from the appropriate
 *            resource bundle.
 * @param pluginName
 *            the name of the plugin to load the require resource bundle
 *            from.
 * @param arguments
 *            a list of objects to use which are formatted, then inserted
 *            into the pattern at the appropriate places.
 * @param locale
 *            the locale to use for retrieving the appropriate
 *            locale-specific string.
 * @param fallback
 *            if {@code true}, the global locale used by Openfire will be
 *            used if the requested locale is not available)
 * @return the localized string.
 */
public static String getLocalizedString(String key, String pluginName, List<?> arguments, Locale locale, boolean fallback) {
    if (pluginName == null) {
        return getLocalizedString(key, arguments);
    }

    if (locale == null) {
        locale = JiveGlobals.getLocale();
    }
    String i18nFile = getI18nFile(pluginName);

    // Retrieve classloader from pluginName.
    final XMPPServer xmppServer = XMPPServer.getInstance();
    PluginManager pluginManager = xmppServer.getPluginManager();
    Plugin plugin = pluginManager.getPlugin(pluginName);
    if (plugin == null) {
        throw new NullPointerException("Plugin could not be located: " + pluginName);
    }

    ClassLoader pluginClassLoader = pluginManager.getPluginClassloader(plugin);
    try {
        ResourceBundle bundle = ResourceBundle.getBundle(i18nFile, locale, pluginClassLoader);
        return getLocalizedString(key, locale, arguments, bundle);
    }
    catch (MissingResourceException mre) {
        Locale jivesLocale = JiveGlobals.getLocale();
        if (fallback && !jivesLocale.equals(locale)) {
            Log.info("Could not find the requested locale. Falling back to default locale.", mre);
            return getLocalizedString(key, pluginName, arguments, jivesLocale, false);
        }
        
        Log.error(mre.getMessage(), mre);
        return key;
    }
}
 
Example #10
Source File: OpenfireLBSPlugin.java    From openfireLBS with Apache License 2.0 5 votes vote down vote up
@Override
public void initializePlugin(PluginManager manager, File pluginDirectory) {
	try {
		openfireDBConn = DbConnectionManager.getConnection();
	} catch (SQLException e) {
		e.printStackTrace();
	}
	
	server = XMPPServer.getInstance();
	
	server.getIQRouter().addHandler(new LocationHandler(MODULE_NAME_LOCATION));
}
 
Example #11
Source File: JitsiJicofoWrapper.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize( final PluginManager pluginManager, final File pluginDirectory )
{
    ((InternalComponentManager) ComponentManagerFactory.getComponentManager()).addListener( this );

    ensureFocusUser();

    // The Jitsi Videobridge component must be fully loaded before focus starts to do service discovery.
    initThread = new Thread() {
        @Override
        public void run()
        {
            boolean running = true;
            while ( running )
            {
                if ( isAcceptingClientConnections() && !jvbComponents.isEmpty() )
                {
                    try
                    {
                        initializeComponent();
                        return;
                    }
                    catch ( Exception e )
                    {
                        Log.error( "An exception occurred while initializing the Jitsi Jicofo wrapper.", e );
                    }
                }

                Log.trace( "Waiting for the server to accept client connections and/or the JVB to become available ..." );
                try
                {
                    Thread.sleep( 500 );
                }
                catch ( InterruptedException e )
                {
                    Log.debug( "Interrupted wait for the server to accept client connections and/or the JVB to become available.", e );
                    running = false;
                }
            }
        }
    };
    initThread.start();
}
 
Example #12
Source File: WebappWrapper.java    From openfire-ofmeet-plugin with Apache License 2.0 4 votes vote down vote up
public WebappWrapper( final PluginManager manager, final File pluginDirectory )
{
    this.manager = manager;
    this.pluginDirectory = pluginDirectory;
}
 
Example #13
Source File: XMPPServer.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the <code>PluginManager</code> instance registered with this server.
 *
 * @return the PluginManager instance.
 */
public PluginManager getPluginManager() {
    return pluginManager;
}
 
Example #14
Source File: Module.java    From openfire-ofmeet-plugin with Apache License 2.0 votes vote down vote up
void initialize( final PluginManager manager, final File pluginDirectory );