struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dge...@apache.org
Subject svn commit: r190662 [3/6] - in /struts/sandbox/trunk/tiles: ./ core-library/ core-library/src/ core-library/src/conf/ core-library/src/java/ core-library/src/java/org/ core-library/src/java/org/apache/ core-library/src/java/org/apache/taglib/ core-library/src/java/org/apache/taglib/tiles/ core-library/src/java/org/apache/taglib/tiles/doc-files/ core-library/src/java/org/apache/taglib/tiles/util/ core-library/src/java/org/apache/tiles/ core-library/src/java/org/apache/tiles/beans/ core-library/src/java/org/apache/tiles/definition/ core-library/src/java/org/apache/tiles/doc-files/ core-library/src/java/org/apache/tiles/servlets/ core-library/src/java/org/apache/tiles/xmlDefinition/ core-library/src/java/org/apache/util/ core-library/src/test/ examples/ examples/simple/ examples/simple/WEB-INF/ examples/simple/WEB-INF/lib/ examples/simple/graphics/ examples/simple/graphics/flags/
Date Tue, 14 Jun 2005 21:59:17 GMT
Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentContext.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentContext.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentContext.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentContext.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.jsp.PageContext;
+
+import org.apache.taglib.tiles.ComponentConstants;
+
+/**
+ * Component context.
+ */
+public class ComponentContext implements Serializable {
+
+    /**
+     * Component attributes.
+     */
+    private Map attributes=null;
+
+    /**
+     * Constructor.
+     */
+    public ComponentContext() {
+        super();
+    }
+
+    /**
+     * Constructor.
+     * Create a context and set specified attributes.
+     * @param attributes Attributes to initialize context.
+     */
+    public ComponentContext(Map attributes) {
+        if (attributes != null) {
+            this.attributes = new HashMap(attributes);
+        }
+    }
+
+    /**
+     * Add all attributes to this context.
+     * Copies all of the mappings from the specified attribute map to this context.
+     * New attribute mappings will replace any mappings that this context had for any of the keys
+     * currently in the specified attribute map.
+     * @param newAttributes Attributes to add.
+     */
+    public void addAll(Map newAttributes) {
+        if (attributes == null) {
+            attributes = new HashMap(newAttributes);
+            return;
+        }
+        
+        attributes.putAll(newAttributes);
+    }
+
+    /**
+     * Add all missing attributes to this context.
+     * Copies all of the mappings from the specified attributes map to this context.
+     * New attribute mappings will be added only if they don't already exist in
+     * this context.
+     * @param defaultAttributes Attributes to add.
+     */
+    public void addMissing(Map defaultAttributes) {
+        if (defaultAttributes == null) {
+            return;
+        }
+        
+        if (attributes == null) {
+            attributes = new HashMap(defaultAttributes);
+            return;
+        }
+
+        Set entries = defaultAttributes.entrySet();
+        Iterator iterator = entries.iterator();
+        while (iterator.hasNext()) {
+            Map.Entry entry = (Map.Entry) iterator.next();
+            if (!attributes.containsKey(entry.getKey())) {
+                attributes.put(entry.getKey(), entry.getValue());
+            }
+        }
+    }
+
+    /**
+     * Get an attribute from context.
+     * @param name Name of the attribute.
+     * @return <{Object}>
+     */
+    public Object getAttribute(String name) {
+        if (attributes == null){
+            return null;
+        }
+        
+        return attributes.get(name);
+    }
+
+    /**
+     * Get names of all attributes.
+     * @return <{Object}>
+     */
+    public Iterator getAttributeNames() {
+        if (attributes == null) {
+            return Collections.EMPTY_LIST.iterator();
+        }
+        
+        return attributes.keySet().iterator();
+    }
+
+    /**
+     * Put a new attribute to context.
+     * @param name Name of the attribute.
+     * @param value Value of the attribute.
+     */
+    public void putAttribute(String name, Object value) {
+        if (attributes == null) {
+            attributes = new HashMap();
+        }
+
+        attributes.put(name, value);
+    }
+
+    /**
+     * Find object in one of the contexts.
+     * Order : component then pageContext.findAttribute()
+     * @param beanName Name of the bean to find.
+     * @param pageContext Page context.
+     * @return Requested bean or <code>null</code> if not found.
+     */
+    public Object findAttribute(String beanName, PageContext pageContext) {
+        Object attribute = getAttribute(beanName);
+        if (attribute == null) {
+            attribute = pageContext.findAttribute(beanName);
+        }
+        
+        return attribute;
+    }
+
+    /**
+     * Get object from requested context.
+     * Context can be 'component'.
+     * @param beanName Name of the bean to find.
+     * @param scope Search scope (see {@link PageContext}).
+     * @param pageContext Page context.
+     * @return requested bean or <code>null</code> if not found.
+     */
+    public Object getAttribute(
+        String beanName,
+        int scope,
+        PageContext pageContext) {
+            
+        if (scope == ComponentConstants.COMPONENT_SCOPE){
+            return getAttribute(beanName);
+        }
+        
+        return pageContext.getAttribute(beanName, scope);
+    }
+
+    /**
+     * Get component context from request.
+     * @param request ServletRequest.
+     * @return ComponentContext
+     */
+    static public ComponentContext getContext(ServletRequest request) {
+        return (ComponentContext) request.getAttribute(
+            ComponentConstants.COMPONENT_CONTEXT);
+    }
+
+    /**
+     * Store component context into request.
+     * @param context ComponentContext to store.
+     * @param request Request to store ComponentContext.
+     */
+    static public void setContext(
+        ComponentContext context,
+        ServletRequest request) {
+            
+        request.setAttribute(ComponentConstants.COMPONENT_CONTEXT, context);
+    }
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinition.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinition.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinition.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinition.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,545 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tiles.xmlDefinition.XmlDefinition;
+import org.apache.tiles.TilesUtil;
+
+/**
+ * Definition of a template / component attributes.
+ * Attributes of a component can be defined with the help of this class.
+ * An instance of this class can be used as a bean, and passed to 'insert' tag.
+ *
+ * @author Cedric Dumoulin
+ * @author David Geary
+ */
+public class ComponentDefinition implements Serializable {
+
+    /**
+     * Commons Logging instance. 
+     */
+    protected static Log log = LogFactory.getLog(ComponentDefinition.class);
+
+    /**
+     * Definition name
+     */
+    protected String name = null;
+
+    /**
+     * Component / template path (URL).
+     */
+    protected String path = null;
+
+    /**
+     * Attributes defined for the component.
+     */
+    protected Map attributes = null;
+
+    /** 
+     * Role associated to definition. 
+     */
+    protected String role = null;
+
+    /** Associated Controller URL or classname, if defined */
+    protected String controller = null;
+
+    /** 
+     * Associated Controller typename, if controllerName defined.
+     * Can be CONTROLLER, ACTION or URL, or null. 
+     */
+    protected String controllerType = null;
+
+    /** 
+     * Controller name type. 
+     */
+    public static final String URL = "url";
+
+    /** 
+     * Controller name type. 
+     */
+    public static final String CONTROLLER = "controller";
+
+    /** 
+     * Controller name type. 
+     */
+    public static final String ACTION = "action";
+
+    /**
+     * Controller associated to Definition.
+     * Lazy creation : only on first request
+     */
+    private Controller controllerInstance = null;
+
+    /**
+     * Constructor.
+     */
+    public ComponentDefinition() {
+        attributes = new HashMap();
+    }
+
+    /**
+     * Copy Constructor.
+     * Create a new definition initialized with parent definition.
+     * Do a shallow copy : attributes are shared between copies, but not the Map
+     * containing attributes.
+     */
+    public ComponentDefinition(ComponentDefinition definition) {
+        attributes = new HashMap(definition.getAttributes());
+        this.name = definition.getName();
+        this.path = definition.getPath();
+        this.role = definition.getRole();
+        this.controllerInstance = definition.getControllerInstance();
+        this.controller = definition.getController();
+        this.controllerType = definition.getControllerType();
+    }
+
+    /**
+     * Constructor.
+     * Create a new definition initialized from a RawDefinition.
+     * Raw definitions are used to read definition from a data source (xml file, db, ...).
+     * A RawDefinition mainly contains properties of type String, while Definition
+     * contains more complex type (ex : Controller).
+     * Do a shallow copy : attributes are shared between objects, but not the Map
+     * containing attributes.
+     * OO Design issues : Actually RawDefinition (XmlDefinition) extends ComponentDefinition.
+     * This must not be the case. I have do it because I am lazy.
+     * @throws InstantiationException if an error occur while instanciating Controller :
+     * (classname can't be instanciated, Illegal access with instanciated class,
+     * Error while instanciating class, classname can't be instanciated.
+     */
+    public ComponentDefinition(XmlDefinition definition) {
+
+        this((ComponentDefinition) definition);
+    }
+
+    /**
+     * Constructor.
+     */
+    public ComponentDefinition(String name, String path, Map attributes) {
+        this.name = name;
+        this.path = path;
+        this.attributes = attributes;
+    }
+
+    /**
+     * Access method for the name property.
+     *
+     * @return   the current value of the name property
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Sets the value of the name property.
+     *
+     * @param aName the new value of the name property
+     */
+    public void setName(String aName) {
+        name = aName;
+    }
+
+    /**
+     * Access method for the path property.
+     *
+     * @return The current value of the path property.
+     */
+    public String getPage() {
+        return path;
+    }
+
+    /**
+     * Sets the value of the path property.
+     *
+     * @param aPath the new value of the path property
+     */
+    public void setPage(String page) {
+        path = page;
+    }
+
+    /**
+     * Access method for the path property.
+     *
+     * @return   the current value of the path property
+     */
+    public String getPath() {
+        return path;
+    }
+
+    /**
+     * Sets the value of the path property.
+     *
+     * @param aPath the new value of the path property
+     */
+    public void setPath(String aPath) {
+        path = aPath;
+    }
+
+    /**
+     * Access method for the template property.
+     * Same as getPath()
+     * @return   the current value of the template property
+     */
+    public String getTemplate() {
+        return path;
+    }
+
+    /**
+     * Sets the value of the template property.
+     * Same as setPath()
+     *
+     * @param template the new value of the path property
+     */
+    public void setTemplate(String template) {
+        path = template;
+    }
+
+    /**
+     * Access method for the role property.
+     * @return   the current value of the role property
+     */
+    public String getRole() {
+        return role;
+    }
+
+    /**
+     * Sets the value of the role property.
+     *
+     * @param role the new value of the path property
+     */
+    public void setRole(String role) {
+        this.role = role;
+    }
+
+    /**
+     * Access method for the attributes property.
+     * If there is no attributes, return an empty map.
+     * @return   the current value of the attributes property
+     */
+    public Map getAttributes() {
+        return attributes;
+    }
+
+    /**
+     * 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
+     */
+    public Object getAttribute(String key) {
+        return attributes.get(key);
+    }
+
+    /**
+     * Put a new attribute in this component
+     *
+     * @param key String key for attribute
+     * @param value Attibute value.
+     */
+    public void putAttribute(String key, Object value) {
+        attributes.put(key, value);
+    }
+
+    /**
+     * Put an attribute in component / template definition.
+     * Attribute can be used as content for tag get.
+     * @param name Attribute name
+     * @param content Attribute value
+     */
+    public void put(String name, Object content) {
+        put(name, content, false, null);
+    }
+
+    /**
+     * Put an attribute in template definition.
+     * Attribute can be used as content for tag get.
+     * @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
+     */
+    public void put(String name, Object content, boolean direct) {
+        put(name, content, direct, null);
+    }
+
+    /**
+     * Put an attribute in template definition.
+     * Attribute can be used as content for tag get.
+     * @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.
+     */
+    public void put(String name, Object content, boolean direct, String role) {
+        if (direct == true) { // direct String
+            put(name, content, "string", role);
+        } else {
+            put(name, content, "template", role);
+        }
+
+    }
+
+    /**
+     * Put an attribute in template definition.
+     * Attribute can be used as content for tag get.
+     * @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.
+     */
+    public void put(String name, Object content, String type, String role) {
+        // Is there a type set ?
+        // First check direct attribute, and translate it to a valueType.
+        // Then, evaluate valueType, and create requested typed attribute.
+        AttributeDefinition attribute = null;
+
+        if (content != null
+            && type != null
+            && !(content instanceof AttributeDefinition)) {
+
+            String strValue = content.toString();
+            if (type.equalsIgnoreCase("string")) {
+                attribute = new DirectStringAttribute(strValue);
+
+            } else if (type.equalsIgnoreCase("page")) {
+                attribute = new PathAttribute(strValue);
+
+            } else if (type.equalsIgnoreCase("template")) {
+                attribute = new PathAttribute(strValue);
+
+            } else if (type.equalsIgnoreCase("instance")) {
+                attribute = new DefinitionNameAttribute(strValue);
+
+            } else if (type.equalsIgnoreCase("definition")) {
+                attribute = new DefinitionNameAttribute(strValue);
+            }
+        }
+
+        putAttribute(name, attribute);
+    }
+
+    /**
+     * Returns a description of the attributes.
+     */
+    public String toString() {
+        return "{name="
+            + name
+            + ", path="
+            + path
+            + ", role="
+            + role
+            + ", controller="
+            + controller
+            + ", controllerType="
+            + controllerType
+            + ", controllerInstance="
+            + controllerInstance
+            + ", attributes="
+            + attributes
+            + "}\n";
+    }
+
+    /**
+     * Get associated controller type.
+     * Type denote a fully qualified classname.
+     */
+    public String getControllerType() {
+        return controllerType;
+    }
+
+    /**
+     * Set associated controller type.
+     * Type denote a fully qualified classname.
+     * @param controllerType Typeof associated controller
+     */
+    public void setControllerType(String controllerType) {
+        this.controllerType = controllerType;
+    }
+
+    /**
+     * Set associated controller name as an url, and controller
+     * type as "url".
+     * Name must be an url (not checked).
+     * Convenience method.
+     * @param controller Controller url
+     */
+    public void setControllerUrl(String controller) {
+        setController(controller);
+        setControllerType("url");
+    }
+
+    /**
+     * Set associated controller name as a classtype, and controller
+     * type as "classname".
+     * Name denote a fully qualified classname
+     * Convenience method.
+     * @param controller Controller classname.
+     */
+    public void setControllerClass(String controller) {
+        setController(controller);
+        setControllerType("classname");
+    }
+
+    /**
+     * Get associated controller local URL.
+     * URL should be local to webcontainer in order to allow request context followup.
+     * URL comes as a string.
+     */
+    public String getController() {
+        return controller;
+    }
+
+    /**
+     * Set associated controller 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 setController(String url) {
+        this.controller = url;
+    }
+
+    /**
+     * Get controller instance.
+     * @return controller instance.
+     */
+    public Controller getControllerInstance() {
+        return controllerInstance;
+    }
+
+    /**
+     * Get or create controller.
+     * Get controller, create it if necessary.
+     * @return controller if controller or controllerType is set, null otherwise.
+     * @throws InstantiationException if an error occur while instanciating Controller :
+     * (classname can't be instanciated, Illegal access with instanciated class,
+     * Error while instanciating class, classname can't be instanciated.
+     */
+    public Controller getOrCreateController() throws InstantiationException {
+
+        if (controllerInstance != null) {
+            return controllerInstance;
+        }
+
+        // Do we define a controller ?
+        if (controller == null && controllerType == null) {
+            return null;
+        }
+
+        // check parameters
+        if (controllerType != null && controller == null) {
+            throw new InstantiationException("Controller name should be defined if controllerType is set");
+        }
+
+        controllerInstance = createController(controller, controllerType);
+
+        return controllerInstance;
+    }
+
+    /**
+     * Set controller.
+     */
+    public void setControllerInstance(Controller controller) {
+        this.controllerInstance = controller;
+    }
+
+    /**
+     * Create a new instance of controller named in parameter.
+     * If controllerType is specified, create controller accordingly.
+     * Otherwise, if name denote a classname, create an instance of it. If class is
+     *  subclass of org.apache.struts.action.Action, wrap controller
+     * appropriately.
+     * Otherwise, consider name as an url.
+     * @param name Controller name (classname, url, ...)
+     * @param controllerType Expected Controller type
+     * @return org.apache.tiles.Controller
+     * @throws InstantiationException if an error occur while instanciating Controller :
+     * (classname can't be instanciated, Illegal access with instanciated class,
+     * Error while instanciating class, classname can't be instanciated.
+     */
+    public static Controller createController(String name, String controllerType)
+        throws InstantiationException {
+
+        if (log.isDebugEnabled()) {
+            log.debug("Create controller name=" + name + ", type=" + controllerType);
+        }
+
+        Controller controller = null;
+
+        if (controllerType == null) { // first try as a classname
+            try {
+                return createControllerFromClassname(name);
+
+            } catch (InstantiationException ex) { // ok, try something else
+                controller = new UrlController(name);
+            }
+
+        } else if ("url".equalsIgnoreCase(controllerType)) {
+            controller = new UrlController(name);
+
+        } else if ("classname".equalsIgnoreCase(controllerType)) {
+            controller = createControllerFromClassname(name);
+        }
+
+        return controller;
+    }
+
+    /**
+     * Create a controller from specified classname
+     * @param classname Controller classname.
+     * @return org.apache.tiles.Controller
+     * @throws InstantiationException if an error occur while instanciating Controller :
+     * (classname can't be instanciated, Illegal access with instanciated class,
+     * Error while instanciating class, classname can't be instanciated.
+     */
+    public static Controller createControllerFromClassname(String classname)
+        throws InstantiationException {
+
+        try {
+            Class requestedClass = TilesUtil.applicationClass(classname);
+            Object instance = requestedClass.newInstance();
+
+            if (log.isDebugEnabled()) {
+                log.debug("Controller created : " + instance);
+            }
+            return (Controller) instance;
+
+        } catch (java.lang.ClassNotFoundException ex) {
+            throw new InstantiationException(
+                "Error - Class not found :" + ex.getMessage());
+
+        } catch (java.lang.IllegalAccessException ex) {
+            throw new InstantiationException(
+                "Error - Illegal class access :" + ex.getMessage());
+
+        } catch (java.lang.InstantiationException ex) {
+            throw ex;
+
+        } catch (java.lang.ClassCastException ex) {
+            throw new InstantiationException(
+                "Controller of class '"
+                    + classname
+                    + "' should implements 'Controller' or extends 'Action'");
+        }
+    }
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinitionsFactory.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinitionsFactory.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinitionsFactory.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ComponentDefinitionsFactory.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.util.Map;
+import java.io.Serializable;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletContext;
+
+/**
+ * Component repository interface.
+ * This interface allows to retrieve an definition by its name, independently of the
+ * factory implementation.
+ * Implementation must be Serializable, in order to be compliant with web Container
+ * having this constraint (Weblogic 6.x).
+ * @deprecated Use DefinitionsFactory instead.
+*/
+public interface ComponentDefinitionsFactory extends Serializable
+{
+
+   /**
+     * Get a definition by its name.
+     * @param name Name of requested definition.
+     * @param request Current servelet request
+     * @param servletContext current servlet context
+     * @throws DefinitionsFactoryException An error occur while getting definition.
+     * @throws NoSuchDefinitionException No definition found for specified name
+     * Implementation can throw more accurate exception as a subclass of this exception
+   */
+   public ComponentDefinition getDefinition(String name, ServletRequest request, ServletContext servletContext) throws NoSuchDefinitionException,DefinitionsFactoryException;
+
+   /**
+     * Init factory.
+     * This method is called exactly once immediately after factory creation in
+     * case of internal creation (by DefinitionUtil).
+     * @param servletContext Servlet Context passed to newly created factory.
+     * @param properties Map of name/property passed to newly created factory.
+     * Map can contains more properties than requested.
+     * @throws DefinitionsFactoryException An error occur during initialization.
+   */
+   public void initFactory(ServletContext servletContext, Map properties) throws DefinitionsFactoryException;
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Controller.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Controller.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Controller.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Controller.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
+/**
+ * A controller is a piece of code called before rendering a jsp page.
+ * A controller can be associated to a tile. See <insert> or <definition> for
+ * association syntax.
+ */
+public interface Controller
+{
+
+   /**
+    * Method associated to a tile and called immediately before the tile is included.
+    * @param tileContext Current tile context.
+    * @param request Current request
+    * @param response Current response
+    * @param servletContext Current servlet context
+    */
+   public void perform(ComponentContext tileContext,
+                       HttpServletRequest request, HttpServletResponse response,
+                       ServletContext servletContext)
+        throws ServletException, IOException;
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ControllerSupport.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ControllerSupport.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ControllerSupport.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/ControllerSupport.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
+/**
+ * Basic implementation of Controller.
+ */
+public class ControllerSupport implements Controller {
+
+   /**
+    * Method associated with a tile and called immediately before tile is included.
+    * This implementation does nothing.
+    * @param tileContext Current tile context.
+    * @param request Current request
+    * @param response Current response
+    * @param servletContext Current servlet context
+    */
+   public void perform(ComponentContext tileContext,
+                       HttpServletRequest request, HttpServletResponse response,
+                       ServletContext servletContext)
+        throws ServletException, IOException {
+
+   }
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionAttribute.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionAttribute.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionAttribute.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionAttribute.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+/**
+ * Attribute representing a Component Definition.
+ * This attribute definition contains a Component definition.
+ */
+public class DefinitionAttribute extends UntypedAttribute {
+
+    public DefinitionAttribute(String value) {
+        super(value);
+    }
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionNameAttribute.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionNameAttribute.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionNameAttribute.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionNameAttribute.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+/**
+ * Component attribute.
+ * Such attribute value represent an instance name.
+ */
+public class DefinitionNameAttribute extends UntypedAttribute {
+    
+    /**
+     * Constructor.
+     */
+    public DefinitionNameAttribute(String value) {
+        super(value);
+    }
+
+    /**
+     * Constructor.
+     */
+    public DefinitionNameAttribute(String value, String role) {
+        super(value, role);
+    }
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactory.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactory.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactory.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactory.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.Serializable;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+
+/**
+ * Tiles Definition factory.
+ * This interface replace old ComponentDefinitionsFactory.
+ * Main method getDefinition() is exactly the same. Initialization method change.
+ * This interface allows to retrieve a definition by its name, independently of
+ * the factory implementation.
+ * Object life cycle is as follow:
+ * <ul>
+ * <li>Constructor: create object</li>
+ * <li>setConfig: set config and initialize factory. After first call to this
+ * method, factory is operational.</li>
+ * <li>destroy: factory is being shutdown.</li>
+ * </ul>
+ * Implementation must be Serializable, in order to be compliant with web Container
+ * having this constraint (Weblogic 6.x).
+ */
+public interface DefinitionsFactory extends Serializable
+{
+
+   /**
+     * Get a definition by its name.
+     * @param name Name of requested definition.
+     * @param request Current servelet request
+     * @param servletContext current servlet context
+     * @throws DefinitionsFactoryException An error occur while getting definition.
+     * @throws NoSuchDefinitionException No definition found for specified name
+     * Implementation can throw more accurate exception as a subclass of this exception
+   */
+   public ComponentDefinition getDefinition(String name, ServletRequest request, ServletContext servletContext)
+     throws NoSuchDefinitionException,DefinitionsFactoryException;
+
+   /**
+    * Init definition factory.
+    * This method is called immediately after factory creation, and prior any call
+    * to setConfig().
+    *
+    * @param config Configuration object used to set factory configuration.
+    * @param servletContext Servlet Context passed to factory.
+    * @throws DefinitionsFactoryException An error occur during initialization.
+    */
+   public void init(DefinitionsFactoryConfig config, ServletContext servletContext)
+     throws DefinitionsFactoryException;
+
+    /**
+     * <p>Receive notification that the factory is being
+     * shut down.</p>
+     */
+    public void destroy();
+
+   /**
+    * Set factory configuration.
+    * This method is used to change factory configuration.
+    * This method is optional, and can send an exception if implementation
+    * doesn't allow change in configuration.
+    *
+    * @param config Configuration object used to set factory configuration.
+    * @param servletContext Servlet Context passed to factory.
+    * @throws DefinitionsFactoryException An error occur during initialization.
+    */
+   public void setConfig(DefinitionsFactoryConfig config, ServletContext servletContext)
+     throws DefinitionsFactoryException;
+
+   /**
+    * Get factory configuration.
+    * @return TilesConfig
+    */
+   public DefinitionsFactoryConfig getConfig();
+
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryConfig.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryConfig.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryConfig.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryConfig.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.beanutils.BeanUtils;
+
+/**
+ * A TilesFactoryConfig object hold configuration attributes for a tile
+ * definition factory.
+ *
+ * @author Cedric Dumoulin
+ * @since Struts 1.1
+ * @version $Revision: 1.9 $ $Date: 2003/07/09 00:05:17 $
+ */
+public class DefinitionsFactoryConfig implements Serializable {
+
+    /**
+     * Fully qualified classname of the factory to create.
+     * If no classname is set, a default factory is created
+     * (of class "org.apache.tiles.xmlDefinition.I18nFactorySet").
+     */
+    protected String factoryClassname =
+        "org.apache.tiles.xmlDefinition.I18nFactorySet";
+
+    /**
+     * Specifies whether the parser will validate configuration files.
+     * Default value is true.
+     */
+    protected boolean parserValidate = true;
+
+    /** 
+     * Definition configuration file specified by user. 
+     */
+    protected String definitionConfigFiles = null;
+
+    /**
+     * Specifies whether the factory is "module-aware".
+     */
+    protected boolean moduleAware = true;
+
+    /**
+     * The name associated to this factory.
+     * <br>
+     * With Struts 1.1, this name is the module name to which this factory
+     * belong. It is set by the system.
+     * <br>
+     * In prior versions, this property is not used.
+     */
+    protected String factoryName;
+
+    /** 
+     * 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. 
+     */
+    public static final String PARSER_VALIDATE_PARAMETER_NAME =
+        "definitions-parser-validate";
+
+    /** 
+     * Alternate name for factory classname properties in configuration file. 
+     */
+    public static final String FACTORY_CLASSNAME_PARAMETER_NAME =
+        "definitions-factory-class";
+
+    /** 
+     * 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. 
+     * @deprecated This will be removed in a release after Struts 1.2.
+     */
+    public static final String TILES_DETAILS_PARAMETER_NAME = "definitions-debug";
+
+    /**
+     * Map of extra attribute available.
+     */
+    private Map extraAttributes = new HashMap();
+
+    /**
+     * Default constructor.
+     */
+    public DefinitionsFactoryConfig() {
+        super();
+    }
+
+    /**
+     * Constructor.
+     * 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) {
+        super();
+    }
+
+    /**
+     * Get the module aware flag.
+     * @return <code>true</code>: user wants a single factory instance,
+     * <code>false</code>: user wants multiple factory 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 factory instance,
+     * <code>false</code>: user wants multiple factory instances (one per module with Struts)
+     */
+    public void setModuleAware(boolean moduleAware) {
+        this.moduleAware = moduleAware;
+    }
+
+    /**
+     * Get the classname of the factory.
+     * @return Classname.
+     */
+    public String getFactoryClassname() {
+        return factoryClassname;
+    }
+
+    /**
+     * Set the classname of the factory..
+     * @param aFactoryClassname Classname of the factory.
+     */
+    public void setFactoryClassname(String aFactoryClassname) {
+        factoryClassname = aFactoryClassname;
+    }
+
+    /**
+     * Determines if the parser is validating.
+     * @return <code>true<code> when in validating mode.
+     */
+    public boolean getParserValidate() {
+        return parserValidate;
+    }
+
+    /**
+     * Set the validating mode for the parser.
+     * @param aParserValidate <code>true</code> for validation, <code>false</code> otherwise
+     */
+    public void setParserValidate(boolean aParserValidate) {
+        parserValidate = aParserValidate;
+    }
+
+    /**
+     * Get the definition config files.
+     * @return Defition config files.
+     */
+    public String getDefinitionConfigFiles() {
+        return definitionConfigFiles;
+    }
+
+    /**
+     * Set the definition config files.
+     * @param aDefinitionConfigFiles Definition config files.
+     */
+    public void setDefinitionConfigFiles(String aDefinitionConfigFiles) {
+        definitionConfigFiles = aDefinitionConfigFiles;
+    }
+
+    /**
+     * Set value of an additional attribute.
+     * @param name Name of the attribute.
+     * @param value Value of the attribute.
+     */
+    public void setAttribute(String name, Object value) {
+        extraAttributes.put(name, value);
+    }
+
+    /**
+     * Get value of an additional attribute.
+     * @param name Name of the attribute.
+     * @return Value of the attribute, or null if not found.
+     */
+    public Object getAttribute(String name) {
+        return extraAttributes.get(name);
+    }
+
+    /**
+     * Get additional attributes as a Map.
+     * @return Map A Map containing attribute name - value pairs.
+     */
+    public Map getAttributes() {
+        Map map = new HashMap(extraAttributes);
+        // Add property attributes using old names
+        /*
+          map.put(DEFINITIONS_CONFIG_PARAMETER_NAME, getDefinitionConfigFiles());
+          map.put(TILES_DETAILS_PARAMETER_NAME, Integer.toString(getDebugLevel()) );
+          map.put(PARSER_DETAILS_PARAMETER_NAME, Integer.toString(getParserDebugLevel()) );
+          map.put(PARSER_VALIDATE_PARAMETER_NAME, new Boolean(getParserValidate()).toString() );
+        
+          if( ! "org.apache.tiles.xmlDefinition.I18nFactorySet".equals(getFactoryClassname()) )
+          map.put(FACTORY_CLASSNAME_PARAMETER_NAME, getFactoryClassname());
+        */
+        return map;
+    }
+
+    /**
+     * 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>
+     * Properties keys are scanned for old property names, and linked to the new name
+     * if necessary. This modifies the properties map.
+     * <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>
+     * <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.
+     * @see org.apache.commons.beanutils.BeanUtils
+     */
+    public void populate(Map properties)
+        throws IllegalAccessException, InvocationTargetException {
+
+        // link old parameter names for backward compatibility
+        linkOldPropertyNames(properties);
+        BeanUtils.populate(this, properties);
+    }
+
+    /**
+     * 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.
+     */
+    static public void linkOldPropertyNames(Map properties) {
+        Set entries = properties.entrySet();
+        Map toAdd = new HashMap();
+        Iterator i = entries.iterator();
+        while (i.hasNext()) {
+            Map.Entry entry = (Map.Entry) i.next();
+
+            if (DEFINITIONS_CONFIG_PARAMETER_NAME.equals(entry.getKey())) {
+                toAdd.put("definitionConfigFiles", entry.getValue());
+
+            } else if (FACTORY_CLASSNAME_PARAMETER_NAME.equals(entry.getKey())) {
+                toAdd.put("factoryClassname", entry.getValue());
+
+            } else if (PARSER_DETAILS_PARAMETER_NAME.equals(entry.getKey())) {
+                toAdd.put("parserDebugLevel", entry.getValue());
+
+            } else if (PARSER_VALIDATE_PARAMETER_NAME.equals(entry.getKey())) {
+                toAdd.put("parserValidate", entry.getValue());
+
+            } else if (TILES_DETAILS_PARAMETER_NAME.equals(entry.getKey())) {
+                toAdd.put("debugLevel", entry.getValue());
+            }
+        }
+
+        if (toAdd.size() > 0) {
+            properties.putAll(toAdd);
+        }
+    }
+
+    /**
+     * Get the factory name.
+     */
+    public String getFactoryName() {
+        return factoryName;
+    }
+    /**
+     * Set the factory name.
+     * @param factoryName Name of the factory.
+     */
+    public void setFactoryName(String factoryName) {
+        this.factoryName = factoryName;
+    }
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryException.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryException.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryException.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsFactoryException.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+  /**
+   * Exception thrown when an error occurs while the factory 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;
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsUtil.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsUtil.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsUtil.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DefinitionsUtil.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.taglib.tiles.ComponentConstants;
+
+/**
+ * Utilities class for definitions factory.
+ * Also define userDebugLevel property (TODO to be moved from this class ?).
+ * @deprecated Use {@link TilesUtil#createDefinitionsFactory(ServletContext, DefinitionsFactoryConfig)}
+ */
+public class DefinitionsUtil extends TilesUtil implements ComponentConstants {
+
+    /** 
+     * Commons Logging instance. 
+     */
+    protected static Log log = LogFactory.getLog(DefinitionsUtil.class);
+
+    /** 
+     * Global user defined debug level.
+     * @deprecated This will be removed in a release after Struts 1.2. 
+     */
+    public static int userDebugLevel = 0;
+
+    /** 
+     * User Debug level. 
+     * @deprecated This will be removed in a release after Struts 1.2. 
+     */
+    public static final int NO_DEBUG = 0;
+
+    /** 
+     * Name of init property carrying debug level. 
+     */
+    public static final String DEFINITIONS_CONFIG_USER_DEBUG_LEVEL =
+        "definitions-debug";
+
+    /** 
+     * Name of init property carrying factory class name. 
+     */
+    public static final String DEFINITIONS_FACTORY_CLASSNAME =
+        "definitions-factory-class";
+
+    /** 
+     * Constant name used to store factory in context. 
+     */
+    public static final String DEFINITIONS_FACTORY =
+        "org.apache.tiles.DEFINITIONS_FACTORY";
+
+    /** 
+     * Constant name used to store definition in jsp context.
+     * Used to pass definition from a Struts action to servlet forward. 
+     */
+    public static final String ACTION_DEFINITION =
+        "org.apache.tiles.ACTION_DEFINITION";
+
+    /**
+     * Create Definition factory.
+     * If a factory class name is provided, a factory of this class is created. Otherwise,
+     * default factory is created.
+     * @param classname Class name of the factory to create.
+     * @param servletContext Servlet Context passed to newly created factory.
+     * @param properties Map of name/property used to initialize factory configuration object.
+     * @return newly created factory.
+     * @throws DefinitionsFactoryException If an error occur while initializing factory
+     * @deprecated Use createDefinitionsFactory(ServletContext servletContext, ServletConfig servletConfig)
+     */
+    public static DefinitionsFactory createDefinitionsFactory(
+        ServletContext servletContext,
+        Map properties,
+        String classname)
+        throws DefinitionsFactoryException {
+
+        // Create config object
+        DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
+        // populate it from map.
+        try {
+            factoryConfig.populate(properties);
+
+        } catch (Exception ex) {
+            throw new DefinitionsFactoryException(
+                "Error - createDefinitionsFactory : Can't populate config object from properties map",
+                ex);
+        }
+
+        // Add classname
+        if (classname != null)
+            factoryConfig.setFactoryClassname(classname);
+
+        // Create factory using config object
+        return createDefinitionsFactory(servletContext, factoryConfig);
+    }
+
+    /**
+     * Create default Definition factory.
+     * @param servletContext Servlet Context passed to newly created factory.
+     * @param properties Map of name/property used to initialize factory configuration object.
+     * @return newly created factory of type ConfigurableDefinitionsFactory.
+     * @throws DefinitionsFactoryException If an error occur while initializing factory
+     */
+    public static DefinitionsFactory createDefinitionsFactory(
+        ServletContext servletContext,
+        Map properties)
+        throws DefinitionsFactoryException {
+
+        return createDefinitionsFactory(servletContext, properties, null);
+    }
+
+    /**
+     * Create Definition factory.
+     * Create configuration object from servlet web.xml file, then create
+     * ConfigurableDefinitionsFactory and initialized it with object.
+     * <p>
+     * Convenience method. Calls createDefinitionsFactory(ServletContext servletContext, DefinitionsFactoryConfig factoryConfig)
+     *
+     * @param servletContext Servlet Context passed to newly created factory.
+     * @param servletConfig Servlet config containing parameters to be passed to factory configuration object.
+     * @return newly created factory of type ConfigurableDefinitionsFactory.
+     * @throws DefinitionsFactoryException If an error occur while initializing factory
+     */
+    public static DefinitionsFactory createDefinitionsFactory(
+        ServletContext servletContext,
+        ServletConfig servletConfig)
+        throws DefinitionsFactoryException {
+
+        DefinitionsFactoryConfig factoryConfig = readFactoryConfig(servletConfig);
+
+        return createDefinitionsFactory(servletContext, factoryConfig);
+    }
+
+    /**
+     * Create Definition factory.
+     * Create configuration object from servlet web.xml file, then create
+     * ConfigurableDefinitionsFactory and initialized it with object.
+     * <p>
+     * If checkIfExist is true, start by checking if factory already exist. If yes,
+     * return it. If no, create a new one.
+     * <p>
+     * If checkIfExist is false, factory is always created.
+     * <p>
+     * Convenience method. Calls createDefinitionsFactory(ServletContext servletContext, DefinitionsFactoryConfig factoryConfig)
+     *
+     * @param servletContext Servlet Context passed to newly created factory.
+     * @param servletConfig Servlet config containing parameters to be passed to factory configuration object.
+     * @param checkIfExist Check if factory already exist. If true and factory exist, return it.
+     * If true and factory doesn't exist, create it. If false, create it in all cases.
+     * @return newly created factory of type ConfigurableDefinitionsFactory.
+     * @throws DefinitionsFactoryException If an error occur while initializing factory
+     */
+    public static DefinitionsFactory createDefinitionsFactory(
+        ServletContext servletContext,
+        ServletConfig servletConfig,
+        boolean checkIfExist)
+        throws DefinitionsFactoryException {
+
+        if (checkIfExist) {
+            // Check if already exist in context
+            DefinitionsFactory factory = getDefinitionsFactory(servletContext);
+            if (factory != null)
+                return factory;
+        }
+
+        return createDefinitionsFactory(servletContext, servletConfig);
+    }
+
+    /**
+     * Get definition factory from appropriate servlet context.
+     * @return Definitions factory or null if not found.
+     * @deprecated Use {@link TilesUtil#getDefinitionsFactory(ServletRequest, ServletContext)}
+     * @since 20020708
+     */
+    public static DefinitionsFactory getDefinitionsFactory(ServletContext servletContext) {
+        return (DefinitionsFactory) servletContext.getAttribute(DEFINITIONS_FACTORY);
+    }
+
+    /**
+     * Get Definition stored in jsp context by an action.
+     * @return ComponentDefinition or null if not found.
+     */
+    public static ComponentDefinition getActionDefinition(ServletRequest request) {
+        return (ComponentDefinition) request.getAttribute(ACTION_DEFINITION);
+    }
+
+    /**
+     * Store definition in jsp context.
+     * Mainly used by Struts to pass a definition defined in an Action to the forward.
+     */
+    public static void setActionDefinition(
+        ServletRequest request,
+        ComponentDefinition definition) {
+
+        request.setAttribute(ACTION_DEFINITION, definition);
+    }
+
+    /**
+     * Remove Definition stored in jsp context.
+     * Mainly used by Struts to pass a definition defined in an Action to the forward.
+     */
+    public static void removeActionDefinition(
+        ServletRequest request,
+        ComponentDefinition definition) {
+
+        request.removeAttribute(ACTION_DEFINITION);
+    }
+
+    /**
+     * Populate Definition Factory Config from web.xml properties.
+     * @param factoryConfig Definition Factory Config to populate.
+     * @param servletConfig Current servlet config containing web.xml properties.
+     * @exception IllegalAccessException if the caller does not have
+     *  access to the property accessor method
+     * @exception java.lang.reflect.InvocationTargetException if the property accessor method
+     *  throws an exception
+     * @see org.apache.commons.beanutils.BeanUtils
+     * @since tiles 20020708
+     */
+    public static void populateDefinitionsFactoryConfig(
+        DefinitionsFactoryConfig factoryConfig,
+        ServletConfig servletConfig)
+        throws IllegalAccessException, InvocationTargetException {
+
+        Map properties = new DefinitionsUtil.ServletPropertiesMap(servletConfig);
+		  System.out.println("Populating factory config with these properties: " + properties);
+        factoryConfig.populate(properties);
+		  System.out.println("Done populating factory config");
+    }
+
+    /**
+     * Create FactoryConfig and initialize it from web.xml.
+     *
+     * @param servletConfig ServletConfig for the module with which
+     *  this plug in is associated
+     * @exception DefinitionsFactoryException if this <code>PlugIn</code> cannot
+     *  be successfully initialized
+     */
+    protected static DefinitionsFactoryConfig readFactoryConfig(ServletConfig servletConfig)
+        throws DefinitionsFactoryException {
+
+        // Create tiles definitions config object
+        DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
+
+        // Get init parameters from web.xml files
+        try {
+            DefinitionsUtil.populateDefinitionsFactoryConfig(
+                factoryConfig,
+                servletConfig);
+
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            throw new DefinitionsFactoryException(
+                "Can't populate DefinitionsFactoryConfig class from 'web.xml'.",
+                ex);
+        }
+
+        return factoryConfig;
+    }
+
+    /**
+     * Inner class.
+     * Wrapper for ServletContext init parameters.
+     * Object of this class is an hashmap containing parameters and values
+     * defined in the servlet config file (web.xml).
+     */
+    static class ServletPropertiesMap extends HashMap {
+        /**
+         * Constructor.
+         */
+        ServletPropertiesMap(ServletConfig config) {
+            // This implementation is very simple.
+            // It is possible to avoid creation of a new structure, but this need
+            // imply writing all Map interface.
+				System.out.println("Iterating over servlet parameters");
+            Enumeration enum = config.getInitParameterNames();
+            while (enum.hasMoreElements()) {
+                String key = (String) enum.nextElement();
+                put(key, config.getInitParameter(key));
+				    System.out.println("Storing key " + key);
+            }
+        }
+    } // end inner class
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DirectStringAttribute.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DirectStringAttribute.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DirectStringAttribute.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/DirectStringAttribute.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+/**
+ * Component attribute.
+ * Such attribute value represent a path used to include a JSP.
+ */
+public class DirectStringAttribute extends UntypedAttribute {
+
+    public DirectStringAttribute(String value) {
+        super(value);
+    }
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/FactoryNotFoundException.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/FactoryNotFoundException.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/FactoryNotFoundException.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/FactoryNotFoundException.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+  /**
+   * Exception thrown when definitions factory is not found.
+   */
+public class FactoryNotFoundException extends DefinitionsFactoryException
+{
+    /**
+     * Constructor.
+     */
+  public FactoryNotFoundException()
+    {
+    super();
+    }
+    /**
+     * Constructor.
+     * @param msg Message.
+     */
+  public FactoryNotFoundException( String msg )
+    {
+    super(msg);
+    }
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Globals.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Globals.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Globals.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/Globals.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+import java.io.Serializable;
+
+/**
+ * Global manifest constants for the entire Struts Framework.
+ *
+ * @author Craig R. McClanahan
+ * @author David Graham
+ * @author David Geary: migrated from struts package to eliminate Struts
+ *                      dependencies
+ */
+public class Globals implements Serializable {
+
+
+    // ----------------------------------------------------- Manifest Constants
+
+
+    /**
+     * The context attributes key under which our <code>ActionServlet</code>
+     * instance will be stored.
+     *
+     * @since Struts 1.1
+     */
+    public static final String ACTION_SERVLET_KEY =
+        "org.apache.tiles.action.ACTION_SERVLET";
+
+    /**
+     * The request attributes key under which a boolean <code>true</code>
+     * value should be stored if this request was cancelled.
+     *
+     * @since Struts 1.1
+     */
+    public static final String CANCEL_KEY =
+        "org.apache.tiles.action.CANCEL";
+
+    /**
+     * <p>The base of the context attributes key under which our
+     * <code>ModuleConfig</code> data structure will be stored.  This
+     * will be suffixed with the actual module prefix (including the
+     * leading "/" character) to form the actual attributes key.</p>
+     *
+     * <p>For each request processed by the controller servlet, the
+     * <code>ModuleConfig</code> object for the module selected by
+     * the request URI currently being processed will also be exposed under
+     * this key as a request attribute.</p>
+     *
+     * @since Struts 1.1
+     */
+    public static final String MODULE_KEY =
+        "org.apache.tiles.action.MODULE";
+        
+    /**
+     * The ServletContext attribute under which we store the module prefixes 
+     * String[].
+     * @since Struts 1.2
+     */
+    public static final String MODULE_PREFIXES_KEY =
+        "org.apache.tiles.globals.MODULE_PREFIXES";
+
+
+    /**
+     * The context attributes key under which our <strong>default</strong>
+     * configured data source (which must implement
+     * <code>javax.sql.DataSource</code>) is stored,
+     * if one is configured for this module.
+     */
+    public static final String DATA_SOURCE_KEY =
+      "org.apache.tiles.action.DATA_SOURCE";
+
+
+    /**
+     * The request attributes key under which your action should store an
+     * <code>org.apache.tiles.action.ActionErrors</code> object, if you
+     * are using the corresponding custom tag library elements.
+     */
+    public static final String ERROR_KEY =
+      "org.apache.tiles.action.ERROR";
+
+
+    /**
+     * The request attributes key under which Struts custom tags might store a
+     * <code>Throwable</code> that caused them to report a JspException at
+     * runtime.  This value can be used on an error page to provide more
+     * detailed information about what really went wrong.
+     */
+    public static final String EXCEPTION_KEY =
+        "org.apache.tiles.action.EXCEPTION";
+
+
+    /**
+     * The context attributes key under which our
+     * <code>org.apache.tiles.action.ActionFormBeans</code> collection
+     * is normally stored, unless overridden when initializing our
+     * ActionServlet.
+     *
+     * @deprecated Replaced by collection in ModuleConfig
+     */
+    public static final String FORM_BEANS_KEY =
+        "org.apache.tiles.action.FORM_BEANS";
+
+
+    /**
+     * The context attributes key under which our
+     * <code>org.apache.tiles.action.ActionForwards</code> collection
+     * is normally stored, unless overridden when initializing our
+     * ActionServlet.
+     *
+     * @deprecated Replaced by collection in ModuleConfig.
+     */
+    public static final String FORWARDS_KEY =
+      "org.apache.tiles.action.FORWARDS";
+
+
+    /**
+     * The session attributes key under which the user's selected
+     * <code>java.util.Locale</code> is stored, if any.  If no such
+     * attribute is found, the system default locale
+     * will be used when retrieving internationalized messages.  If used, this
+     * attribute is typically set during user login processing.
+     */
+    public static final String LOCALE_KEY =
+      "org.apache.tiles.action.LOCALE";
+
+
+    /**
+     * The request attributes key under which our
+     * <code>org.apache.tiles.ActionMapping</code> instance
+     * is passed.
+     */
+    public static final String MAPPING_KEY =
+        "org.apache.tiles.action.mapping.instance";
+
+
+    /**
+     * The context attributes key under which our
+     * <code>org.apache.tiles.action.ActionMappings</code> collection
+     * is normally stored, unless overridden when initializing our
+     * ActionServlet.
+     *
+     * @deprecated Replaced by collection in ModuleConfig
+     */
+    public static final String MAPPINGS_KEY =
+      "org.apache.tiles.action.MAPPINGS";
+
+
+    /**
+     * The request attributes key under which your action should store an
+     * <code>org.apache.tiles.action.ActionMessages</code> object, if you
+     * are using the corresponding custom tag library elements.
+     *
+     * @since Struts 1.1
+     */
+    public static final String MESSAGE_KEY =
+      "org.apache.tiles.action.ACTION_MESSAGE";
+
+
+    /**
+     * <p>The base of the context attributes key under which our
+     * module <code>MessageResources</code> will be stored.  This
+     * will be suffixed with the actual module prefix (including the
+     * leading "/" character) to form the actual resources key.</p>
+     *
+     * <p>For each request processed by the controller servlet, the
+     * <code>MessageResources</code> object for the module selected by
+     * the request URI currently being processed will also be exposed under
+     * this key as a request attribute.</p>
+     */
+    public static final String MESSAGES_KEY =
+      "org.apache.tiles.action.MESSAGE";
+
+
+    /**
+     * The request attributes key under which our multipart class is stored.
+     */
+    public static final String MULTIPART_KEY =
+        "org.apache.tiles.action.mapping.multipartclass";
+
+
+    /**
+     * <p>The base of the context attributes key under which an array of
+     * <code>PlugIn</code> instances will be stored.  This
+     * will be suffixed with the actual module prefix (including the
+     * leading "/" character) to form the actual attributes key.</p>
+     * @since Struts 1.1
+     */
+    public static final String PLUG_INS_KEY =
+        "org.apache.tiles.action.PLUG_INS";
+
+
+    /**
+     * <p>The base of the context attributes key under which our
+     * <code>RequestProcessor</code> instance will be stored.  This
+     * will be suffixed with the actual module prefix (including the
+     * leading "/" character) to form the actual attributes key.</p>
+     * @since Struts 1.1
+     */
+    public static final String REQUEST_PROCESSOR_KEY =
+        "org.apache.tiles.action.REQUEST_PROCESSOR";
+
+
+    /**
+     * The context attributes key under which we store the mapping defined
+     * for our controller serlet, which will be either a path-mapped pattern
+     * (<code>/action/*</code>) or an extension mapped pattern
+     * (<code>*.do</code>).
+     */
+    public static final String SERVLET_KEY =
+        "org.apache.tiles.action.SERVLET_MAPPING";
+
+
+    /**
+     * The session attributes key under which our transaction token is
+     * stored, if it is used.
+     */
+    public static final String TRANSACTION_TOKEN_KEY =
+        "org.apache.tiles.action.TOKEN";
+        
+    /**
+     * The page attributes key under which xhtml status is stored.  This may be "true"
+     * or "false".  When set to true, the html tags output xhtml.
+     * @since Struts 1.1
+     */
+    public static final String XHTML_KEY =
+        "org.apache.tiles.globals.XHTML";
+
+        
+    /**
+     * The application-scope key whose value represents an
+	  * exception thrown when Tiles parses the tile definition
+	  * file(s).
+     */
+    public static final String TILES_INIT_EXCEPTION =
+        "org.apache.tiles.globals.TILES_INIT_EXCEPTION";
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/NoSuchDefinitionException.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/NoSuchDefinitionException.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/NoSuchDefinitionException.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/NoSuchDefinitionException.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+  /**
+   * Exception thrown when a definition is not found.
+   */
+public class NoSuchDefinitionException extends DefinitionsFactoryException
+{
+    /**
+     * Constructor.
+     */
+   public NoSuchDefinitionException() {
+      super();
+   }
+
+    /**
+     * Constructor.
+     * @param msg Message.
+     */
+   public NoSuchDefinitionException( String msg ) {
+      super(msg);
+   }
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/PathAttribute.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/PathAttribute.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/PathAttribute.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/PathAttribute.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+/**
+ * Component attribute.
+ * Attribute value represents a path used to include a JSP.
+ */
+public class PathAttribute extends UntypedAttribute {
+
+    public PathAttribute(String value) {
+        super(value);
+    }
+
+}

Added: struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/TilesException.java
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/TilesException.java?rev=190662&view=auto
==============================================================================
--- struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/TilesException.java (added)
+++ struts/sandbox/trunk/tiles/core-library/src/java/org/apache/tiles/TilesException.java Tue Jun 14 14:59:13 2005
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tiles;
+
+/**
+ * Root class for all Tiles-exceptions.
+ * @author Cedric Dumoulin
+ */
+public class TilesException extends Exception
+{
+
+
+  /**
+   * Any "wrapped" exception will be exposed when this is serialized.
+   * @serial
+   */
+  private Exception exception;
+  /**
+    * Constructor.
+    */
+  public TilesException() {
+    super();
+    this.exception = null;
+  }
+
+  /**
+    * Constructor.
+    * @param message The error or warning message.
+    */
+  public TilesException(String message) {
+    super(message);
+    this.exception = null;
+  }
+
+
+  /**
+    * Create a new <code>TilesException</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 TilesException.</p>
+    *
+    * @param e The exception to be wrapped.
+    */
+  public TilesException(Exception e) {
+    super();
+    this.exception = e;
+  }
+
+
+  /**
+    * Create a new <code>TilesException</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 TilesException(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 TilesException
+    * 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;
+  }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message