KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > feeder > BasicFeederRepository


1 /*
2  * This file is part of "SnipSnap Radeox Rendering Engine".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://radeox.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  * --LICENSE NOTICE--
24  */

25
26 package org.snipsnap.feeder;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.radeox.api.engine.context.InitialRenderContext;
31 import org.radeox.macro.PluginRepository;
32
33 import java.util.*;
34
35 /**
36  * Repository for feeders
37  *
38  * @author Stephan J. Schmidt
39  * @version $Id: BasicFeederRepository.java 1606 2004-05-17 10:56:18Z leo $
40  */

41
42 public class BasicFeederRepository extends PluginRepository implements FeederRepository {
43   private static Log log = LogFactory.getLog(FeederRepository.class);
44
45   private InitialRenderContext context;
46
47   protected List loaders;
48
49   public BasicFeederRepository() {
50     super();
51     init();
52     loaders = new ArrayList();
53     loaders.add(new GroovyFeederLoader());
54     loaders.add(new FeederLoader());
55     load();
56   }
57
58   private void init() {
59     Map newPlugins = new HashMap();
60
61     Iterator iterator = list.iterator();
62     while (iterator.hasNext()) {
63       Feeder feeder = (Feeder) iterator.next();
64       newPlugins.put(feeder.getName(), feeder);
65     }
66     plugins = newPlugins;
67   }
68
69   /**
70    * Loads macros from all loaders into plugins.
71    */

72   private void load() {
73     Iterator iterator = loaders.iterator();
74     while (iterator.hasNext()) {
75       FeederLoader loader = (FeederLoader) iterator.next();
76       loader.setRepository(this);
77       log.debug("Loading from: " + loader.getClass());
78       loader.loadPlugins(this);
79     }
80   }
81
82   public void addLoader(FeederLoader loader) {
83     loader.setRepository(this);
84     loaders.add(loader);
85     plugins = new HashMap();
86     list = new ArrayList();
87     load();
88   }
89 }
90
Popular Tags