Search code examples
openfire

Custom properties that can be used by all properties in OpenFire


Can I set a custom property in OpenFire that can be read by other plugins?

I need to set a global property in one OF plugin and have the other plugins pick it up. it will be a simple string.

I just couldn't find that in the docs

After MrPk's advice, I found the correct spot in JiveGlobals. There is a set and get property.

/**
 * Sets a Jive property. If the property doesn't already exists, a new
 * one will be created.
 *
 * @param name the name of the property being set.
 * @param value the value of the property being set.
 */
public static void setProperty(String name, String value) {
    setProperty(name, value, false);
}

Solution

  • Store your property in OFPROPERTY table (or by admin console -> System Properties).

    As example, shared.const.test -> myValueFoo

    Then, programmatically, you can retrieve it by invoking something like

    String propertyValue = JiveGlobals.getProperty("shared.const.test", "myValueDefaultIfNotFound");
    

    So propertyValue will be "myValueDefaultIfNotFound" if select from db is null, "myValueFoo" if you had all right.