01: /*
02: * (C) Copyright 2006 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program 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
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19: package com.nabhinc.portal.core;
20:
21: import java.util.List;
22:
23: import javax.servlet.ServletConfig;
24: import javax.servlet.ServletException;
25:
26: import com.nabhinc.portal.model.PortalConfiguration;
27: import com.nabhinc.util.ComponentConfig;
28:
29: /**
30: *
31: *
32: * @author Padmanabh Dabke
33: * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
34: */
35: public class PluginManager {
36:
37: private static PortalPlugin[] pmPlugins = new PortalPlugin[0];
38:
39: protected static void init(ServletConfig config)
40: throws ServletException {
41: List<ComponentConfig> pluginList = PortalConfiguration
42: .getInstance().getPortalPluginConfigs();
43: if (pluginList == null)
44: return;
45: pmPlugins = new PortalPlugin[pluginList.size()];
46: for (int i = 0; i < pluginList.size(); i++) {
47: ComponentConfig pluginConfig = pluginList.get(i);
48: try {
49: pmPlugins[i] = (PortalPlugin) ComponentConfig
50: .createComponent(pluginConfig);
51: } catch (Exception e) {
52: throw new ServletException(
53: "Failed to instantiate plug-in number " + i, e);
54: }
55:
56: try {
57: pmPlugins[i].init(config);
58: } catch (Exception e) {
59: throw new ServletException(
60: "Failed to initialize plug-in number " + i, e);
61: }
62: }
63: }
64:
65: protected static void portletsLoaded() throws ServletException {
66: for (int i = 0; i < pmPlugins.length; i++) {
67: pmPlugins[i].portletsLoaded();
68: }
69: }
70: }
|