KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > classfile > engine > bcel > EngineRegistrar


1 /*
2  * FindBugs - Find Bugs in Java programs
3  * Copyright (C) 2006, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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 library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.classfile.engine.bcel;
21
22 import edu.umd.cs.findbugs.ba.AnnotationRetentionDatabase;
23 import edu.umd.cs.findbugs.ba.CheckReturnAnnotationDatabase;
24 import edu.umd.cs.findbugs.ba.InnerClassAccessMap;
25 import edu.umd.cs.findbugs.ba.JCIPAnnotationDatabase;
26 import edu.umd.cs.findbugs.ba.NullnessAnnotationDatabase;
27 import edu.umd.cs.findbugs.ba.SourceFinder;
28 import edu.umd.cs.findbugs.ba.SourceInfoMap;
29 import edu.umd.cs.findbugs.ba.ch.Subtypes;
30 import edu.umd.cs.findbugs.ba.npe.ParameterNullnessPropertyDatabase;
31 import edu.umd.cs.findbugs.ba.type.FieldStoreTypeDatabase;
32 import edu.umd.cs.findbugs.classfile.IAnalysisCache;
33 import edu.umd.cs.findbugs.classfile.IAnalysisEngineRegistrar;
34 import edu.umd.cs.findbugs.classfile.IClassAnalysisEngine;
35 import edu.umd.cs.findbugs.classfile.IDatabaseFactory;
36 import edu.umd.cs.findbugs.classfile.ReflectionDatabaseFactory;
37
38 /**
39  * Register BCEL-framework analysis engines.
40  *
41  * <p>
42  * <b>NOTE</b>: the database factories will only work with
43  * AnalysisCacheToAnalysisContextAdapter,
44  * not with LegacyAnalysisContext.
45  * However, that's ok since the databases for BCEL-based
46  * analyses are only ever accessed through the
47  * AnalysisContext.
48  * </p>
49  *
50  * @author David Hovemeyer
51  */

52 public class EngineRegistrar implements IAnalysisEngineRegistrar {
53     private static final IClassAnalysisEngine[] classAnalysisEngineList = {
54         new ClassContextClassAnalysisEngine(),
55         new JavaClassAnalysisEngine(),
56     };
57     
58     private static final IDatabaseFactory<?>[] databaseFactoryList = {
59         new ReflectionDatabaseFactory<Subtypes>(Subtypes.class),
60         new ReflectionDatabaseFactory<InnerClassAccessMap>(InnerClassAccessMap.class),
61         new ReflectionDatabaseFactory<CheckReturnAnnotationDatabase>(CheckReturnAnnotationDatabase.class),
62         new ReflectionDatabaseFactory<AnnotationRetentionDatabase>(AnnotationRetentionDatabase.class),
63         new ReflectionDatabaseFactory<JCIPAnnotationDatabase>(JCIPAnnotationDatabase.class),
64         new ReflectionDatabaseFactory<NullnessAnnotationDatabase>(NullnessAnnotationDatabase.class),
65         new ReflectionDatabaseFactory<SourceFinder>(SourceFinder.class),
66         new ReflectionDatabaseFactory<SourceInfoMap>(SourceInfoMap.class),
67         new ReflectionDatabaseFactory<FieldStoreTypeDatabase>(FieldStoreTypeDatabase.class),
68         new ReflectionDatabaseFactory<ParameterNullnessPropertyDatabase>(ParameterNullnessPropertyDatabase.class),
69     };
70
71     /* (non-Javadoc)
72      * @see edu.umd.cs.findbugs.classfile.IAnalysisEngineRegistrar#registerAnalysisEngines(edu.umd.cs.findbugs.classfile.IAnalysisCache)
73      */

74     public void registerAnalysisEngines(IAnalysisCache analysisCache) {
75         for (IClassAnalysisEngine engine : classAnalysisEngineList) {
76             engine.registerWith(analysisCache);
77         }
78         
79         for (IDatabaseFactory<?> databaseFactory : databaseFactoryList) {
80             databaseFactory.registerWith(analysisCache);
81         }
82     }
83
84 }
85
Popular Tags