qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject svn commit: r565561 - in /incubator/qpid/trunk/qpid/java: client/src/main/java/org/apache/qpidity/client/ client/src/main/java/org/apache/qpidity/jms/message/ common/src/main/grammar/ common/src/main/java/org/apache/qpidity/ common/src/main/java/org/ap...
Date Mon, 13 Aug 2007 23:05:13 GMT
Author: rajith
Date: Mon Aug 13 16:05:11 2007
New Revision: 565561

URL: http://svn.apache.org/viewvc?view=rev&rev=565561
Log:
added error code support

Added:
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java
Modified:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Client.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSession.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSessionDelegate.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java
    incubator/qpid/trunk/qpid/java/common/src/main/grammar/SelectorParser.jj
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/QpidException.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Client.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Client.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/Client.java
Mon Aug 13 16:05:11 2007
@@ -10,6 +10,7 @@
 import org.apache.qpidity.Connection;
 import org.apache.qpidity.ConnectionClose;
 import org.apache.qpidity.ConnectionDelegate;
+import org.apache.qpidity.ErrorCode;
 import org.apache.qpidity.MinaHandler;
 import org.apache.qpidity.QpidException;
 import org.apache.qpidity.SessionDelegate;
@@ -39,9 +40,13 @@
                 return new ClientSessionDelegate();
             }
             
-            @Override public void connectionClose(Channel context, ConnectionClose struct)

+            @Override public void connectionClose(Channel context, ConnectionClose connectionClose)

             {
-                _exceptionListner.onException(new QpidException("Server closed the connection:
Reason " + struct.getReplyText(),struct.getReplyCode(),null));
+                _exceptionListner.onException(
+                        new QpidException("Server closed the connection: Reason " + 
+                                           connectionClose.getReplyText(),
+                                           ErrorCode.get(connectionClose.getReplyCode()),
+                                           null));
             }
         };
         

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSession.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSession.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSession.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSession.java
Mon Aug 13 16:05:11 2007
@@ -3,6 +3,7 @@
 import java.io.EOFException;
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -21,11 +22,9 @@
     private ExceptionListener _exceptionListner;
     private RangeSet _acquiredMessages;
     private RangeSet _rejectedMessages;
-    private Map<String,List<RangeSet>> _unackedMessages = new HashMap<String,List<RangeSet>>();
     
     @Override public void sessionClose()
     {
-        // release all unacked messages and then issues a close
         super.sessionClose();
     }
     

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSessionDelegate.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSessionDelegate.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSessionDelegate.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/client/ClientSessionDelegate.java
Mon Aug 13 16:05:11 2007
@@ -2,6 +2,7 @@
 
 import java.nio.ByteBuffer;
 
+import org.apache.qpidity.ErrorCode;
 import org.apache.qpidity.Frame;
 import org.apache.qpidity.MessageAcquired;
 import org.apache.qpidity.MessageReject;
@@ -10,6 +11,7 @@
 import org.apache.qpidity.Range;
 import org.apache.qpidity.RangeSet;
 import org.apache.qpidity.Session;
+import org.apache.qpidity.SessionClosed;
 import org.apache.qpidity.SessionDelegate;
 import org.apache.qpidity.Struct;
 
@@ -19,6 +21,14 @@
     private MessageTransfer _currentTransfer;
     private MessagePartListener _currentMessageListener;
     
+    @Override public void sessionClosed(Session ssn,SessionClosed sessionClosed)
+    {
+        ((ClientSession)ssn).notifyException(new QpidException(sessionClosed.getReplyText(),ErrorCode.get(sessionClosed.getReplyCode()),null));
+    }
+    
+    //  --------------------------------------------
+    //   Message methods
+    // --------------------------------------------
     @Override public void data(Session ssn, Frame frame)
     {
         for (ByteBuffer b : frame)
@@ -52,10 +62,6 @@
         }
     }
     
-    //  --------------------------------------------
-    //   Message methods
-    // --------------------------------------------
-    
     
     @Override public void messageReject(Session session, MessageReject struct) 
     {
@@ -68,7 +74,7 @@
             }
         }
         ((ClientSession)session).setRejectedMessages(struct.getTransfers());
-        ((ClientSession)session).notifyException(new QpidException("Message Rejected",0,null));
+        ((ClientSession)session).notifyException(new QpidException("Message Rejected",ErrorCode.MESSAGE_REJECTED,null));
     }
     
     @Override public void messageAcquired(Session session, MessageAcquired struct) 

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/MessageImpl.java
Mon Aug 13 16:05:11 2007
@@ -864,7 +864,7 @@
     {
         if (_destination == null)
         {
-            throw new QpidException("Invalid destination null", null, null);
+            throw new QpidException("Invalid destination null",null, null);
         }
     }
 

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpidity/jms/message/QpidMessage.java
Mon Aug 13 16:05:11 2007
@@ -20,15 +20,15 @@
  */
 package org.apache.qpidity.jms.message;
 
-import org.apache.qpidity.ReplyTo;
-import org.apache.qpidity.QpidException;
-
-import javax.jms.Message;
-import java.util.Map;
+import java.nio.ByteBuffer;
 import java.util.Enumeration;
-import java.util.Vector;
 import java.util.HashMap;
-import java.nio.ByteBuffer;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.qpidity.ErrorCode;
+import org.apache.qpidity.QpidException;
+import org.apache.qpidity.ReplyTo;
 
 
 public class QpidMessage
@@ -170,7 +170,7 @@
         {
             throw new QpidException(
                     "Problem when setting message delivery mode, " + deliveryMode + " is
not a valid mode",
-                    "wrong delivery mode", null);
+                    ErrorCode.UNDEFINED, null);
         }
         _qpidityMessage.getDeliveryProperties().setDeliveryMode(deliveryMode);
     }

Modified: incubator/qpid/trunk/qpid/java/common/src/main/grammar/SelectorParser.jj
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/grammar/SelectorParser.jj?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/grammar/SelectorParser.jj (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/grammar/SelectorParser.jj Mon Aug 13 16:05:11
2007
@@ -94,7 +94,7 @@
             return this.JmsSelector();
         }
         catch (Throwable e) {
-	        throw new QpidException(sql,"filter error",e);
+	        throw new QpidException(sql,null,e);
         }
 
     }

Added: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java?view=auto&rev=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java
(added)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/ErrorCode.java
Mon Aug 13 16:05:11 2007
@@ -0,0 +1,101 @@
+package org.apache.qpidity;
+
+public enum ErrorCode
+{
+    //Qpid specific - for the time being
+    UNDEFINED(1,"undefined",true),
+    MESSAGE_REJECTED(1,"message_rejected",true),
+    
+    //This might change in the spec, the error class is not applicable
+    NO_ERROR(200,"reply-success",true),
+    
+    //From the spec
+    CONTENT_TOO_LARGE(311,"content-too-large",false),
+    NO_ROUTE(312,"no-route",false),
+    NO_CONSUMERS(313,"content-consumers",false),
+    CONNECTION_FORCED(320,"connection-forced",true),
+    INVALID_PATH(402,"invalid-path",true),
+    ACCESS_REFUSED(403,"access-refused",false),
+    NOT_FOUND(404,"not-found",false),    
+    RESOURCE_LOCKED(405,"resource-locked",false),    
+    PRE_CONDITION_FAILED(406,"precondition-failed",false),
+    
+    FRAME_ERROR(501,"frame_error",true),
+    SYNTAX_ERROR(502,"syntax_error",true),
+    COMMAND_INVALID(503,"command_invalid",true),
+    SESSION_ERROR(504,"sesion_error",true),
+    NOT_ALLOWED(530,"not_allowed",true),
+    NOT_IMPLEMENTED(540,"not_implemented",true),
+    INTERNAL_ERROR(541,"internal_error",true),
+    INVALID_ARGUMENT(542,"invalid_argument",true);
+        
+    private int _code;
+    private String _desc;
+    private boolean _hardError;
+    
+    private ErrorCode(int code,String desc,boolean hardError)
+    {
+        _code = code;
+        _desc= desc;
+        _hardError = hardError;
+    }
+
+    public int getCode()
+    {
+        return _code;
+    }
+
+    public String getDesc()
+    {
+        return _desc;
+    }
+    
+    private boolean isHardError()
+    {
+        return _hardError;
+    }
+    
+    public static ErrorCode get(int code)
+    {
+        switch(code)
+        {
+            case 200 : return NO_ERROR;
+            case 311 : return CONTENT_TOO_LARGE;
+            case 312 : return NO_ROUTE;
+            case 313 : return NO_CONSUMERS;
+            case 320 : return CONNECTION_FORCED;
+            case 402 : return INVALID_PATH;
+            case 403 : return ACCESS_REFUSED;
+            case 404 : return NOT_FOUND;
+            case 405 : return RESOURCE_LOCKED;
+            case 406 : return PRE_CONDITION_FAILED;
+            case 501 : return FRAME_ERROR;
+            case 502 : return SYNTAX_ERROR;
+            case 503 : return COMMAND_INVALID;
+            case 504 : return SESSION_ERROR;            
+            case 530 : return NOT_ALLOWED;
+            case 540 : return NOT_IMPLEMENTED;
+            case 541 : return INTERNAL_ERROR;
+            case 542 : return INVALID_ARGUMENT;
+            
+            default : return UNDEFINED;
+        }
+    }
+    
+}
+
+/*
+
+<constant name="internal-error" value="541" class="hard-error">
+<doc>
+  The server could not complete the method because of an internal error. The server may require
+  intervention by an operator in order to resume normal operations.
+</doc>
+</constant>
+
+<constant name="invalid-argument" value="542" class="hard-error">
+<doc>
+  An invalid or illegal argument was passed to a method, and the operation could not proceed.
+</doc>
+</constant>
+*/
\ No newline at end of file

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/QpidException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/QpidException.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/QpidException.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/QpidException.java
Mon Aug 13 16:05:11 2007
@@ -17,17 +17,12 @@
  */
 package org.apache.qpidity;
 
-/**
- * Created by Arnaud Simon
- * Date: 20-Jul-2007
- * Time: 10:56:55
- */
 public class QpidException extends Exception
 {
     /**
      * AMQP error code
      */
-    private int _errorCode;
+    private ErrorCode _errorCode;
 
     /**
      * Constructor for a Qpid Exception.
@@ -38,24 +33,24 @@
      * @param cause      The linked Execption.    * 
      * 
      */
-    public QpidException(String message, int errorCode, Throwable cause)
+    public QpidException(String message, ErrorCode errorCode, Throwable cause)
     {
         super(message, cause);
         _errorCode = errorCode;
     }
     
-    //hack to get rid of a compile error from a  generated class
+    /*hack to get rid of a compile error from a  generated class
     public QpidException(String message, String errorCode, Throwable cause)
     {
         
-    }
+    }*/
 
     /**
      * Get this execption error code.
      *
      * @return This exception error code.
      */
-    public int getErrorCode()
+    public ErrorCode getErrorCode()
     {
         return _errorCode;
     }

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/SecurityHelper.java
Mon Aug 13 16:05:11 2007
@@ -64,7 +64,7 @@
         }
         catch (Exception e)
         {
-            throw new QpidException("Unable to create callback handler: " + e,0, e.getCause());
+            throw new QpidException("Unable to create callback handler: " + e,ErrorCode.UNDEFINED,
e.getCause());
         }
     }
 

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java?view=diff&rev=565561&r1=565560&r2=565561
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/filter/PropertyExpression.java
Mon Aug 13 16:05:11 2007
@@ -18,6 +18,7 @@
 package org.apache.qpidity.filter;
 
 import org.slf4j.LoggerFactory;
+import org.apache.qpidity.ErrorCode;
 import org.apache.qpidity.QpidException;
 
 import javax.jms.Message;
@@ -56,7 +57,7 @@
             }
             catch (Exception e)
             {
-                throw new QpidException("cannot evaluate property ", 0, e);
+                throw new QpidException("cannot evaluate property ", ErrorCode.UNDEFINED,
e);
             }
         }
         return result;



Mime
View raw message