1 16 package org.apache.cocoon.portal.wsrp.consumer; 17 18 import java.util.Hashtable ; 19 import java.util.Iterator ; 20 21 import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter; 22 import org.apache.wsrp4j.consumer.ConsumerEnvironment; 23 import org.apache.wsrp4j.consumer.PortletDriver; 24 import org.apache.wsrp4j.consumer.PortletDriverRegistry; 25 import org.apache.wsrp4j.consumer.WSRPPortlet; 26 import org.apache.wsrp4j.exception.WSRPException; 27 28 37 public class PortletDriverRegistryImpl 38 implements PortletDriverRegistry, 39 RequiresConsumerEnvironment, 40 RequiresWSRPAdapter { 41 42 43 protected final Hashtable portletDrivers = new Hashtable (); 44 45 46 protected ConsumerEnvironment consumerEnv; 47 48 49 protected WSRPAdapter adapter; 50 51 54 public void setConsumerEnvironment(ConsumerEnvironment env) { 55 this.consumerEnv = env; 56 } 57 58 61 public void setWSRPAdapter(WSRPAdapter adapter) { 62 this.adapter = adapter; 63 } 64 65 73 public PortletDriver getPortletDriver(WSRPPortlet portlet) 74 throws WSRPException { 75 PortletDriver driver = null; 76 77 if ((driver = (PortletDriver)portletDrivers.get(portlet.getPortletKey().toString())) == null) { 78 String driverClass = this.adapter.getAdapterConfiguration().getParameter("portlet-driver-class", PortletDriverImpl.class.getName()); 79 try { 80 driver = (PortletDriverImpl)this.adapter.createObject(driverClass); 81 } catch (Exception e) { 82 throw new WSRPException(0, e); 83 } 84 ((PortletDriverImpl)driver).init(portlet); 85 this.portletDrivers.put(portlet.getPortletKey().toString(), driver); 86 } 87 return driver; 88 } 89 90 95 public Iterator getAllPortletDrivers() { 96 return portletDrivers.values().iterator(); 97 } 98 } 99 | Popular Tags |