KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > engine > ConvertListeners


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/engine/ConvertListeners.java,v 1.10 2004/02/14 03:34:29 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
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.apache.jmeter.engine;
20
21 import java.rmi.RemoteException JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24 import org.apache.jmeter.samplers.RemoteListenerWrapper;
25 import org.apache.jmeter.samplers.RemoteSampleListener;
26 import org.apache.jmeter.samplers.RemoteSampleListenerImpl;
27 import org.apache.jmeter.samplers.RemoteSampleListenerWrapper;
28 import org.apache.jmeter.samplers.RemoteTestListenerWrapper;
29 import org.apache.jmeter.samplers.Remoteable;
30 import org.apache.jmeter.samplers.SampleListener;
31 import org.apache.jmeter.testelement.TestListener;
32 import org.apache.jmeter.threads.ThreadGroup;
33 import org.apache.jorphan.collections.HashTree;
34 import org.apache.jorphan.collections.HashTreeTraverser;
35 import org.apache.jorphan.logging.LoggingManager;
36 import org.apache.log.Logger;
37
38 /**
39  * @author mstover
40  */

41 public class ConvertListeners implements HashTreeTraverser
42 {
43     transient private static Logger log = LoggingManager.getLoggerForClass();
44
45     /* (non-Javadoc)
46      * @see HashTreeTraverser#addNode(Object, HashTree)
47      */

48     public void addNode(Object JavaDoc node, HashTree subTree)
49     {
50         if (node instanceof ThreadGroup JavaDoc)
51         {
52             log.info("num threads = " + ((ThreadGroup JavaDoc) node).getNumThreads());
53         }
54         Iterator JavaDoc iter = subTree.list().iterator();
55         while (iter.hasNext())
56         {
57             Object JavaDoc item = iter.next();
58             if (item instanceof ThreadGroup JavaDoc)
59             {
60                 log.info(
61                     "num threads = " + ((ThreadGroup JavaDoc) item).getNumThreads());
62             }
63             if (item instanceof Remoteable
64                 && (item instanceof TestListener
65                     || item instanceof SampleListener))
66             {
67                 try
68                 {
69                     RemoteSampleListener rtl =
70                         new RemoteSampleListenerImpl(item);
71                     if (item instanceof TestListener
72                         && item instanceof SampleListener)
73                     {
74                         RemoteListenerWrapper wrap =
75                             new RemoteListenerWrapper(rtl);
76                         subTree.replace(item, wrap);
77                     }
78                     else if (item instanceof TestListener)
79                     {
80                         RemoteTestListenerWrapper wrap =
81                             new RemoteTestListenerWrapper(rtl);
82                         subTree.replace(item, wrap);
83                     }
84                     else
85                     {
86                         RemoteSampleListenerWrapper wrap =
87                             new RemoteSampleListenerWrapper(rtl);
88                         subTree.replace(item, wrap);
89                     }
90                 }
91                 catch (RemoteException JavaDoc e)
92                 {
93                     log.error("", e);
94                 }
95             }
96         }
97     }
98
99     /* (non-Javadoc)
100      * @see HashTreeTraverser#subtractNode()
101      */

102     public void subtractNode()
103     {
104     }
105
106     /* (non-Javadoc)
107      * @see HashTreeTraverser#processPath()
108      */

109     public void processPath()
110     {
111     }
112
113 }
114
Popular Tags