mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashish <paliwalash...@gmail.com>
Subject Re: svn commit: r798592 - /mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
Date Wed, 29 Jul 2009 04:53:10 GMT
Couple of observations [May not be related to this commit]
1. Related to spec compliance use - The current implementation has
same element nested within

@SpecCompliance(compliant = {
        @SpecCompliant(spec = "RFC3921bis-05", section = "3.1.5",
status = IN_PROGRESS, comment = "...."),
        @SpecCompliant(spec = "RFC3921bis-08", section = "3.1.5",
status = NOT_STARTED, comment = "....")
    })

Not sure about the possibility, but if we can specify them
individually (something like @param in javadoc), would be better. I am
yet to explore the possibility

Something like
@SpecCompliant(spec = "RFC3921bis-05", section = "3.1.5", status =
IN_PROGRESS, comment = "...."),
@SpecCompliant(spec = "RFC3921bis-08", section = "3.1.5", status =
NOT_STARTED, comment = "....")

I am not sure if it allowed by JSR 308. If not we can live with this.

2. We should separate static imports from normal imports. Makes it more readable

like

import java....
...// all normal imports
import static ...
...// all static imports

3. Max line length is way higher than normal 80 chars, mostly above
120 chars. For most of MINA code, the limit has been followed.

Let me see if I can dive-in and help out over the weekend.

thanks
ashish

On Tue, Jul 28, 2009 at 9:40 PM, <berndf@apache.org> wrote:
> Author: berndf
> Date: Tue Jul 28 16:10:00 2009
> New Revision: 798592
>
> URL: http://svn.apache.org/viewvc?rev=798592&view=rev
> Log:
> fix VYSPER-154: handle presence probes a little bit more correctly
>
> Modified:
>    mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
>
> Modified: mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
> URL: http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java?rev=798592&r1=798591&r2=798592&view=diff
> ==============================================================================
> --- mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
(original)
> +++ mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
Tue Jul 28 16:10:00 2009
> @@ -229,6 +229,7 @@
>             // send probes to all contacts of the current jid where
>             // 'subscription' is either 'to' or 'both'
>             // TODO: ...and jid is not blocking inbound presence notification
> +            // TODO: optimize: don't send server-local probes when contact's presence
is known locally
>             List<RosterItem> rosterContacts_TO = new ArrayList<RosterItem>();
>             rosterContacts_TO.addAll(item_TO);
>             rosterContacts_TO.addAll(item_BOTH);
> @@ -257,7 +258,19 @@
>         return presenceStanza;
>     }
>
> -    @SpecCompliant(spec = "RFC3921bis-04", section = "4.3.2")
> +    /**
> +     * TODO I don't think this works particulary good.
> +     * @param stanza
> +     * @param serverRuntimeContext
> +     * @param sessionContext
> +     * @param registry
> +     * @param rosterManager
> +     * @return
> +     */
> +    @SpecCompliance(compliant = {
> +        @SpecCompliant(spec = "RFC3921bis-04", section = "4.3.2"),
> +        @SpecCompliant(spec = "RFC3921bis-08", section = "4.3.2")
> +    })
>        private XMPPCoreStanza handleInboundPresenceProbe(PresenceStanza stanza, ServerRuntimeContext
serverRuntimeContext, SessionContext sessionContext, ResourceRegistry registry, RosterManager
rosterManager) {
>                Entity contact = stanza.getFrom();
>                Entity user = stanza.getTo();
> @@ -274,21 +287,35 @@
>             return null;
>                }
>
> -        if (user.getResource() == null) {
> +        if (contact.getResource() == null) {
>             // presence probes must happen on resource level!
>             relayStanza(contact, buildPresenceStanza(user, contact, UNSUBSCRIBED,
null), sessionContext);
>             return null;
>         }
>
> -        PresenceStanza presenceStanza = retrieveLatestPresence(sessionContext, user);
> -        if (presenceStanza == null) {
> +        PresenceStanza latestPresenceStanza = null;
> +        if (!user.isResourceSet()) {
> +            List<String> availableResources = serverRuntimeContext.getResourceRegistry().getAvailableResources(user);
> +            for (String availableResource : availableResources) {
> +                PresenceStanza presenceStanza = serverRuntimeContext.getPresenceCache().get(new
EntityImpl(user, availableResource));
> +                // TODO which one to take? which resource has the current presence?
> +                if (presenceStanza != null) {
> +                    latestPresenceStanza = presenceStanza;
> +                    break;
> +                }
> +            }
> +        } else {
> +            latestPresenceStanza = retrieveLatestPresence(sessionContext, user);
> +        }
> +
> +        if (latestPresenceStanza == null) {
>             // we have no current presence info
>             relayStanza(contact, buildPresenceStanza(user, contact, UNAVAILABLE,
null), sessionContext);
>             return null;
>         }
>
>         // return current presence as probing result
> -        relayStanza(contact, buildPresenceStanza(user, contact, null, presenceStanza.getInnerElements()),
sessionContext);
> +        relayStanza(contact, buildPresenceStanza(user, contact, null, latestPresenceStanza.getInnerElements()),
sessionContext);
>
>                return null;
>        }
>
>
>

Mime
View raw message