1 16 package org.apache.cocoon.portal.event.impl; 17 18 import java.util.ArrayList ; 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import org.apache.avalon.framework.configuration.Configuration; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 import org.apache.avalon.framework.parameters.Parameters; 25 import org.apache.avalon.framework.service.ServiceException; 26 import org.apache.avalon.framework.service.ServiceSelector; 27 28 35 public final class EventAspectChain { 36 37 private List aspects = new ArrayList (); 38 39 private List configs = new ArrayList (); 40 41 public void configure(ServiceSelector selector, Configuration conf) 42 throws ConfigurationException { 43 if ( conf != null ) { 44 Configuration[] aspects = conf.getChildren("aspect"); 45 if ( aspects != null ) { 46 for(int i=0; i < aspects.length; i++) { 47 final Configuration current = aspects[i]; 48 final String role = current.getAttribute("type"); 49 try { 50 this.aspects.add(selector.select(role)); 51 this.configs.add(Parameters.fromConfiguration(current)); 52 } catch (ServiceException se) { 53 throw new ConfigurationException("Unable to lookup aspect " + role, se); 54 } 55 } 56 } 57 } else { 58 throw new ConfigurationException("No aspects configured"); 59 } 60 } 61 62 public Iterator getIterator() { 63 return this.aspects.iterator(); 64 } 65 66 public Iterator getConfigIterator() { 67 return this.configs.iterator(); 68 } 69 70 public void dispose(ServiceSelector selector) { 71 Iterator i = this.aspects.iterator(); 72 while (i.hasNext()) { 73 selector.release(i.next()); 74 } 75 this.aspects.clear(); 76 } 77 } 78 | Popular Tags |