1 9 package org.jboss.portal.server; 10 11 import java.util.HashMap ; 12 import java.util.Map ; 13 import java.util.Set ; 14 15 import org.apache.log4j.Logger; 16 import org.jboss.portal.common.plugin.Plugin; 17 import org.jboss.portal.common.plugin.PluginContainer; 18 import org.jboss.portal.server.invocation.Invocation; 19 import org.jboss.portal.server.kernel.BaseService; 20 import org.jboss.portal.server.kernel.Registration; 21 import org.jboss.portal.server.kernel.Service; 22 import org.jboss.portal.server.kernel.ServiceImplementation; 23 import org.jboss.portal.server.metadata.ServerObjectMetaData; 24 import org.jboss.portal.server.plugins.PluginID; 25 import org.jboss.portal.server.user.ServerObjectContext; 26 27 33 public abstract class ServerObject 34 extends BaseService 35 implements Service, 36 Registration, 37 PluginContainer 38 { 39 40 41 protected final String name; 42 43 44 protected final Logger log; 45 46 47 protected Map plugins; 48 49 52 public ServerObject(String name) 53 { 54 if (name == null) 55 { 56 throw new IllegalArgumentException ("Component name cannot be null"); 57 } 58 this.name = name; 59 this.log = Logger.getLogger(getClass()); 60 this.plugins = new HashMap (); 61 } 62 63 66 public abstract ServerObjectMetaData getMetaData(); 67 68 71 public ServerObjectID getID() 72 { 73 return (ServerObjectID)ctx.getID(); 74 } 75 76 79 public abstract PortalServer getServer(); 80 81 84 public String getName() 85 { 86 return name; 87 } 88 89 95 public ServerObjectContext createContext() throws UnsupportedOperationException 96 { 97 throw new UnsupportedOperationException ("Contextualization not supported"); 98 } 99 100 public void addIDependOn(ServiceImplementation implementation) 101 { 102 } 103 104 public void removeIDependOn(ServiceImplementation implementation) 105 { 106 } 107 108 public void addDependsOnMe(ServiceImplementation implementation) 109 { 110 Service service = implementation.getService(); 111 if (service instanceof Plugin) 112 { 113 Plugin plugin = (Plugin)service; 114 PluginID pluginID = (PluginID)implementation.getID(); 115 addPlugin(pluginID.getName(), plugin); 116 } 117 } 118 119 public void removeDependsOnMe(ServiceImplementation implementation) 120 { 121 Service service = implementation.getService(); 122 if (service instanceof Plugin) 123 { 124 PluginID pluginID = (PluginID)implementation.getID(); 125 removePlugin(pluginID.getName()); 126 } 127 } 128 129 public void addPlugin(String key, Plugin plugin) 130 { 131 plugins.put(key, plugin); 132 plugin.setPluginContainer(this); 133 } 134 135 public void removePlugin(String key) 136 { 137 Plugin plugin = (Plugin)plugins.remove(key); 138 plugin.setPluginContainer(null); 139 } 140 141 public Plugin getPlugin(String key) 142 { 143 return (Plugin)plugins.get(key); 144 } 145 146 public Set getPluginKeySet() 147 { 148 return plugins.keySet(); 149 } 150 151 public void create() throws Exception 152 { 153 } 154 155 public void start() throws Exception 156 { 157 } 158 159 public void stop() 160 { 161 } 162 163 public void destroy() 164 { 165 } 166 167 170 public Object invoke(Invocation invocation) 171 { 172 throw new UnsupportedOperationException (); 173 } 174 175 178 public ServerURL createURL() 179 { 180 throw new UnsupportedOperationException (); 181 } 182 } 183 | Popular Tags |