Package org.objectweb.speedo.generation.mivisitor

Source Code of org.objectweb.speedo.generation.mivisitor.MetaDataAnalyzer

/**
* Speedo: an implementation of JDO compliant personality on top of JORM generic
* I/O sub-system.
* Copyright (C) 2001-2004 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*
*
* Contact: speedo@objectweb.org
*
* Authors: S.Chassande-Barrioz.
*
*/
package org.objectweb.speedo.generation.mivisitor;

import org.objectweb.asm.ClassReader;
import org.objectweb.speedo.api.SpeedoException;
import org.objectweb.speedo.api.SpeedoProperties;
import org.objectweb.speedo.generation.api.SpeedoCompilerParameter;
import org.objectweb.speedo.generation.enhancer.common.AbstractEnhancerComponent;
import org.objectweb.speedo.lib.Personality;
import org.objectweb.speedo.metadata.SpeedoClass;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;

public class MetaDataAnalyzer extends  AbstractMetaInfoVisitor {
    private Loader loader;

    public MetaDataAnalyzer(Personality p) {
        super(p);
        loader = new Loader(p);
    }

    public MetaDataAnalyzer(MetaInfoVisitor mim, Personality p) {
        super(mim, p);
        loader = new Loader(p);
    }

    private class Loader extends AbstractEnhancerComponent {

      public Loader(Personality p) {
        super(p);
      }
     
        public boolean init() throws SpeedoException {
            isSrcJar = false;
          return true;
        }

        public void process() throws SpeedoException {
            //nothing
        }
        public void setLogger(Logger logger) {
            this.logger = logger;
        }
    }

    protected String getLoggerName() {
        return SpeedoProperties.LOGGER_NAME + ".generation.enhancer.analyzer";
    }

    public void setLogger(Logger logger) {
        super.setLogger(logger);
        loader.setLogger(logger);
    }

    public void visitCompilerParameter(SpeedoCompilerParameter scp) throws SpeedoException {
        loader.setSpeedoCompilerParameter(scp);
        super.visitCompilerParameter(scp);
    }

    public void visitClass(SpeedoClass sc) throws SpeedoException {
        logger.log(BasicLevel.DEBUG, "MetaDataAnalyzer.visitClass(" + sc.getFQName() + ")");
        boolean isSrcJar = false;
        SpeedoCompilerParameter _scp = loader.getSpeedoCompilerParameter();
      ClassReader cr = loader.loadJavaClass(
                    isSrcJar,
                    sc.moPackage.name + '.' + sc.name,
                    _scp.output,
                    false);

        cr.accept(new ClassInfoAnalyzer(
                loader, sc, _scp.getXmldescriptor().values(), logger), true);
        super.visitClass(sc);
    }
}
TOP

Related Classes of org.objectweb.speedo.generation.mivisitor.MetaDataAnalyzer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.