001: /**
002: * Speedo: an implementation of JDO compliant personality on top of JORM generic
003: * I/O sub-system.
004: * Copyright (C) 2001-2004 France Telecom R&D
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: *
021: *
022: * Contact: speedo@objectweb.org
023: *
024: * Authors: S.Chassande-Barrioz.
025: *
026: */package org.objectweb.speedo.generation.mivisitor;
027:
028: import org.objectweb.asm.ClassReader;
029: import org.objectweb.speedo.api.SpeedoException;
030: import org.objectweb.speedo.api.SpeedoProperties;
031: import org.objectweb.speedo.generation.api.SpeedoCompilerParameter;
032: import org.objectweb.speedo.generation.enhancer.common.AbstractEnhancerComponent;
033: import org.objectweb.speedo.lib.Personality;
034: import org.objectweb.speedo.metadata.SpeedoClass;
035: import org.objectweb.util.monolog.api.BasicLevel;
036: import org.objectweb.util.monolog.api.Logger;
037:
038: public class MetaDataAnalyzer extends AbstractMetaInfoVisitor {
039: private Loader loader;
040:
041: public MetaDataAnalyzer(Personality p) {
042: super (p);
043: loader = new Loader(p);
044: }
045:
046: public MetaDataAnalyzer(MetaInfoVisitor mim, Personality p) {
047: super (mim, p);
048: loader = new Loader(p);
049: }
050:
051: private class Loader extends AbstractEnhancerComponent {
052:
053: public Loader(Personality p) {
054: super (p);
055: }
056:
057: public boolean init() throws SpeedoException {
058: isSrcJar = false;
059: return true;
060: }
061:
062: public void process() throws SpeedoException {
063: //nothing
064: }
065:
066: public void setLogger(Logger logger) {
067: this .logger = logger;
068: }
069: }
070:
071: protected String getLoggerName() {
072: return SpeedoProperties.LOGGER_NAME
073: + ".generation.enhancer.analyzer";
074: }
075:
076: public void setLogger(Logger logger) {
077: super .setLogger(logger);
078: loader.setLogger(logger);
079: }
080:
081: public void visitCompilerParameter(SpeedoCompilerParameter scp)
082: throws SpeedoException {
083: loader.setSpeedoCompilerParameter(scp);
084: super .visitCompilerParameter(scp);
085: }
086:
087: public void visitClass(SpeedoClass sc) throws SpeedoException {
088: logger.log(BasicLevel.DEBUG, "MetaDataAnalyzer.visitClass("
089: + sc.getFQName() + ")");
090: boolean isSrcJar = false;
091: SpeedoCompilerParameter _scp = loader
092: .getSpeedoCompilerParameter();
093: ClassReader cr = loader.loadJavaClass(isSrcJar,
094: sc.moPackage.name + '.' + sc.name, _scp.output, false);
095:
096: cr.accept(new ClassInfoAnalyzer(loader, sc, _scp
097: .getXmldescriptor().values(), logger), true);
098: super.visitClass(sc);
099: }
100: }
|