KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > server > plugins > mode > Modes


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.server.plugins.mode;
10
11 import java.util.HashSet JavaDoc;
12 import java.util.Iterator JavaDoc;
13 import java.util.Set JavaDoc;
14
15 import org.jboss.portal.common.metadata.MetaData;
16 import org.jboss.portal.common.plugin.PluginContainer;
17 import org.jboss.portal.server.metadata.ModesMetaData;
18 import org.jboss.portal.server.plugins.PluginService;
19
20 /**
21  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
22  * @version $Revision: 1.2 $
23  */

24 public class Modes
25    extends PluginService
26    implements ModeProvider
27 {
28
29    /** The set of modes. */
30    protected Set JavaDoc modes;
31
32    /** The plugin container. */
33    protected PluginContainer container;
34
35    /** Our meta data. */
36    protected ModesMetaData metaData;
37
38    public Set JavaDoc getModes()
39    {
40       return modes;
41    }
42
43    public boolean containsMode(Mode mode)
44    {
45       return modes.contains(mode);
46    }
47
48    public void addMode(Mode mode)
49    {
50       modes.add(mode);
51    }
52
53    public void removeMode(Mode mode)
54    {
55       modes.remove(mode);
56    }
57
58    public void setPluginContainer(PluginContainer container)
59    {
60       this.container = container;
61    }
62
63    public PluginContainer getPluginContainer()
64    {
65       return container;
66    }
67
68    public void start() throws Exception JavaDoc
69    {
70       modes = new HashSet JavaDoc();
71       for (Iterator JavaDoc i = this.metaData.getModes().iterator();i.hasNext();)
72       {
73          String JavaDoc modeAsString = (String JavaDoc)i.next();
74          Mode mode = Mode.create(modeAsString);
75          modes.add(mode);
76       }
77    }
78
79    public void setMetaData(MetaData metaData)
80    {
81       this.metaData = (ModesMetaData)metaData;
82    }
83
84    public MetaData getMetaData()
85    {
86       return metaData;
87    }
88 }
89
Popular Tags