1 23 package org.infoglue.deliver.portal.services; 24 25 import java.util.Collections ; 26 import java.util.Hashtable ; 27 import java.util.Iterator ; 28 import java.util.Map ; 29 30 import javax.naming.NameNotFoundException ; 31 32 import org.apache.commons.logging.Log; 33 import org.apache.commons.logging.LogFactory; 34 import org.apache.pluto.om.entity.PortletApplicationEntity; 35 import org.apache.pluto.om.entity.PortletApplicationEntityList; 36 import org.apache.pluto.om.entity.PortletEntity; 37 import org.apache.pluto.om.window.PortletWindow; 38 import org.apache.pluto.om.window.PortletWindowListCtrl; 39 import org.apache.pluto.portalImpl.services.Service; 40 import org.apache.pluto.portalImpl.services.portletentityregistry.PortletEntityRegistry; 41 import org.apache.pluto.portalImpl.util.ObjectID; 42 import org.infoglue.deliver.portal.om.PortletWindowImpl; 43 44 50 public class PortletWindowRegistryServiceImpl extends Service implements PortletWindowRegistryService 51 { 52 private static final Log log = LogFactory.getLog(PortletWindowRegistryServiceImpl.class); 53 54 55 private static Map wid2win = Collections.synchronizedMap(new Hashtable ()); 56 57 public synchronized PortletWindow createPortletWindow(String windowID, String entityID) throws NameNotFoundException 58 { 59 PortletWindow window = (PortletWindow) wid2win.get(windowID); 60 61 if (window == null) 62 { 63 log.debug("Found no portletwindow with id[" + windowID + "], registring new instance"); 64 65 PortletApplicationEntityList applicationList = PortletEntityRegistry.getPortletApplicationEntityList(); 66 Iterator portletApplicationEntityListIterator = applicationList.iterator(); 67 while(portletApplicationEntityListIterator.hasNext()) 68 { 69 PortletApplicationEntity pae = (PortletApplicationEntity)portletApplicationEntityListIterator.next(); 70 log.debug("Available application: " + pae.getId()); 71 } 72 73 PortletEntity entity = PortletEntityRegistry.getPortletEntity(ObjectID.createFromString(entityID)); 74 75 if (entity == null) 76 { 77 log.fatal("Couldn't find entity with id: " + entityID); 78 throw new NameNotFoundException ("Portlet entity not found: " + entityID); 79 } 80 81 window = new PortletWindowImpl(windowID, entity); 82 83 ((PortletWindowListCtrl) entity.getPortletWindowList()).add(window); 84 85 wid2win.put(windowID, window); 86 } 87 88 return window; 89 } 90 91 98 public PortletWindow getPortletWindow(String id) { 99 return (PortletWindow) wid2win.get(id); 100 } 101 102 } | Popular Tags |