KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > server > TracingInterceptor


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq.server;
23
24 import javax.jms.Destination JavaDoc;
25 import javax.jms.JMSException JavaDoc;
26 import javax.jms.Queue JavaDoc;
27 import javax.jms.TemporaryQueue JavaDoc;
28 import javax.jms.TemporaryTopic JavaDoc;
29 import javax.jms.Topic JavaDoc;
30 import javax.transaction.xa.Xid JavaDoc;
31
32 import org.jboss.mq.AcknowledgementRequest;
33 import org.jboss.mq.ConnectionToken;
34 import org.jboss.mq.DurableSubscriptionID;
35 import org.jboss.mq.SpyDestination;
36 import org.jboss.mq.SpyMessage;
37 import org.jboss.mq.SpyTopic;
38 import org.jboss.mq.Subscription;
39 import org.jboss.mq.TransactionRequest;
40
41 /**
42  * A pass through Interceptor, wich will trace all calls.
43  *
44  * @author <a HREF="mailto:pra@tim.se">Peter Antman</a>
45  * @version $Revision: 45317 $
46  */

47 public class TracingInterceptor extends JMSServerInterceptorSupport
48 {
49    public ThreadGroup JavaDoc getThreadGroup()
50    {
51       if (!log.isTraceEnabled())
52       {
53          return getNext().getThreadGroup();
54       }
55
56       try
57       {
58          log.trace("CALLED : getThreadGroup");
59          return getNext().getThreadGroup();
60       }
61       finally
62       {
63          log.trace("RETURN : getThreadGroup");
64       }
65    }
66
67
68    public String JavaDoc getID() throws JMSException JavaDoc
69    {
70
71       if (!log.isTraceEnabled())
72       {
73          return getNext().getID();
74       }
75
76       try
77       {
78          log.trace("CALLED : getID");
79          return getNext().getID();
80       }
81       catch (JMSException JavaDoc e)
82       {
83          throw e;
84       }
85       catch (RuntimeException JavaDoc e)
86       {
87          log.trace("EXCEPTION : getID: ", e);
88          throw e;
89       }
90       finally
91       {
92          log.trace("RETURN : getID");
93       }
94    }
95
96    public TemporaryTopic JavaDoc getTemporaryTopic(ConnectionToken dc) throws JMSException JavaDoc
97    {
98
99       if (!log.isTraceEnabled())
100       {
101          return getNext().getTemporaryTopic(dc);
102       }
103
104       try
105       {
106          log.trace("CALLED : getTemporaryTopic");
107          return getNext().getTemporaryTopic(dc);
108       }
109       catch (JMSException JavaDoc e)
110       {
111          log.trace("EXCEPTION : getTemporaryTopic: ", e);
112          throw e;
113       }
114       catch (RuntimeException JavaDoc e)
115       {
116          log.trace("EXCEPTION : getTemporaryTopic: ", e);
117          throw e;
118       }
119       finally
120       {
121          log.trace("RETURN : getTemporaryTopic");
122       }
123
124    }
125
126    public TemporaryQueue JavaDoc getTemporaryQueue(ConnectionToken dc) throws JMSException JavaDoc
127    {
128
129       if (!log.isTraceEnabled())
130       {
131          return getNext().getTemporaryQueue(dc);
132       }
133
134       try
135       {
136          log.trace("CALLED : getTemporaryQueue");
137          return getNext().getTemporaryQueue(dc);
138       }
139       catch (JMSException JavaDoc e)
140       {
141          log.trace("EXCEPTION : getTemporaryQueue: ", e);
142          throw e;
143       }
144       catch (RuntimeException JavaDoc e)
145       {
146          log.trace("EXCEPTION : getTemporaryQueue: ", e);
147          throw e;
148       }
149       finally
150       {
151          log.trace("RETURN : getTemporaryQueue");
152       }
153
154    }
155
156    public void connectionClosing(ConnectionToken dc) throws JMSException JavaDoc
157    {
158
159       if (!log.isTraceEnabled())
160       {
161          getNext().connectionClosing(dc);
162          return;
163       }
164
165       try
166       {
167          log.trace("CALLED : connectionClosing");
168          getNext().connectionClosing(dc);
169          return;
170       }
171       catch (JMSException JavaDoc e)
172       {
173          log.trace("EXCEPTION : connectionClosing: ", e);
174          throw e;
175       }
176       catch (RuntimeException JavaDoc e)
177       {
178          log.trace("EXCEPTION : receive: ", e);
179          throw e;
180       }
181       finally
182       {
183          log.trace("RETURN : connectionClosing");
184       }
185
186    }
187
188    public void checkID(String JavaDoc ID) throws JMSException JavaDoc
189    {
190
191       if (!log.isTraceEnabled())
192       {
193          getNext().checkID(ID);
194          return;
195       }
196
197       try
198       {
199          log.trace("CALLED : checkID");
200          log.trace("ARG : " + ID);
201          getNext().checkID(ID);
202          return;
203       }
204       catch (JMSException JavaDoc e)
205       {
206          log.trace("EXCEPTION : checkID: ", e);
207          throw e;
208       }
209       catch (RuntimeException JavaDoc e)
210       {
211          log.trace("EXCEPTION : checkID: ", e);
212          throw e;
213       }
214       finally
215       {
216          log.trace("RETURN : checkID");
217       }
218
219    }
220
221    public void addMessage(ConnectionToken dc, SpyMessage message) throws JMSException JavaDoc
222    {
223
224       if (!log.isTraceEnabled())
225       {
226          getNext().addMessage(dc, message);
227          return;
228       }
229
230       try
231       {
232          log.trace("CALLED : addMessage");
233          log.trace("ARG : " + message);
234          getNext().addMessage(dc, message);
235          return;
236       }
237       catch (JMSException JavaDoc e)
238       {
239          log.trace("EXCEPTION : addMessage: ", e);
240          throw e;
241       }
242       catch (RuntimeException JavaDoc e)
243       {
244          log.trace("EXCEPTION : addMessage: ", e);
245          throw e;
246       }
247       finally
248       {
249          log.trace("RETURN : addMessage");
250       }
251
252    }
253
254    public Queue JavaDoc createQueue(ConnectionToken dc, String JavaDoc dest) throws JMSException JavaDoc
255    {
256
257       if (!log.isTraceEnabled())
258       {
259          return getNext().createQueue(dc, dest);
260       }
261
262       try
263       {
264          log.trace("CALLED : createQueue");
265          log.trace("ARG : " + dest);
266          return getNext().createQueue(dc, dest);
267       }
268       catch (JMSException JavaDoc e)
269       {
270          log.trace("EXCEPTION : createQueue: ", e);
271          throw e;
272       }
273       catch (RuntimeException JavaDoc e)
274       {
275          log.trace("EXCEPTION : createQueue: ", e);
276          throw e;
277       }
278       finally
279       {
280          log.trace("RETURN : createQueue");
281       }
282
283    }
284
285    public Topic JavaDoc createTopic(ConnectionToken dc, String JavaDoc dest) throws JMSException JavaDoc
286    {
287
288       if (!log.isTraceEnabled())
289       {
290          return getNext().createTopic(dc, dest);
291       }
292
293       try
294       {
295          log.trace("CALLED : createTopic");
296          log.trace("ARG : " + dest);
297          return getNext().createTopic(dc, dest);
298       }
299       catch (JMSException JavaDoc e)
300       {
301          log.trace("EXCEPTION : createTopic: ", e);
302          throw e;
303       }
304       catch (RuntimeException JavaDoc e)
305       {
306          log.trace("EXCEPTION : createTopic: ", e);
307          throw e;
308       }
309       finally
310       {
311          log.trace("RETURN : createTopic");
312       }
313    }
314
315    public void deleteTemporaryDestination(ConnectionToken dc, SpyDestination dest) throws JMSException JavaDoc
316    {
317
318       if (!log.isTraceEnabled())
319       {
320          getNext().deleteTemporaryDestination(dc, dest);
321          return;
322       }
323
324       try
325       {
326          log.trace("CALLED : deleteTemporaryDestination");
327          log.trace("ARG : " + dest);
328          getNext().deleteTemporaryDestination(dc, dest);
329          return;
330       }
331       catch (JMSException JavaDoc e)
332       {
333          log.trace("EXCEPTION : deleteTemporaryDestination: ", e);
334          throw e;
335       }
336       catch (RuntimeException JavaDoc e)
337       {
338          log.trace("EXCEPTION : deleteTemporaryDestination: ", e);
339          throw e;
340       }
341       finally
342       {
343          log.trace("RETURN : deleteTemporaryDestination");
344       }
345    }
346
347    public void transact(ConnectionToken dc, TransactionRequest t) throws JMSException JavaDoc
348    {
349
350       if (!log.isTraceEnabled())
351       {
352          getNext().transact(dc, t);
353          return;
354       }
355
356       try
357       {
358          log.trace("CALLED : transact");
359          log.trace("ARG : " + t);
360          getNext().transact(dc, t);
361          return;
362       }
363       catch (JMSException JavaDoc e)
364       {
365          log.trace("EXCEPTION : transact: ", e);
366          throw e;
367       }
368       catch (RuntimeException JavaDoc e)
369       {
370          log.trace("EXCEPTION : transact: ", e);
371          throw e;
372       }
373       finally
374       {
375          log.trace("RETURN : transact");
376       }
377
378    }
379
380    public void acknowledge(ConnectionToken dc, AcknowledgementRequest item) throws JMSException JavaDoc
381    {
382
383       if (!log.isTraceEnabled())
384       {
385          getNext().acknowledge(dc, item);
386          return;
387       }
388
389       try
390       {
391          log.trace("CALLED : acknowledge");
392          log.trace("ARG : " + item);
393          getNext().acknowledge(dc, item);
394          return;
395       }
396       catch (JMSException JavaDoc e)
397       {
398          log.trace("EXCEPTION : acknowledge: ", e);
399          throw e;
400       }
401       catch (RuntimeException JavaDoc e)
402       {
403          log.trace("EXCEPTION : acknowledge: ", e);
404          throw e;
405       }
406       finally
407       {
408          log.trace("RETURN : acknowledge");
409       }
410
411    }
412
413    public SpyMessage[] browse(ConnectionToken dc, Destination JavaDoc dest, String JavaDoc selector) throws JMSException JavaDoc
414    {
415
416       if (!log.isTraceEnabled())
417       {
418          return getNext().browse(dc, dest, selector);
419       }
420
421       try
422       {
423          log.trace("CALLED : browse");
424          log.trace("ARG : " + dest);
425          log.trace("ARG : " + selector);
426          return getNext().browse(dc, dest, selector);
427       }
428       catch (JMSException JavaDoc e)
429       {
430          log.trace("EXCEPTION : browse: ", e);
431          throw e;
432       }
433       catch (RuntimeException JavaDoc e)
434       {
435          log.trace("EXCEPTION : browse: ", e);
436          throw e;
437       }
438       finally
439       {
440          log.trace("RETURN : browse");
441       }
442
443    }
444
445    public SpyMessage receive(ConnectionToken dc, int subscriberId, long wait) throws JMSException JavaDoc
446    {
447
448       if (!log.isTraceEnabled())
449       {
450          return getNext().receive(dc, subscriberId, wait);
451       }
452
453       try
454       {
455          log.trace("CALLED : receive");
456          log.trace("ARG : " + subscriberId);
457          log.trace("ARG : " + wait);
458          return getNext().receive(dc, subscriberId, wait);
459       }
460       catch (JMSException JavaDoc e)
461       {
462          log.trace("EXCEPTION : receive: ", e);
463          throw e;
464       }
465       catch (RuntimeException JavaDoc e)
466       {
467          log.trace("EXCEPTION : receive: ", e);
468          throw e;
469       }
470       finally
471       {
472          log.trace("RETURN : receive");
473       }
474
475    }
476
477    public void setEnabled(ConnectionToken dc, boolean enabled) throws JMSException JavaDoc
478    {
479
480       if (!log.isTraceEnabled())
481       {
482          getNext().setEnabled(dc, enabled);
483          return;
484       }
485
486       try
487       {
488          log.trace("CALLED : setEnabled");
489          log.trace("ARG : " + enabled);
490          getNext().setEnabled(dc, enabled);
491          return;
492       }
493       catch (JMSException JavaDoc e)
494       {
495          log.trace("EXCEPTION : setEnabled: ", e);
496          throw e;
497       }
498       catch (RuntimeException JavaDoc e)
499       {
500          log.trace("EXCEPTION : setEnabled: ", e);
501          throw e;
502       }
503       finally
504       {
505          log.trace("RETURN : setEnabled");
506       }
507
508    }
509
510    public void unsubscribe(ConnectionToken dc, int subscriptionId) throws JMSException JavaDoc
511    {
512
513       if (!log.isTraceEnabled())
514       {
515          getNext().unsubscribe(dc, subscriptionId);
516          return;
517       }
518
519       try
520       {
521          log.trace("CALLED : unsubscribe");
522          log.trace("ARG : " + subscriptionId);
523          getNext().unsubscribe(dc, subscriptionId);
524          return;
525       }
526       catch (JMSException JavaDoc e)
527       {
528          log.trace("EXCEPTION : unsubscribe: ", e);
529          throw e;
530       }
531       catch (RuntimeException JavaDoc e)
532       {
533          log.trace("EXCEPTION : unsubscribe: ", e);
534          throw e;
535       }
536       finally
537       {
538          log.trace("RETURN : unsubscribe");
539       }
540
541    }
542
543    public void destroySubscription(ConnectionToken dc, DurableSubscriptionID id) throws JMSException JavaDoc
544    {
545
546       if (!log.isTraceEnabled())
547       {
548          getNext().destroySubscription(dc, id);
549          return;
550       }
551
552       try
553       {
554          log.trace("CALLED : destroySubscription");
555          log.trace("ARG : " + id);
556          getNext().destroySubscription(dc, id);
557          return;
558       }
559       catch (JMSException JavaDoc e)
560       {
561          log.trace("EXCEPTION : destroySubscription: ", e);
562          throw e;
563       }
564       catch (RuntimeException JavaDoc e)
565       {
566          log.trace("EXCEPTION : destroySubscription: ", e);
567          throw e;
568       }
569       finally
570       {
571          log.trace("RETURN : destroySubscription");
572       }
573
574    }
575
576    public String JavaDoc checkUser(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
577    {
578
579       if (!log.isTraceEnabled())
580       {
581          return getNext().checkUser(userName, password);
582       }
583
584       try
585       {
586          log.trace("CALLED : checkUser");
587          log.trace("ARG : " + userName);
588          log.trace("ARG : (password not shown)");
589          return getNext().checkUser(userName, password);
590       }
591       catch (JMSException JavaDoc e)
592       {
593          log.trace("EXCEPTION : checkUser: ", e);
594          throw e;
595       }
596       catch (RuntimeException JavaDoc e)
597       {
598          log.trace("EXCEPTION : checkUser: ", e);
599          throw e;
600       }
601       finally
602       {
603          log.trace("RETURN : checkUser");
604       }
605
606    }
607
608    public String JavaDoc authenticate(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
609    {
610
611       if (!log.isTraceEnabled())
612       {
613          return getNext().authenticate(userName, password);
614       }
615
616       try
617       {
618          log.trace("CALLED : authenticate");
619          return getNext().authenticate(userName, password);
620       }
621       catch (JMSException JavaDoc e)
622       {
623          log.trace("EXCEPTION : authenticate: ", e);
624          throw e;
625       }
626       catch (RuntimeException JavaDoc e)
627       {
628          log.trace("EXCEPTION : authenticate: ", e);
629          throw e;
630       }
631       finally
632       {
633          log.trace("RETURN : authenticate");
634       }
635
636    }
637
638    public void subscribe(org.jboss.mq.ConnectionToken dc, org.jboss.mq.Subscription s) throws JMSException JavaDoc
639    {
640
641       if (!log.isTraceEnabled())
642       {
643          getNext().subscribe(dc, s);
644          return;
645       }
646
647       try
648       {
649          log.trace("CALLED : subscribe");
650          log.trace("ARG : " + s);
651          getNext().subscribe(dc, s);
652          return;
653       }
654       catch (JMSException JavaDoc e)
655       {
656          log.trace("EXCEPTION : subscribe: ", e);
657          throw e;
658       }
659       catch (RuntimeException JavaDoc e)
660       {
661          log.trace("EXCEPTION : subscribe: ", e);
662          throw e;
663       }
664       finally
665       {
666          log.trace("RETURN : subscribe");
667       }
668
669    }
670
671    public void ping(ConnectionToken dc, long clientTime) throws JMSException JavaDoc
672    {
673
674       if (!log.isTraceEnabled())
675       {
676          getNext().ping(dc, clientTime);
677          return;
678       }
679
680       try
681       {
682          log.trace("CALLED : ping");
683          log.trace("ARG : " + clientTime);
684          getNext().ping(dc, clientTime);
685          return;
686       }
687       catch (JMSException JavaDoc e)
688       {
689          log.trace("EXCEPTION : ping: ", e);
690          throw e;
691       }
692       catch (RuntimeException JavaDoc e)
693       {
694          log.trace("EXCEPTION : ping: ", e);
695          throw e;
696       }
697       finally
698       {
699          log.trace("RETURN : ping");
700       }
701
702    }
703
704    public SpyTopic getDurableTopic(DurableSubscriptionID sub) throws JMSException JavaDoc
705    {
706
707       if (!log.isTraceEnabled())
708       {
709          return getNext().getDurableTopic(sub);
710       }
711
712       try
713       {
714          log.trace("CALLED : getDurableTopic");
715          log.trace("ARG : " + sub);
716          return getNext().getDurableTopic(sub);
717       }
718       catch (JMSException JavaDoc e)
719       {
720          log.trace("EXCEPTION : getDurableTopic: ", e);
721          throw e;
722       }
723       catch (RuntimeException JavaDoc e)
724       {
725          log.trace("EXCEPTION : getDurableTopic: ", e);
726          throw e;
727       }
728       finally
729       {
730          log.trace("RETURN : getDurableTopic");
731       }
732
733    }
734
735    public Subscription getSubscription(ConnectionToken dc, int subscriberId) throws JMSException JavaDoc
736    {
737
738       if (!log.isTraceEnabled())
739       {
740          return getNext().getSubscription(dc, subscriberId);
741       }
742
743       try
744       {
745          log.trace("CALLED : getSubscription");
746          log.trace("ARG : " + subscriberId);
747          return getNext().getSubscription(dc, subscriberId);
748       }
749       catch (JMSException JavaDoc e)
750       {
751          log.trace("EXCEPTION : getSubscription: ", e);
752          throw e;
753       }
754       catch (RuntimeException JavaDoc e)
755       {
756          log.trace("EXCEPTION : getSubscription: ", e);
757          throw e;
758       }
759       finally
760       {
761          log.trace("RETURN : getSubscription");
762       }
763
764    }
765
766    public Xid JavaDoc[] recover(ConnectionToken dc, int flags) throws Exception JavaDoc
767    {
768       if (log.isTraceEnabled() == false)
769          return super.recover(dc, flags);
770
771       try
772       {
773          log.trace("CALLED : recover");
774          log.trace("ARG : " + flags);
775          return super.recover(dc, flags);
776       }
777       catch (JMSException JavaDoc e)
778       {
779          log.trace("EXCEPTION : recover: ", e);
780          throw e;
781       }
782       catch (RuntimeException JavaDoc e)
783       {
784          log.trace("EXCEPTION : recover: ", e);
785          throw e;
786       }
787       finally
788       {
789          log.trace("RETURN : recover");
790       }
791    }
792 }
793
Popular Tags