Projects tigase _server server-core Issues #413
Add support for using Annotations to define stanzas supported by XMPPProcessor (#413)
Closed
Andrzej Wójcik (Tigase) opened 10 years ago

Current state of how we define what stanzas are supported by XMPPProcessor is unintuitive and error prone as we defined two arrays (one with paths and one with XMLNSs) which are related by index of entries in both arrays. This is error prone due to no indication in code how path is related to XMLNS.

It would be nice to have support for annotations which applied will be properly handled and converted into definition which may be used by @XMPPProcessor@, ie.

package tigase.xmpp.impl.annotation;

import static tigase.xmpp.impl.annotation.TestAnnotatedXMPPProcessor.*;

@Id(ID)
@Handles({
	@Handle(path={ "iq", "query" }, xmlns=XMLNS1),
	@Handle(pathStr=IQ_QUERY_PATH, xmlns=XMLNS2)
})
@DiscoFeatures({
	XMLNS1,
	XMLNS2
})
@StreamFeatures({
	@StreamFeature(elem="bind", xmlns="urn:ietf:params:xml:ns:xmpp-bind")
})
public class TestAnnotatedXMPPProcessor extends AnnotatedXMPPProcessor {
	
	protected static final String ID = "test-123";
	protected static final String XMLNS1 = "tigase:test1";
	protected static final String XMLNS2 = "tigase:test2";
	protected static final String IQ_QUERY_PATH = "iq/query";
	
}
Andrzej Wójcik (Tigase) commented 10 years ago

I added implementation for this feature and as I tested it it works fine and may improve code readability, however I would consider this just a begining and this code may change in future.

Artur Hefczyc commented 10 years ago

Yes, I agree. Our framework architect %bmalkow will review it in next version and perhaps suggest a better way.

Artur Hefczyc commented 10 years ago

Ups, and... Wow. I am sorry, I mistakenly assumed this is a different ticket to change code for Auth plugin. This is really cool stuff. I like it. I agree this is much better then the old way. I am OK with pushing this to the 7.0.0 and rewrite all the plugins, even though we are at the final stage of the version. This change is worth it.

By the way. You remember that my last changes introduced also stanza type as one of the elements defining supported stanzas by a plugin? This is important to split Presence processing into separate plugins. One for subscriptions and another for online/offline processing. This is important because subscription require DB access and are slow but others do not require DB and are fast.

Andrzej Wójcik (Tigase) commented 10 years ago

I wanted just to push it to 7.0.0 to add possibility to use it in future plugins, (ie. by custom plugins created by our user), but not necessary to rewrite all plugins for 7.0.0 release but maybe for 7.1.0.

I remember your changes which introduced stanza type as one of criteria to check if plugin supports stanza. I remember our chat about possible changes in this processing, but how it is related to what I done in this changes?

Should I add annotation for type of stanza as well or maybe something else you would like me to do?

Artur Hefczyc commented 10 years ago

Andrzej Wójcik wrote:

I wanted just to push it to 7.0.0 to add possibility to use it in future plugins, (ie. by custom plugins created by our user), but not necessary to rewrite all plugins for 7.0.0 release but maybe for 7.1.0.

Good point, but if there is code example, nobody would use it anyway because nobody knows how to use it. So we need at least a few plugins to use the new API.

I remember your changes which introduced stanza type as one of criteria to check if plugin supports stanza. I remember our chat about possible changes in this processing, but how it is related to what I done in this changes? Should I add annotation for type of stanza as well or maybe something else you would like me to do?

Yes, I thought of adding annotation for the stanza type as well, to have a complete API for this.

Andrzej Wójcik (Tigase) commented 10 years ago

I addded @HandleStanzaType annotation, converted few processors to use annotations as an example and update DevGuide section about writting processors.

Artur Hefczyc commented 10 years ago

Good work.

issue 1 of 1
Type
New Feature
Priority
Normal
Assignee
RedmineID
2607
Version
tigase-server-7.0.0
Estimation
4h
Spent time
48h
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#413
Please wait...
Page is in error, reload to recover