01: /**
02: * Copyright (C) 2001-2005 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package org.objectweb.speedo.generation.mivisitor;
18:
19: import org.objectweb.speedo.api.SpeedoException;
20: import org.objectweb.speedo.api.SpeedoProperties;
21: import org.objectweb.speedo.generation.lib.AbstractGeneratorComponent;
22: import org.objectweb.speedo.lib.Personality;
23:
24: /**
25: * Visit the speedo meta information in order to fill the meta information with
26: * the part forgotten by the user. this class is the generic implementation.
27: * It must me extended for specializing the list of visitors.
28: *
29: * @author S.Chassande-Barrioz
30: */
31: public abstract class MetaInfoVisitors extends
32: AbstractGeneratorComponent {
33: public final static String LOGGER_NAME = SpeedoProperties.LOGGER_NAME
34: + ".generation.compiler";
35: /**
36: * Is the first visitor starting the visit.
37: */
38: private AbstractMetaInfoVisitor firstVisitor;
39:
40: protected abstract AbstractMetaInfoVisitor[] getMIVisitors();
41:
42: public MetaInfoVisitors(Personality p) {
43: super (p);
44: }
45:
46: public boolean init() throws SpeedoException {
47: if (scp.getXmldescriptor().isEmpty()) {
48: return false;
49: }
50: logger = scp.loggerFactory.getLogger(LOGGER_NAME);
51: AbstractMetaInfoVisitor[] modifiers = getMIVisitors();
52: firstVisitor = new MetaInfoVisitorImpl(personality);
53: firstVisitor.setSpeedoCompilerParameter(scp);
54: firstVisitor.init();
55: firstVisitor.setNext(modifiers[0]);
56: for (int i = 1; i < modifiers.length; i++) {
57: modifiers[i - 1].setSpeedoCompilerParameter(scp);
58: modifiers[i - 1].init();
59: modifiers[i - 1].setNext(modifiers[i]);
60: }
61: return true;
62: }
63:
64: public String getTitle() {
65: return "Completing the meta data...";
66: }
67:
68: public void process() throws SpeedoException {
69: firstVisitor.visitCompilerParameter(scp);
70: }
71: }
|