1 9 package org.jboss.portal.server; 10 11 import java.util.Collection ; 12 import java.util.HashMap ; 13 import java.util.Map ; 14 15 import javax.servlet.ServletContext ; 16 17 import org.jboss.portal.server.kernel.Service; 18 import org.jboss.portal.server.kernel.ServiceImplementation; 19 import org.jboss.portal.server.metadata.ApplicationMetaData; 20 import org.jboss.portal.server.metadata.ServerObjectMetaData; 21 22 26 public abstract class Application extends ServerObject 27 { 28 29 protected ServletContext servletContext; 30 protected String contextPath; 31 protected ClassLoader classLoader; 32 33 protected Map components; 34 35 protected ApplicationMetaData metaData; 36 37 private PortalServer portalServer; 38 39 public Application(String name, ApplicationMetaData applicationMD) 40 { 41 super(name); 42 this.components = new HashMap (); 43 this.metaData = applicationMD; 44 this.servletContext = applicationMD.getServletContext(); 45 this.contextPath = applicationMD.getContextPath(); 46 this.classLoader = applicationMD.getClassLoader(); 47 } 48 49 public ServerObjectMetaData getMetaData() 50 { 51 return metaData; 52 } 53 54 public PortalServer getServer() 55 { 56 return portalServer; 57 } 58 59 public String getContextPath() 60 { 61 return contextPath; 62 } 63 64 public ClassLoader getClassLoader() 65 { 66 return classLoader; 67 } 68 69 public ServletContext getServletContext() 70 { 71 return servletContext; 72 } 73 74 public Component getComponent(String name) 75 { 76 return (Component)components.get(name); 77 } 78 79 public Collection getComponents() 80 { 81 return components.values(); 82 } 83 84 public void addDependsOnMe(ServiceImplementation implementation) 85 { 86 Service service = implementation.getService(); 87 if (service instanceof Component) 88 { 89 Component component = (Component)service; 90 components.put(component.getName(), component); 91 log.debug("Added component " + component.getName()); 92 } 93 else 94 { 95 super.addDependsOnMe(implementation); 96 } 97 } 98 99 public void removeDependsOnMe(ServiceImplementation implementation) 100 { 101 Service service = implementation.getService(); 102 if (service instanceof Component) 103 { 104 Component component = (Component)service; 105 components.remove(component.getName()); 106 log.debug("Removed component " + component.getName()); 107 } 108 else 109 { 110 super.removeDependsOnMe(implementation); 111 } 112 } 113 114 public void addIDependOn(ServiceImplementation implementation) 115 { 116 Service service = implementation.getService(); 117 if (service instanceof PortalServer) 118 { 119 portalServer = (PortalServer)service; 120 } 121 else 122 { 123 super.addIDependOn(implementation); 124 } 125 } 126 127 public void removeIDependOn(ServiceImplementation implementation) 128 { 129 Service service = implementation.getService(); 130 if (service instanceof PortalServer) 131 { 132 portalServer = null; 133 } 134 else 135 { 136 super.removeIDependOn(implementation); 137 } 138 } 139 } 140 | Popular Tags |