Clover coverage report -
Coverage timestamp: Thu Jun 22 2006 14:24:50 CEST
file stats: LOC: 96   Methods: 2
NCLOC: 43   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
InterfaceAnnotatedHelper.java 21.4% 47.8% 50% 38.5%
coverage coverage
 1    /**
 2    * EasyBeans
 3    * Copyright (C) 2006 Bull S.A.S.
 4    * Contact: easybeans@objectweb.org
 5    *
 6    * This library is free software; you can redistribute it and/or
 7    * modify it under the terms of the GNU Lesser General Public
 8    * License as published by the Free Software Foundation; either
 9    * version 2.1 of the License, or any later version.
 10    *
 11    * This library is distributed in the hope that it will be useful,
 12    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 14    * Lesser General Public License for more details.
 15    *
 16    * You should have received a copy of the GNU Lesser General Public
 17    * License along with this library; if not, write to the Free Software
 18    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 19    * USA
 20    *
 21    * --------------------------------------------------------------------------
 22    * $Id: InterfaceAnnotatedHelper.java 266 2006-03-24 12:58:05Z benoitf $
 23    * --------------------------------------------------------------------------
 24    */
 25   
 26    package org.objectweb.easybeans.deployment.annotations.helper.bean;
 27   
 28    import org.objectweb.easybeans.deployment.annotations.exceptions.ResolverException;
 29    import org.objectweb.easybeans.deployment.annotations.impl.JLocal;
 30    import org.objectweb.easybeans.deployment.annotations.impl.JRemote;
 31    import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata;
 32    import org.objectweb.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata;
 33   
 34    /**
 35    * Lookup the annotated interfaces of a class and report it to the class
 36    * metadata.
 37    * @author Florent Benoit
 38    */
 39    public final class InterfaceAnnotatedHelper {
 40   
 41    /**
 42    * Helper class, no public constructor.
 43    */
 44  0 private InterfaceAnnotatedHelper() {
 45    }
 46   
 47    /**
 48    * Gets interface of a bean and report their types to the bean metadata.
 49    * @param sessionBean Session bean to analyze
 50    * @throws ResolverException if there is a failure in a resolver
 51    */
 52  31 public static void resolve(final ClassAnnotationMetadata sessionBean) throws ResolverException {
 53    // root metadata
 54  31 EjbJarAnnotationMetadata ejbJarAnnotationMetadata = sessionBean.getEjbJarAnnotationMetadata();
 55   
 56    // Local and remote interfaces of the bean.
 57  31 JLocal currentLocalInterfaces = sessionBean.getLocalInterfaces();
 58  31 JRemote currentRemoteInterfaces = sessionBean.getRemoteInterfaces();
 59   
 60    // Get all interfaces of the bean
 61  31 String[] interfaces = sessionBean.getInterfaces();
 62  31 for (String itf : interfaces) {
 63  35 ClassAnnotationMetadata itfAnnotationMetadata = ejbJarAnnotationMetadata.getClassAnnotationMetadata(itf);
 64   
 65    // Interface was analyzed, try to see the type of the interface
 66  35 if (itfAnnotationMetadata != null) {
 67    // Report type of interface in the bean
 68  35 JLocal jLocal = itfAnnotationMetadata.getLocalInterfaces();
 69  35 if (jLocal != null) {
 70  0 if (currentLocalInterfaces == null) {
 71  0 currentLocalInterfaces = new JLocal();
 72  0 sessionBean.setLocalInterfaces(currentLocalInterfaces);
 73    }
 74  0 String itfName = itfAnnotationMetadata.getClassName();
 75  0 if (!currentLocalInterfaces.getInterfaces().contains(itfName)) {
 76  0 currentLocalInterfaces.addInterface(itfName);
 77    }
 78    }
 79   
 80    // Report type of interface in the bean
 81  35 JRemote jRemote = itfAnnotationMetadata.getRemoteInterfaces();
 82  35 if (jRemote != null) {
 83  0 if (currentRemoteInterfaces == null) {
 84  0 currentRemoteInterfaces = new JRemote();
 85  0 sessionBean.setRemoteInterfaces(currentRemoteInterfaces);
 86    }
 87  0 String itfName = itfAnnotationMetadata.getClassName();
 88  0 if (!currentRemoteInterfaces.getInterfaces().contains(itfName)) {
 89  0 currentRemoteInterfaces.addInterface(itfName);
 90    }
 91    }
 92    }
 93    }
 94    }
 95   
 96    }