1 16 package org.apache.cocoon.portal.pluto.om; 17 18 import java.util.Collection ; 19 import java.util.HashMap ; 20 import java.util.Iterator ; 21 import java.util.Vector ; 22 23 import org.apache.pluto.om.servlet.ServletDefinition; 24 import org.apache.pluto.om.servlet.ServletDefinitionList; 25 import org.apache.pluto.om.servlet.ServletDefinitionListCtrl; 26 import org.apache.pluto.om.servlet.WebApplicationDefinition; 27 import org.apache.cocoon.ProcessingException; 28 import org.apache.cocoon.portal.pluto.om.common.AbstractSupportSet; 29 import org.apache.cocoon.portal.pluto.om.common.Support; 30 31 38 public class ServletDefinitionListImpl extends AbstractSupportSet 39 implements ServletDefinitionList, ServletDefinitionListCtrl, java.io.Serializable , Support { 40 41 43 public ServletDefinition get(String name) { 44 Iterator iterator = this.iterator(); 45 while (iterator.hasNext()) { 46 ServletDefinition servletDefinition = (ServletDefinition)iterator.next(); 47 if (servletDefinition.getServletName().equals(name)) { 48 return servletDefinition; 49 } 50 } 51 return null; 52 } 53 54 56 public ServletDefinition add(String name, String className) { 57 ServletDefinitionImpl servletDefinition = new ServletDefinitionImpl(); 58 servletDefinition.setServletName(name); 59 servletDefinition.setServletClass(className); 60 61 super.add(servletDefinition); 62 63 return servletDefinition; 64 } 65 66 public ServletDefinition remove(String name) { 67 Iterator iterator = this.iterator(); 68 while (iterator.hasNext()) { 69 ServletDefinition servletDefinition = (ServletDefinition)iterator.next(); 70 if (servletDefinition.getServletName().equals(name)) { 71 super.remove(servletDefinition); 72 return servletDefinition; 73 } 74 } 75 return null; 76 } 77 78 public void remove(ServletDefinition servletDefinition) { 79 super.remove(servletDefinition); 80 } 81 82 84 public void preBuild(Object parameter) throws Exception { 85 Vector structure = (Vector )parameter; 86 WebApplicationDefinition webApplicationDefinition = (WebApplicationDefinition)structure.get(0); 87 Collection servletMappings = (Collection )structure.get(1); 88 HashMap servletMap = (HashMap )structure.get(2); 89 90 HashMap mappings = new HashMap (servletMappings.size()); 92 Iterator iterator = servletMappings.iterator(); 93 while (iterator.hasNext()) { 94 ServletMapping servletMapping = (ServletMapping)iterator.next(); 95 mappings.put(servletMapping.getServletName(),servletMapping); 96 } 97 iterator = this.iterator(); 99 while (iterator.hasNext()) { 100 ServletDefinition servlet = (ServletDefinition)iterator.next(); 101 ((Support)servlet).preBuild(webApplicationDefinition); 102 103 if (servlet.getInitParameterSet() != null) { 104 if (servlet.getInitParameterSet().get("portlet-guid") != null) { 105 String guid = servlet.getInitParameterSet().get("portlet-guid").getValue(); 106 servletMap.put(guid, servlet); 107 108 ServletMapping servletMapping = (ServletMapping)mappings.get(servlet.getServletName()); 109 if (mappings==null) { 110 throw new ProcessingException("No corresponding servlet mapping found for servlet name '"+servlet.getServletName()+"'"); 111 } 112 ((Support)servlet).postBuild(servletMapping); 113 114 } 115 } 116 } 117 118 } 119 120 public void postBuild(Object parameter) throws Exception { 121 } 123 124 public void postLoad(Object parameter) throws Exception { 125 Iterator iterator = this.iterator(); 126 while (iterator.hasNext()) { 127 ((ServletDefinitionImpl)iterator.next()).postLoad(parameter); 128 } 129 130 } 131 132 public void postStore(Object parameter) throws Exception { 133 } 135 136 public void preStore(Object parameter) throws Exception { 137 } 139 140 } 141 | Popular Tags |