001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq.server;
023:
024: import javax.jms.Destination;
025: import javax.jms.JMSException;
026: import javax.jms.Queue;
027: import javax.jms.TemporaryQueue;
028: import javax.jms.TemporaryTopic;
029: import javax.jms.Topic;
030: import javax.transaction.xa.Xid;
031:
032: import org.jboss.mq.AcknowledgementRequest;
033: import org.jboss.mq.ConnectionToken;
034: import org.jboss.mq.DurableSubscriptionID;
035: import org.jboss.mq.SpyDestination;
036: import org.jboss.mq.SpyMessage;
037: import org.jboss.mq.SpyTopic;
038: import org.jboss.mq.Subscription;
039: import org.jboss.mq.TransactionRequest;
040:
041: /**
042: * A pass through Interceptor, wich will trace all calls.
043: *
044: * @author <a href="mailto:pra@tim.se">Peter Antman</a>
045: * @version $Revision: 57198 $
046: */
047: public class TracingInterceptor extends JMSServerInterceptorSupport {
048: public ThreadGroup getThreadGroup() {
049: if (!log.isTraceEnabled()) {
050: return getNext().getThreadGroup();
051: }
052:
053: try {
054: log.trace("CALLED : getThreadGroup");
055: return getNext().getThreadGroup();
056: } finally {
057: log.trace("RETURN : getThreadGroup");
058: }
059: }
060:
061: public String getID() throws JMSException {
062:
063: if (!log.isTraceEnabled()) {
064: return getNext().getID();
065: }
066:
067: try {
068: log.trace("CALLED : getID");
069: return getNext().getID();
070: } catch (JMSException e) {
071: throw e;
072: } catch (RuntimeException e) {
073: log.trace("EXCEPTION : getID: ", e);
074: throw e;
075: } finally {
076: log.trace("RETURN : getID");
077: }
078: }
079:
080: public TemporaryTopic getTemporaryTopic(ConnectionToken dc)
081: throws JMSException {
082:
083: if (!log.isTraceEnabled()) {
084: return getNext().getTemporaryTopic(dc);
085: }
086:
087: try {
088: log.trace("CALLED : getTemporaryTopic");
089: return getNext().getTemporaryTopic(dc);
090: } catch (JMSException e) {
091: log.trace("EXCEPTION : getTemporaryTopic: ", e);
092: throw e;
093: } catch (RuntimeException e) {
094: log.trace("EXCEPTION : getTemporaryTopic: ", e);
095: throw e;
096: } finally {
097: log.trace("RETURN : getTemporaryTopic");
098: }
099:
100: }
101:
102: public TemporaryQueue getTemporaryQueue(ConnectionToken dc)
103: throws JMSException {
104:
105: if (!log.isTraceEnabled()) {
106: return getNext().getTemporaryQueue(dc);
107: }
108:
109: try {
110: log.trace("CALLED : getTemporaryQueue");
111: return getNext().getTemporaryQueue(dc);
112: } catch (JMSException e) {
113: log.trace("EXCEPTION : getTemporaryQueue: ", e);
114: throw e;
115: } catch (RuntimeException e) {
116: log.trace("EXCEPTION : getTemporaryQueue: ", e);
117: throw e;
118: } finally {
119: log.trace("RETURN : getTemporaryQueue");
120: }
121:
122: }
123:
124: public void connectionClosing(ConnectionToken dc)
125: throws JMSException {
126:
127: if (!log.isTraceEnabled()) {
128: getNext().connectionClosing(dc);
129: return;
130: }
131:
132: try {
133: log.trace("CALLED : connectionClosing");
134: getNext().connectionClosing(dc);
135: return;
136: } catch (JMSException e) {
137: log.trace("EXCEPTION : connectionClosing: ", e);
138: throw e;
139: } catch (RuntimeException e) {
140: log.trace("EXCEPTION : receive: ", e);
141: throw e;
142: } finally {
143: log.trace("RETURN : connectionClosing");
144: }
145:
146: }
147:
148: public void checkID(String ID) throws JMSException {
149:
150: if (!log.isTraceEnabled()) {
151: getNext().checkID(ID);
152: return;
153: }
154:
155: try {
156: log.trace("CALLED : checkID");
157: log.trace("ARG : " + ID);
158: getNext().checkID(ID);
159: return;
160: } catch (JMSException e) {
161: log.trace("EXCEPTION : checkID: ", e);
162: throw e;
163: } catch (RuntimeException e) {
164: log.trace("EXCEPTION : checkID: ", e);
165: throw e;
166: } finally {
167: log.trace("RETURN : checkID");
168: }
169:
170: }
171:
172: public void addMessage(ConnectionToken dc, SpyMessage message)
173: throws JMSException {
174:
175: if (!log.isTraceEnabled()) {
176: getNext().addMessage(dc, message);
177: return;
178: }
179:
180: try {
181: log.trace("CALLED : addMessage");
182: log.trace("ARG : " + message);
183: getNext().addMessage(dc, message);
184: return;
185: } catch (JMSException e) {
186: log.trace("EXCEPTION : addMessage: ", e);
187: throw e;
188: } catch (RuntimeException e) {
189: log.trace("EXCEPTION : addMessage: ", e);
190: throw e;
191: } finally {
192: log.trace("RETURN : addMessage");
193: }
194:
195: }
196:
197: public Queue createQueue(ConnectionToken dc, String dest)
198: throws JMSException {
199:
200: if (!log.isTraceEnabled()) {
201: return getNext().createQueue(dc, dest);
202: }
203:
204: try {
205: log.trace("CALLED : createQueue");
206: log.trace("ARG : " + dest);
207: return getNext().createQueue(dc, dest);
208: } catch (JMSException e) {
209: log.trace("EXCEPTION : createQueue: ", e);
210: throw e;
211: } catch (RuntimeException e) {
212: log.trace("EXCEPTION : createQueue: ", e);
213: throw e;
214: } finally {
215: log.trace("RETURN : createQueue");
216: }
217:
218: }
219:
220: public Topic createTopic(ConnectionToken dc, String dest)
221: throws JMSException {
222:
223: if (!log.isTraceEnabled()) {
224: return getNext().createTopic(dc, dest);
225: }
226:
227: try {
228: log.trace("CALLED : createTopic");
229: log.trace("ARG : " + dest);
230: return getNext().createTopic(dc, dest);
231: } catch (JMSException e) {
232: log.trace("EXCEPTION : createTopic: ", e);
233: throw e;
234: } catch (RuntimeException e) {
235: log.trace("EXCEPTION : createTopic: ", e);
236: throw e;
237: } finally {
238: log.trace("RETURN : createTopic");
239: }
240: }
241:
242: public void deleteTemporaryDestination(ConnectionToken dc,
243: SpyDestination dest) throws JMSException {
244:
245: if (!log.isTraceEnabled()) {
246: getNext().deleteTemporaryDestination(dc, dest);
247: return;
248: }
249:
250: try {
251: log.trace("CALLED : deleteTemporaryDestination");
252: log.trace("ARG : " + dest);
253: getNext().deleteTemporaryDestination(dc, dest);
254: return;
255: } catch (JMSException e) {
256: log.trace("EXCEPTION : deleteTemporaryDestination: ", e);
257: throw e;
258: } catch (RuntimeException e) {
259: log.trace("EXCEPTION : deleteTemporaryDestination: ", e);
260: throw e;
261: } finally {
262: log.trace("RETURN : deleteTemporaryDestination");
263: }
264: }
265:
266: public void transact(ConnectionToken dc, TransactionRequest t)
267: throws JMSException {
268:
269: if (!log.isTraceEnabled()) {
270: getNext().transact(dc, t);
271: return;
272: }
273:
274: try {
275: log.trace("CALLED : transact");
276: log.trace("ARG : " + t);
277: getNext().transact(dc, t);
278: return;
279: } catch (JMSException e) {
280: log.trace("EXCEPTION : transact: ", e);
281: throw e;
282: } catch (RuntimeException e) {
283: log.trace("EXCEPTION : transact: ", e);
284: throw e;
285: } finally {
286: log.trace("RETURN : transact");
287: }
288:
289: }
290:
291: public void acknowledge(ConnectionToken dc,
292: AcknowledgementRequest item) throws JMSException {
293:
294: if (!log.isTraceEnabled()) {
295: getNext().acknowledge(dc, item);
296: return;
297: }
298:
299: try {
300: log.trace("CALLED : acknowledge");
301: log.trace("ARG : " + item);
302: getNext().acknowledge(dc, item);
303: return;
304: } catch (JMSException e) {
305: log.trace("EXCEPTION : acknowledge: ", e);
306: throw e;
307: } catch (RuntimeException e) {
308: log.trace("EXCEPTION : acknowledge: ", e);
309: throw e;
310: } finally {
311: log.trace("RETURN : acknowledge");
312: }
313:
314: }
315:
316: public SpyMessage[] browse(ConnectionToken dc, Destination dest,
317: String selector) throws JMSException {
318:
319: if (!log.isTraceEnabled()) {
320: return getNext().browse(dc, dest, selector);
321: }
322:
323: try {
324: log.trace("CALLED : browse");
325: log.trace("ARG : " + dest);
326: log.trace("ARG : " + selector);
327: return getNext().browse(dc, dest, selector);
328: } catch (JMSException e) {
329: log.trace("EXCEPTION : browse: ", e);
330: throw e;
331: } catch (RuntimeException e) {
332: log.trace("EXCEPTION : browse: ", e);
333: throw e;
334: } finally {
335: log.trace("RETURN : browse");
336: }
337:
338: }
339:
340: public SpyMessage receive(ConnectionToken dc, int subscriberId,
341: long wait) throws JMSException {
342:
343: if (!log.isTraceEnabled()) {
344: return getNext().receive(dc, subscriberId, wait);
345: }
346:
347: try {
348: log.trace("CALLED : receive");
349: log.trace("ARG : " + subscriberId);
350: log.trace("ARG : " + wait);
351: return getNext().receive(dc, subscriberId, wait);
352: } catch (JMSException e) {
353: log.trace("EXCEPTION : receive: ", e);
354: throw e;
355: } catch (RuntimeException e) {
356: log.trace("EXCEPTION : receive: ", e);
357: throw e;
358: } finally {
359: log.trace("RETURN : receive");
360: }
361:
362: }
363:
364: public void setEnabled(ConnectionToken dc, boolean enabled)
365: throws JMSException {
366:
367: if (!log.isTraceEnabled()) {
368: getNext().setEnabled(dc, enabled);
369: return;
370: }
371:
372: try {
373: log.trace("CALLED : setEnabled");
374: log.trace("ARG : " + enabled);
375: getNext().setEnabled(dc, enabled);
376: return;
377: } catch (JMSException e) {
378: log.trace("EXCEPTION : setEnabled: ", e);
379: throw e;
380: } catch (RuntimeException e) {
381: log.trace("EXCEPTION : setEnabled: ", e);
382: throw e;
383: } finally {
384: log.trace("RETURN : setEnabled");
385: }
386:
387: }
388:
389: public void unsubscribe(ConnectionToken dc, int subscriptionId)
390: throws JMSException {
391:
392: if (!log.isTraceEnabled()) {
393: getNext().unsubscribe(dc, subscriptionId);
394: return;
395: }
396:
397: try {
398: log.trace("CALLED : unsubscribe");
399: log.trace("ARG : " + subscriptionId);
400: getNext().unsubscribe(dc, subscriptionId);
401: return;
402: } catch (JMSException e) {
403: log.trace("EXCEPTION : unsubscribe: ", e);
404: throw e;
405: } catch (RuntimeException e) {
406: log.trace("EXCEPTION : unsubscribe: ", e);
407: throw e;
408: } finally {
409: log.trace("RETURN : unsubscribe");
410: }
411:
412: }
413:
414: public void destroySubscription(ConnectionToken dc,
415: DurableSubscriptionID id) throws JMSException {
416:
417: if (!log.isTraceEnabled()) {
418: getNext().destroySubscription(dc, id);
419: return;
420: }
421:
422: try {
423: log.trace("CALLED : destroySubscription");
424: log.trace("ARG : " + id);
425: getNext().destroySubscription(dc, id);
426: return;
427: } catch (JMSException e) {
428: log.trace("EXCEPTION : destroySubscription: ", e);
429: throw e;
430: } catch (RuntimeException e) {
431: log.trace("EXCEPTION : destroySubscription: ", e);
432: throw e;
433: } finally {
434: log.trace("RETURN : destroySubscription");
435: }
436:
437: }
438:
439: public String checkUser(String userName, String password)
440: throws JMSException {
441:
442: if (!log.isTraceEnabled()) {
443: return getNext().checkUser(userName, password);
444: }
445:
446: try {
447: log.trace("CALLED : checkUser");
448: log.trace("ARG : " + userName);
449: log.trace("ARG : (password not shown)");
450: return getNext().checkUser(userName, password);
451: } catch (JMSException e) {
452: log.trace("EXCEPTION : checkUser: ", e);
453: throw e;
454: } catch (RuntimeException e) {
455: log.trace("EXCEPTION : checkUser: ", e);
456: throw e;
457: } finally {
458: log.trace("RETURN : checkUser");
459: }
460:
461: }
462:
463: public String authenticate(String userName, String password)
464: throws JMSException {
465:
466: if (!log.isTraceEnabled()) {
467: return getNext().authenticate(userName, password);
468: }
469:
470: try {
471: log.trace("CALLED : authenticate");
472: return getNext().authenticate(userName, password);
473: } catch (JMSException e) {
474: log.trace("EXCEPTION : authenticate: ", e);
475: throw e;
476: } catch (RuntimeException e) {
477: log.trace("EXCEPTION : authenticate: ", e);
478: throw e;
479: } finally {
480: log.trace("RETURN : authenticate");
481: }
482:
483: }
484:
485: public void subscribe(org.jboss.mq.ConnectionToken dc,
486: org.jboss.mq.Subscription s) throws JMSException {
487:
488: if (!log.isTraceEnabled()) {
489: getNext().subscribe(dc, s);
490: return;
491: }
492:
493: try {
494: log.trace("CALLED : subscribe");
495: log.trace("ARG : " + s);
496: getNext().subscribe(dc, s);
497: return;
498: } catch (JMSException e) {
499: log.trace("EXCEPTION : subscribe: ", e);
500: throw e;
501: } catch (RuntimeException e) {
502: log.trace("EXCEPTION : subscribe: ", e);
503: throw e;
504: } finally {
505: log.trace("RETURN : subscribe");
506: }
507:
508: }
509:
510: public void ping(ConnectionToken dc, long clientTime)
511: throws JMSException {
512:
513: if (!log.isTraceEnabled()) {
514: getNext().ping(dc, clientTime);
515: return;
516: }
517:
518: try {
519: log.trace("CALLED : ping");
520: log.trace("ARG : " + clientTime);
521: getNext().ping(dc, clientTime);
522: return;
523: } catch (JMSException e) {
524: log.trace("EXCEPTION : ping: ", e);
525: throw e;
526: } catch (RuntimeException e) {
527: log.trace("EXCEPTION : ping: ", e);
528: throw e;
529: } finally {
530: log.trace("RETURN : ping");
531: }
532:
533: }
534:
535: public SpyTopic getDurableTopic(DurableSubscriptionID sub)
536: throws JMSException {
537:
538: if (!log.isTraceEnabled()) {
539: return getNext().getDurableTopic(sub);
540: }
541:
542: try {
543: log.trace("CALLED : getDurableTopic");
544: log.trace("ARG : " + sub);
545: return getNext().getDurableTopic(sub);
546: } catch (JMSException e) {
547: log.trace("EXCEPTION : getDurableTopic: ", e);
548: throw e;
549: } catch (RuntimeException e) {
550: log.trace("EXCEPTION : getDurableTopic: ", e);
551: throw e;
552: } finally {
553: log.trace("RETURN : getDurableTopic");
554: }
555:
556: }
557:
558: public Subscription getSubscription(ConnectionToken dc,
559: int subscriberId) throws JMSException {
560:
561: if (!log.isTraceEnabled()) {
562: return getNext().getSubscription(dc, subscriberId);
563: }
564:
565: try {
566: log.trace("CALLED : getSubscription");
567: log.trace("ARG : " + subscriberId);
568: return getNext().getSubscription(dc, subscriberId);
569: } catch (JMSException e) {
570: log.trace("EXCEPTION : getSubscription: ", e);
571: throw e;
572: } catch (RuntimeException e) {
573: log.trace("EXCEPTION : getSubscription: ", e);
574: throw e;
575: } finally {
576: log.trace("RETURN : getSubscription");
577: }
578:
579: }
580:
581: public Xid[] recover(ConnectionToken dc, int flags)
582: throws Exception {
583: if (log.isTraceEnabled() == false)
584: return super .recover(dc, flags);
585:
586: try {
587: log.trace("CALLED : recover");
588: log.trace("ARG : " + flags);
589: return super .recover(dc, flags);
590: } catch (JMSException e) {
591: log.trace("EXCEPTION : recover: ", e);
592: throw e;
593: } catch (RuntimeException e) {
594: log.trace("EXCEPTION : recover: ", e);
595: throw e;
596: } finally {
597: log.trace("RETURN : recover");
598: }
599: }
600: }
|