1 9 package org.jboss.portal.core.plugins.page; 10 11 import java.util.Collection ; 12 import java.util.HashMap ; 13 import java.util.Iterator ; 14 import java.util.Map ; 15 16 import org.jboss.portal.core.metadata.PageMetaData; 17 import org.jboss.portal.core.metadata.WindowLocationMetaData; 18 import org.jboss.portal.server.PortalServer; 19 import org.jboss.portal.server.ServerObject; 20 import org.jboss.portal.server.ServerObjectID; 21 import org.jboss.portal.server.ServerURL; 22 import org.jboss.portal.server.kernel.Service; 23 import org.jboss.portal.server.kernel.ServiceImplementation; 24 import org.jboss.portal.server.metadata.ServerObjectMetaData; 25 26 30 public class Page 31 extends ServerObject 32 { 33 34 private PageRepository repository; 35 private PageMetaData pageMD; 36 private Map locations; 37 39 public Page(PageMetaData pageMD) 40 { 41 super(pageMD.getName()); 42 this.pageMD = pageMD; 43 this.locations = new HashMap (); 44 } 45 46 public String getName() 47 { 48 return name; 49 } 50 51 public PageRepository getRepository() 52 { 53 return repository; 54 } 55 56 67 68 public Collection getLocations() 69 { 70 return locations.values(); 71 } 72 73 public WindowLocation getLocation(ServerObjectID id) 74 { 75 return (WindowLocation)locations.get(id); 76 } 77 78 public PortalServer getServer() 79 { 80 throw new UnsupportedOperationException ("todo"); 81 } 82 83 public ServerObjectMetaData getMetaData() 84 { 85 return pageMD; 86 } 87 88 public void start() throws Exception 89 { 90 for (Iterator j = pageMD.getWindowSet().iterator();j.hasNext();) 92 { 93 WindowLocationMetaData windowMDLocation = (WindowLocationMetaData)j.next(); 94 WindowLocation location = new WindowLocation(windowMDLocation); 95 locations.put(location.getID(), location); 96 } 97 98 105 106 repository.addPage(this); 108 } 109 110 public void stop() 111 { 112 repository.removePage(this); 114 115 locations.clear(); 118 } 119 120 public void addIDependOn(ServiceImplementation implementation) 121 { 122 Service service = implementation.getService(); 123 if (service instanceof PageRepository) 124 { 125 repository = (PageRepository)service; 126 } 127 } 128 129 public void removeIDependOn(ServiceImplementation implementation) 130 { 131 Service service = implementation.getService(); 132 if (service instanceof PageRepository) 133 { 134 repository = null; 135 } 136 } 137 138 public ServerURL createURL() 139 { 140 ServerURL url = new ServerURL(getID()); 141 return url; 142 } 143 } 144 | Popular Tags |