1 9 package org.jboss.portal.server; 10 11 import java.util.Collection ; 12 import java.util.Map ; 13 14 import org.jboss.portal.common.plugin.PluginContainer; 15 import org.jboss.portal.server.kernel.Service; 16 import org.jboss.portal.server.kernel.ServiceImplementation; 17 import org.jboss.portal.server.metadata.PortalMetaData; 18 import org.jboss.portal.server.metadata.ServerObjectMetaData; 19 import org.jboss.portal.server.plugins.mode.ModeProvider; 20 import org.jboss.portal.server.plugins.windowstate.WindowStateProvider; 21 import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; 22 23 29 public class Portal 30 extends ServerObject 31 implements PluginContainer 32 { 33 34 35 protected Map windows; 36 37 38 protected PortalServer portalServer; 39 40 41 protected PortalMetaData portalMD; 42 43 44 protected Map properties; 45 46 public Portal(PortalMetaData portalMD, String name) 47 { 48 super(name); 49 this.portalMD = portalMD; 50 this.windows = new ConcurrentHashMap(); 51 this.properties = new ConcurrentHashMap(); 52 } 53 54 public ServerObjectMetaData getMetaData() 55 { 56 return portalMD; 57 } 58 59 public ModeProvider getModeProvider() 60 { 61 return (ModeProvider)getPlugin(PortalConstants.PLUGIN_MODES); 62 } 63 64 public WindowStateProvider getWindowStateProvider() 65 { 66 return (WindowStateProvider)getPlugin(PortalConstants.PLUGIN_WINDOW_STATES); 67 } 68 69 public void start() throws Exception 70 { 71 Map tmp = portalMD.getProperties(); 72 properties.putAll(tmp); 73 properties.put(PortalConstants.PORTAL_PROP_NAME_KEY, name); 74 } 75 76 public void stop() 77 { 78 properties.clear(); 79 } 80 81 public PortalServer getServer() 82 { 83 return portalServer; 84 } 85 86 public Map getProperties() 87 { 88 return properties; 89 } 90 91 public Window getWindow(String name) 92 { 93 return (Window)windows.get(name); 94 } 95 96 public Collection getWindows() 97 { 98 return windows.values(); 99 } 100 101 public void addIDependOn(ServiceImplementation implementation) 102 { 103 Service service = implementation.getService(); 104 if (service instanceof PortalServer) 105 { 106 portalServer = (PortalServer)service; 107 } 108 else 109 { 110 super.addIDependOn(implementation); 111 } 112 } 113 114 public void removeIDependOn(ServiceImplementation implementation) 115 { 116 Service service = implementation.getService(); 117 if (service instanceof PortalServer) 118 { 119 portalServer = null; 120 } 121 else 122 { 123 super.removeIDependOn(implementation); 124 } 125 } 126 127 public void addDependsOnMe(ServiceImplementation implementation) 128 { 129 Service service = implementation.getService(); 130 if (service instanceof Window) 131 { 132 Window window = (Window)service; 133 windows.put(window.getName(), window); 134 log.debug("Added window " + window.getName()); 135 } 136 else 137 { 138 super.addDependsOnMe(implementation); 139 } 140 } 141 142 public void removeDependsOnMe(ServiceImplementation implementation) 143 { 144 Service service = implementation.getService(); 145 if (service instanceof Window) 146 { 147 Window window = (Window)service; 148 windows.remove(window.getName()); 149 log.debug("Removed window " + window.getName()); 150 } 151 else 152 { 153 super.removeDependsOnMe(implementation); 154 } 155 } 156 157 public ServerURL createURL() 158 { 159 ServerURL url = new ServerURL(getID()); 160 return url; 161 } 162 } 163 | Popular Tags |