KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > generation > enhancer > MetaDataAnalyzer


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
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 of the License, or (at your option) 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 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  * Authors: S.Chassande-Barrioz.
25  *
26  */

27 package org.objectweb.speedo.generation.enhancer;
28
29 import org.objectweb.asm.ClassReader;
30 import org.objectweb.speedo.api.SpeedoException;
31 import org.objectweb.speedo.api.SpeedoProperties;
32 import org.objectweb.speedo.generation.api.SpeedoCompilerParameter;
33 import org.objectweb.speedo.generation.mivisitor.AbstractMetaInfoVisitor;
34 import org.objectweb.speedo.generation.mivisitor.MetaInfoVisitor;
35 import org.objectweb.speedo.metadata.SpeedoClass;
36 import org.objectweb.util.monolog.api.BasicLevel;
37 import org.objectweb.util.monolog.api.Logger;
38
39 public class MetaDataAnalyzer extends AbstractMetaInfoVisitor {
40
41     private Loader loader;
42
43     public MetaDataAnalyzer() {
44         super();
45         loader = new Loader();
46     }
47
48     public MetaDataAnalyzer(MetaInfoVisitor mim) {
49         super(mim);
50         loader = new Loader();
51     }
52
53     private class Loader extends EnhancerComponent {
54
55         public boolean init() throws SpeedoException {
56             isSrcJar = false;
57             return true;
58         }
59
60         public void process() throws SpeedoException {
61             //nothing
62
}
63         public void setLogger(Logger logger) {
64             this.logger = logger;
65         }
66     }
67
68     protected String JavaDoc getLoggerName() {
69         return SpeedoProperties.LOGGER_NAME + ".generation.enhancer.analyzer";
70     }
71
72     public void setLogger(Logger logger) {
73         super.setLogger(logger);
74         loader.setLogger(logger);
75     }
76
77     public void visitCompilerParameter(SpeedoCompilerParameter scp) throws SpeedoException {
78         loader.setSpeedoCompilerParameter(scp);
79         super.visitCompilerParameter(scp);
80     }
81
82     public void visitClass(SpeedoClass sc) throws SpeedoException {
83         logger.log(BasicLevel.DEBUG, "MetaDataAnalyzer.visitClass(" + sc.getFQName() + ")");
84         boolean isSrcJar = false;
85         SpeedoCompilerParameter _scp = loader.getSpeedoCompilerParameter();
86         ClassReader cr = loader.loadJavaClass(
87                     isSrcJar,
88                     sc.jdoPackage.name + '.' + sc.name,
89                     _scp.output,
90                     false);
91
92         cr.accept(new ClassInfoAnalyzer(
93                 loader, sc, _scp.getXmldescriptor().values(), logger), true);
94         super.visitClass(sc);
95     }
96 }
97
Popular Tags