1 18 19 20 package org.apache.struts.tiles.xmlDefinition; 21 22 import java.io.Serializable ; 23 import java.util.HashMap ; 24 import java.util.Iterator ; 25 import java.util.Map ; 26 27 import javax.servlet.ServletContext ; 28 import javax.servlet.ServletRequest ; 29 30 import org.apache.struts.tiles.ComponentDefinition; 31 import org.apache.struts.tiles.DefinitionsFactoryException; 32 import org.apache.struts.tiles.NoSuchDefinitionException; 33 34 38 public class DefinitionsFactory implements Serializable 39 { 40 41 protected Map definitions; 42 43 54 public ComponentDefinition getDefinition(String name, ServletRequest request, ServletContext servletContext) 55 throws NoSuchDefinitionException, DefinitionsFactoryException 56 { 57 return (ComponentDefinition)definitions.get(name); 58 } 59 60 64 public void putDefinition(ComponentDefinition definition) 65 { 66 definitions.put( definition.getName(), definition ); 67 } 68 69 75 public DefinitionsFactory(XmlDefinitionsSet xmlDefinitions) 76 throws NoSuchDefinitionException 77 { 78 definitions = new HashMap (); 79 80 xmlDefinitions.resolveInheritances(); 82 83 Iterator i = xmlDefinitions.getDefinitions().values().iterator(); 85 while( i.hasNext() ) 86 { 87 XmlDefinition xmlDefinition = (XmlDefinition)i.next(); 88 putDefinition( new ComponentDefinition( xmlDefinition) ); 89 } } 91 95 public String toString() 96 { 97 return definitions.toString(); 98 } 99 100 } 101 102 | Popular Tags |