You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by dd...@apache.org on 2006/11/02 03:03:04 UTC
svn commit: r470185 [2/5] - in /struts/sandbox/trunk/tiles:
tiles-api/src/main/java/org/apache/tiles/
tiles-core/src/main/java/org/apache/tiles/
tiles-core/src/main/java/org/apache/tiles/access/
tiles-core/src/main/java/org/apache/tiles/beans/ tiles-co...
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java (from r470071, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentDefinition.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentDefinition.java&r1=470071&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentDefinition.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java Wed Nov 1 18:03:00 2006
@@ -16,16 +16,19 @@
* limitations under the License.
*/
-package org.apache.tiles;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
+package org.apache.tiles.definition;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.definition.ComponentAttribute;
+import org.apache.tiles.preparer.UrlViewPreparer;
+import org.apache.tiles.preparer.ViewPreparer;
import org.apache.tiles.util.RequestUtils;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Definition of a template / component attributes.
* Attributes of a component can be defined with the help of this class.
@@ -37,9 +40,9 @@
* Extends attribute value.
*/
private String inherit;
-
+
/**
- * Commons Logging instance.
+ * Commons Logging instance.
*/
protected static Log log = LogFactory.getLog(ComponentDefinition.class);
@@ -58,37 +61,39 @@
*/
protected Map attributes = null;
- /**
- * Role associated to definition.
+ /**
+ * Role associated to definition.
*/
protected String role = null;
- /** Associated ViewPreparer URL or classname, if defined */
+ /**
+ * Associated ViewPreparer URL or classname, if defined
+ */
protected String preparer = null;
- /**
+ /**
* Associated ViewPreparer typename, if preparerName defined.
- * Can be PREPARER, ACTION or URL, or null.
+ * Can be PREPARER, ACTION or URL, or null.
*/
protected String preparerType = null;
/**
* Used for resolving inheritance.
*/
- private boolean isVisited=false;
+ private boolean isVisited = false;
- /**
- * ViewPreparer name type.
+ /**
+ * ViewPreparer name type.
*/
public static final String URL = "url";
- /**
- * ViewPreparer name type.
+ /**
+ * ViewPreparer name type.
*/
public static final String PREPARER = "preparer";
- /**
- * ViewPreparer name type.
+ /**
+ * ViewPreparer name type.
*/
public static final String ACTION = "action";
@@ -133,7 +138,7 @@
/**
* Access method for the name property.
*
- * @return the current value of the name property
+ * @return the current value of the name property
*/
public String getName() {
return name;
@@ -169,7 +174,7 @@
/**
* Access method for the path property.
*
- * @return the current value of the path property
+ * @return the current value of the path property
*/
public String getPath() {
return path;
@@ -187,7 +192,8 @@
/**
* Access method for the template property.
* Same as getPath()
- * @return the current value of the template property
+ *
+ * @return the current value of the template property
*/
public String getTemplate() {
return path;
@@ -205,7 +211,8 @@
/**
* Access method for the role property.
- * @return the current value of the role property
+ *
+ * @return the current value of the role property
*/
public String getRole() {
return role;
@@ -223,7 +230,8 @@
/**
* Access method for the attributes property.
* If there is no attributes, return an empty map.
- * @return the current value of the attributes property
+ *
+ * @return the current value of the attributes property
*/
public Map getAttributes() {
return attributes;
@@ -233,7 +241,7 @@
* Returns the value of the named attribute as an Object, or null if no
* attribute of the given name exists.
*
- * @return requested attribute or null if not found
+ * @return requested attribute or null if not found
*/
public Object getAttribute(String key) {
ComponentAttribute attribute = (ComponentAttribute) attributes.get(key);
@@ -247,7 +255,7 @@
/**
* Put a new attribute in this component
*
- * @param key String key for attribute
+ * @param key String key for attribute
* @param value Attibute value.
*/
public void putAttribute(String key, ComponentAttribute value) {
@@ -257,7 +265,8 @@
/**
* Put an attribute in component / template definition.
* Attribute can be used as content for tag get.
- * @param name Attribute name
+ *
+ * @param name Attribute name
* @param content Attribute value
*/
public void put(String name, Object content) {
@@ -267,9 +276,10 @@
/**
* Put an attribute in template definition.
* Attribute can be used as content for tag get.
- * @param name Attribute name
+ *
+ * @param name Attribute name
* @param content Attribute value �
- * @param direct Determines how content is handled by get tag: true means content is printed directly; false, the default, means content is included
+ * @param direct Determines how content is handled by get tag: true means content is printed directly; false, the default, means content is included
*/
public void put(String name, Object content, boolean direct) {
put(name, content, direct, null);
@@ -278,10 +288,11 @@
/**
* Put an attribute in template definition.
* Attribute can be used as content for tag get.
- * @param name Attribute name
+ *
+ * @param name Attribute name
* @param content Attribute value
- * @param direct Determines how content is handled by get tag: true means content is printed directly; false, the default, means content is included
- * @param role Determine if content is used by get tag. If user is in role, content is used.
+ * @param direct Determines how content is handled by get tag: true means content is printed directly; false, the default, means content is included
+ * @param role Determine if content is used by get tag. If user is in role, content is used.
*/
public void put(String name, Object content, boolean direct, String role) {
if (direct == true) { // direct String
@@ -295,10 +306,11 @@
/**
* Put an attribute in template definition.
* Attribute can be used as content for tag get.
- * @param name Attribute name
+ *
+ * @param name Attribute name
* @param content Attribute value
- * @param type attribute type: template, string, definition
- * @param role Determine if content is used by get tag. If user is in role, content is used.
+ * @param type attribute type: template, string, definition
+ * @param role Determine if content is used by get tag. If user is in role, content is used.
*/
public void put(String name, Object content, String type, String role) {
// Is there a type set ?
@@ -340,6 +352,7 @@
/**
* Set associated preparer type.
* Type denote a fully qualified classname.
+ *
* @param preparerType Typeof associated preparer
*/
public void setPreparerType(String preparerType) {
@@ -351,6 +364,7 @@
* type as "url".
* Name must be an url (not checked).
* Convenience method.
+ *
* @param preparer ViewPreparer url
*/
public void setPreparerUrl(String preparer) {
@@ -363,6 +377,7 @@
* type as "classname".
* Name denote a fully qualified classname
* Convenience method.
+ *
* @param preparer ViewPreparer classname.
*/
public void setPreparerClass(String preparer) {
@@ -383,6 +398,7 @@
* Set associated preparer URL.
* URL should be local to webcontainer in order to allow request context followup.
* URL is specified as a string.
+ *
* @param url Url called locally
*/
public void setPreparer(String url) {
@@ -391,6 +407,7 @@
/**
* Get preparer instance.
+ *
* @return preparer instance.
*/
public ViewPreparer getPreparerInstance() {
@@ -400,10 +417,11 @@
/**
* Get or create preparer.
* Get preparer, create it if necessary.
+ *
* @return preparer if preparer or preparerType is set, null otherwise.
* @throws InstantiationException if an error occur while instanciating ViewPreparer :
- * (classname can't be instanciated, Illegal access with instanciated class,
- * Error while instanciating class, classname can't be instanciated.
+ * (classname can't be instanciated, Illegal access with instanciated class,
+ * Error while instanciating class, classname can't be instanciated.
*/
public ViewPreparer getOrCreatePreparer() throws InstantiationException {
@@ -437,15 +455,16 @@
* Create a new instance of preparer named in parameter.
* If preparerType is specified, create preparer accordingly.
* Otherwise, if name denote a classname, create an instance of it. If class is
- * subclass of org.apache.struts.action.Action, wrap preparer
+ * subclass of org.apache.struts.action.Action, wrap preparer
* appropriately.
* Otherwise, consider name as an url.
- * @param name ViewPreparer name (classname, url, ...)
+ *
+ * @param name ViewPreparer name (classname, url, ...)
* @param preparerType Expected ViewPreparer type
* @return org.apache.struts.tiles.ViewPreparer
* @throws InstantiationException if an error occur while instanciating ViewPreparer :
- * (classname can't be instanciated, Illegal access with instanciated class,
- * Error while instanciating class, classname can't be instanciated.
+ * (classname can't be instanciated, Illegal access with instanciated class,
+ * Error while instanciating class, classname can't be instanciated.
*/
public static ViewPreparer createPreparer(String name, String preparerType)
throws InstantiationException {
@@ -476,11 +495,12 @@
/**
* Create a preparer from specified classname
+ *
* @param classname ViewPreparer classname.
* @return org.apache.struts.tiles.ViewPreparer
* @throws InstantiationException if an error occur while instanciating ViewPreparer :
- * (classname can't be instanciated, Illegal access with instanciated class,
- * Error while instanciating class, classname can't be instanciated.
+ * (classname can't be instanciated, Illegal access with instanciated class,
+ * Error while instanciating class, classname can't be instanciated.
*/
public static ViewPreparer createPreparerFromClassname(String classname)
throws InstantiationException {
@@ -513,96 +533,84 @@
}
}
- /**
- * Add an attribute to this component.
- *
- * This method is used by Digester to load definitions.
- *
- * @param attribute Attribute to add.
- */
- public void addAttribute( ComponentAttribute attribute)
- {
- putAttribute( attribute.getName(), attribute );
- }
-
- /**
- * Set extends.
- *
- * @param name Name of the extended definition.
- */
- public void setExtends(String name)
- {
- inherit = name;
- }
-
- /**
- * Get extends.
- *
- * @return Name of the extended definition.
- */
- public String getExtends()
- {
- return inherit;
- }
-
- /**
- * Get extends flag.
- *
- */
- public boolean isExtending( )
- {
- return inherit!=null;
- }
-
- /**
- * Sets the visit flag, used during inheritance resolution.
- *
- * @param isVisited <code>true</code> is the definition has been visited.
- *
- */
- public void setIsVisited( boolean isVisited )
- {
- this.isVisited = isVisited;
- }
-
- /**
- * Returns the visit flag, used during inheritance resolution.
- *
- * @return isVisited <code>true</code> is the definition has been visited.
- */
- public boolean isIsVisited()
- {
- return isVisited;
- }
-
-
- /**
- * Overload this definition with passed child.
- * All attributes from child are copied to this definition. Previous attributes with
- * same name are disguarded.
- * Special attribute 'path','role' and 'extends' are overloaded if defined in child.
- * @param child Child used to overload this definition.
- */
- public void overload( ComponentDefinition child )
- {
- if( child.getPath() != null )
- {
- path = child.getPath();
- }
- if( child.getExtends() != null )
- {
- inherit = child.getExtends();
- }
- if( child.getRole() != null )
- {
- role = child.getRole();
- }
- if( child.getPreparer()!=null )
- {
- preparer = child.getPreparer();
- preparerType = child.getPreparerType();
- }
- // put all child attributes in parent.
- attributes.putAll( child.getAttributes());
+ /**
+ * Add an attribute to this component.
+ * <p/>
+ * This method is used by Digester to load definitions.
+ *
+ * @param attribute Attribute to add.
+ */
+ public void addAttribute(ComponentAttribute attribute) {
+ putAttribute(attribute.getName(), attribute);
+ }
+
+ /**
+ * Set extends.
+ *
+ * @param name Name of the extended definition.
+ */
+ public void setExtends(String name) {
+ inherit = name;
+ }
+
+ /**
+ * Get extends.
+ *
+ * @return Name of the extended definition.
+ */
+ public String getExtends() {
+ return inherit;
+ }
+
+ /**
+ * Get extends flag.
+ */
+ public boolean isExtending() {
+ return inherit != null;
+ }
+
+ /**
+ * Sets the visit flag, used during inheritance resolution.
+ *
+ * @param isVisited <code>true</code> is the definition has been visited.
+ */
+ public void setIsVisited(boolean isVisited) {
+ this.isVisited = isVisited;
+ }
+
+ /**
+ * Returns the visit flag, used during inheritance resolution.
+ *
+ * @return isVisited <code>true</code> is the definition has been visited.
+ */
+ public boolean isIsVisited() {
+ return isVisited;
+ }
+
+
+ /**
+ * Overload this definition with passed child.
+ * All attributes from child are copied to this definition. Previous attributes with
+ * same name are disguarded.
+ * Special attribute 'path','role' and 'extends' are overloaded if defined in child.
+ *
+ * @param child Child used to overload this definition.
+ */
+ public void overload(ComponentDefinition child) {
+ if (child.getPath() != null) {
+ path = child.getPath();
+ }
+ if (child.getExtends() != null) {
+ inherit = child.getExtends();
+ }
+ if (child.getRole() != null) {
+ role = child.getRole();
+ }
+ if (child.getPreparer() != null) {
+ preparer = child.getPreparer();
+ preparerType = child.getPreparerType();
+ }
+ // put all child attributes in parent.
+ attributes.putAll(child.getAttributes());
}
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinition.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitions.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentDefinitions.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitions.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentDefinitions.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitions.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentDefinitions.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitions.java Wed Nov 1 18:03:00 2006
@@ -16,73 +16,73 @@
* limitations under the License.
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
import java.util.Locale;
import java.util.Map;
/**
* Interface for managing collections of {@link ComponentDefinition} objects.
- *
- * <p>The ComponentDefinitions interface provides a pattern for managing
+ * <p/>
+ * <p>The ComponentDefinitions interface provides a pattern for managing
* ComponentDefinition objects. Implementations will provide a means to append
* new ComponentDefinitions to the collection, add and retrieve lcale-specific
* ComponentDefinitions objects, and reset the collections.</p>
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public interface ComponentDefinitions {
-
+
/**
* Returns a ComponentDefinition object that matches the given name.
*
* @param name The name of the ComponentDefinition to return.
* @return the ComponentDefinition matching the given name or null if none
- * is found.
+ * is found.
*/
public ComponentDefinition getDefinition(String name);
-
+
/**
- * Adds new ComponentDefinition objects to the internal collection and
+ * Adds new ComponentDefinition objects to the internal collection and
* resolves inheritance attraibutes.
*
* @param defsMap The new definitions to add.
* @throws NoSuchDefinitionException if a ComponentDefinition extends from
- * one that doesn't exist.
+ * one that doesn't exist.
*/
- public void addDefinitions(Map defsMap) throws NoSuchDefinitionException ;
+ public void addDefinitions(Map defsMap) throws NoSuchDefinitionException;
/**
- * Adds new locale-specific ComponentDefinition objects to the internal
+ * Adds new locale-specific ComponentDefinition objects to the internal
* collection and resolves inheritance attraibutes.
*
* @param defsMap The new definitions to add.
- * @param locale The locale to add the definitions to.
+ * @param locale The locale to add the definitions to.
* @throws NoSuchDefinitionException if a ComponentDefinition extends from
- * one that doesn't exist.
+ * one that doesn't exist.
*/
- public void addDefinitions(Map defsMap, Locale locale) throws NoSuchDefinitionException ;
+ public void addDefinitions(Map defsMap, Locale locale) throws NoSuchDefinitionException;
/**
* Returns a ComponentDefinition object that matches the given name and locale.
*
- * @param name The name of the ComponentDefinition to return.
+ * @param name The name of the ComponentDefinition to return.
* @param locale The locale to use to resolve the definition.
* @return the ComponentDefinition matching the given name or null if none
- * is found.
+ * is found.
*/
public ComponentDefinition getDefinition(String name, Locale locale);
-
+
/**
* Resolves configuration inheritance properties.
*/
public void resolveInheritances() throws NoSuchDefinitionException;
-
+
/**
* Resolves locale-specific configuration inheritance properties.
*/
public void resolveInheritances(Locale locale) throws NoSuchDefinitionException;
-
+
/**
* Clears definitions.
*/
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitions.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitions.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentDefinitionsImpl.java Wed Nov 1 18:03:00 2006
@@ -18,29 +18,25 @@
package org.apache.tiles.definition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.definition.ComponentAttribute;
+
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tiles.ComponentAttribute;
-import org.apache.tiles.ComponentDefinition;
-import org.apache.tiles.ComponentDefinitions;
-import org.apache.tiles.NoSuchDefinitionException;
-
/**
- *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date$
*/
public class ComponentDefinitionsImpl implements ComponentDefinitions {
-
+
/**
- * Commons Logging instance.
+ * Commons Logging instance.
*/
private static Log log = LogFactory.getLog(ComponentDefinitionsImpl.class);
-
+
/**
* The base set of ComponentDefinition objects not discriminated by locale.
*/
@@ -49,8 +45,10 @@
* The locale-specific set of definitions objects.
*/
private Map localeSpecificDefinitions;
-
- /** Creates a new instance of ComponentDefinitionsImpl */
+
+ /**
+ * Creates a new instance of ComponentDefinitionsImpl
+ */
public ComponentDefinitionsImpl() {
baseDefinitions = new HashMap();
localeSpecificDefinitions = new HashMap();
@@ -58,19 +56,19 @@
/**
* Returns a ComponentDefinition object that matches the given name.
- *
+ *
* @param name The name of the ComponentDefinition to return.
* @return the ComponentDefinition matching the given name or null if none
- * is found.
+ * is found.
*/
public ComponentDefinition getDefinition(String name) {
return (ComponentDefinition) baseDefinitions.get(name);
}
/**
- * Adds new ComponentDefinition objects to the internal collection and
+ * Adds new ComponentDefinition objects to the internal collection and
* resolves inheritance attraibutes.
- *
+ *
* @param defsMap The new definitions to add.
*/
public void addDefinitions(Map defsMap) throws NoSuchDefinitionException {
@@ -80,25 +78,25 @@
}
/**
- * Adds new locale-specific ComponentDefinition objects to the internal
+ * Adds new locale-specific ComponentDefinition objects to the internal
* collection and resolves inheritance attraibutes.
*
* @param defsMap The new definitions to add.
- * @param locale The locale to add the definitions to.
+ * @param locale The locale to add the definitions to.
*/
public void addDefinitions(Map defsMap, Locale locale) throws NoSuchDefinitionException {
localeSpecificDefinitions.put(locale, defsMap);
resolveAttributeDependencies(locale);
resolveInheritances(locale);
}
-
+
/**
* Returns a ComponentDefinition object that matches the given name and locale.
*
- * @param name The name of the ComponentDefinition to return.
+ * @param name The name of the ComponentDefinition to return.
* @param locale The locale to use to resolve the definition.
* @return the ComponentDefinition matching the given name or null if none
- * is found.
+ * is found.
*/
public ComponentDefinition getDefinition(String name, Locale locale) {
ComponentDefinition definition = null;
@@ -106,41 +104,41 @@
if (localeSpecificMap != null) {
definition = (ComponentDefinition) localeSpecificMap.get(name);
}
-
+
if (definition == null) {
definition = getDefinition(name);
}
-
+
return definition;
}
-
+
/**
* Resolve extended instances.
*/
public void resolveInheritances() throws NoSuchDefinitionException {
Iterator i = baseDefinitions.values().iterator();
- while( i.hasNext() ) {
- ComponentDefinition definition = (ComponentDefinition)i.next();
- resolveInheritance( definition );
+ while (i.hasNext()) {
+ ComponentDefinition definition = (ComponentDefinition) i.next();
+ resolveInheritance(definition);
} // end loop
}
-
+
/**
* Resolve locale-specific extended instances.
*/
public void resolveInheritances(Locale locale) throws NoSuchDefinitionException {
resolveInheritances();
-
+
Map map = (Map) localeSpecificDefinitions.get(locale);
if (map != null) {
Iterator i = map.values().iterator();
- while( i.hasNext() ) {
- ComponentDefinition definition = (ComponentDefinition)i.next();
- resolveInheritance( definition, locale );
+ while (i.hasNext()) {
+ ComponentDefinition definition = (ComponentDefinition) i.next();
+ resolveInheritance(definition, locale);
} // end loop
}
}
-
+
/**
* Clears definitions.
*/
@@ -155,10 +153,10 @@
public Map getBaseDefinitions() {
return this.baseDefinitions;
}
-
+
public void resolveAttributeDependencies() {
Iterator i = this.baseDefinitions.values().iterator();
-
+
while (i.hasNext()) {
ComponentDefinition def = (ComponentDefinition) i.next();
Map attributes = def.getAttributes();
@@ -167,9 +165,9 @@
ComponentAttribute attr = (ComponentAttribute) j.next();
if (attr.getType() != null) {
if (attr.getType().equalsIgnoreCase("definition") ||
- attr.getType().equalsIgnoreCase("instance")) {
- ComponentDefinition subDef =
- getDefinitionByAttribute(attr);
+ attr.getType().equalsIgnoreCase("instance")) {
+ ComponentDefinition subDef =
+ getDefinitionByAttribute(attr);
attr.setValue(subDef);
}
} else {
@@ -181,16 +179,16 @@
}
}
}
-
+
public void resolveAttributeDependencies(Locale locale) {
resolveAttributeDependencies(); // FIXME Is it necessary?
Map defsMap = (Map) localeSpecificDefinitions.get(locale);
if (defsMap == null) {
return;
}
-
+
Iterator i = defsMap.values().iterator();
-
+
while (i.hasNext()) {
ComponentDefinition def = (ComponentDefinition) i.next();
Map attributes = def.getAttributes();
@@ -199,14 +197,14 @@
ComponentAttribute attr = (ComponentAttribute) j.next();
if (attr.getType() != null) {
if (attr.getType().equalsIgnoreCase("definition") ||
- attr.getType().equalsIgnoreCase("instance")) {
+ attr.getType().equalsIgnoreCase("instance")) {
ComponentDefinition subDef = getDefinitionByAttribute(
- attr, locale);
+ attr, locale);
attr.setValue(subDef);
}
} else {
ComponentDefinition subDef = getDefinitionByAttribute(attr,
- locale);
+ locale);
if (subDef != null) {
attr.setValue(subDef);
}
@@ -214,69 +212,70 @@
}
}
}
-
+
/**
* Searches for a definition specified as an attribute.
- *
+ *
* @param attr The attribute to use.
* @return The required definition if found, otherwise it returns
- * <code>null</code>.
+ * <code>null</code>.
*/
private ComponentDefinition getDefinitionByAttribute(
- ComponentAttribute attr) {
+ ComponentAttribute attr) {
ComponentDefinition retValue = null;
-
+
Object attrValue = attr.getValue();
if (attrValue instanceof ComponentDefinition) {
retValue = (ComponentDefinition) attrValue;
} else if (attrValue instanceof String) {
retValue = this.getDefinition((String) attr
- .getValue());
+ .getValue());
}
-
+
return retValue;
}
-
+
/**
* Searches for a definition specified as an attribute.
- *
- * @param attr The attribute to use.
+ *
+ * @param attr The attribute to use.
* @param locale The locale to search into.
* @return The required definition if found, otherwise it returns
- * <code>null</code>.
+ * <code>null</code>.
*/
private ComponentDefinition getDefinitionByAttribute(
- ComponentAttribute attr, Locale locale) {
+ ComponentAttribute attr, Locale locale) {
ComponentDefinition retValue = null;
-
+
Object attrValue = attr.getValue();
if (attrValue instanceof ComponentDefinition) {
retValue = (ComponentDefinition) attrValue;
} else if (attrValue instanceof String) {
retValue = this.getDefinition((String) attr
- .getValue(), locale);
+ .getValue(), locale);
}
-
+
return retValue;
}
-
+
/**
* Resolve inheritance.
* First, resolve parent's inheritance, then set path to the parent's path.
* Also copy attributes setted in parent, and not set in child
* If instance doesn't extend anything, do nothing.
+ *
* @throws NoSuchDefinitionException If an inheritance can not be solved.
*/
protected void resolveInheritance(ComponentDefinition definition)
- throws NoSuchDefinitionException {
+ throws NoSuchDefinitionException {
// Already done, or not needed ?
if (definition.isIsVisited() || !definition.isExtending())
return;
if (log.isDebugEnabled())
log.debug("Resolve definition for child name='"
- + definition.getName()
- + "' extends='" + definition.getExtends() + "'.");
+ + definition.getName()
+ + "' extends='" + definition.getExtends() + "'.");
// Set as visited to avoid endless recurisvity.
definition.setIsVisited(true);
@@ -285,10 +284,10 @@
ComponentDefinition parent = getDefinition(definition.getExtends());
if (parent == null) { // error
String msg = "Error while resolving definition inheritance: child '"
- + definition.getName()
- + "' can't find its ancestor '"
- + definition.getExtends()
- + "'. Please check your description file.";
+ + definition.getName()
+ + "' can't find its ancestor '"
+ + definition.getExtends()
+ + "'. Please check your description file.";
log.error(msg);
// to do : find better exception
throw new NoSuchDefinitionException(msg);
@@ -298,37 +297,38 @@
overload(parent, definition);
}
-
+
/**
* Resolve locale-specific inheritance.
* First, resolve parent's inheritance, then set path to the parent's path.
* Also copy attributes setted in parent, and not set in child
* If instance doesn't extend anything, do nothing.
+ *
* @throws NoSuchDefinitionException If an inheritance can not be solved.
*/
protected void resolveInheritance(ComponentDefinition definition,
- Locale locale) throws NoSuchDefinitionException {
+ Locale locale) throws NoSuchDefinitionException {
// Already done, or not needed ?
if (definition.isIsVisited() || !definition.isExtending())
return;
if (log.isDebugEnabled())
log.debug("Resolve definition for child name='"
- + definition.getName()
- + "' extends='" + definition.getExtends() + "'.");
+ + definition.getName()
+ + "' extends='" + definition.getExtends() + "'.");
// Set as visited to avoid endless recurisvity.
definition.setIsVisited(true);
// Resolve parent before itself.
ComponentDefinition parent = getDefinition(definition.getExtends(),
- locale);
+ locale);
if (parent == null) { // error
String msg = "Error while resolving definition inheritance: child '"
- + definition.getName()
- + "' can't find its ancestor '"
- + definition.getExtends()
- + "'. Please check your description file.";
+ + definition.getName()
+ + "' can't find its ancestor '"
+ + definition.getExtends()
+ + "'. Please check your description file.";
log.error(msg);
// to do : find better exception
throw new NoSuchDefinitionException(msg);
@@ -338,18 +338,19 @@
overload(parent, definition);
}
-
+
/**
* Overloads a child definition with a given parent.
* All attributes present in child are kept. All missing attributes are
* copied from the parent.
* Special attribute 'path','role' and 'extends' are overloaded in child if
* not defined
+ *
* @param parent The parent definition.
- * @param child The child that will be overloaded.
+ * @param child The child that will be overloaded.
*/
protected void overload(ComponentDefinition parent,
- ComponentDefinition child) {
+ ComponentDefinition child) {
// Iterate on each parent's attribute and add it if not defined in child.
Iterator parentAttributes = parent.getAttributes().keySet().iterator();
while (parentAttributes.hasNext()) {
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentListAttribute.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentListAttribute.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentListAttribute.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentListAttribute.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentListAttribute.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ComponentListAttribute.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentListAttribute.java Wed Nov 1 18:03:00 2006
@@ -17,7 +17,7 @@
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
import java.util.ArrayList;
import java.util.List;
@@ -33,60 +33,65 @@
* @version $Rev$ $Date$
*/
public class ComponentListAttribute extends ComponentAttribute {
- /** List.
+ /**
+ * List.
* We declare a List to avoid cast.
* Parent "value" property points to the same list.
*/
- private List list;
+ private List list;
/**
* Constructor.
*/
- public ComponentListAttribute() {
- list = new ArrayList();
- setValue(list);
- }
+ public ComponentListAttribute() {
+ list = new ArrayList();
+ setValue(list);
+ }
/**
* Constructor.
- * @param name Name.
+ *
+ * @param name Name.
* @param value List.
*/
- public ComponentListAttribute( String name, List value) {
- super( name, value );
- list = value;
- }
+ public ComponentListAttribute(String name, List value) {
+ super(name, value);
+ list = value;
+ }
/**
* Add an element in list.
* We use a property to avoid rewriting a new class.
+ *
* @param element XmlAttribute to add.
*/
- public void add( ComponentAttribute element ) {
- list.add( element.getValue() );
- }
+ public void add(ComponentAttribute element) {
+ list.add(element.getValue());
+ }
/**
* Add an element in list.
+ *
* @param value Object to add.
*/
- public void add( Object value ) {
- //list.add( value );
- // To correct a bug in digester, we need to check the object type
- // Digester doesn't call correct method according to object type ;-(
- if(value instanceof ComponentAttribute) {
- add((ComponentAttribute)value);
- return;
- } else {
- list.add( value );
+ public void add(Object value) {
+ //list.add( value );
+ // To correct a bug in digester, we need to check the object type
+ // Digester doesn't call correct method according to object type ;-(
+ if (value instanceof ComponentAttribute) {
+ add((ComponentAttribute) value);
+ return;
+ } else {
+ list.add(value);
+ }
}
- }
/**
* Add an element in list.
+ *
* @param value Object to add.
*/
- public void addObject( Object value ) {
+ public void addObject( Object value ) {
list.add( value );
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentListAttribute.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ComponentListAttribute.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactory.java (from r470071, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactory.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactory.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactory.java&r1=470071&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactory.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactory.java Wed Nov 1 18:03:00 2006
@@ -16,38 +16,39 @@
* limitations under the License.
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
+
+import org.apache.tiles.TilesRequestContext;
import java.util.Map;
/**
- * Interface for creating a {@link ComponentDefinitions} object and managing
+ * Interface for creating a {@link org.apache.tiles.definition.ComponentDefinitions} object and managing
* its contents.
- *
+ * <p/>
* <p>DefinitionsFactory implementations are responsible for maintaining the data
- * sources of Tiles configuration data and using the data to create
+ * sources of Tiles configuration data and using the data to create
* ComponentDefinitions sets. Implementations also know how to append
* locale-specific configuration data to an existing ComponentDefinitions set.</p>
*
- *
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date$
*/
public interface DefinitionsFactory {
-
+
/**
* Property name that specifies the implementation of the DefinitionsReader.
*/
public static final String READER_IMPL_PROPERTY =
- "org.apache.tiles.DefinitionsReader";
+ "org.apache.tiles.definition.DefinitionsReader";
/**
* Property name that specifies the implementation of ComponentDefinitions.
*/
public static final String DEFINITIONS_IMPL_PROPERTY =
- "org.apache.tiles.ComponentDefinitions";
-
+ "org.apache.tiles.definition.ComponentDefinitions";
+
/**
* Initializes the DefinitionsFactory and its subcomponents.
- *
+ * <p/>
* Implementations may support configuration properties to be passed in via
* the params Map.
*
@@ -55,43 +56,43 @@
* @throws DefinitionsFactoryException if an initialization error occurs.
*/
public void init(Map<String, String> params) throws DefinitionsFactoryException;
-
+
/**
* Returns a ComponentDefinition object that matches the given name and
* Tiles context
*
- * @param name The name of the ComponentDefinition to return.
+ * @param name The name of the ComponentDefinition to return.
* @param tilesContext The Tiles context to use to resolve the definition.
* @return the ComponentDefinition matching the given name or null if none
- * is found.
+ * is found.
* @throws DefinitionsFactoryException if an error occurs reading definitions.
*/
public ComponentDefinition getDefinition(String name,
- TilesRequestContext tilesContext) throws DefinitionsFactoryException;
-
+ TilesRequestContext tilesContext) throws DefinitionsFactoryException;
+
/**
* Adds a source where ComponentDefinition objects are stored.
- *
+ * <p/>
* Implementations should publish what type of source object they expect.
* The source should contain enough information to resolve a configuration
* source containing definitions. The source should be a "base" source for
* configurations. Internationalization and Localization properties will be
* applied by implementations to discriminate the correct data sources based
* on locale.
- *
+ *
* @param source The configuration source for definitions.
* @throws DefinitionsFactoryException if an invalid source is passed in or
- * an error occurs resolving the source to an actual data store.
+ * an error occurs resolving the source to an actual data store.
*/
public void addSource(Object source) throws DefinitionsFactoryException;
-
+
/**
- * Creates and returns a {@link ComponentDefinitions} set by reading
+ * Creates and returns a {@link ComponentDefinitions} set by reading
* configuration data from the applied sources.
*
- * @throws DefinitionsFactoryException if an error occurs reading the
- * sources.
+ * @throws DefinitionsFactoryException if an error occurs reading the
+ * sources.
*/
- public ComponentDefinitions readDefinitions()
- throws DefinitionsFactoryException;
+ public ComponentDefinitions readDefinitions()
+ throws DefinitionsFactoryException;
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryConfig.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactoryConfig.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryConfig.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactoryConfig.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryConfig.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactoryConfig.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryConfig.java Wed Nov 1 18:03:00 2006
@@ -16,7 +16,9 @@
* limitations under the License.
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
+
+import org.apache.commons.beanutils.BeanUtils;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
@@ -25,14 +27,12 @@
import java.util.Map;
import java.util.Set;
-import org.apache.commons.beanutils.BeanUtils;
-
/**
* A TilesFactoryConfig object hold configuration attributes for a tile
* definition impl.
*
- * @since Struts 1.1
* @version $Rev$ $Date$
+ * @since Struts 1.1
*/
public class DefinitionsFactoryConfig implements Serializable {
@@ -50,8 +50,8 @@
*/
protected boolean parserValidate = true;
- /**
- * Definition configuration file specified by user.
+ /**
+ * Definition configuration file specified by user.
*/
protected String definitionConfigFiles = null;
@@ -70,33 +70,35 @@
*/
protected String factoryName;
- /**
- * Alternate name for parser debug details properties in configuration file.
+ /**
+ * Alternate name for parser debug details properties in configuration file.
+ *
* @deprecated This will be removed in a release after Struts 1.2.
*/
public static final String PARSER_DETAILS_PARAMETER_NAME =
"definitions-parser-details";
/**
- * Alternate name for parser validate properties in configuration file.
+ * Alternate name for parser validate properties in configuration file.
*/
public static final String PARSER_VALIDATE_PARAMETER_NAME =
"definitions-parser-validate";
- /**
+ /**
* Alternate name for impl classname properties in configuration file.
*/
public static final String FACTORY_CLASSNAME_PARAMETER_NAME =
"definitions-impl-class";
- /**
- * Alternate name for definition files properties in configuration file.
+ /**
+ * Alternate name for definition files properties in configuration file.
*/
public static final String DEFINITIONS_CONFIG_PARAMETER_NAME =
"definitions-config";
- /**
- * Alternate name for definition debug details properties in configuration file.
+ /**
+ * Alternate name for definition debug details properties in configuration file.
+ *
* @deprecated This will be removed in a release after Struts 1.2.
*/
public static final String TILES_DETAILS_PARAMETER_NAME = "definitions-debug";
@@ -118,6 +120,7 @@
* Create configuration object, and initialize it with parameters from Map.
* Parameters corresponding to an attribute are filtered and stored in appropriate
* attribute.
+ *
* @param initParameters Map.
*/
public DefinitionsFactoryConfig(Map initParameters) {
@@ -126,16 +129,19 @@
/**
* Get the module aware flag.
+ *
* @return <code>true</code>: user wants a single impl instance,
- * <code>false</code>: user wants multiple impl instances (one per module with Struts)
+ * <code>false</code>: user wants multiple impl instances (one per module with Struts)
*/
public boolean isModuleAware() {
return moduleAware;
}
+
/**
* Set the module aware flag.
+ *
* @param moduleAware <code>true</code>: user wants a single impl instance,
- * <code>false</code>: user wants multiple impl instances (one per module with Struts)
+ * <code>false</code>: user wants multiple impl instances (one per module with Struts)
*/
public void setModuleAware(boolean moduleAware) {
this.moduleAware = moduleAware;
@@ -143,6 +149,7 @@
/**
* Get the classname of the impl.
+ *
* @return Classname.
*/
public String getFactoryClassname() {
@@ -151,6 +158,7 @@
/**
* Set the classname of the impl..
+ *
* @param aFactoryClassname Classname of the impl.
*/
public void setFactoryClassname(String aFactoryClassname) {
@@ -159,6 +167,7 @@
/**
* Determines if the parser is validating.
+ *
* @return <code>true<code> when in validating mode.
*/
public boolean getParserValidate() {
@@ -167,6 +176,7 @@
/**
* Set the validating mode for the parser.
+ *
* @param aParserValidate <code>true</code> for validation, <code>false</code> otherwise
*/
public void setParserValidate(boolean aParserValidate) {
@@ -175,6 +185,7 @@
/**
* Get the definition config files.
+ *
* @return Defition config files.
*/
public String getDefinitionConfigFiles() {
@@ -183,6 +194,7 @@
/**
* Set the definition config files.
+ *
* @param aDefinitionConfigFiles Definition config files.
*/
public void setDefinitionConfigFiles(String aDefinitionConfigFiles) {
@@ -191,7 +203,8 @@
/**
* Set value of an additional attribute.
- * @param name Name of the attribute.
+ *
+ * @param name Name of the attribute.
* @param value Value of the attribute.
*/
public void setAttribute(String name, Object value) {
@@ -200,6 +213,7 @@
/**
* Get value of an additional attribute.
+ *
* @param name Name of the attribute.
* @return Value of the attribute, or null if not found.
*/
@@ -209,6 +223,7 @@
/**
* Get additional attributes as a Map.
+ *
* @return Map A Map containing attribute name - value pairs.
*/
public Map getAttributes() {
@@ -230,28 +245,27 @@
* Populate this config object from properties map, based on
* the specified name/value pairs. This method uses the populate() method from
* org.apache.commons.beanutils.BeanUtil.
- * <p>
+ * <p/>
* Properties keys are scanned for old property names, and linked to the new name
* if necessary. This modifies the properties map.
- * <p>
+ * <p/>
* The particular setter method to be called for each property is
* determined using the usual JavaBeans introspection mechanisms. Thus,
* you may identify custom setter methods using a BeanInfo class that is
* associated with the class of the bean itself. If no such BeanInfo
* class is available, the standard method name conversion ("set" plus
* the capitalized name of the property in question) is used.
- * <p>
+ * <p/>
* <strong>NOTE</strong>: It is contrary to the JavaBeans Specification
* to have more than one setter method (with different argument
* signatures) for the same property.
*
* @param properties Map keyed by property name, with the
- * corresponding (String or String[]) value(s) to be set.
- *
- * @exception IllegalAccessException if the caller does not have
- * access to the property accessor method.
- * @exception InvocationTargetException if the property accessor method
- * throws an exception.
+ * corresponding (String or String[]) value(s) to be set.
+ * @throws IllegalAccessException if the caller does not have
+ * access to the property accessor method.
+ * @throws InvocationTargetException if the property accessor method
+ * throws an exception.
* @see org.apache.commons.beanutils.BeanUtils
*/
public void populate(Map properties)
@@ -266,8 +280,9 @@
/**
* Link old property names to new property names.
* This modifies the map.
+ *
* @param properties Map keyed by property name, with the
- * corresponding (String or String[]) value(s) to be set.
+ * corresponding (String or String[]) value(s) to be set.
*/
static public void linkOldPropertyNames(Map properties) {
Set entries = properties.entrySet();
@@ -304,24 +319,26 @@
public String getFactoryName() {
return factoryName;
}
+
/**
* Set the impl name.
+ *
* @param factoryName Name of the impl.
*/
public void setFactoryName(String factoryName) {
this.factoryName = factoryName;
}
-
+
/**
* Adds all implementation-specific extra attributes from the configuration.
- *
+ *
* @param properties Map keyed by property name, with the
- * corresponding (String or String[]) value(s) to be set.
+ * corresponding (String or String[]) value(s) to be set.
*/
protected void populateExtraAttributes(Map properties) {
setAttribute(DefinitionsFactory.READER_IMPL_PROPERTY,
- properties.get(DefinitionsFactory.READER_IMPL_PROPERTY));
+ properties.get(DefinitionsFactory.READER_IMPL_PROPERTY));
setAttribute(DefinitionsFactory.DEFINITIONS_IMPL_PROPERTY,
- properties.get(DefinitionsFactory.DEFINITIONS_IMPL_PROPERTY));
+ properties.get(DefinitionsFactory.DEFINITIONS_IMPL_PROPERTY));
}
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryConfig.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryException.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactoryException.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryException.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactoryException.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryException.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsFactoryException.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryException.java Wed Nov 1 18:03:00 2006
@@ -17,104 +17,102 @@
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
- /**
- * Exception thrown when an error occurs while the impl tries to
- * create a new instance mapper.
- */
-public class DefinitionsFactoryException extends TilesException
-{
- /**
- * Constructor.
- */
- public DefinitionsFactoryException()
- {
- super();
- this.exception = null;
- }
-
- /**
- * Constructor.
- * @param message The error or warning message.
- */
- public DefinitionsFactoryException(String message)
- {
- super(message);
- this.exception = null;
- }
-
-
- /**
- * Create a new <code>DefinitionsFactoryException</code> wrapping an existing exception.
- *
- * <p>The existing exception will be embedded in the new
- * one and its message will become the default message for
- * the DefinitionsFactoryException.</p>
- *
- * @param e The exception to be wrapped.
- */
- public DefinitionsFactoryException(Exception e)
- {
- super();
- this.exception = e;
- }
-
-
- /**
- * Create a new <code>DefinitionsFactoryException</code> from an existing exception.
- *
- * <p>The existing exception will be embedded in the new
- * one, but the new exception will have its own message.</p>
- *
- * @param message The detail message.
- * @param e The exception to be wrapped.
- */
- public DefinitionsFactoryException(String message, Exception e)
- {
- super(message);
- this.exception = e;
- }
-
-
- /**
- * Return a detail message for this exception.
- *
- * <p>If there is a embedded exception, and if the DefinitionsFactoryException
- * has no detail message of its own, this method will return
- * the detail message from the embedded exception.</p>
- *
- * @return The error or warning message.
- */
- public String getMessage ()
- {
- String message = super.getMessage ();
-
- if (message == null && exception != null) {
- return exception.getMessage();
- } else {
- return message;
- }
- }
-
-
- /**
- * Return the embedded exception, if any.
- * @return The embedded exception, or <code>null</code> if there is none.
- */
- public Exception getException ()
- {
- return exception;
- }
-
- //////////////////////////////////////////////////////////////////////
- // Internal state.
- //////////////////////////////////////////////////////////////////////
-
-
- /**
- * Any "wrapped" exception will be exposed when this is serialized.
- * @serial
- */
- private Exception exception;
+import org.apache.tiles.TilesException;
+
+/**
+ * Exception thrown when an error occurs while the impl tries to
+ * create a new instance mapper.
+ */
+public class DefinitionsFactoryException extends TilesException {
+ /**
+ * Constructor.
+ */
+ public DefinitionsFactoryException() {
+ super();
+ this.exception = null;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param message The error or warning message.
+ */
+ public DefinitionsFactoryException(String message) {
+ super(message);
+ this.exception = null;
+ }
+
+
+ /**
+ * Create a new <code>DefinitionsFactoryException</code> wrapping an existing exception.
+ * <p/>
+ * <p>The existing exception will be embedded in the new
+ * one and its message will become the default message for
+ * the DefinitionsFactoryException.</p>
+ *
+ * @param e The exception to be wrapped.
+ */
+ public DefinitionsFactoryException(Exception e) {
+ super();
+ this.exception = e;
+ }
+
+
+ /**
+ * Create a new <code>DefinitionsFactoryException</code> from an existing exception.
+ * <p/>
+ * <p>The existing exception will be embedded in the new
+ * one, but the new exception will have its own message.</p>
+ *
+ * @param message The detail message.
+ * @param e The exception to be wrapped.
+ */
+ public DefinitionsFactoryException(String message, Exception e) {
+ super(message);
+ this.exception = e;
+ }
+
+
+ /**
+ * Return a detail message for this exception.
+ * <p/>
+ * <p>If there is a embedded exception, and if the DefinitionsFactoryException
+ * has no detail message of its own, this method will return
+ * the detail message from the embedded exception.</p>
+ *
+ * @return The error or warning message.
+ */
+ public String getMessage() {
+ String message = super.getMessage();
+
+ if (message == null && exception != null) {
+ return exception.getMessage();
+ } else {
+ return message;
+ }
+ }
+
+
+ /**
+ * Return the embedded exception, if any.
+ *
+ * @return The embedded exception, or <code>null</code> if there is none.
+ */
+ public Exception getException() {
+ return exception;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Internal state.
+ //////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Any "wrapped" exception will be exposed when this is serialized.
+ *
+ * @serial
+ */
+ private Exception exception;
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsFactoryException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsReader.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsReader.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsReader.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsReader.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsReader.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/DefinitionsReader.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsReader.java Wed Nov 1 18:03:00 2006
@@ -16,48 +16,47 @@
* limitations under the License.
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
import java.util.Map;
/**
- * Interface for reading <code>{@link ComponentDefinition}</code> from a source.
- *
- * <p>This interface provides a standard way to read
- * <code>{@link ComponentDefinition}</code> objects from a source. Implementations
+ * Interface for reading <code>{@link org.apache.tiles.definition.ComponentDefinition}</code> from a source.
+ * <p/>
+ * <p>This interface provides a standard way to read
+ * <code>{@link org.apache.tiles.definition.ComponentDefinition}</code> objects from a source. Implementations
* should define what the source is, whether it be a persistent store such as a
- * configuration file or database, or something like a web service. The
+ * configuration file or database, or something like a web service. The
* DefinitionsReader is responsible for reading from a single location. It does
* not perform any internationalization duties or inheritance of ComponentDefinitions.
* It only reads from the source and returns a Map of objects read.</p>
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date$
*/
public interface DefinitionsReader {
/**
* Initializes the <code>DefinitionsReader</code> object.
- *
+ * <p/>
* This method must be called before the {@link #read(java.lang.Object)} method is called.
*
* @param params A map of properties used to set up the reader.
* @throws DefinitionsFactoryException if required properties are not
- * passed in or the initialization fails.
- *
+ * passed in or the initialization fails.
*/
public void init(Map params) throws DefinitionsFactoryException;
-
+
/**
- * Reads <code>{@link ComponentDefinition}</code> objects from a source.
- *
+ * Reads <code>{@link org.apache.tiles.definition.ComponentDefinition}</code> objects from a source.
+ * <p/>
* Implementations should publish what type of source object is expected.
*
* @param source The source from which definitions will be read.
* @return a Map of <code>ComponentDefinition</code> objects read from
- * the source.
+ * the source.
* @throws DefinitionsFactoryException if the source is invalid or
- * an error occurs when reading definitions.
+ * an error occurs when reading definitions.
*/
public Map read(Object source) throws DefinitionsFactoryException;
-
+
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/DefinitionsReader.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/FactoryNotFoundException.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/FactoryNotFoundException.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/FactoryNotFoundException.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/FactoryNotFoundException.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/FactoryNotFoundException.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/FactoryNotFoundException.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/FactoryNotFoundException.java Wed Nov 1 18:03:00 2006
@@ -17,26 +17,25 @@
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
- /**
- * Exception thrown when definitions impl is not found.
- */
-public class FactoryNotFoundException extends DefinitionsFactoryException
-{
+/**
+ * Exception thrown when definitions impl is not found.
+ */
+public class FactoryNotFoundException extends DefinitionsFactoryException {
/**
* Constructor.
*/
- public FactoryNotFoundException()
- {
- super();
+ public FactoryNotFoundException() {
+ super();
}
+
/**
* Constructor.
+ *
* @param msg Message.
*/
- public FactoryNotFoundException( String msg )
- {
- super(msg);
+ public FactoryNotFoundException(String msg) {
+ super(msg);
}
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/FactoryNotFoundException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/FactoryNotFoundException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/NoSuchDefinitionException.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/NoSuchDefinitionException.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/NoSuchDefinitionException.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/NoSuchDefinitionException.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/NoSuchDefinitionException.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/NoSuchDefinitionException.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/NoSuchDefinitionException.java Wed Nov 1 18:03:00 2006
@@ -17,26 +17,25 @@
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
- /**
- * Exception thrown when a definition is not found.
- */
-public class NoSuchDefinitionException extends DefinitionsFactoryException
-{
+/**
+ * Exception thrown when a definition is not found.
+ */
+public class NoSuchDefinitionException extends DefinitionsFactoryException {
/**
* Constructor.
*/
- public NoSuchDefinitionException()
- {
- super();
+ public NoSuchDefinitionException() {
+ super();
}
+
/**
* Constructor.
+ *
* @param msg Message.
*/
- public NoSuchDefinitionException( String msg )
- {
- super(msg);
+ public NoSuchDefinitionException(String msg) {
+ super(msg);
}
}
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/NoSuchDefinitionException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/NoSuchDefinitionException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Copied: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ReloadableDefinitionsFactory.java (from r469623, struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ReloadableDefinitionsFactory.java)
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ReloadableDefinitionsFactory.java?view=diff&rev=470185&p1=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ReloadableDefinitionsFactory.java&r1=469623&p2=struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ReloadableDefinitionsFactory.java&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/ReloadableDefinitionsFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ReloadableDefinitionsFactory.java Wed Nov 1 18:03:00 2006
@@ -17,15 +17,15 @@
*/
-package org.apache.tiles;
+package org.apache.tiles.definition;
/**
* Indicates support for reloading Tiles configuration when it changes.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date$
*/
public interface ReloadableDefinitionsFactory {
-
+
/**
* Indicates whether the DefinitionsFactory is out of date and needs to be
* reloaded.
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ReloadableDefinitionsFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/ReloadableDefinitionsFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java?view=diff&rev=470185&r1=470184&r2=470185
==============================================================================
--- struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java (original)
+++ struts/sandbox/trunk/tiles/tiles-core/src/main/java/org/apache/tiles/definition/UrlDefinitionsFactory.java Wed Nov 1 18:03:00 2006
@@ -17,30 +17,30 @@
*/
package org.apache.tiles.definition;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.TilesRequestContext;
+import org.apache.tiles.definition.digester.DigesterDefinitionsReader;
+import org.apache.tiles.util.RequestUtils;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
-import org.apache.tiles.util.RequestUtils;
-import org.apache.tiles.*;
-import org.apache.tiles.digester.DigesterDefinitionsReader;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
/**
- * {@link org.apache.tiles.DefinitionsFactory DefinitionsFactory} implementation
+ * {@link DefinitionsFactory DefinitionsFactory} implementation
* that manages ComponentDefinitions configuration data from URLs.
* <p/>
* <p>The ComponentDefinition objects are read from the
- * {@link org.apache.tiles.digester.DigesterDefinitionsReader DigesterDefinitionsReader}
+ * {@link org.apache.tiles.definition.digester.DigesterDefinitionsReader DigesterDefinitionsReader}
* class unless another implementation is specified.</p>
*
* @version $Rev$ $Date$
*/
public class UrlDefinitionsFactory
- implements DefinitionsFactory, ReloadableDefinitionsFactory {
+ implements DefinitionsFactory, ReloadableDefinitionsFactory {
/**
* LOG instance for all UrlDefinitionsFactory instances.
@@ -101,8 +101,8 @@
}
private ComponentDefinitions getComponentDefinitions()
- throws DefinitionsFactoryException {
- if(definitions == null) {
+ throws DefinitionsFactoryException {
+ if (definitions == null) {
definitions = readDefinitions();
}
return definitions;
@@ -121,7 +121,7 @@
*/
public ComponentDefinition getDefinition(String name,
TilesRequestContext tilesContext)
- throws DefinitionsFactoryException {
+ throws DefinitionsFactoryException {
ComponentDefinitions definitions = getComponentDefinitions();
Locale locale = tilesContext.getRequestLocale();
@@ -151,12 +151,12 @@
public void addSource(Object source) throws DefinitionsFactoryException {
if (source == null) {
throw new DefinitionsFactoryException(
- "Source object must not be null");
+ "Source object must not be null");
}
if (!(source instanceof URL)) {
throw new DefinitionsFactoryException(
- "Source object must be an URL");
+ "Source object must be an URL");
}
sources.add(source);
@@ -173,7 +173,7 @@
*/
protected void addDefinitions(ComponentDefinitions definitions,
TilesRequestContext tilesContext)
- throws DefinitionsFactoryException {
+ throws DefinitionsFactoryException {
Locale locale = tilesContext.getRequestLocale();
List<String> postfixes = calculatePostixes(locale);
@@ -195,15 +195,15 @@
URLConnection connection = newUrl.openConnection();
connection.connect();
lastModifiedDates.put(newUrl.toExternalForm(),
- connection.getLastModified());
+ connection.getLastModified());
Map defsMap = reader.read(connection.getInputStream());
definitions.addDefinitions(defsMap,
- tilesContext.getRequestLocale());
+ tilesContext.getRequestLocale());
} catch (FileNotFoundException e) {
// File not found. continue.
} catch (IOException e) {
throw new DefinitionsFactoryException(
- "I/O error processing configuration.");
+ "I/O error processing configuration.");
}
}
}
@@ -217,7 +217,7 @@
* sources.
*/
public ComponentDefinitions readDefinitions()
- throws DefinitionsFactoryException {
+ throws DefinitionsFactoryException {
ComponentDefinitions definitions = new ComponentDefinitionsImpl();
try {
for (Object source1 : sources) {
@@ -225,7 +225,7 @@
URLConnection connection = source.openConnection();
connection.connect();
lastModifiedDates.put(source.toExternalForm(),
- connection.getLastModified());
+ connection.getLastModified());
Map defsMap = reader.read(connection.getInputStream());
definitions.addDefinitions(defsMap);
}
@@ -367,17 +367,17 @@
private void createReader(String readerClassName) throws DefinitionsFactoryException {
try {
Class readerClass =
- RequestUtils.applicationClass(readerClassName);
+ RequestUtils.applicationClass(readerClassName);
reader = (DefinitionsReader) readerClass.newInstance();
} catch (ClassNotFoundException e) {
throw new DefinitionsFactoryException(
- "Cannot find reader class '" + readerClassName + "'.", e);
+ "Cannot find reader class '" + readerClassName + "'.", e);
} catch (InstantiationException e) {
throw new DefinitionsFactoryException(
- "Unable to instantiate reader class '" + readerClassName + "'.", e);
+ "Unable to instantiate reader class '" + readerClassName + "'.", e);
} catch (IllegalAccessException e) {
throw new DefinitionsFactoryException(
- "Unable to access reader class '" + readerClassName + "'.", e);
+ "Unable to access reader class '" + readerClassName + "'.", e);
}
}
}