EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hiveevents]

COVERAGE SUMMARY FOR SOURCE FILE [ChannelRepositoryImpl.java]

nameclass, %method, %block, %line, %
ChannelRepositoryImpl.java100% (1/1)100% (2/2)100% (77/77)100% (17/17)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ChannelRepositoryImpl100% (1/1)100% (2/2)100% (77/77)100% (17/17)
ChannelRepositoryImpl (Log, Map): void 100% (1/1)100% (12/12)100% (4/4)
getChannel (String): Channel 100% (1/1)100% (65/65)100% (13/13)

1//  Copyright 2004-2007 Jean-Francois Poilpret
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 
15package net.sourceforge.hiveevents;
16 
17import java.util.HashMap;
18import java.util.Map;
19 
20import org.apache.commons.logging.Log;
21 
22/**
23 * Default implementation of a ChannelRepository.
24 * @author Jean-Francois Poilpret
25 */
26public class ChannelRepositoryImpl implements ChannelRepository
27{
28        public ChannelRepositoryImpl(Log logger, Map<String, ChannelContribution> config)
29        {
30                _logger = logger;
31                _channels = new HashMap<String, Object>(config);
32        }
33        
34        @SuppressWarnings("unchecked")
35        synchronized public Channel<?>        getChannel(String name)
36        {
37                Object info = _channels.get(name);
38                if (info == null)
39                {
40                        _logger.warn("getChannel() undefined channel name <" + name + ">");
41                        return null;
42                }
43                if (info instanceof Channel)
44                {
45                        return (Channel) info;
46                }
47 
48                ChannelContribution contrib = (ChannelContribution) info;
49                Channel<?> channel;
50                if (contrib.isThreadSafe())
51                {
52                        channel = new SyncChannelImpl(name,
53                                                      contrib.getPullConsumerPriority(),
54                                                      contrib.getEventClass(),
55                                                      contrib.isLogEvents());
56                }
57                else
58                {
59                        channel = new ChannelImpl(name,
60                                                  contrib.getPullConsumerPriority(),
61                                                  contrib.getEventClass(),
62                                                  contrib.isLogEvents());
63                }
64                _channels.put(name, channel);
65                return channel;
66        }
67        
68        private final Log                                        _logger;
69        private final Map<String, Object>        _channels;
70}

[all classes][net.sourceforge.hiveevents]
EMMA 2.0.5312 (C) Vladimir Roubtsov