Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/message/Receipt.java


1   /** 
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  
19  package org.activemq.message;
20  
21  import java.io.StringWriter;
22  import java.io.PrintWriter;
23  
24  /**
25   * Sent in receipt of a Packet
26   */
27  
28  public class Receipt extends AbstractPacket {
29  
30      private short correlationId;
31      private String brokerName;
32      private String clusterName;
33      private Throwable exception;
34      private boolean failed;
35      private int brokerMessageCapacity = 100;
36  
37  
38      /**
39       * @return Returns the jmsException.
40       *
41       * @Transient
42       */
43      public Throwable getException() {
44          return exception;
45      }
46  
47      /**
48       * @param exception The exception to set.
49       */
50      public void setException(Throwable exception) {
51          this.exception = exception;
52      }
53  
54      /**
55       * Return the type of Packet
56       *
57       * @return integer representation of the type of Packet
58       */
59  
60      public int getPacketType() {
61          return RECEIPT_INFO;
62      }
63  
64      /**
65       * @return true, this is a receipt packet
66       */
67      public boolean isReceipt() {
68          return true;
69      }
70  
71      /**
72       * @return Returns the correlationId.
73       */
74      public short getCorrelationId() {
75          return this.correlationId;
76      }
77  
78      /**
79       * @param newCorrelationId The correlationId to set.
80       */
81      public void setCorrelationId(short newCorrelationId) {
82          this.correlationId = newCorrelationId;
83      }
84  
85      /**
86       * @return Returns the failed.
87       */
88      public boolean isFailed() {
89          return this.failed;
90      }
91  
92      /**
93       * @param newFailed The failed to set.
94       */
95      public void setFailed(boolean newFailed) {
96          this.failed = newFailed;
97      }
98  
99      /**
100      * @return Returns the brokerMessageCapacity.
101      */
102     public int getBrokerMessageCapacity() {
103         return brokerMessageCapacity;
104     }
105     /**
106      * @param brokerMessageCapacity The brokerMessageCapacity to set.
107      */
108     public void setBrokerMessageCapacity(int brokerMessageCapacity) {
109         this.brokerMessageCapacity = brokerMessageCapacity;
110     }
111     /**
112      * @return Returns the brokerName.
113      */
114     public String getBrokerName() {
115         return brokerName;
116     }
117     /**
118      * @param brokerName The brokerName to set.
119      */
120     public void setBrokerName(String brokerName) {
121         this.brokerName = brokerName;
122     }
123     /**
124      * @return Returns the clusterName.
125      */
126     public String getClusterName() {
127         return clusterName;
128     }
129     /**
130      * @param clusterName The clusterName to set.
131      */
132     public void setClusterName(String clusterName) {
133         this.clusterName = clusterName;
134     }
135 
136     /**
137      * OpenWire helper method
138      */
139     public String getExceptionAsString() {
140         if (exception == null) {
141             return null;
142         }
143         StringWriter buffer = new StringWriter();
144         PrintWriter out = new PrintWriter(buffer);
145         out.println(exception.getMessage());
146         exception.printStackTrace(out);
147         out.close();
148         return buffer.toString();
149     }
150 
151     /**
152      * OpenWire helper method
153      */
154     public void setExceptionAsString(String text) {
155         Exception answer = null;
156         if (text != null && text.length() > 0) {
157             answer = new Exception(answer);
158         }
159         setException(answer);
160     }
161 
162 
163     /**
164      * @return pretty print of a Receipt
165      */
166     public String toString() {
167         return super.toString() + " Receipt{ " +
168                 "brokerMessageCapacity = " + brokerMessageCapacity +
169                 ", correlationId = '" + correlationId + "' " +
170                 ", brokerName = '" + brokerName + "' " +
171                 ", clusterName = '" + clusterName + "' " +
172                 ", exception = " + exception +
173                 ", failed = " + failed +
174                 " }";
175     }
176 }