1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.observation

File WrappedThreadEventListener.java

 

Coverage histogram

../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
6
5
1
79
31
5
0.83
1.2
5
1

Classes

Class Line # Actions
WrappedThreadEventListener 33 6 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 148 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.observation;
21   
22    import java.util.List;
23   
24    import org.xwiki.observation.event.Event;
25   
26    /**
27    * Wraps a provided {@link EventListener} and filters events by only keeping those coming from the provided
28    * {@link Thread}.
29    *
30    * @version $Id: f844184a118edc02ad0fd73a6492cf73769dcd8a $
31    * @since 3.2M3
32    */
 
33    public class WrappedThreadEventListener extends AbstractThreadEventListener
34    {
35    /**
36    * The wrapped listener.
37    */
38    private EventListener listener;
39   
40    /**
41    * Use {@link Thread#currentThread()}.
42    *
43    * @param listener the wrapped listener
44    * @since 6.0M1
45    */
 
46  1134 toggle public WrappedThreadEventListener(EventListener listener)
47    {
48  1134 this.listener = listener;
49    }
50   
51    /**
52    * @param listener the wrapped listener
53    * @param thread the thread to match to receive events
54    */
 
55  1 toggle public WrappedThreadEventListener(EventListener listener, Thread thread)
56    {
57  1 super(thread);
58   
59  1 this.listener = listener;
60    }
61   
 
62  1095 toggle @Override
63    public List<Event> getEvents()
64    {
65  1095 return this.listener.getEvents();
66    }
67   
 
68  8121 toggle @Override
69    public String getName()
70    {
71  8121 return this.listener.getName();
72    }
73   
 
74  18253 toggle @Override
75    protected void onEventInternal(Event event, Object source, Object data)
76    {
77  18253 this.listener.onEvent(event, source, data);
78    }
79    }