01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.util;
20:
21: import java.util.LinkedList;
22:
23: import org.apache.jmeter.testelement.TestElement;
24: import org.apache.jorphan.collections.HashTree;
25: import org.apache.jorphan.collections.HashTreeTraverser;
26: import org.apache.jorphan.logging.LoggingManager;
27: import org.apache.log.Logger;
28:
29: /**
30: * @version $Revision: 493779 $
31: */
32: public class DisabledComponentRemover implements HashTreeTraverser {
33:
34: /*
35: * TODO - does this class work? and is it needed?
36: * It is only called by Start, and then only after
37: * having called convertTree - which removes the disabled elements anyway.
38: * When tried in IncludeController, it failed to work.
39: */
40:
41: private static final Logger log = LoggingManager
42: .getLoggerForClass();
43:
44: HashTree tree;
45:
46: LinkedList stack = new LinkedList();
47:
48: public DisabledComponentRemover(HashTree tree) {
49: this .tree = tree;
50: }
51:
52: public void addNode(Object node, HashTree subTree) {
53: stack.addLast(node);
54: }
55:
56: public void subtractNode() {
57: Object removeLast = stack.removeLast();
58: if (!(removeLast instanceof TestElement)) {
59: log.warn("Expected class TestElement, found "
60: + removeLast.getClass().getName());
61: return;
62: }
63: TestElement lastNode = (TestElement) removeLast;
64: if (!lastNode.getPropertyAsBoolean(TestElement.ENABLED)) {
65: log.info("*** Removing *** " + lastNode);// TODO not sure this is ever called
66: tree.getTree(stack).remove(lastNode);
67: }
68: }
69:
70: public void processPath() {
71: }
72: }
|