01: /*
02: * JacORB - a free Java ORB
03: *
04: * Copyright (C) 2006,2007 Gerald Brose.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Library General Public
08: * License as published by the Free Software Foundation; either
09: * version 2 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Library General Public License for more details.
15: *
16: * You should have received a copy of the GNU Library General Public
17: * License along with this library; if not, write to the Free
18: * Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19: * MA 02110-1301, USA.
20: */
21:
22: package org.jacorb.orb.giop;
23:
24: /**
25: * Class StatisticsProviderAdapter is responsible for managing
26: * the StatisticsProvider instances for collecting transport usage
27: * information.
28: *
29: * @author Iliyan Jeliazkov
30: * @version $Id: StatisticsProviderAdapter.java,v 1.1 2007/02/06 18:16:49 andre.spiegel Exp $
31: */
32:
33: final class StatisticsProviderAdapter implements StatisticsProvider {
34: private int cardinality_;
35: private StatisticsProvider head_;
36: private StatisticsProviderAdapter tail_;
37:
38: public StatisticsProviderAdapter(StatisticsProvider p) {
39: this (p, null);
40: }
41:
42: public StatisticsProviderAdapter(StatisticsProvider head,
43: StatisticsProviderAdapter tail) {
44: this .head_ = head;
45: this .tail_ = tail;
46: this .cardinality_ = (tail == null) ? 0 : tail.cardinality_ + 1;
47: }
48:
49: public StatisticsProvider find(int cardinality) {
50: if (this .cardinality_ == cardinality)
51: return this .head_;
52:
53: if (this .tail_ == null)
54: return null;
55:
56: return this .tail_.find(cardinality);
57: }
58:
59: public void messageChunkSent(int size) {
60: try {
61: if (head_ != null)
62: head_.messageChunkSent(size);
63: } finally {
64: if (tail_ != null)
65: tail_.messageChunkSent(size);
66: }
67: }
68:
69: public void flushed() {
70: try {
71: if (head_ != null)
72: head_.flushed();
73: } finally {
74: if (tail_ != null)
75: tail_.flushed();
76: }
77: }
78:
79: public void messageReceived(int size) {
80: try {
81: if (head_ != null)
82: head_.messageReceived(size);
83: } finally {
84: if (tail_ != null)
85: tail_.messageReceived(size);
86: }
87: }
88: }
|