KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > test > StoreAppender


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.test;
16
17 import java.util.ArrayList JavaDoc;
18 import java.util.List JavaDoc;
19
20 import org.apache.log4j.AppenderSkeleton;
21 import org.apache.log4j.spi.LoggingEvent;
22
23 /**
24  * Used to test logging provided by the {@link org.apache.hivemind.impl.LoggingInterceptorFactory}.
25  *
26  * @author Howard Lewis Ship
27  */

28 class StoreAppender extends AppenderSkeleton
29 {
30     ///CLOVER:OFF
31

32     private List JavaDoc _events = new ArrayList JavaDoc(0);
33
34     /**
35      * Returns any accumulated events since the last invocations of this method.
36      * @return List of {@link LoggingEvent}.
37      */

38     public List JavaDoc getEvents()
39     {
40         List JavaDoc result = new ArrayList JavaDoc(_events);
41
42         _events.clear();
43
44         return result;
45     }
46
47     protected void append(LoggingEvent event)
48     {
49         _events.add(event);
50     }
51
52     /**
53      * Does nothing.
54      */

55     public void close()
56     {
57     }
58
59     /**
60      * Returns false.
61      */

62     public boolean requiresLayout()
63     {
64         return false;
65     }
66
67 }
68
Popular Tags