Projects tigase _server server-core Issues #1439
Add new component error (#1439)
Unknown opened 4 years ago

Describe the bug I added a new test component method by https://docs.tigase.net/tigase-server/master-snapshot/Development_Guide/html/#cil1 The service can be discoveryed but it can not be used.The error dialog said 'Feature not implemented'

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Psi Client' and add an admin user
  2. Go to 'Service Discovery'
  3. See the test component can not use

Impact Can not use test component.

Expected behavior Can use test component.

Screenshots image

Details (please complete the following information):

  • Tigase version: [e.g. 8.1.2]
  • JVM flavour and version [e.g. AdoptOpenJDK11]
  • Operating system/distribution/version [e.g. Linux Centos 7]
Unknown commented 4 years ago

Component Class

package com.xxxxx.zigase.test;

import java.util.logging.Logger;
import tigase.component.AbstractKernelBasedComponent;
import tigase.kernel.beans.Bean;
import tigase.kernel.core.Kernel;

@Bean(name = "muc", parent = Kernel.class, active = true)
public class TestComponent extends AbstractKernelBasedComponent {

    private static final Logger log = Logger.getLogger(TestComponent.class.getName());

    @Override
    public String getComponentVersion() {
        String version = this.getClass().getPackage().getImplementationVersion();
        return version == null ? "0.0.0" : version;
    }

    @Override
    public boolean isDiscoNonAdmin() {
        return false;
    }

    @Override
    protected void registerModules(Kernel kernel) {
        // here we need to register modules responsible for processing packets
    }

}

ModuleClass:

package com.xxxxx.zigase.test.modules;

import com.xxxxx.zigase.test.TestComponent;
import tigase.component.exceptions.ComponentException;
import tigase.component.modules.AbstractModule;
import tigase.criteria.Criteria;
import tigase.criteria.ElementCriteria;
import tigase.kernel.beans.Bean;
import tigase.server.Packet;
import tigase.util.stringprep.TigaseStringprepException;

import java.util.logging.Logger;

@Bean(name = "test-module", parent = TestComponent.class, active = true)
public class TestModule extends AbstractModule {

    private static final Logger log = Logger.getLogger(TestModule.class.getCanonicalName());

    private static final Criteria CRITERIA = ElementCriteria.name("message");

    @Override
    public Criteria getModuleCriteria() {
        return CRITERIA;
    }

    @Override
    public void process(Packet packet) throws ComponentException, TigaseStringprepException {
        log.finest("My packet: " + packet.toString());
    }
}

config.tdsl:

test(class: com.xxxxx.zigase.test.TestComponent) {
}
Unknown commented 4 years ago

In order for the component to properly respond to disco#info and disco#items request you should register DiscoveryModule in your component:

@Override
protected void registerModules(Kernel kernel) {
	kernel.registerBean("disco").asClass(DiscoveryModule.class).exec();
}

NOTE It's essential to explicitly register DiscoveryModule in your component.

Unknown commented 4 years ago

@woj-tek OK thanks!

issue 1 of 1
Type
Bug
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#1439
Please wait...
Page is in error, reload to recover