EMMA Coverage Report (generated Sun Sep 18 11:34:27 PHT 2011)
[all classes][org.apache.maven.continuum.notification.manager.spring]

COVERAGE SUMMARY FOR SOURCE FILE [NotifierFactoryBean.java]

nameclass, %method, %block, %line, %
NotifierFactoryBean.java100% (1/1)83%  (5/6)60%  (50/84)80%  (12/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NotifierFactoryBean100% (1/1)83%  (5/6)60%  (50/84)80%  (12/15)
getObjectType (): Class 0%   (0/1)0%   (0/2)0%   (0/1)
getObject (): Object 100% (1/1)54%  (37/69)78%  (7/9)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
NotifierFactoryBean (): void 100% (1/1)100% (3/3)100% (1/1)
isSingleton (): boolean 100% (1/1)100% (2/2)100% (1/1)
setApplicationContext (ApplicationContext): void 100% (1/1)100% (4/4)100% (2/2)

1package org.apache.maven.continuum.notification.manager.spring;
2 
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21 
22import java.util.HashMap;
23import java.util.Map;
24 
25import org.apache.maven.continuum.notification.Notifier;
26import org.slf4j.Logger;
27import org.slf4j.LoggerFactory;
28import org.springframework.beans.BeansException;
29import org.springframework.beans.factory.BeanFactoryUtils;
30import org.springframework.beans.factory.BeanInitializationException;
31import org.springframework.beans.factory.FactoryBean;
32import org.springframework.context.ApplicationContext;
33import org.springframework.context.ApplicationContextAware;
34 
35/**
36 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
37 * @version $Id: NotifierFactoryBean.java 764863 2009-04-14 16:28:12Z evenisse $
38 */
39public class NotifierFactoryBean
40    implements FactoryBean, ApplicationContextAware
41{
42    private static final Logger log = LoggerFactory.getLogger( NotifierFactoryBean.class );
43 
44    private ApplicationContext applicationContext;
45 
46    public Object getObject()
47        throws Exception
48    {
49        Map<String, Notifier> notifiers = new HashMap<String, Notifier>();
50 
51        Map<String, Notifier> beans =
52            BeanFactoryUtils.beansOfTypeIncludingAncestors( applicationContext, Notifier.class );
53 
54        for ( Notifier notifier : beans.values() )
55        {
56 
57            if ( notifiers.containsKey( notifier.getType() ) )
58            {
59                throw new BeanInitializationException(
60                    "There are two Notifier beans in the appllication context for Notifier type " + notifier.getType() +
61                        ". Probably two conflicting scm implementations are present in the classpath." );
62            }
63 
64            if ( log.isDebugEnabled() )
65            {
66                log.debug(
67                    "put provider with type " + notifier.getType() + " and class " + notifier.getClass().getName() );
68            }
69            notifiers.put( notifier.getType(), notifier );
70        }
71        return notifiers;
72    }
73 
74    public Class getObjectType()
75    {
76        return Map.class;
77    }
78 
79    public boolean isSingleton()
80    {
81        return true;
82    }
83 
84    public void setApplicationContext( ApplicationContext applicationContext )
85        throws BeansException
86    {
87        this.applicationContext = applicationContext;
88    }
89}

[all classes][org.apache.maven.continuum.notification.manager.spring]
EMMA 2.0.5312 (C) Vladimir Roubtsov