summaryrefslogtreecommitdiff
path: root/java/test/Ice/metrics/CommunicatorObserverI.java
blob: 2973880f8847e22eb535710446548cf4e98d9160 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

package test.Ice.metrics;

class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorObserver
{
    private static void
    test(boolean b)
    {
        if(!b)
        {
            throw new RuntimeException();
        }
    }

    public void 
    setObserverUpdater(Ice.Instrumentation.ObserverUpdater u)
    {
        updater = u;
    }
 
    synchronized public Ice.Instrumentation.Observer 
    getConnectionEstablishmentObserver(Ice.Endpoint e, String s)
    {
        if(connectionEstablishmentObserver == null)
        {
            connectionEstablishmentObserver = new ObserverI();
            connectionEstablishmentObserver.reset();
        }
        return connectionEstablishmentObserver;
    }

 
    synchronized public Ice.Instrumentation.Observer 
    getEndpointLookupObserver(Ice.Endpoint e)
    {
        if(endpointLookupObserver == null)
        {
            endpointLookupObserver = new ObserverI();
            endpointLookupObserver.reset();
        }
        return endpointLookupObserver;
    }
    
    synchronized public Ice.Instrumentation.ConnectionObserver 
    getConnectionObserver(Ice.ConnectionInfo c,
                          Ice.Endpoint e,
                          Ice.Instrumentation.ConnectionState s, 
                          Ice.Instrumentation.ConnectionObserver old)
    {
        test(old == null || old instanceof ConnectionObserverI);
        if(connectionObserver == null)
        {
            connectionObserver = new ConnectionObserverI();
            connectionObserver.reset();
        }
        return connectionObserver;
    }

    synchronized public Ice.Instrumentation.ThreadObserver 
    getThreadObserver(String p, String id, Ice.Instrumentation.ThreadState s,
                      Ice.Instrumentation.ThreadObserver old)
    {
        test(old == null || old instanceof ThreadObserverI);
        if(threadObserver == null)
        {
            threadObserver = new ThreadObserverI();
            threadObserver.reset();
        }
        return threadObserver; 
   }

    synchronized public Ice.Instrumentation.InvocationObserver
    getInvocationObserver(Ice.ObjectPrx p, String op, java.util.Map<String, String> ctx)
    {
        if(invocationObserver == null)
        {
            invocationObserver = new InvocationObserverI();
            invocationObserver.reset();
        }
        return invocationObserver;
    }

    synchronized public Ice.Instrumentation.DispatchObserver
    getDispatchObserver(Ice.Current current, int s)
    {
        if(dispatchObserver == null)
        {
            dispatchObserver = new DispatchObserverI();
            dispatchObserver.reset();
        }
        return dispatchObserver;
    }

    synchronized void
    reset()
    {
        if(connectionEstablishmentObserver != null)
        {
            connectionEstablishmentObserver.reset();
        }
        if(endpointLookupObserver != null)
        {
            endpointLookupObserver.reset();
        }
        if(connectionObserver != null)
        {
            connectionObserver.reset();
        }
        if(threadObserver != null)
        {
            threadObserver.reset();
        }
        if(invocationObserver != null)
        {
            invocationObserver.reset();
        }
        if(dispatchObserver != null)
        {
            dispatchObserver.reset();
        }
    }
    
    Ice.Instrumentation.ObserverUpdater updater;

    ObserverI connectionEstablishmentObserver;
    ObserverI endpointLookupObserver;
    ConnectionObserverI connectionObserver;
    ThreadObserverI threadObserver;
    InvocationObserverI invocationObserver;
    DispatchObserverI dispatchObserver;
};