KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > portlet > ObjectFactoryImpl


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.portlet;
10
11 import org.jboss.portal.common.metadata.MetaData;
12 import org.jboss.portal.portlet.metadata.LanguagesMetaData;
13 import org.jboss.portal.portlet.metadata.PortletApplicationMetaData;
14 import org.jboss.portal.portlet.metadata.PortletMetaData;
15 import org.jboss.portal.portlet.metadata.PortletPreferencesMetaData;
16 import org.jboss.portal.portlet.plugins.language.ResourceBundles;
17 import org.jboss.portal.portlet.plugins.preferences.PortletPreferenceSetPlugin;
18 import org.jboss.portal.server.Instance;
19 import org.jboss.portal.server.ObjectFactory;
20 import org.jboss.portal.server.Portal;
21 import org.jboss.portal.server.PortalServer;
22 import org.jboss.portal.server.Window;
23 import org.jboss.portal.server.metadata.ContentTypesMetaData;
24 import org.jboss.portal.server.metadata.InstanceMetaData;
25 import org.jboss.portal.server.metadata.InterceptorListMetaData;
26 import org.jboss.portal.server.metadata.ModesMetaData;
27 import org.jboss.portal.server.metadata.PortalMetaData;
28 import org.jboss.portal.server.metadata.PortalServerMetaData;
29 import org.jboss.portal.server.metadata.PreferencesMetaData;
30 import org.jboss.portal.server.metadata.WindowMetaData;
31 import org.jboss.portal.server.metadata.WindowStatesMetaData;
32 import org.jboss.portal.server.plugins.invocation.InvocationPlugin;
33 import org.jboss.portal.server.plugins.mode.ContentTypes;
34 import org.jboss.portal.server.plugins.mode.Modes;
35 import org.jboss.portal.server.plugins.preferences.PreferenceSetPlugin;
36 import org.jboss.portal.server.plugins.windowstate.WindowStates;
37
38 /**
39  * @jmx.mbean
40  * @jboss.xmbean
41  *
42  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
43  * @version $Revision: 1.3 $
44  */

45 public class ObjectFactoryImpl implements ObjectFactory
46 {
47    /**
48     * @jmx.managed-operation
49     * @jmx.managed-parameter
50     * name="metaData"
51     * type="org.jboss.portal.common.metadata.MetaData"
52     */

53    public Object JavaDoc create(MetaData metaData)
54    {
55       if (metaData instanceof PortalMetaData)
56       {
57          PortalMetaData pmd = (PortalMetaData)metaData;
58          return new Portal(pmd, pmd.getName());
59       }
60       else if (metaData instanceof PortalServerMetaData)
61       {
62          PortalServerMetaData pocmd = (PortalServerMetaData)metaData;
63          return new PortalServer(pocmd);
64       }
65       else if (metaData instanceof InstanceMetaData)
66       {
67          InstanceMetaData imd = (InstanceMetaData)metaData;
68          return new Instance(imd);
69       }
70       else if (metaData instanceof WindowMetaData)
71       {
72          WindowMetaData wmd = (WindowMetaData)metaData;
73          return new Window(wmd);
74       }
75       else if (metaData instanceof PortletMetaData)
76       {
77          PortletMetaData pmmd = (PortletMetaData)metaData;
78          return new PortletContainer(pmmd);
79       }
80       else if (metaData instanceof PortletApplicationMetaData)
81       {
82          PortletApplicationMetaData pamd = (PortletApplicationMetaData)metaData;
83          return new PortletApplication(pamd.getContextPath(), pamd);
84       }
85       else if (metaData instanceof ContentTypesMetaData)
86       {
87          return new ContentTypes();
88       }
89       else if (metaData instanceof WindowStatesMetaData)
90       {
91          return new WindowStates();
92       }
93       else if (metaData instanceof LanguagesMetaData)
94       {
95          return new ResourceBundles();
96       }
97       else if (metaData instanceof PortletPreferencesMetaData)
98       {
99          return new PortletPreferenceSetPlugin();
100       }
101       else if (metaData instanceof PreferencesMetaData)
102       {
103          return new PreferenceSetPlugin();
104       }
105       else if (metaData instanceof LanguagesMetaData)
106       {
107          return new ResourceBundles();
108       }
109       else if (metaData instanceof ModesMetaData)
110       {
111          return new Modes();
112       }
113       else if (metaData instanceof InterceptorListMetaData)
114       {
115          return new InvocationPlugin();
116       }
117       else
118       {
119          throw new IllegalArgumentException JavaDoc("Cannot create object for meta data " + metaData);
120       }
121    }
122 }
123
Popular Tags