1 16 package org.apache.cocoon.components.modules.input; 17 18 import org.apache.avalon.framework.configuration.Configuration; 19 import org.apache.avalon.framework.configuration.ConfigurationException; 20 import org.apache.avalon.framework.logger.AbstractLogEnabled; 21 import org.apache.avalon.framework.service.ServiceException; 22 import org.apache.avalon.framework.service.ServiceManager; 23 import org.apache.avalon.framework.service.Serviceable; 24 import org.apache.avalon.framework.thread.ThreadSafe; 25 26 import java.util.Iterator ; 27 import java.util.Map ; 28 29 37 public final class GlobalInputModule 38 extends AbstractLogEnabled 39 implements InputModule, Serviceable, ThreadSafe { 40 41 private ServiceManager manager; 42 43 46 public void service(ServiceManager manager) { 47 this.manager = manager; 48 } 49 50 64 public Object getAttribute( String name, Configuration modeConf, Map objectModel ) 65 throws ConfigurationException { 66 SitemapVariableHolder holder = null; 67 try { 68 holder = (SitemapVariableHolder)this.manager.lookup(SitemapVariableHolder.ROLE); 69 return holder.get(name); 70 } catch (ServiceException ce) { 71 throw new ConfigurationException("Unable to lookup SitemapVariableHolder.", ce); 72 } finally { 73 this.manager.release(holder); 74 } 75 } 76 77 85 public Iterator getAttributeNames( Configuration modeConf, Map objectModel ) 86 throws ConfigurationException { 87 SitemapVariableHolder holder = null; 88 try { 89 holder = (SitemapVariableHolder)this.manager.lookup(SitemapVariableHolder.ROLE); 90 return holder.getKeys(); 91 } catch (ServiceException ce) { 92 throw new ConfigurationException("Unable to lookup SitemapVariableHolder.", ce); 93 } finally { 94 this.manager.release(holder); 95 } 96 } 97 98 112 public Object [] getAttributeValues( String name, Configuration modeConf, Map objectModel ) 113 throws ConfigurationException { 114 Object o = this.getAttribute(name, modeConf, objectModel); 115 if (o != null) { 116 return new Object [] {o}; 117 } 118 return null; 119 } 120 } 121 | Popular Tags |