Project

General

Profile

with tigase-server 8.0, the method of 'init' in the interface of XMPPImplIfc was deprecated, how to get it working by use other way?

w xy
Added 6 months ago

with SessionManager ,the method of 'addplugin' contain the part of

if (proc != null) {
if (allPlugins.add(proc)) {

            **Map<String, Object> settings = new HashMap<>();**

            try {
                Method m = proc.getClass().getDeclaredMethod("init", Map.class);
                if (m.getAnnotation(Deprecated.class) == null) {
                    log.log(Level.WARNING, "processor " + proc.getClass().getCanonicalName() +
                            " is using deprecated init() method!");
                    **proc.init(settings);**
                }
            } catch (NoSuchMethodException | SecurityException ex) {
                // ignoring...
            }
            //settings.put("sm-jid", getComponentId());
            eventBus.registerAll(proc);
        }
        if (proc instanceof PresenceCapabilitiesManager.PresenceCapabilitiesListener) {
            PresenceCapabilitiesManager.registerPresenceHandler(
                    (PresenceCapabilitiesManager.PresenceCapabilitiesListener) proc);
        }
    }

As we know with obove, the param of setting with in init method is null or the size of the 'settings' is zero. So, in the method of init(Map settings) with in the other plugin class , could not get properties from the config file endwith .tdsl.

However, how can i get properties with the init method, or use other way replace with init method?


Replies (1)

Added by Andrzej Wójcik IoT 1 CloudTigaseTeam 5 months ago

In version 8.0.0, we decided to deprecate support for configuration of Tigase XMPP Server using a properties file and replaced it with TDSL file. At the same time, we decided to introduce dependency and configuration injection using Tigase Kernel and DSLBeanConfigurator.

Due to that, we suggest usage of @ConfigField annotation at the configuration field of plugins and adding public getter and setter for those fields to react on changes of those fields value. Tigase XMPP Server will instantiate your plugin (a bean now) and will inject configuration into this bean.

All of that is explained in updated Tigase XMPP Server documentation for developers which you can find at https://docs.tigase.net/tigase-server/snapshot/Development_Guide/html/ (see sections about Tigase Kernel and Component Development).

    (1-1/1)