You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2010/06/26 22:40:05 UTC

svn commit: r958281 [13/22] - in /mina/vysper/trunk: demo/pubsub/client/src/main/java/org/apache/vysper/demo/pubsub/client/ nbxml/src/main/java/org/apache/vysper/charset/ nbxml/src/main/java/org/apache/vysper/xml/decoder/ nbxml/src/main/java/org/apache...

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java Sat Jun 26 20:39:54 2010
@@ -34,8 +34,7 @@ import org.apache.vysper.xmpp.stanza.XMP
  *
  * @author The Apache MINA Project (dev@mina.apache.org)
  */
-public class ServerErrorResponses
-{
+public class ServerErrorResponses {
     private static ServerErrorResponses serverErrorResponsesInstance = null;
 
     public static ServerErrorResponses getInstance() {
@@ -49,7 +48,8 @@ public class ServerErrorResponses
         // empty
     }
 
-    public Stanza getStreamError(StreamErrorCondition definedErrorCondition, String languageCode, String descriptiveText, XMLElement applicationSpecificError) {
+    public Stanza getStreamError(StreamErrorCondition definedErrorCondition, String languageCode,
+            String descriptiveText, XMLElement applicationSpecificError) {
 
         /*
            <stream:jabber>
@@ -62,16 +62,16 @@ public class ServerErrorResponses
            </stream:jabber>
         */
 
-        if (languageCode == null) languageCode = "en_US";
+        if (languageCode == null)
+            languageCode = "en_US";
         StanzaBuilder stanzaBuilder = new StanzaBuilder("error");
 
-        stanzaBuilder.startInnerElement(definedErrorCondition.value(), NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STREAMS).endInnerElement();
+        stanzaBuilder.startInnerElement(definedErrorCondition.value(),
+                NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STREAMS).endInnerElement();
 
         if (descriptiveText != null) {
-            stanzaBuilder.startInnerElement("text", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STREAMS)
-                .addAttribute(NamespaceURIs.XML, "lang", languageCode)
-                .addText(descriptiveText)
-                .endInnerElement();
+            stanzaBuilder.startInnerElement("text", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STREAMS).addAttribute(
+                    NamespaceURIs.XML, "lang", languageCode).addText(descriptiveText).endInnerElement();
         }
 
         if (applicationSpecificError != null) {
@@ -92,12 +92,11 @@ public class ServerErrorResponses
      * @return error response stanza
      */
     public Stanza getStanzaError(StanzaErrorCondition errorCondition, XMPPCoreStanza stanza, StanzaErrorType type,
-                                 String errorText, String errorLang,
-                                 XMLElement errorConditionElement) {
+            String errorText, String errorLang, XMLElement errorConditionElement) {
 
         if (stanza != null && "error".equals(stanza.getType())) {
-            return ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, errorLang,
-                                                               "cannot respond to IQ stanza of type error with the same", null);
+            return ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE,
+                    errorLang, "cannot respond to IQ stanza of type error with the same", null);
         }
 
         StanzaBuilder responseBuilder = StanzaBuilder.createDirectReply(stanza, true, "error");
@@ -107,15 +106,15 @@ public class ServerErrorResponses
         return responseBuilder.build();
     }
 
-    private void fillErrorStanza(XMPPCoreStanza stanza, StanzaErrorType type, StanzaErrorCondition errorCondition, String errorText, String errorLang, XMLElement errorConditionElement, StanzaBuilder responseBuilder) {
+    private void fillErrorStanza(XMPPCoreStanza stanza, StanzaErrorType type, StanzaErrorCondition errorCondition,
+            String errorText, String errorLang, XMLElement errorConditionElement, StanzaBuilder responseBuilder) {
         // inline incoming stanza as of RFC 3920 9.3.1
-        for(XMLElement innerElement : stanza.getInnerElements()) {
+        for (XMLElement innerElement : stanza.getInnerElements()) {
             responseBuilder.addPreparedElement(innerElement);
         }
 
         // error element
-        responseBuilder.startInnerElement("error", NamespaceURIs.JABBER_CLIENT)
-                         .addAttribute("type", type.value());
+        responseBuilder.startInnerElement("error", NamespaceURIs.JABBER_CLIENT).addAttribute("type", type.value());
 
         // insert defined error condition relating to the stanza error type
         responseBuilder.startInnerElement(errorCondition.value(), NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS);
@@ -123,12 +122,12 @@ public class ServerErrorResponses
 
         // optional error text
         if (errorText != null && errorLang != null) {
-            responseBuilder.startInnerElement("text", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS)
-                             .addAttribute(NamespaceURIs.XML, "lang", errorLang)
-                             .addText(errorText);
+            responseBuilder.startInnerElement("text", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS).addAttribute(
+                    NamespaceURIs.XML, "lang", errorLang).addText(errorText);
         }
         // optional application specific error condition element
-        if (errorConditionElement != null) responseBuilder.addPreparedElement(errorConditionElement);
+        if (errorConditionElement != null)
+            responseBuilder.addPreparedElement(errorConditionElement);
 
         responseBuilder.endInnerElement();
     }
@@ -141,7 +140,8 @@ public class ServerErrorResponses
     public Stanza getSASLFailure(SASLFailureType failureType) {
         StanzaBuilder stanzaBuilder = new StanzaBuilder("failure", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL);
         if (failureType != null) {
-            stanzaBuilder.startInnerElement(failureType.toString(), NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).endInnerElement();
+            stanzaBuilder.startInnerElement(failureType.toString(), NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL)
+                    .endInnerElement();
         }
         return stanzaBuilder.build();
     }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerResponses.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerResponses.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerResponses.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/response/ServerResponses.java Sat Jun 26 20:39:54 2010
@@ -20,16 +20,16 @@
 
 package org.apache.vysper.xmpp.server.response;
 
+import java.util.List;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.authorization.SASLMechanism;
 import org.apache.vysper.xmpp.protocol.NamespaceURIs;
-import org.apache.vysper.xmpp.stanza.Stanza;
-import org.apache.vysper.xmpp.stanza.StanzaBuilder;
-import org.apache.vysper.xmpp.server.XMPPVersion;
 import org.apache.vysper.xmpp.server.SessionContext;
 import org.apache.vysper.xmpp.server.SessionState;
-import org.apache.vysper.xmpp.addressing.Entity;
-import org.apache.vysper.xmpp.authorization.SASLMechanism;
-
-import java.util.List;
+import org.apache.vysper.xmpp.server.XMPPVersion;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.StanzaBuilder;
 
 /**
  *
@@ -43,8 +43,11 @@ public class ServerResponses {
 
     public Stanza getStreamOpener(boolean forClient, Entity from, XMPPVersion version, SessionContext sessionContext) {
         Stanza innerFeatureStanza;
-        if (sessionContext.getState() == SessionState.INITIATED) innerFeatureStanza = getFeaturesForEncryption(sessionContext);
-        else if (sessionContext.getState() == SessionState.ENCRYPTED) innerFeatureStanza = getFeaturesForAuthentication(sessionContext.getServerRuntimeContext().getServerFeatures().getAuthenticationMethods());
+        if (sessionContext.getState() == SessionState.INITIATED)
+            innerFeatureStanza = getFeaturesForEncryption(sessionContext);
+        else if (sessionContext.getState() == SessionState.ENCRYPTED)
+            innerFeatureStanza = getFeaturesForAuthentication(sessionContext.getServerRuntimeContext()
+                    .getServerFeatures().getAuthenticationMethods());
         else if (sessionContext.getState() == SessionState.AUTHENTICATED) {
             sessionContext.setIsReopeningXMLStream();
             innerFeatureStanza = getFeaturesForSession();
@@ -52,33 +55,41 @@ public class ServerResponses {
             throw new IllegalStateException("unsupported state for responding with stream opener");
         }
 
-        StanzaBuilder stanzaBuilder = getStreamOpener(forClient, from, sessionContext.getXMLLang(), version, sessionContext.getSessionId(), innerFeatureStanza);
+        StanzaBuilder stanzaBuilder = getStreamOpener(forClient, from, sessionContext.getXMLLang(), version,
+                sessionContext.getSessionId(), innerFeatureStanza);
 
         return stanzaBuilder.build();
     }
 
-    public StanzaBuilder getStreamOpener(boolean forClient, Entity from, String xmlLang, XMPPVersion version, Stanza innerStanza) {
+    public StanzaBuilder getStreamOpener(boolean forClient, Entity from, String xmlLang, XMPPVersion version,
+            Stanza innerStanza) {
         return getStreamOpener(forClient, from, xmlLang, version, null, innerStanza);
     }
 
-    public StanzaBuilder getStreamOpener(boolean forClient, Entity from, String xmlLang, XMPPVersion version, String sessionId, Stanza innerStanza) {
-        StanzaBuilder stanzaBuilder = new StanzaBuilder("stream", NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS, "stream")
-        	.declareNamespace("", forClient ?  NamespaceURIs.JABBER_CLIENT : NamespaceURIs.JABBER_SERVER)
-            .addAttribute("from", from.getFullQualifiedName());
-        if (xmlLang != null) stanzaBuilder.addAttribute(NamespaceURIs.XML, "lang", xmlLang);
-        if (version != null) stanzaBuilder.addAttribute("version", version.toString());
-        if (forClient && sessionId != null) stanzaBuilder.addAttribute("id", sessionId);
-        if (innerStanza != null) stanzaBuilder.addPreparedElement(innerStanza);
+    public StanzaBuilder getStreamOpener(boolean forClient, Entity from, String xmlLang, XMPPVersion version,
+            String sessionId, Stanza innerStanza) {
+        StanzaBuilder stanzaBuilder = new StanzaBuilder("stream", NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS,
+                "stream").declareNamespace("", forClient ? NamespaceURIs.JABBER_CLIENT : NamespaceURIs.JABBER_SERVER)
+                .addAttribute("from", from.getFullQualifiedName());
+        if (xmlLang != null)
+            stanzaBuilder.addAttribute(NamespaceURIs.XML, "lang", xmlLang);
+        if (version != null)
+            stanzaBuilder.addAttribute("version", version.toString());
+        if (forClient && sessionId != null)
+            stanzaBuilder.addAttribute("id", sessionId);
+        if (innerStanza != null)
+            stanzaBuilder.addPreparedElement(innerStanza);
         return stanzaBuilder;
     }
 
     public Stanza getFeaturesForEncryption(SessionContext sessionContext) {
 
-        StanzaBuilder stanzaBuilder = startFeatureStanza(); 
+        StanzaBuilder stanzaBuilder = startFeatureStanza();
         stanzaBuilder.startInnerElement("starttls", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_TLS);
-            if (sessionContext.getServerRuntimeContext().getServerFeatures().isStartTLSRequired()) {
-                stanzaBuilder.startInnerElement("required", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_TLS).endInnerElement();
-            }
+        if (sessionContext.getServerRuntimeContext().getServerFeatures().isStartTLSRequired()) {
+            stanzaBuilder.startInnerElement("required", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_TLS)
+                    .endInnerElement();
+        }
         stanzaBuilder.endInnerElement();
 
         return stanzaBuilder.build();
@@ -86,34 +97,36 @@ public class ServerResponses {
 
     public Stanza getFeaturesForAuthentication(List<SASLMechanism> authenticationMethods) {
 
-        StanzaBuilder stanzaBuilder = startFeatureStanza(); 
+        StanzaBuilder stanzaBuilder = startFeatureStanza();
         stanzaBuilder.startInnerElement("mechanisms", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL);
-            for (SASLMechanism authenticationMethod : authenticationMethods) {
-                stanzaBuilder.startInnerElement("mechanism", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).addText(authenticationMethod.getName()).endInnerElement();
-            }
-            stanzaBuilder.endInnerElement();
+        for (SASLMechanism authenticationMethod : authenticationMethods) {
+            stanzaBuilder.startInnerElement("mechanism", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SASL).addText(
+                    authenticationMethod.getName()).endInnerElement();
+        }
+        stanzaBuilder.endInnerElement();
 
         return stanzaBuilder.build();
     }
 
     private Stanza getFeaturesForSession() {
-        StanzaBuilder stanzaBuilder = startFeatureStanza(); 
+        StanzaBuilder stanzaBuilder = startFeatureStanza();
 
-        stanzaBuilder.startInnerElement("bind", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND)
-            .startInnerElement("required", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND).endInnerElement();
+        stanzaBuilder.startInnerElement("bind", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND).startInnerElement(
+                "required", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND).endInnerElement();
         stanzaBuilder.endInnerElement();
 
         // session establishment is here for RFC3921 compatibility and is planed to be removed in revisions of this RFC.
         stanzaBuilder.startInnerElement("session", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SESSION)
-            .startInnerElement("required", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SESSION).endInnerElement();
+                .startInnerElement("required", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SESSION).endInnerElement();
         stanzaBuilder.endInnerElement();
 
         return stanzaBuilder.build();
     }
 
     protected StanzaBuilder startFeatureStanza() {
-        StanzaBuilder stanzaBuilder = new StanzaBuilder("features", NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS, "stream");
-        
+        StanzaBuilder stanzaBuilder = new StanzaBuilder("features", NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS,
+                "stream");
+
         return stanzaBuilder;
     }
 

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanza.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanza.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanza.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanza.java Sat Jun 26 20:39:54 2010
@@ -35,7 +35,8 @@ public class IQStanza extends XMPPCoreSt
 
     public IQStanza(Stanza stanza) {
         super(stanza);
-        if (!isOfType(stanza)) throw new IllegalArgumentException("only IQ stanza is allowed here");
+        if (!isOfType(stanza))
+            throw new IllegalArgumentException("only IQ stanza is allowed here");
     }
 
     @Override
@@ -45,7 +46,8 @@ public class IQStanza extends XMPPCoreSt
 
     public IQStanzaType getIQType() {
         String type = getType();
-        if (type == null) return null;
+        if (type == null)
+            return null;
         return IQStanzaType.valueOfOrNull(type);
     }
 

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanzaType.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanzaType.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanzaType.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/IQStanzaType.java Sat Jun 26 20:39:54 2010
@@ -26,10 +26,7 @@ package org.apache.vysper.xmpp.stanza;
  */
 public enum IQStanzaType {
 
-    GET ("get"),
-    SET ("set"),
-    RESULT ("result"),
-    ERROR ("error");
+    GET("get"), SET("set"), RESULT("result"), ERROR("error");
 
     private final String value;
 
@@ -41,7 +38,6 @@ public enum IQStanzaType {
         }
     }
 
-
     IQStanzaType(String value) {
         this.value = value;
     }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanza.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanza.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanza.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanza.java Sat Jun 26 20:39:54 2010
@@ -20,14 +20,15 @@
 
 package org.apache.vysper.xmpp.stanza;
 
-import org.apache.vysper.xml.fragment.XMLElement;
-import org.apache.vysper.xml.fragment.XMLSemanticError;
-import org.apache.vysper.compliance.SpecCompliant;
-import static org.apache.vysper.compliance.SpecCompliant.ComplianceStatus.FINISHED;
 import static org.apache.vysper.compliance.SpecCompliant.ComplianceCoverage.COMPLETE;
+import static org.apache.vysper.compliance.SpecCompliant.ComplianceStatus.FINISHED;
 
 import java.util.Map;
 
+import org.apache.vysper.compliance.SpecCompliant;
+import org.apache.vysper.xml.fragment.XMLElement;
+import org.apache.vysper.xml.fragment.XMLSemanticError;
+
 /**
  * message stanza (push)
  *
@@ -44,7 +45,8 @@ public class MessageStanza extends XMPPC
 
     public MessageStanza(Stanza stanza) {
         super(stanza);
-        if (!MessageStanza.isOfType(stanza)) throw new IllegalArgumentException("only 'message' stanza is allowed here");
+        if (!MessageStanza.isOfType(stanza))
+            throw new IllegalArgumentException("only 'message' stanza is allowed here");
     }
 
     @Override
@@ -65,7 +67,8 @@ public class MessageStanza extends XMPPC
      */
     public String getSubject(String lang) throws XMLSemanticError {
         XMLElement element = getSubjects().get(lang);
-        if (element == null) return null;
+        if (element == null)
+            return null;
         return element.getSingleInnerText().getText();
     }
 
@@ -85,7 +88,8 @@ public class MessageStanza extends XMPPC
      */
     public String getBody(String lang) throws XMLSemanticError {
         XMLElement element = getBodies().get(lang);
-        if (element == null) return null;
+        if (element == null)
+            return null;
         return element.getSingleInnerText().getText();
     }
 
@@ -105,9 +109,9 @@ public class MessageStanza extends XMPPC
      */
     public String getThread() throws XMLSemanticError {
         XMLElement element = getSingleInnerElementsNamed("thread");
-        if (element == null) return null; // thread is optional, see RFC3921/2.1.2.3
+        if (element == null)
+            return null; // thread is optional, see RFC3921/2.1.2.3
         return element.getSingleInnerText().getText();
     }
 
-
 }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanzaType.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanzaType.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanzaType.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanzaType.java Sat Jun 26 20:39:54 2010
@@ -26,11 +26,7 @@ package org.apache.vysper.xmpp.stanza;
  */
 public enum MessageStanzaType {
 
-    CHAT ("chat"),
-    ERROR ("error"),
-    GROUPCHAT ("groupchat"),
-    HEADLINE ("headline"),
-    NORMAL ("normal");
+    CHAT("chat"), ERROR("error"), GROUPCHAT("groupchat"), HEADLINE("headline"), NORMAL("normal");
 
     private final String value;
 
@@ -39,7 +35,8 @@ public enum MessageStanzaType {
      * given
      */
     public static MessageStanzaType valueOfWithDefault(String value) {
-        if (value == null) return NORMAL;
+        if (value == null)
+            return NORMAL;
         try {
             return MessageStanzaType.valueOf(value.toUpperCase());
         } catch (IllegalArgumentException e) {

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanza.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanza.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanza.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanza.java Sat Jun 26 20:39:54 2010
@@ -20,11 +20,11 @@
 
 package org.apache.vysper.xmpp.stanza;
 
+import java.util.Map;
+
 import org.apache.vysper.xml.fragment.XMLElement;
 import org.apache.vysper.xml.fragment.XMLSemanticError;
 
-import java.util.Map;
-
 /**
  * presence stanza (publish/subscribe [aka "pub/sub"] or broadcast)
  *
@@ -39,7 +39,8 @@ public class PresenceStanza extends XMPP
 
     public PresenceStanza(Stanza stanza) {
         super(stanza);
-        if (!PresenceStanza.isOfType(stanza)) throw new IllegalArgumentException("only 'presence' stanza is allowed here");
+        if (!PresenceStanza.isOfType(stanza))
+            throw new IllegalArgumentException("only 'presence' stanza is allowed here");
     }
 
     @Override
@@ -49,7 +50,8 @@ public class PresenceStanza extends XMPP
 
     public PresenceStanzaType getPresenceType() {
         String type = getType();
-        if (type == null) return null;
+        if (type == null)
+            return null;
         return PresenceStanzaType.valueOfOrNull(type);
     }
 
@@ -60,7 +62,8 @@ public class PresenceStanza extends XMPP
      */
     public String getShow() throws XMLSemanticError {
         XMLElement element = getSingleInnerElementsNamed("show");
-        if (element == null) return null; // show is optional, see RFC3921/2.2.2.1
+        if (element == null)
+            return null; // show is optional, see RFC3921/2.2.2.1
         return element.getSingleInnerText().getText();
     }
 
@@ -72,7 +75,8 @@ public class PresenceStanza extends XMPP
      */
     public String getStatus(String lang) throws XMLSemanticError {
         XMLElement element = getStatusMap().get(lang);
-        if (element == null) return null;
+        if (element == null)
+            return null;
         return element.getSingleInnerText().getText();
     }
 

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanzaType.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanzaType.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanzaType.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanzaType.java Sat Jun 26 20:39:54 2010
@@ -26,13 +26,8 @@ package org.apache.vysper.xmpp.stanza;
  */
 public enum PresenceStanzaType {
 
-    UNAVAILABLE("unavailable"),
-    SUBSCRIBE("subscribe"),
-    SUBSCRIBED("subscribed"),
-    UNSUBSCRIBE("unsubscribe"),
-    UNSUBSCRIBED("unsubscribed"),
-    PROBE("probe"),
-    ERROR("error");
+    UNAVAILABLE("unavailable"), SUBSCRIBE("subscribe"), SUBSCRIBED("subscribed"), UNSUBSCRIBE("unsubscribe"), UNSUBSCRIBED(
+            "unsubscribed"), PROBE("probe"), ERROR("error");
 
     private final String value;
 
@@ -53,10 +48,9 @@ public enum PresenceStanzaType {
     }
 
     public static boolean isSubscriptionType(PresenceStanzaType presenceStanzaType) {
-        return presenceStanzaType != null && (
-               presenceStanzaType == SUBSCRIBE || presenceStanzaType == SUBSCRIBED ||
-               presenceStanzaType == UNSUBSCRIBE || presenceStanzaType == UNSUBSCRIBED
-               );
+        return presenceStanzaType != null
+                && (presenceStanzaType == SUBSCRIBE || presenceStanzaType == SUBSCRIBED
+                        || presenceStanzaType == UNSUBSCRIBE || presenceStanzaType == UNSUBSCRIBED);
     }
 
     /**

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java Sat Jun 26 20:39:54 2010
@@ -30,7 +30,6 @@ import org.apache.vysper.xmpp.addressing
 import org.apache.vysper.xmpp.addressing.EntityFormatException;
 import org.apache.vysper.xmpp.addressing.EntityImpl;
 import org.apache.vysper.xmpp.modules.core.base.handler.XMPPCoreStanzaHandler;
-import org.apache.vysper.xmpp.protocol.NamespaceURIs;
 import org.apache.vysper.xmpp.writer.DenseStanzaLogRenderer;
 
 /**
@@ -41,23 +40,26 @@ import org.apache.vysper.xmpp.writer.Den
  */
 public class Stanza extends XMLElement {
 
-    public Stanza(String namespaceURI, String name, String namespacePrefix, List<Attribute> attributes, List<XMLFragment> innerFragments) {
+    public Stanza(String namespaceURI, String name, String namespacePrefix, List<Attribute> attributes,
+            List<XMLFragment> innerFragments) {
         this(namespaceURI, name, namespacePrefix, attributes, innerFragments, null);
     }
 
-    public Stanza(String namespaceURI, String name, String namespacePrefix, List<Attribute> attributes, List<XMLFragment> innerFragments, Map<String, String> namespaces) {
-    	super(namespaceURI, name, namespacePrefix, attributes, innerFragments, namespaces);
+    public Stanza(String namespaceURI, String name, String namespacePrefix, List<Attribute> attributes,
+            List<XMLFragment> innerFragments, Map<String, String> namespaces) {
+        super(namespaceURI, name, namespacePrefix, attributes, innerFragments, namespaces);
     }
-    
-    public Stanza(String namespaceURI, String name, String namespacePrefix, Attribute[] attributes, XMLFragment[] innerFragments) {
+
+    public Stanza(String namespaceURI, String name, String namespacePrefix, Attribute[] attributes,
+            XMLFragment[] innerFragments) {
         this(namespaceURI, name, namespacePrefix, attributes, innerFragments, null);
     }
 
-    public Stanza(String namespaceURI, String name, String namespacePrefix, Attribute[] attributes, XMLFragment[] innerFragments, Map<String, String> namespaces) {
+    public Stanza(String namespaceURI, String name, String namespacePrefix, Attribute[] attributes,
+            XMLFragment[] innerFragments, Map<String, String> namespaces) {
         super(namespaceURI, name, namespacePrefix, attributes, innerFragments, namespaces);
     }
 
-    
     public Entity getTo() {
         return parseEntityAttribute("to");
     }
@@ -76,7 +78,7 @@ public class Stanza extends XMLElement {
     public Entity parseEntityAttribute(String attributeName) {
         EntityImpl entity = null;
         String attributeValue = getAttributeValue(attributeName);
-        if(attributeValue != null) {
+        if (attributeValue != null) {
             try {
                 entity = EntityImpl.parse(attributeValue);
             } catch (EntityFormatException e) {

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java Sat Jun 26 20:39:54 2010
@@ -43,8 +43,10 @@ public class StanzaBuilder extends Abstr
 
     public static StanzaBuilder createIQStanza(Entity from, Entity to, IQStanzaType type, String id) {
         StanzaBuilder stanzaBuilder = new StanzaBuilder("iq", NamespaceURIs.JABBER_CLIENT);
-        if (from != null) stanzaBuilder.addAttribute("from", from.getFullQualifiedName());
-        if (to != null) stanzaBuilder.addAttribute("to", to.getFullQualifiedName());
+        if (from != null)
+            stanzaBuilder.addAttribute("from", from.getFullQualifiedName());
+        if (to != null)
+            stanzaBuilder.addAttribute("to", to.getFullQualifiedName());
         stanzaBuilder.addAttribute("type", type.value());
         stanzaBuilder.addAttribute("id", id);
         return stanzaBuilder;
@@ -54,33 +56,43 @@ public class StanzaBuilder extends Abstr
         StanzaBuilder stanzaBuilder = new StanzaBuilder("message", NamespaceURIs.JABBER_CLIENT);
         stanzaBuilder.addAttribute("from", from.getFullQualifiedName());
         stanzaBuilder.addAttribute("to", to.getFullQualifiedName());
-        if(lang != null) stanzaBuilder.addAttribute(NamespaceURIs.XML, "lang", lang);
-        if(body != null) stanzaBuilder.startInnerElement("body", NamespaceURIs.JABBER_CLIENT).addText(body).endInnerElement();
+        if (lang != null)
+            stanzaBuilder.addAttribute(NamespaceURIs.XML, "lang", lang);
+        if (body != null)
+            stanzaBuilder.startInnerElement("body", NamespaceURIs.JABBER_CLIENT).addText(body).endInnerElement();
         return stanzaBuilder;
     }
 
-    public static StanzaBuilder createMessageStanza(Entity from, Entity to, MessageStanzaType type, String lang, String body) {
+    public static StanzaBuilder createMessageStanza(Entity from, Entity to, MessageStanzaType type, String lang,
+            String body) {
         StanzaBuilder stanzaBuilder = createMessageStanza(from, to, lang, body);
-        if (type != null) stanzaBuilder.addAttribute("type", type.value());
+        if (type != null)
+            stanzaBuilder.addAttribute("type", type.value());
         return stanzaBuilder;
     }
 
-    public static Stanza createUnavailablePresenceStanza(String status, SessionContext.SessionTerminationCause terminationCause) {
-        StanzaBuilder presenceUnavailBuilder = createPresenceStanza(null, null, null, PresenceStanzaType.UNAVAILABLE, null, status);
+    public static Stanza createUnavailablePresenceStanza(String status,
+            SessionContext.SessionTerminationCause terminationCause) {
+        StanzaBuilder presenceUnavailBuilder = createPresenceStanza(null, null, null, PresenceStanzaType.UNAVAILABLE,
+                null, status);
         if (terminationCause == null) {
             return presenceUnavailBuilder.build();
-        }
-        else {
+        } else {
             return new EndOfSessionCommandStanza(presenceUnavailBuilder.build(), terminationCause);
         }
     }
 
-    public static StanzaBuilder createPresenceStanza(Entity from, Entity to, String lang, PresenceStanzaType type, String show, String status) {
+    public static StanzaBuilder createPresenceStanza(Entity from, Entity to, String lang, PresenceStanzaType type,
+            String show, String status) {
         StanzaBuilder stanzaBuilder = new StanzaBuilder("presence", NamespaceURIs.JABBER_CLIENT);
-        if (from != null) stanzaBuilder.addAttribute("from", from.getFullQualifiedName());
-        if (to != null) stanzaBuilder.addAttribute("to", to.getFullQualifiedName());
-        if (lang != null) stanzaBuilder.addAttribute(NamespaceURIs.XML, "lang", lang);
-        if (type != null) stanzaBuilder.addAttribute("type", type.value());
+        if (from != null)
+            stanzaBuilder.addAttribute("from", from.getFullQualifiedName());
+        if (to != null)
+            stanzaBuilder.addAttribute("to", to.getFullQualifiedName());
+        if (lang != null)
+            stanzaBuilder.addAttribute(NamespaceURIs.XML, "lang", lang);
+        if (type != null)
+            stanzaBuilder.addAttribute("type", type.value());
         if (show != null) {
             stanzaBuilder.startInnerElement("show", NamespaceURIs.JABBER_CLIENT).addText(show).endInnerElement();
         }
@@ -95,9 +107,11 @@ public class StanzaBuilder extends Abstr
     }
 
     public static StanzaBuilder createDirectReply(XMPPCoreStanza original, boolean fromIsServerOnly, String type) {
-        if (original == null) throw new IllegalArgumentException();
+        if (original == null)
+            throw new IllegalArgumentException();
 
-        StanzaBuilder stanzaBuilder = new StanzaBuilder(original.getName(), original.getNamespaceURI(), original.getNamespacePrefix());
+        StanzaBuilder stanzaBuilder = new StanzaBuilder(original.getName(), original.getNamespaceURI(), original
+                .getNamespacePrefix());
         // reverse to and from
         Entity newTo = original.getFrom();
         if (newTo != null) {
@@ -105,11 +119,13 @@ public class StanzaBuilder extends Abstr
         }
         Entity newFrom = original.getTo();
         if (newFrom != null) {
-            if (fromIsServerOnly) newFrom = new EntityImpl(null, newFrom.getDomain(), null);
+            if (fromIsServerOnly)
+                newFrom = new EntityImpl(null, newFrom.getDomain(), null);
             stanzaBuilder.addAttribute("from", newFrom.getFullQualifiedName());
         }
         stanzaBuilder.addAttribute("type", type);
-        if (original.getID() != null) stanzaBuilder.addAttribute("id", original.getID());
+        if (original.getID() != null)
+            stanzaBuilder.addAttribute("id", original.getID());
 
         return stanzaBuilder;
     }
@@ -125,17 +141,20 @@ public class StanzaBuilder extends Abstr
      * @return
      */
     public static StanzaBuilder createClone(XMLElement original, boolean deep, List<Attribute> replacingAttributes) {
-        StanzaBuilder stanzaBuilder = new StanzaBuilder(original.getName(), original.getNamespaceURI(), original.getNamespacePrefix());
+        StanzaBuilder stanzaBuilder = new StanzaBuilder(original.getName(), original.getNamespaceURI(), original
+                .getNamespacePrefix());
 
         List<Attribute> replacingAttributesCopy = new ArrayList<Attribute>();
-        if (replacingAttributes != null) replacingAttributesCopy.addAll(replacingAttributes);
+        if (replacingAttributes != null)
+            replacingAttributesCopy.addAll(replacingAttributes);
 
         List<Attribute> originalAttributes = original.getAttributes();
         for (Attribute originalAttribute : originalAttributes) {
             boolean wasReplaced = false;
             for (Iterator<Attribute> it = replacingAttributesCopy.iterator(); it.hasNext();) {
                 Attribute replacingAttribute = it.next();
-                if (replacingAttribute == null) continue;
+                if (replacingAttribute == null)
+                    continue;
                 if (replacingAttribute.getName().equals(originalAttribute.getName())) {
                     stanzaBuilder.addAttribute(replacingAttribute);
                     it.remove(); // this has been processed
@@ -143,7 +162,8 @@ public class StanzaBuilder extends Abstr
                     break;
                 }
             }
-            if (!wasReplaced) stanzaBuilder.addAttribute(originalAttribute);
+            if (!wasReplaced)
+                stanzaBuilder.addAttribute(originalAttribute);
         }
 
         // add remaining replacements, which are actually additions
@@ -161,7 +181,7 @@ public class StanzaBuilder extends Abstr
 
         return stanzaBuilder;
     }
-    
+
     /**
      * creates a new stanza which only differs from the given original by 'from' and 'to' attributes. 
      * 
@@ -172,8 +192,10 @@ public class StanzaBuilder extends Abstr
      */
     public static StanzaBuilder createForward(Stanza original, Entity from, Entity to) {
         List<Attribute> toFromReplacements = new ArrayList<Attribute>(2);
-        if (to != null) toFromReplacements.add(new Attribute("to", to.getFullQualifiedName()));
-        if (from != null) toFromReplacements.add(new Attribute("from", from.getFullQualifiedName()));
+        if (to != null)
+            toFromReplacements.add(new Attribute("to", to.getFullQualifiedName()));
+        if (from != null)
+            toFromReplacements.add(new Attribute("from", from.getFullQualifiedName()));
 
         return createClone(original, true, toFromReplacements);
     }
@@ -192,8 +214,11 @@ public class StanzaBuilder extends Abstr
 
     class ElementStruct {
         public ElementStruct parentElement = null;
+
         public XMLElement element = null;
+
         public List<Attribute> attributes = null;
+
         public List<XMLFragment> innerFragments = null;
     }
 
@@ -206,23 +231,21 @@ public class StanzaBuilder extends Abstr
     }
 
     public StanzaBuilder(String stanzaName, String namespaceURI, String namespacePrefix) {
-    	super(stanzaName, namespaceURI, namespacePrefix);
+        super(stanzaName, namespaceURI, namespacePrefix);
+    }
+
+    public StanzaBuilder(String stanzaName, String namespaceURI, String namespacePrefix, List<Attribute> attributes,
+            List<XMLFragment> innerFragments) {
+        super(stanzaName, namespaceURI, namespacePrefix, attributes, null, innerFragments);
     }
 
-    public StanzaBuilder(String stanzaName, String namespaceURI,
-			String namespacePrefix, List<Attribute> attributes,
-			List<XMLFragment> innerFragments) {
-    	super(stanzaName, namespaceURI, namespacePrefix, attributes, null, innerFragments);
-	}
-
-    public StanzaBuilder(String stanzaName, String namespaceURI,
-			String namespacePrefix, List<Attribute> attributes,
-			Map<String, String> namespaces, 
-			List<XMLFragment> innerFragments) {
-    	super(stanzaName, namespaceURI, namespacePrefix, attributes, namespaces, innerFragments);
-	}
+    public StanzaBuilder(String stanzaName, String namespaceURI, String namespacePrefix, List<Attribute> attributes,
+            Map<String, String> namespaces, List<XMLFragment> innerFragments) {
+        super(stanzaName, namespaceURI, namespacePrefix, attributes, namespaces, innerFragments);
+    }
 
-	protected XMLElement createElement(String namespaceURI, String name, String namespacePrefix, List<Attribute> attributes, Map<String, String> namespaces, List<XMLFragment> innerFragments) {
+    protected XMLElement createElement(String namespaceURI, String name, String namespacePrefix,
+            List<Attribute> attributes, Map<String, String> namespaces, List<XMLFragment> innerFragments) {
         // when creating the first element, make it a stanza
         if (currentElement == null) {
             return new Stanza(namespaceURI, name, namespacePrefix, attributes, innerFragments, namespaces);

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaErrorCondition.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaErrorCondition.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaErrorCondition.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaErrorCondition.java Sat Jun 26 20:39:54 2010
@@ -30,30 +30,15 @@ package org.apache.vysper.xmpp.stanza;
  */
 public enum StanzaErrorCondition {
 
-    BAD_REQUEST ("bad-request"),
-    CONFLICT ("conflict"),
-    FEATURE_NOT_IMPLEMENTED ("feature-not-implemented"),
-    FORBIDDEN ("forbidden"),
-    GONE ("gone"),
-    INTERNAL_SERVER_ERROR ("internal-server-error"),
-    ITEM_NOT_FOUND ("item-not-found"),
-    JID_MALFORMED ("jid-malformed"),
-    NOT_ACCEPTABLE ("not-acceptable"),
-    NOT_ALLOWED ("not-allowed"),
-    NOT_AUTHORIZED ("not-authorized"),
-    NOT_MODIFIED ("not-modified"),
-    PAYMENT_REQUIRED ("payment-required"),
-    RECIPIENT_UNAVAILABLE ("recipient-unavailable"),
-    REDIRECT ("redirect"),
-    REGISTRATION_REQUIRED ("registration-required"),
-    REMOTE_SERVER_NOT_FOUND ("remote-server-not-found"),
-    REMOTE_SERVER_TIMEOUT ("remote-server-timeout"),
-    RESOURCE_CONSTRAINT ("resource-constraint"),
-    SERVICE_UNAVAILABLE ("service-unavailable"),
-    SUBSCRIPTION_REQUIRED ("subscription-required"),
-    UNDEFINED_CONDITION ("undefined-condition"),
-    UNEXPECTED_REQUEST ("unexpected-request"),
-    UNKNOWN_SENDER ("unknown-sender");
+    BAD_REQUEST("bad-request"), CONFLICT("conflict"), FEATURE_NOT_IMPLEMENTED("feature-not-implemented"), FORBIDDEN(
+            "forbidden"), GONE("gone"), INTERNAL_SERVER_ERROR("internal-server-error"), ITEM_NOT_FOUND("item-not-found"), JID_MALFORMED(
+            "jid-malformed"), NOT_ACCEPTABLE("not-acceptable"), NOT_ALLOWED("not-allowed"), NOT_AUTHORIZED(
+            "not-authorized"), NOT_MODIFIED("not-modified"), PAYMENT_REQUIRED("payment-required"), RECIPIENT_UNAVAILABLE(
+            "recipient-unavailable"), REDIRECT("redirect"), REGISTRATION_REQUIRED("registration-required"), REMOTE_SERVER_NOT_FOUND(
+            "remote-server-not-found"), REMOTE_SERVER_TIMEOUT("remote-server-timeout"), RESOURCE_CONSTRAINT(
+            "resource-constraint"), SERVICE_UNAVAILABLE("service-unavailable"), SUBSCRIPTION_REQUIRED(
+            "subscription-required"), UNDEFINED_CONDITION("undefined-condition"), UNEXPECTED_REQUEST(
+            "unexpected-request"), UNKNOWN_SENDER("unknown-sender");
 
     private final String value;
 

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanza.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanza.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanza.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanza.java Sat Jun 26 20:39:54 2010
@@ -36,20 +36,26 @@ abstract public class XMPPCoreStanza ext
     }
 
     public static XMPPCoreStanza getWrapper(Stanza stanza) {
-        if (stanza instanceof XMPPCoreStanza) return (XMPPCoreStanza)stanza;
-        if (IQStanza.isOfType(stanza)) return new IQStanza(stanza);
-        if (MessageStanza.isOfType(stanza)) return new MessageStanza(stanza);
-        if (PresenceStanza.isOfType(stanza)) return new PresenceStanza(stanza);
+        if (stanza instanceof XMPPCoreStanza)
+            return (XMPPCoreStanza) stanza;
+        if (IQStanza.isOfType(stanza))
+            return new IQStanza(stanza);
+        if (MessageStanza.isOfType(stanza))
+            return new MessageStanza(stanza);
+        if (PresenceStanza.isOfType(stanza))
+            return new PresenceStanza(stanza);
         return null;
     }
 
     public XMPPCoreStanza(Stanza stanza) {
-        super(stanza.getNamespaceURI(), stanza.getName(), stanza.getNamespacePrefix(), stanza.getAttributes(), stanza.getInnerFragments());
+        super(stanza.getNamespaceURI(), stanza.getName(), stanza.getNamespacePrefix(), stanza.getAttributes(), stanza
+                .getInnerFragments());
     }
 
     @Override
     public XMLElementVerifier getVerifier() {
-        if (xmlElementVerifier == null) xmlElementVerifier = new XMPPCoreStanzaVerifier(this);
+        if (xmlElementVerifier == null)
+            xmlElementVerifier = new XMPPCoreStanzaVerifier(this);
         return xmlElementVerifier;
     }
 
@@ -76,5 +82,4 @@ abstract public class XMPPCoreStanza ext
         return getNamespaceURI().equals(NamespaceURIs.JABBER_SERVER);
     }
 
-
 }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanzaVerifier.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanzaVerifier.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanzaVerifier.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanzaVerifier.java Sat Jun 26 20:39:54 2010
@@ -37,7 +37,8 @@ public class XMPPCoreStanzaVerifier exte
         boolean clientCall = namespacePresent(NamespaceURIs.JABBER_CLIENT);
         boolean serverCall = namespacePresent(NamespaceURIs.JABBER_SERVER);
 
-        if (clientCall && serverCall) serverCall = false; // silently ignore ambiguous attributes
+        if (clientCall && serverCall)
+            serverCall = false; // silently ignore ambiguous attributes
         return serverCall;
     }
 

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataForm.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataForm.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataForm.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataForm.java Sat Jun 26 20:39:54 2010
@@ -19,14 +19,14 @@
  */
 package org.apache.vysper.xmpp.stanza.dataforms;
 
-import org.apache.vysper.compliance.SpecCompliant;
-import static org.apache.vysper.compliance.SpecCompliant.ComplianceCoverage;
-import static org.apache.vysper.compliance.SpecCompliant.ComplianceStatus;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.vysper.compliance.SpecCompliant;
+import org.apache.vysper.compliance.SpecCompliant.ComplianceCoverage;
+import org.apache.vysper.compliance.SpecCompliant.ComplianceStatus;
+
 /**
  * object model for data forms, according to XEP-0004, as used by many XMPP extensions (and the core).
  * 
@@ -34,21 +34,25 @@ import java.util.List;
  */
 @SpecCompliant(spec = "XEP-0004", status = ComplianceStatus.IN_PROGRESS, coverage = ComplianceCoverage.PARTIAL)
 public class DataForm {
-    
-    public static enum Type { 
-        
-        cancel, form, result, submit; 
-        
+
+    public static enum Type {
+
+        cancel, form, result, submit;
+
         public String value() {
             return name();
         }
-    
+
     }
-    
+
     protected Type type;
+
     protected List<String> instructions = new ArrayList<String>();
+
     protected String title;
+
     protected final List<Field> fields = new ArrayList<Field>();
+
     protected final List<List<Field>> items = new ArrayList<List<Field>>();
 
     public Type getType() {
@@ -74,27 +78,28 @@ public class DataForm {
     public void setTitle(String title) {
         this.title = title;
     }
-    
+
     public Iterator<Field> getFieldIterator() {
         return fields.iterator();
     }
-    
+
     public void addField(Field field) {
         fields.add(field);
-    } 
-    
+    }
+
     public Iterator<List<Field>> getItemIterator() {
         return items.iterator();
     }
-    
+
     public void addItem(List<Field> item) {
         items.add(item);
     }
 
     public Iterator<Field> getReportedIterator() {
         List<Field> reportedFields = new ArrayList<Field>();
-        
-        if (items.size() == 0) return reportedFields.iterator();
+
+        if (items.size() == 0)
+            return reportedFields.iterator();
 
         // reported fields are implicitly defined by item fields
         // here, reported fields are only taken from the first item.
@@ -108,5 +113,5 @@ public class DataForm {
 
         return reportedFields.iterator();
     }
-    
+
 }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataFormEncoder.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataFormEncoder.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataFormEncoder.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/DataFormEncoder.java Sat Jun 26 20:39:54 2010
@@ -19,16 +19,16 @@
  */
 package org.apache.vysper.xmpp.stanza.dataforms;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.vysper.xml.fragment.Attribute;
 import org.apache.vysper.xml.fragment.XMLElement;
 import org.apache.vysper.xml.fragment.XMLFragment;
 import org.apache.vysper.xml.fragment.XMLText;
 import org.apache.vysper.xmpp.protocol.NamespaceURIs;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * makes XMPP out of a Data Form as provided by the model contained in a {@link org.apache.vysper.xmpp.stanza.dataforms.DataForm}
  * instance.
@@ -42,7 +42,8 @@ public class DataFormEncoder {
         Iterator<String> instructionIterator = dataForm.getInstructionIterator();
         while (instructionIterator.hasNext()) {
             String instruction = instructionIterator.next();
-            if (instruction == null) continue;
+            if (instruction == null)
+                continue;
             childElements.add(createTextOnlyElement(NamespaceURIs.JABBER_X_DATA, "instructions", instruction));
         }
 
@@ -58,7 +59,8 @@ public class DataFormEncoder {
                 Field field = reportedIterator.next();
                 reportedFields.add(encodeField(field));
             }
-            XMLElement reportedElement = new XMLElement(NamespaceURIs.JABBER_X_DATA, "reported", null, null, reportedFields);
+            XMLElement reportedElement = new XMLElement(NamespaceURIs.JABBER_X_DATA, "reported", null, null,
+                    reportedFields);
             childElements.add(reportedElement);
 
             // all item elements with their values
@@ -72,7 +74,7 @@ public class DataFormEncoder {
                 XMLElement itemElement = new XMLElement(NamespaceURIs.JABBER_X_DATA, "item", null, null, itemFields);
                 childElements.add(itemElement);
             }
-        } 
+        }
 
         if (dataForm.getType() != DataForm.Type.cancel) {
             // all fields
@@ -85,14 +87,14 @@ public class DataFormEncoder {
 
         List<Attribute> attributes = new ArrayList<Attribute>();
         attributes.add(new Attribute("type", dataForm.getType().value()));
-        
+
         return new XMLElement(NamespaceURIs.JABBER_X_DATA, "x", NamespaceURIs.JABBER_X_DATA, attributes, childElements);
     }
-    
+
     protected XMLElement encodeField(Field field) {
-        
+
         ArrayList<XMLFragment> fieldElements = new ArrayList<XMLFragment>();
-        
+
         List<Attribute> fieldAttributes = new ArrayList<Attribute>();
         if (field.getVar() != null) {
             fieldAttributes.add(new Attribute("var", field.getVar()));
@@ -106,14 +108,14 @@ public class DataFormEncoder {
 
         ArrayList<XMLFragment> descFragment = new ArrayList<XMLFragment>();
         if (field.getDesc() != null) {
-            descFragment.add(new XMLText(field.getDesc()));     
+            descFragment.add(new XMLText(field.getDesc()));
         }
         fieldElements.add(new XMLElement(NamespaceURIs.JABBER_X_DATA, "desc", null, null, descFragment));
 
         if (field.isRequired()) {
             fieldElements.add(createEmptyElement(NamespaceURIs.JABBER_X_DATA, "required"));
         }
-        
+
         Iterator<String> valueIterator = field.getValueIterator();
         while (valueIterator.hasNext()) {
             String value = valueIterator.next();
@@ -125,22 +127,24 @@ public class DataFormEncoder {
         while (optionIterator.hasNext()) {
             Option option = optionIterator.next();
 
-            Attribute[] attributes = option.getLabel() == null ? null : new Attribute[]{new Attribute("label", option.getLabel())};
-            XMLFragment[] elements = option.getValue() == null ? null : new XMLFragment[]{new XMLText(option.getValue())};
+            Attribute[] attributes = option.getLabel() == null ? null : new Attribute[] { new Attribute("label", option
+                    .getLabel()) };
+            XMLFragment[] elements = option.getValue() == null ? null : new XMLFragment[] { new XMLText(option
+                    .getValue()) };
 
             XMLElement optionElement = new XMLElement(NamespaceURIs.JABBER_X_DATA, "option", null, attributes, elements);
             fieldElements.add(optionElement);
         }
 
         return new XMLElement(NamespaceURIs.JABBER_X_DATA, "field", null, fieldAttributes, fieldElements);
-        
+
     }
 
     protected XMLElement createEmptyElement(String namespaceURI, String elementName) {
-        return new XMLElement(namespaceURI, elementName, null, (Attribute[])null, (XMLFragment[])null);
+        return new XMLElement(namespaceURI, elementName, null, (Attribute[]) null, (XMLFragment[]) null);
     }
-    
+
     protected XMLElement createTextOnlyElement(String namespaceURI, String elementName, String text) {
-        return new XMLElement(namespaceURI, elementName, null, null, new XMLFragment[]{new XMLText(text)});
+        return new XMLElement(namespaceURI, elementName, null, null, new XMLFragment[] { new XMLText(text) });
     }
 }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Field.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Field.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Field.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Field.java Sat Jun 26 20:39:54 2010
@@ -19,27 +19,20 @@
  */
 package org.apache.vysper.xmpp.stanza.dataforms;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ArrayList;
 
 /**
  */
 public class Field {
-    
+
     public static enum Type {
-        
-        BOOLEAN("boolean"), 
-        FIXED("fixed"), 
-        HIDDEN("hidden"),
-        JID_MULTI("jid-multi"),
-        JID_SINGLE("jid-single"),
-        LIST_MULTI("list-multi"),
-        LIST_SINGLE("list-single"),
-        TEXT_MULTI("text-multi"),
-        TEXT_PRIVATE("text-private"), 
-        TEXT_SINGLE("text-single");
-        
+
+        BOOLEAN("boolean"), FIXED("fixed"), HIDDEN("hidden"), JID_MULTI("jid-multi"), JID_SINGLE("jid-single"), LIST_MULTI(
+                "list-multi"), LIST_SINGLE("list-single"), TEXT_MULTI("text-multi"), TEXT_PRIVATE("text-private"), TEXT_SINGLE(
+                "text-single");
+
         private final String value;
 
         Type(String value) {
@@ -52,11 +45,17 @@ public class Field {
     }
 
     protected String label;
+
     protected Type type;
+
     protected String var;
+
     protected String desc;
+
     protected boolean required = false;
+
     protected final List<Option> options = new ArrayList<Option>();
+
     protected final List<String> values = new ArrayList<String>();
 
     public Field(String label, Type type, String var) {

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Option.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Option.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Option.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/dataforms/Option.java Sat Jun 26 20:39:54 2010
@@ -22,8 +22,9 @@ package org.apache.vysper.xmpp.stanza.da
 /**
  */
 public class Option {
-    
+
     protected String label;
+
     protected String value;
 
     public Option(String label, String value) {

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/AbstractBaseCache.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/AbstractBaseCache.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/AbstractBaseCache.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/AbstractBaseCache.java Sat Jun 26 20:39:54 2010
@@ -45,20 +45,19 @@ public abstract class AbstractBaseCache 
 
         if (entity.getResource() == null) {
             throw new PresenceCachingException("presense stanzas are cached per resource, failure for "
-                                                + entity.getFullQualifiedName());
+                    + entity.getFullQualifiedName());
         }
     }
 
     /**
      * @inheritDoc
      */
-    public void put(Entity entity, PresenceStanza presenceStanza)
-                                    throws PresenceCachingException {
+    public void put(Entity entity, PresenceStanza presenceStanza) throws PresenceCachingException {
         checkEntry(entity);
 
         // Can't store null entity
-        if(presenceStanza == null) {
-            throw new PresenceCachingException("Presence Stanza cannot be null");            
+        if (presenceStanza == null) {
+            throw new PresenceCachingException("Presence Stanza cannot be null");
         }
 
         put0(entity, presenceStanza);
@@ -72,8 +71,7 @@ public abstract class AbstractBaseCache 
      * @param presenceStanza    PresenceStanza to be stored
      * @throws PresenceCachingException
      */
-    protected abstract void put0(Entity entity, PresenceStanza presenceStanza)
-                                    throws PresenceCachingException;
+    protected abstract void put0(Entity entity, PresenceStanza presenceStanza) throws PresenceCachingException;
 
     public PresenceStanza get(Entity entity) throws PresenceCachingException {
         checkEntry(entity);
@@ -87,6 +85,5 @@ public abstract class AbstractBaseCache 
      * @return              PresenceStanza related with the key
      * @throws PresenceCachingException
      */
-    protected abstract PresenceStanza get0(Entity entity)
-                                            throws PresenceCachingException;
+    protected abstract PresenceStanza get0(Entity entity) throws PresenceCachingException;
 }
\ No newline at end of file

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/EhCachePresenceCacheImpl.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/EhCachePresenceCacheImpl.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/EhCachePresenceCacheImpl.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/EhCachePresenceCacheImpl.java Sat Jun 26 20:39:54 2010
@@ -20,14 +20,15 @@
 
 package org.apache.vysper.xmpp.state.presence;
 
+import java.net.URL;
+
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
+
 import org.apache.vysper.xmpp.addressing.Entity;
 import org.apache.vysper.xmpp.stanza.PresenceStanza;
 
-import java.net.URL;
-
 /**
  * EhCache based cache Presence cache implementation. The imlpementation stores
  * the PresenceStanza into two cache's. One is for Entity as a key. However to
@@ -51,7 +52,7 @@ public class EhCachePresenceCacheImpl ex
 
     // Cache instance to store the presence information against Entity
     private Cache presenceCache = null;
-    
+
     // Cache instance to store presence information against JID
     private Cache jidPresenceCache = null;
 
@@ -75,25 +76,24 @@ public class EhCachePresenceCacheImpl ex
      * @param configFile    ehcache configuration file
      */
     protected void createCache(String configFile) {
-        if(configFile == null) {
-            configFile = DEFAULT_EHCACHE_CONFIG_FILE;            
+        if (configFile == null) {
+            configFile = DEFAULT_EHCACHE_CONFIG_FILE;
         }
         URL configFileURL = getClass().getResource(configFile);
-        if(configFileURL == null) {
+        if (configFileURL == null) {
             throw new RuntimeException("ehcache configuration file ehcache.xml not found on classpath");
         }
         CacheManager.create();
 
         presenceCache = CacheManager.getInstance().getCache(PRESENCE_CACHE);
-        jidPresenceCache = CacheManager.getInstance().getCache(JID_PRESENCE_CACHE); 
+        jidPresenceCache = CacheManager.getInstance().getCache(JID_PRESENCE_CACHE);
     }
 
     /**
      * @inheritDoc
      */
     @Override
-    protected void put0(Entity entity, PresenceStanza presenceStanza)
-                                    throws PresenceCachingException {
+    protected void put0(Entity entity, PresenceStanza presenceStanza) throws PresenceCachingException {
         // Create EhCache elements to be stored
         Element cacheElement = new Element(entity, presenceStanza);
         Element jidElement = new Element(entity.getBareJID(), presenceStanza);
@@ -111,8 +111,8 @@ public class EhCachePresenceCacheImpl ex
         Element cacheElement = presenceCache.get(entity);
 
         // return the value from presence cache
-        if(cacheElement != null) {
-            return (PresenceStanza)cacheElement.getObjectValue();
+        if (cacheElement != null) {
+            return (PresenceStanza) cacheElement.getObjectValue();
         }
         return null;
     }
@@ -122,15 +122,15 @@ public class EhCachePresenceCacheImpl ex
      */
     public PresenceStanza getForBareJID(Entity entity) throws PresenceCachingException {
         // return null for null entries
-        if(entity == null) {
-            return null;           
+        if (entity == null) {
+            return null;
         }
 
         Element cacheElement = jidPresenceCache.get(entity);
 
         // return the value from presence cache
-        if(cacheElement != null) {
-            return (PresenceStanza)cacheElement.getObjectValue();
+        if (cacheElement != null) {
+            return (PresenceStanza) cacheElement.getObjectValue();
         }
         return null;
     }
@@ -140,8 +140,8 @@ public class EhCachePresenceCacheImpl ex
      */
     public void remove(Entity entity) {
         // if entity is null, keep silent
-        if(entity == null) {
-            return;            
+        if (entity == null) {
+            return;
         }
 
         // Remove the cache from presence and jid presence cache

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/LatestPresenceCache.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/LatestPresenceCache.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/LatestPresenceCache.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/LatestPresenceCache.java Sat Jun 26 20:39:54 2010
@@ -24,7 +24,7 @@ import org.apache.vysper.xmpp.stanza.Pre
 
 /**
  * Keeps the latest presence for a resource
- */                                 
+ */
 public interface LatestPresenceCache {
 
     /**

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/SimplePresenceCache.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/SimplePresenceCache.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/SimplePresenceCache.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/presence/SimplePresenceCache.java Sat Jun 26 20:39:54 2010
@@ -19,12 +19,12 @@
  */
 package org.apache.vysper.xmpp.state.presence;
 
-import org.apache.vysper.xmpp.addressing.Entity;
-import org.apache.vysper.xmpp.stanza.PresenceStanza;
-
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.stanza.PresenceStanza;
+
 /**
  * unbounded in-memory-only cache, but entries are timestamped and oldest entry is the first in list
  */
@@ -36,7 +36,7 @@ public class SimplePresenceCache extends
     protected void put0(Entity entity, PresenceStanza presenceStanza) {
         checkEntry(entity);
         // force adding at the end, this guarantees that the entry is the latest in getForBareJID()
-        presenceMap.remove(entity);  
+        presenceMap.remove(entity);
         presenceMap.put(entity, new Entry(presenceStanza));
     }
 
@@ -44,7 +44,8 @@ public class SimplePresenceCache extends
     protected PresenceStanza get0(Entity entity) throws PresenceCachingException {
         checkEntry(entity);
         Entry entry = presenceMap.get(entity);
-        if (entry == null) return null;
+        if (entry == null)
+            return null;
         return entry.getPresenceStanza();
     }
 
@@ -65,6 +66,7 @@ public class SimplePresenceCache extends
 
     static class Entry {
         protected long timestamp = System.currentTimeMillis();
+
         protected PresenceStanza presenceStanza;
 
         Entry(PresenceStanza presenceStanza) {

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceRegistry.java Sat Jun 26 20:39:54 2010
@@ -19,20 +19,23 @@
  */
 package org.apache.vysper.xmpp.state.resourcebinding;
 
+import static org.apache.vysper.xmpp.state.resourcebinding.ResourceState.AVAILABLE;
+import static org.apache.vysper.xmpp.state.resourcebinding.ResourceState.AVAILABLE_INTERESTED;
+import static org.apache.vysper.xmpp.state.resourcebinding.ResourceState.CONNECTED;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.vysper.xmpp.addressing.Entity;
 import org.apache.vysper.xmpp.server.SessionContext;
 import org.apache.vysper.xmpp.uuid.JVMBuiltinUUIDGenerator;
 import org.apache.vysper.xmpp.uuid.UUIDGenerator;
-import org.apache.vysper.xmpp.addressing.Entity;
-import static org.apache.vysper.xmpp.state.resourcebinding.ResourceState.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Map;
-import java.util.HashMap;
-
 /**
  * assigns and holds resource ids and their related session
  *
@@ -51,8 +54,8 @@ public class ResourceRegistry {
         private Integer priority;
 
         SessionData(SessionContext context, ResourceState status, Integer priority) {
-			this.context = context;
-			this.state = status;
+            this.context = context;
+            this.state = status;
             this.priority = priority == null ? 0 : priority;
         }
 
@@ -85,32 +88,29 @@ public class ResourceRegistry {
      * @return newly allocated resource id
      */
     public String bindSession(SessionContext sessionContext) {
-		if (sessionContext == null) {
-			throw new IllegalArgumentException("session context cannot be NULL");
-		}
-		if (sessionContext.getInitiatingEntity() == null) {
-			throw new IllegalStateException(
-					"session context must have a initiating entity set");
-		}
-		String resourceId = resourceIdGenerator.create();
+        if (sessionContext == null) {
+            throw new IllegalArgumentException("session context cannot be NULL");
+        }
+        if (sessionContext.getInitiatingEntity() == null) {
+            throw new IllegalStateException("session context must have a initiating entity set");
+        }
+        String resourceId = resourceIdGenerator.create();
 
-		synchronized (boundResources) {
-			synchronized (entityResources) {
+        synchronized (boundResources) {
+            synchronized (entityResources) {
                 synchronized (sessionResources) {
                     // record session for the resource id
-                    boundResources.put(resourceId, new SessionData(sessionContext,
-                            CONNECTED, 0));
+                    boundResources.put(resourceId, new SessionData(sessionContext, CONNECTED, 0));
 
                     Entity initiatingEntity = sessionContext.getInitiatingEntity();
                     List<String> resourceForEntityList = getResourceList(initiatingEntity);
                     if (resourceForEntityList == null) {
                         resourceForEntityList = new ArrayList<String>(1);
-                        entityResources.put(getBareEntity(initiatingEntity),
-                                resourceForEntityList);
+                        entityResources.put(getBareEntity(initiatingEntity), resourceForEntityList);
                     }
                     resourceForEntityList.add(resourceId);
-                    logger.info("added resource no. " + resourceForEntityList.size() + " to entity {} <- {}", 
-                                initiatingEntity.getFullQualifiedName(), resourceId);
+                    logger.info("added resource no. " + resourceForEntityList.size() + " to entity {} <- {}",
+                            initiatingEntity.getFullQualifiedName(), resourceId);
 
                     List<String> resourcesForSessionList = sessionResources.get(sessionContext);
                     if (resourcesForSessionList == null) {
@@ -118,14 +118,14 @@ public class ResourceRegistry {
                         sessionResources.put(sessionContext, resourcesForSessionList);
                     }
                     resourcesForSessionList.add(resourceId);
-                    logger.info("added resource no. " + resourcesForSessionList.size() + " to session {} <- {}", 
-                                sessionContext.getSessionId(), resourceId);
+                    logger.info("added resource no. " + resourcesForSessionList.size() + " to session {} <- {}",
+                            sessionContext.getSessionId(), resourceId);
                 }
-			}
-		}
+            }
+        }
 
-		return resourceId;
-	}
+        return resourceId;
+    }
 
     /**
      * not as commonly used as #unbindSession, this method unbinds only one of multiple resource ids for the _same_
@@ -137,29 +137,31 @@ public class ResourceRegistry {
      */
     public boolean unbindResource(String resourceId) {
         boolean noResourceRemainsForSession = false;
-		synchronized (boundResources) {
-			synchronized (entityResources) {
-    			synchronized (sessionResources) {
+        synchronized (boundResources) {
+            synchronized (entityResources) {
+                synchronized (sessionResources) {
                     SessionContext sessionContext = getSessionContext(resourceId);
 
                     // remove from entity's list of resources
                     List<String> resourceListForEntity = getResourceList(sessionContext.getInitiatingEntity());
                     resourceListForEntity.remove(resourceId);
-                    if (resourceListForEntity.isEmpty()) entityResources.remove(sessionContext.getInitiatingEntity());
+                    if (resourceListForEntity.isEmpty())
+                        entityResources.remove(sessionContext.getInitiatingEntity());
 
                     // remove from session's list of resources
                     List<String> resourceListForSession = sessionResources.get(sessionContext);
                     resourceListForSession.remove(resourceId);
                     noResourceRemainsForSession = resourceListForSession.isEmpty();
-                    if (noResourceRemainsForSession) sessionResources.remove(sessionContext);
+                    if (noResourceRemainsForSession)
+                        sessionResources.remove(sessionContext);
 
                     // remove from overall list of bound resource
                     boundResources.remove(resourceId);
-    			}
-			}
-		}
+                }
+            }
+        }
         return noResourceRemainsForSession;
-	}
+    }
 
     /**
      * unbinds a complete session, together with all its bound resources. this is typically done when a XMPP session
@@ -167,11 +169,12 @@ public class ResourceRegistry {
      * @param unbindingSessionContext sessionContext to be unbound
      */
     public void unbindSession(SessionContext unbindingSessionContext) {
-		if (unbindingSessionContext == null) return;
+        if (unbindingSessionContext == null)
+            return;
 
-		synchronized (boundResources) {
-			synchronized (entityResources) {
-			    synchronized (sessionResources) {
+        synchronized (boundResources) {
+            synchronized (entityResources) {
+                synchronized (sessionResources) {
                     // collect all remove candidates
                     List<String> removeResourceIds = getResourcesForSessionInternal(unbindingSessionContext);
 
@@ -181,8 +184,7 @@ public class ResourceRegistry {
                     }
 
                     // actually remove from entity map
-                    List<String> resourceList = getResourceList(unbindingSessionContext
-                            .getInitiatingEntity());
+                    List<String> resourceList = getResourceList(unbindingSessionContext.getInitiatingEntity());
                     if (resourceList != null) {
                         resourceList.removeAll(removeResourceIds);
                     }
@@ -190,9 +192,9 @@ public class ResourceRegistry {
                     // actually remove from session map
                     sessionResources.remove(unbindingSessionContext);
                 }
-			}
-		}
-	}
+            }
+        }
+    }
 
     /**
      * retrieves the one and only bound resource for a given session.
@@ -201,7 +203,8 @@ public class ResourceRegistry {
      */
     public String getUniqueResourceForSession(SessionContext sessionContext) {
         List<String> list = getResourcesForSessionInternal(sessionContext);
-        if (list != null && list.size() == 1) return list.get(0);
+        if (list != null && list.size() == 1)
+            return list.get(0);
         return null;
     }
 
@@ -209,58 +212,62 @@ public class ResourceRegistry {
         return Collections.unmodifiableList(getResourcesForSessionInternal(sessionContext));
     }
 
-    /*package*/ List<String> getResourcesForSessionInternal(SessionContext sessionContext) {
-		if (sessionContext == null) return null;
+    /*package*/List<String> getResourcesForSessionInternal(SessionContext sessionContext) {
+        if (sessionContext == null)
+            return null;
 
         List<String> resourceList = sessionResources.get(sessionContext);
-        if (resourceList == null) resourceList = Collections.emptyList();
+        if (resourceList == null)
+            resourceList = Collections.emptyList();
         return resourceList;
     }
 
     public SessionContext getSessionContext(String resourceId) {
-		SessionData data = boundResources.get(resourceId);
-		if (data == null) return null;
-		return data.context;
-	}
+        SessionData data = boundResources.get(resourceId);
+        if (data == null)
+            return null;
+        return data.context;
+    }
 
     private Entity getBareEntity(Entity entity) {
         return entity == null ? null : entity.getBareJID();
-	}
+    }
 
     /**
-	 * @param entity
-	 * @return all resources bound to this entity modulo the entity's resource
-	 *         (if given)
-	 */
-	private List<String> getResourceList(Entity entity) {
-		return entityResources.get(getBareEntity(entity));
-	}
-
-    /**
-	 * retrieve IDs of all bound resources for this entity
-	 */
-	protected List<String> getBoundResources(Entity entity) {
-		return getBoundResources(entity, true);
-	}
-
-    /**
-	 * retrieve IDs of all bound resources for this entity
-	 */
-	public List<String> getBoundResources(Entity entity, boolean considerBareID) {
-		// all resources for the entity
-		List<String> resourceList = getResourceList(entity);
-        if (resourceList == null) return Collections.emptyList();
+     * @param entity
+     * @return all resources bound to this entity modulo the entity's resource
+     *         (if given)
+     */
+    private List<String> getResourceList(Entity entity) {
+        return entityResources.get(getBareEntity(entity));
+    }
+
+    /**
+     * retrieve IDs of all bound resources for this entity
+     */
+    protected List<String> getBoundResources(Entity entity) {
+        return getBoundResources(entity, true);
+    }
+
+    /**
+     * retrieve IDs of all bound resources for this entity
+     */
+    public List<String> getBoundResources(Entity entity, boolean considerBareID) {
+        // all resources for the entity
+        List<String> resourceList = getResourceList(entity);
+        if (resourceList == null)
+            return Collections.emptyList();
 
         // if resource should not be considered, return all resources
-		if (considerBareID || entity.getResource() == null)
-			return Collections.unmodifiableList(resourceList);
-		// resource not contained, result is empty
-		if (!resourceList.contains(entity.getResource())) {
-			return Collections.emptyList();
-		}
-		// do we have a bound entity and want only their resource returned?
-		return Collections.singletonList(entity.getResource());
-	}
+        if (considerBareID || entity.getResource() == null)
+            return Collections.unmodifiableList(resourceList);
+        // resource not contained, result is empty
+        if (!resourceList.contains(entity.getResource())) {
+            return Collections.emptyList();
+        }
+        // do we have a bound entity and want only their resource returned?
+        return Collections.singletonList(entity.getResource());
+    }
 
     /**
      * retrieves all sessions handling this entity. note: if given entity is not a bare JID, it will return only the
@@ -268,15 +275,15 @@ public class ResourceRegistry {
      * @param entity
      */
     public List<SessionContext> getSessions(Entity entity) {
-		List<SessionContext> sessionContexts = new ArrayList<SessionContext>();
+        List<SessionContext> sessionContexts = new ArrayList<SessionContext>();
 
-		List<String> boundResources = getBoundResources(entity, false);
-		for (String resourceId : boundResources) {
-			sessionContexts.add(getSessionContext(resourceId));
-		}
+        List<String> boundResources = getBoundResources(entity, false);
+        for (String resourceId : boundResources) {
+            sessionContexts.add(getSessionContext(resourceId));
+        }
 
-		return sessionContexts;
-	}
+        return sessionContexts;
+    }
 
     /**
      * retrieves sessions with same or above threshold
@@ -287,21 +294,23 @@ public class ResourceRegistry {
      * @return returns the sessions matching the given JID (bare) with same or higher priority
      */
     public List<SessionContext> getSessions(Entity entity, Integer prioThreshold) {
-        if (prioThreshold == null) prioThreshold = 0;
+        if (prioThreshold == null)
+            prioThreshold = 0;
         List<SessionContext> results = new ArrayList<SessionContext>();
 
         List<String> boundResourceIds = getBoundResources(entity, true);
-		for (String resourceId : boundResourceIds) {
+        for (String resourceId : boundResourceIds) {
             SessionData sessionData = boundResources.get(resourceId);
-            if (sessionData == null) continue;
+            if (sessionData == null)
+                continue;
 
             if (sessionData.priority >= prioThreshold) {
                 results.add(sessionData.context);
             }
         }
         return results;
-	}
-    
+    }
+
     /**
      * retrieves the highest prioritized session(s) for this entity.
      * 
@@ -320,10 +329,11 @@ public class ResourceRegistry {
         boolean isResourceSet = entity.isResourceSet();
 
         List<String> boundResourceIds = getBoundResources(entity, false);
-		for (String resourceId : boundResourceIds) {
+        for (String resourceId : boundResourceIds) {
             SessionData sessionData = boundResources.get(resourceId);
-            if (sessionData == null) continue;
-            
+            if (sessionData == null)
+                continue;
+
             if (isResourceSet) {
                 // if resource id matches, there can only be one result
                 // this overrides even parameter prio threshold
@@ -331,76 +341,81 @@ public class ResourceRegistry {
                 results.add(sessionData.context);
                 return results;
             }
-            
+
             if (sessionData.priority > currentPrio) {
                 results.clear(); // discard all accumulated lower prio sessions
                 currentPrio = sessionData.priority;
                 results.add(sessionData.context);
-            } else if(sessionData.priority.intValue() == currentPrio.intValue()) {
+            } else if (sessionData.priority.intValue() == currentPrio.intValue()) {
                 results.add(sessionData.context);
             }
         }
 
         return results;
-	}
+    }
 
     /**
-	 * Sets the {@link ResourceState} for the given resource.
-	 *
-	 * @param resourceId
-	 *            the resource identifier
-	 * @param state
-	 *            the {@link ResourceState} to set
+     * Sets the {@link ResourceState} for the given resource.
+     *
+     * @param resourceId
+     *            the resource identifier
+     * @param state
+     *            the {@link ResourceState} to set
      * @return true iff the state has effectively changed
-	 */
-	public boolean setResourceState(String resourceId, ResourceState state) {
-		SessionData data = boundResources.get(resourceId);
+     */
+    public boolean setResourceState(String resourceId, ResourceState state) {
+        SessionData data = boundResources.get(resourceId);
         if (data == null) {
             throw new IllegalArgumentException("resource not registered: " + resourceId);
         }
         synchronized (data) {
-            boolean result =  data.state != state;
+            boolean result = data.state != state;
             data.state = state;
             return result;
         }
-	}
+    }
 
     /**
-	 * Gets the {@link ResourceState} of the given resource.
-	 *
-	 * @param resourceId
-	 *            the resource identifier
-	 * @return the {@link ResourceState}
-	 */
-	public ResourceState getResourceState(String resourceId) {
-        if (resourceId == null) return null;
+     * Gets the {@link ResourceState} of the given resource.
+     *
+     * @param resourceId
+     *            the resource identifier
+     * @return the {@link ResourceState}
+     */
+    public ResourceState getResourceState(String resourceId) {
+        if (resourceId == null)
+            return null;
         SessionData data = boundResources.get(resourceId);
-		if (data == null) return null;
-		return data.state;
-	}
+        if (data == null)
+            return null;
+        return data.state;
+    }
 
     public void setResourcePriority(String resourceId, int priority) {
-        if (resourceId == null) return;
+        if (resourceId == null)
+            return;
         SessionData data = boundResources.get(resourceId);
-		if (data == null) return;
-		data.priority = priority;
+        if (data == null)
+            return;
+        data.priority = priority;
     }
 
-	public List<String> getInterestedResources(Entity entity) {
+    public List<String> getInterestedResources(Entity entity) {
         List<String> resources = getResourceList(entity);
         List<String> result = new ArrayList<String>();
         for (String resource : resources) {
             ResourceState resourceState = getResourceState(resource);
-            if (ResourceState.isInterested(resourceState)) result.add(resource);
+            if (ResourceState.isInterested(resourceState))
+                result.add(resource);
         }
         return result;
-	}
+    }
 
     /**
      * resources which are available or even interested - an higher form of available.
      * @see org.apache.vysper.xmpp.state.resourcebinding.ResourceState
      */
-	public List<String> getAvailableResources(Entity entity) {
+    public List<String> getAvailableResources(Entity entity) {
         List<String> resources = getResourceList(entity);
         List<String> result = new ArrayList<String>();
         for (String resource : resources) {
@@ -410,5 +425,5 @@ public class ResourceRegistry {
             }
         }
         return result;
-	}
+    }
 }

Modified: mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java
URL: http://svn.apache.org/viewvc/mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java?rev=958281&r1=958280&r2=958281&view=diff
==============================================================================
--- mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java (original)
+++ mina/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/state/resourcebinding/ResourceState.java Sat Jun 26 20:39:54 2010
@@ -29,10 +29,10 @@ package org.apache.vysper.xmpp.state.res
  *
  */
 public enum ResourceState {
-	/**
-	 * A resource is connected if resource binding was successful.
-	 */
-	CONNECTED,
+    /**
+     * A resource is connected if resource binding was successful.
+     */
+    CONNECTED,
     /**
      * A conntected resource has requested the
      * entity's roster without sending initial presence first
@@ -67,12 +67,14 @@ public enum ResourceState {
      * @return new state
      */
     public static ResourceState makeAvailable(ResourceState inState) {
-        if (inState == null || !isInterested(inState)) return AVAILABLE;
+        if (inState == null || !isInterested(inState))
+            return AVAILABLE;
         return AVAILABLE_INTERESTED;
     }
 
     public static ResourceState makeInterested(ResourceState inState) {
-        if (inState == AVAILABLE) return AVAILABLE_INTERESTED;
+        if (inState == AVAILABLE)
+            return AVAILABLE_INTERESTED;
         return CONNECTED_INTERESTED;
     }
 }