1 /* 2 * Copyright 2004 Blandware (http://www.blandware.com) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.blandware.atleap.webapp.struts; 17 18 import org.apache.struts.tiles.NoSuchDefinitionException; 19 import org.apache.struts.tiles.xmlDefinition.DefinitionsFactory; 20 import org.apache.struts.tiles.xmlDefinition.XmlDefinition; 21 import org.apache.struts.tiles.xmlDefinition.XmlDefinitionsSet; 22 23 import java.util.HashMap; 24 import java.util.Iterator; 25 import java.util.Map; 26 27 /** 28 * <p>A factory for definitions. 29 * This factory allows to retrieve definitions by their keys.</p> 30 * <p><a HREF="HeritableDefinitionsFactory.java.htm"><i>View Source</i></a></p> 31 * <p/> 32 * 33 * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com"><andrey.grebnev@blandware.com></a> 34 * @version $Revision: 1.6 $ $Date: 2005/08/04 17:25:20 $ 35 */ 36 public class HeritableDefinitionsFactory extends DefinitionsFactory { 37 38 /** 39 * Constructor. 40 * Creates a factory initialized with definitions from {@link org.apache.struts.tiles.xmlDefinition.XmlDefinitionsSet}. 41 * 42 * @param xmlDefinitions Resolved definition from XmlDefinitionSet. 43 * @throws org.apache.struts.tiles.NoSuchDefinitionException 44 * If an error occurs while resolving inheritance 45 */ 46 public HeritableDefinitionsFactory(XmlDefinitionsSet xmlDefinitions) 47 throws NoSuchDefinitionException { 48 super(xmlDefinitions); 49 50 definitions = new HashMap(); 51 // Walk thru xml set and copy each definitions. 52 Iterator i = xmlDefinitions.getDefinitions().values().iterator(); 53 while ( i.hasNext() ) { 54 XmlDefinition xmlDefinition = (XmlDefinition) i.next(); 55 putDefinition(new HeritableComponentDefinition(xmlDefinition)); 56 } // end loop 57 58 } 59 60 /** 61 * Gets a mapping from definition names to definitions that can be 62 * manufactured by this factory 63 * 64 * @return mapping from definition names to definitions 65 */ 66 public Map getDefinitions() { 67 return definitions; 68 } 69 70 } 71