myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sless...@apache.org
Subject svn commit: r761982 [6/10] - in /myfaces/core/branches/2_0_0/impl/src: main/java/com/ main/java/org/apache/myfaces/application/ main/java/org/apache/myfaces/config/ main/java/org/apache/myfaces/config/impl/digester/ main/java/org/apache/myfaces/config/...
Date Sat, 04 Apr 2009 18:45:04 GMT
Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/AbstractTagLibrary.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,624 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.ConverterConfig;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.FaceletHandler;
+import javax.faces.view.facelets.Tag;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+import javax.faces.view.facelets.ValidatorConfig;
+
+import org.apache.myfaces.view.facelets.tag.jsf.ConvertHandler;
+import org.apache.myfaces.view.facelets.tag.jsf.ValidateHandler;
+
+/**
+ * Base class for defining TagLibraries in Java
+ * 
+ * @author Jacob Hookom
+ * @version $Id: AbstractTagLibrary.java,v 1.10 2008/07/13 19:01:36 rlubke Exp $
+ */
+public abstract class AbstractTagLibrary implements TagLibrary
+{
+    private final Map<String, TagHandlerFactory> _factories;
+
+    private final Map<String, Method> _functions;
+
+    private final String _namespace;
+
+    public AbstractTagLibrary(String namespace)
+    {
+        _namespace = namespace;
+        _factories = new HashMap<String, TagHandlerFactory>();
+        _functions = new HashMap<String, Method>();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#containsNamespace(java.lang.String)
+     */
+    public boolean containsNamespace(String ns)
+    {
+        return _namespace.equals(ns);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#containsTagHandler(java.lang.String, java.lang.String)
+     */
+    public boolean containsTagHandler(String ns, String localName)
+    {
+        return containsNamespace(ns) && _factories.containsKey(localName);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#createTagHandler(java.lang.String, java.lang.String,
+     * org.apache.myfaces.view.facelets.tag.TagConfig)
+     */
+    public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException
+    {
+        if (containsNamespace(ns))
+        {
+            TagHandlerFactory f = _factories.get(localName);
+            if (f != null)
+            {
+                return f.createHandler(tag);
+            }
+        }
+        
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#containsFunction(java.lang.String, java.lang.String)
+     */
+    public boolean containsFunction(String ns, String name)
+    {
+        return containsNamespace(ns) && _functions.containsKey(name);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#createFunction(java.lang.String, java.lang.String)
+     */
+    public Method createFunction(String ns, String name)
+    {
+        return containsNamespace(ns) ? _functions.get(name) : null;
+    }
+
+    public String getNamespace()
+    {
+        return _namespace;
+    }
+
+    /**
+     * Add a ComponentHandler with the specified componentType and rendererType, aliased by the tag name.
+     * 
+     * @see ComponentHandler
+     * @see javax.faces.application.Application#createComponent(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param componentType
+     *            componentType to use
+     * @param rendererType
+     *            rendererType to use
+     */
+    protected final void addComponent(String name, String componentType, String rendererType)
+    {
+        _factories.put(name, new ComponentHandlerFactory(componentType, rendererType));
+    }
+
+    /**
+     * Add a ComponentHandler with the specified componentType and rendererType, aliased by the tag name. The Facelet
+     * will be compiled with the specified HandlerType (which must extend AbstractComponentHandler).
+     * 
+     * @see AbstractComponentHandler
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param componentType
+     *            componentType to use
+     * @param rendererType
+     *            rendererType to use
+     * @param handlerType
+     *            a Class that extends AbstractComponentHandler
+     */
+    protected final void addComponent(String name, String componentType, String rendererType, 
+                                      Class<? extends TagHandler> handlerType)
+    {
+        _factories.put(name, new UserComponentHandlerFactory(componentType, rendererType, handlerType));
+    }
+
+    /**
+     * Add a ConvertHandler for the specified converterId
+     * 
+     * @see ConvertHandler
+     * @see javax.faces.application.Application#createConverter(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param converterId
+     *            id to pass to Application instance
+     */
+    protected final void addConverter(String name, String converterId)
+    {
+        _factories.put(name, new ConverterHandlerFactory(converterId));
+    }
+
+    /**
+     * Add a ConvertHandler for the specified converterId of a TagHandler type
+     * 
+     * @see ConvertHandler
+     * @see ConverterConfig
+     * @see javax.faces.application.Application#createConverter(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param converterId
+     *            id to pass to Application instance
+     * @param type
+     *            TagHandler type that takes in a ConverterConfig
+     */
+    protected final void addConverter(String name, String converterId, Class<? extends TagHandler> type)
+    {
+        _factories.put(name, new UserConverterHandlerFactory(converterId, type));
+    }
+
+    /**
+     * Add a ValidateHandler for the specified validatorId
+     * 
+     * @see ValidateHandler
+     * @see javax.faces.application.Application#createValidator(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param validatorId
+     *            id to pass to Application instance
+     */
+    protected final void addValidator(String name, String validatorId)
+    {
+        _factories.put(name, new ValidatorHandlerFactory(validatorId));
+    }
+
+    /**
+     * Add a ValidateHandler for the specified validatorId
+     * 
+     * @see ValidateHandler
+     * @see ValidatorConfig
+     * @see javax.faces.application.Application#createValidator(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param validatorId
+     *            id to pass to Application instance
+     * @param type
+     *            TagHandler type that takes in a ValidatorConfig
+     */
+    protected final void addValidator(String name, String validatorId, Class<? extends TagHandler> type)
+    {
+        _factories.put(name, new UserValidatorHandlerFactory(validatorId, type));
+    }
+
+    /**
+     * Use the specified HandlerType in compiling Facelets. HandlerType must extend TagHandler.
+     * 
+     * @see TagHandler
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param handlerType
+     *            must extend TagHandler
+     */
+    protected final void addTagHandler(String name, Class<? extends TagHandler> handlerType)
+    {
+        _factories.put(name, new HandlerFactory(handlerType));
+    }
+
+    /**
+     * Add a UserTagHandler specified a the URL source.
+     * 
+     * @see UserTagHandler
+     * @param name
+     *            name to use, "foo" would be &lt;my:foo />
+     * @param source
+     *            source where the Facelet (Tag) source is
+     */
+    protected final void addUserTag(String name, URL source)
+    {
+        _factories.put(name, new UserTagFactory(source));
+    }
+
+    /**
+     * Add a Method to be used as a Function at Compilation.
+     * 
+     * @see javax.el.FunctionMapper
+     * 
+     * @param name
+     *            (suffix) of function name
+     * @param method
+     *            method instance
+     */
+    protected final void addFunction(String name, Method method)
+    {
+        _functions.put(name, method);
+    }
+
+    private static class ValidatorConfigWrapper implements ValidatorConfig
+    {
+
+        private final TagConfig parent;
+        private final String validatorId;
+
+        public ValidatorConfigWrapper(TagConfig parent, String validatorId)
+        {
+            this.parent = parent;
+            this.validatorId = validatorId;
+        }
+
+        public String getValidatorId()
+        {
+            return this.validatorId;
+        }
+
+        public FaceletHandler getNextHandler()
+        {
+            return this.parent.getNextHandler();
+        }
+
+        public Tag getTag()
+        {
+            return this.parent.getTag();
+        }
+
+        public String getTagId()
+        {
+            return this.parent.getTagId();
+        }
+    }
+
+    private static class ConverterConfigWrapper implements ConverterConfig
+    {
+        private final TagConfig parent;
+        private final String converterId;
+
+        public ConverterConfigWrapper(TagConfig parent, String converterId)
+        {
+            this.parent = parent;
+            this.converterId = converterId;
+        }
+
+        public String getConverterId()
+        {
+            return this.converterId;
+        }
+
+        public FaceletHandler getNextHandler()
+        {
+            return this.parent.getNextHandler();
+        }
+
+        public Tag getTag()
+        {
+            return this.parent.getTag();
+        }
+
+        public String getTagId()
+        {
+            return this.parent.getTagId();
+        }
+    }
+
+    private static class HandlerFactory implements TagHandlerFactory
+    {
+        private final static Class<?>[] CONSTRUCTOR_SIG = new Class[]{TagConfig.class};
+
+        protected final Class<? extends TagHandler> handlerType;
+
+        public HandlerFactory(Class<? extends TagHandler> handlerType)
+        {
+            this.handlerType = handlerType;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                return handlerType.getConstructor(CONSTRUCTOR_SIG).newInstance(new Object[] { cfg });
+            }
+            catch (InvocationTargetException ite)
+            {
+                Throwable t = ite.getCause();
+                if (t instanceof FacesException)
+                {
+                    throw (FacesException) t;
+                }
+                else if (t instanceof ELException)
+                {
+                    throw (ELException) t;
+                }
+                else
+                {
+                    throw new FacesException("Error Instantiating: " + handlerType.getName(), t);
+                }
+            }
+            catch (Exception e)
+            {
+                throw new FacesException("Error Instantiating: " + handlerType.getName(), e);
+            }
+        }
+    }
+
+    private static class ComponentConfigWrapper implements ComponentConfig
+    {
+
+        protected final TagConfig parent;
+
+        protected final String componentType;
+
+        protected final String rendererType;
+
+        public ComponentConfigWrapper(TagConfig parent, String componentType, String rendererType)
+        {
+            this.parent = parent;
+            this.componentType = componentType;
+            this.rendererType = rendererType;
+        }
+
+        public String getComponentType()
+        {
+            return this.componentType;
+        }
+
+        public String getRendererType()
+        {
+            return this.rendererType;
+        }
+
+        public FaceletHandler getNextHandler()
+        {
+            return this.parent.getNextHandler();
+        }
+
+        public Tag getTag()
+        {
+            return this.parent.getTag();
+        }
+
+        public String getTagId()
+        {
+            return this.parent.getTagId();
+        }
+    }
+
+    private static class UserTagFactory implements TagHandlerFactory
+    {
+        protected final URL location;
+
+        public UserTagFactory(URL location)
+        {
+            this.location = location;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            return new UserTagHandler(cfg, this.location);
+        }
+    }
+
+    private static class ComponentHandlerFactory implements TagHandlerFactory
+    {
+
+        protected final String componentType;
+
+        protected final String renderType;
+
+        /**
+         * @param handlerType
+         */
+        public ComponentHandlerFactory(String componentType, String renderType)
+        {
+            this.componentType = componentType;
+            this.renderType = renderType;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            ComponentConfig ccfg = new ComponentConfigWrapper(cfg, this.componentType, this.renderType);
+            return new ComponentHandler(ccfg);
+        }
+    }
+
+    private static class UserComponentHandlerFactory implements TagHandlerFactory
+    {
+
+        private final static Class<?>[] CONS_SIG = new Class[] { ComponentConfig.class };
+
+        protected final String componentType;
+
+        protected final String renderType;
+
+        protected final Class<? extends TagHandler> type;
+
+        protected final Constructor<? extends TagHandler> constructor;
+
+        /**
+         * @param handlerType
+         */
+        public UserComponentHandlerFactory(String componentType, String renderType, Class<? extends TagHandler> type)
+        {
+            this.componentType = componentType;
+            this.renderType = renderType;
+            this.type = type;
+            try
+            {
+                this.constructor = this.type.getConstructor(CONS_SIG);
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Must have a Constructor that takes in a ComponentConfig", e);
+            }
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                ComponentConfig ccfg = new ComponentConfigWrapper(cfg, componentType, renderType);
+                return constructor.newInstance(new Object[] { ccfg });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Error Instantiating ComponentHandler: " + this.type.getName(), e);
+            }
+        }
+    }
+
+    private static class ValidatorHandlerFactory implements TagHandlerFactory
+    {
+
+        protected final String validatorId;
+
+        public ValidatorHandlerFactory(String validatorId)
+        {
+            this.validatorId = validatorId;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            return new ValidateHandler(new ValidatorConfigWrapper(cfg, this.validatorId));
+        }
+    }
+
+    private static class ConverterHandlerFactory implements TagHandlerFactory
+    {
+
+        protected final String converterId;
+
+        public ConverterHandlerFactory(String converterId)
+        {
+            this.converterId = converterId;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            return new ConvertHandler(new ConverterConfigWrapper(cfg, this.converterId));
+        }
+    }
+
+    private static class UserConverterHandlerFactory implements TagHandlerFactory
+    {
+        private final static Class<?>[] CONS_SIG = new Class[] { ConverterConfig.class };
+
+        protected final String converterId;
+
+        protected final Class<? extends TagHandler> type;
+
+        protected final Constructor<? extends TagHandler> constructor;
+
+        public UserConverterHandlerFactory(String converterId, Class<? extends TagHandler> type)
+        {
+            this.converterId = converterId;
+            this.type = type;
+            try
+            {
+                this.constructor = this.type.getConstructor(CONS_SIG);
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Must have a Constructor that takes in a ConverterConfig", e);
+            }
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                ConverterConfig ccfg = new ConverterConfigWrapper(cfg, converterId);
+                return constructor.newInstance(new Object[] { ccfg });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Error Instantiating ConverterHandler: " + type.getName(), e);
+            }
+        }
+    }
+
+    private static class UserValidatorHandlerFactory implements TagHandlerFactory
+    {
+        private final static Class<?>[] CONS_SIG = new Class[] { ValidatorConfig.class };
+
+        protected final String validatorId;
+
+        protected final Class<? extends TagHandler> type;
+
+        protected final Constructor<? extends TagHandler> constructor;
+
+        public UserValidatorHandlerFactory(String validatorId, Class<? extends TagHandler> type)
+        {
+            this.validatorId = validatorId;
+            this.type = type;
+            try
+            {
+                this.constructor = this.type.getConstructor(CONS_SIG);
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Must have a Constructor that takes in a ConverterConfig", e);
+            }
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                ValidatorConfig ccfg = new ValidatorConfigWrapper(cfg, validatorId);
+                return constructor.newInstance(new Object[] { ccfg });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Error Instantiating ValidatorHandler: " + type.getName(), e);
+            }
+        }
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/BeanPropertyTagRule.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/BeanPropertyTagRule.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/BeanPropertyTagRule.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/BeanPropertyTagRule.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: BeanPropertyTagRule.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+final class BeanPropertyTagRule extends MetaRule
+{
+    public final static BeanPropertyTagRule Instance = new BeanPropertyTagRule();
+
+    public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+    {
+        Method m = meta.getWriteMethod(name);
+
+        // if the property is writable
+        if (m != null)
+        {
+            if (attribute.isLiteral())
+            {
+                return new LiteralPropertyMetadata(m, attribute);
+            }
+            else
+            {
+                return new DynamicPropertyMetadata(m, attribute);
+            }
+        }
+
+        return null;
+    }
+    
+    final static class LiteralPropertyMetadata extends Metadata
+    {
+
+        private final Method method;
+
+        private final TagAttribute attribute;
+
+        private Object[] value;
+
+        public LiteralPropertyMetadata(Method method, TagAttribute attribute)
+        {
+            this.method = method;
+            this.attribute = attribute;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            if (value == null)
+            {
+                String str = this.attribute.getValue();
+                value = new Object[] { ctx.getExpressionFactory().coerceToType(str, method.getParameterTypes()[0]) };
+            }
+            try
+            {
+                method.invoke(instance, this.value);
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new TagAttributeException(this.attribute, e.getCause());
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(this.attribute, e);
+            }
+        }
+
+    }
+
+    final static class DynamicPropertyMetadata extends Metadata
+    {
+
+        private final Method method;
+
+        private final TagAttribute attribute;
+
+        private final Class<?> type;
+
+        public DynamicPropertyMetadata(Method method, TagAttribute attribute)
+        {
+            this.method = method;
+            this.type = method.getParameterTypes()[0];
+            this.attribute = attribute;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            try
+            {
+                method.invoke(instance, new Object[] { attribute.getObject(ctx, type) });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new TagAttributeException(attribute, e.getCause());
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(attribute, e);
+            }
+        }
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeFaceletHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeFaceletHandler.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeFaceletHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeFaceletHandler.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.FaceletHandler;
+
+/**
+ * A FaceletHandler that is derived of 1 or more, inner FaceletHandlers. This class would be found if the next
+ * FaceletHandler is structually, a body with multiple child elements as defined in XML.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: CompositeFaceletHandler.java,v 1.5 2008/07/13 19:01:36 rlubke Exp $
+ */
+public final class CompositeFaceletHandler implements FaceletHandler
+{
+
+    private final FaceletHandler[] children;
+    private final int len;
+
+    public CompositeFaceletHandler(FaceletHandler[] children)
+    {
+        this.children = children;
+        this.len = children.length;
+    }
+
+    public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+            ELException
+    {
+        for (int i = 0; i < len; i++)
+        {
+            this.children[i].apply(ctx, parent);
+        }
+    }
+
+    public FaceletHandler[] getHandlers()
+    {
+        return this.children;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagDecorator.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagDecorator.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagDecorator.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import javax.faces.view.facelets.Tag;
+
+import org.apache.myfaces.view.facelets.util.ParameterCheck;
+
+/**
+ * A TagDecorator that is composed of 1 or more TagDecorator instances. It uses the chain of responsibility pattern to
+ * stop processing if any of the TagDecorators return a value other than null.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: CompositeTagDecorator.java,v 1.5 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class CompositeTagDecorator implements TagDecorator
+{
+
+    private final TagDecorator[] decorators;
+
+    public CompositeTagDecorator(TagDecorator[] decorators)
+    {
+        ParameterCheck.notNull("decorators", decorators);
+        this.decorators = decorators;
+    }
+
+    /**
+     * Uses the chain of responsibility pattern to stop processing if any of the TagDecorators return a value other than
+     * null.
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagDecorator#decorate(org.apache.myfaces.view.facelets.tag.Tag)
+     */
+    public Tag decorate(Tag tag)
+    {
+        Tag t = null;
+        for (int i = 0; i < this.decorators.length; i++)
+        {
+            t = this.decorators[i].decorate(tag);
+            if (t != null)
+            {
+                return t;
+            }
+        }
+        return tag;
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagLibrary.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/CompositeTagLibrary.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.lang.reflect.Method;
+
+import javax.faces.FacesException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.view.facelets.util.ParameterCheck;
+
+/**
+ * A TagLibrary that is composed of 1 or more TagLibrary children. Uses the chain of responsibility pattern to stop
+ * searching as soon as one of the children handles the requested method.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: CompositeTagLibrary.java,v 1.4 2008/07/13 19:01:36 rlubke Exp $
+ */
+public final class CompositeTagLibrary implements TagLibrary
+{
+
+    private final TagLibrary[] libraries;
+
+    public CompositeTagLibrary(TagLibrary[] libraries)
+    {
+        ParameterCheck.notNull("libraries", libraries);
+        this.libraries = libraries;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#containsNamespace(java.lang.String)
+     */
+    public boolean containsNamespace(String ns)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsNamespace(ns))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#containsTagHandler(java.lang.String, java.lang.String)
+     */
+    public boolean containsTagHandler(String ns, String localName)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsTagHandler(ns, localName))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#createTagHandler(java.lang.String, java.lang.String,
+     * org.apache.myfaces.view.facelets.tag.TagConfig)
+     */
+    public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsTagHandler(ns, localName))
+            {
+                return this.libraries[i].createTagHandler(ns, localName, tag);
+            }
+        }
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#containsFunction(java.lang.String, java.lang.String)
+     */
+    public boolean containsFunction(String ns, String name)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsFunction(ns, name))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.myfaces.view.facelets.tag.TagLibrary#createFunction(java.lang.String, java.lang.String)
+     */
+    public Method createFunction(String ns, String name)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsFunction(ns, name))
+            {
+                return this.libraries[i].createFunction(ns, name);
+            }
+        }
+        return null;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRule.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRule.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRule.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRule.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+//import javax.faces.view.facelets.tag.TagAttribute;
+//
+///**
+// * A potential rule for Metadata on the passed MetadataTarget
+// * 
+// * @see org.apache.myfaces.view.facelets.tag.Metadata
+// * @see org.apache.myfaces.view.facelets.tag.MetadataTarget
+// * @author Jacob Hookom
+// * @version $Id: MetaRule.java,v 1.3 2008/07/13 19:01:36 rlubke Exp $
+// */
+//public abstract class MetaRule
+//{
+//
+//    /**
+//     * @param name
+//     * @param attribute
+//     * @param meta
+//     * @return
+//     */
+//    public abstract Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta);
+//
+//}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaRulesetImpl.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.beans.IntrospectionException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.Tag;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagException;
+
+import org.apache.myfaces.view.facelets.util.ParameterCheck;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetaRulesetImpl.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class MetaRulesetImpl extends MetaRuleset
+{
+    private final static Metadata NONE = new NullMetadata();
+
+    private final static Logger log = Logger.getLogger("facelets.tag.meta");
+
+    private final static WeakHashMap<String, MetadataTarget> _metadata = new WeakHashMap<String, MetadataTarget>();
+
+    private final Map<String, TagAttribute> _attributes;
+
+    private final List<Metadata> _mappers;
+
+    private final List<MetaRule> _rules;
+
+    private final Tag _tag;
+
+    private final Class<?> _type;
+
+    public MetaRulesetImpl(Tag tag, Class<?> type)
+    {
+        _tag = tag;
+        _type = type;
+        _attributes = new HashMap<String, TagAttribute>();
+        _mappers = new ArrayList<Metadata>();
+        _rules = new ArrayList<MetaRule>();
+
+        // setup attributes
+        for (TagAttribute attribute : _tag.getAttributes().getAll())
+        {
+            _attributes.put(attribute.getLocalName(), attribute);
+        }
+
+        // add default rules
+        _rules.add(BeanPropertyTagRule.Instance);
+    }
+
+    public MetaRuleset add(Metadata mapper)
+    {
+        ParameterCheck.notNull("mapper", mapper);
+
+        if (!_mappers.contains(mapper))
+        {
+            _mappers.add(mapper);
+        }
+
+        return this;
+    }
+
+    public MetaRuleset addRule(MetaRule rule)
+    {
+        ParameterCheck.notNull("rule", rule);
+
+        _rules.add(rule);
+
+        return this;
+    }
+
+    public MetaRuleset alias(String attribute, String property)
+    {
+        ParameterCheck.notNull("attribute", attribute);
+        ParameterCheck.notNull("property", property);
+
+        TagAttribute attr = (TagAttribute) _attributes.remove(attribute);
+        if (attr != null)
+        {
+            _attributes.put(property, attr);
+        }
+
+        return this;
+    }
+
+    public Metadata finish()
+    {
+        assert !_rules.isEmpty();
+        
+        if (!_attributes.isEmpty())
+        {
+            MetadataTarget target = this._getMetadataTarget();
+            int ruleEnd = _rules.size() - 1;
+
+            // now iterate over attributes
+            for (Map.Entry<String, TagAttribute> entry : _attributes.entrySet())
+            {
+                Metadata data = null;
+
+                int i = ruleEnd;
+
+                // First loop is always safe
+                do
+                {
+                    MetaRule rule = _rules.get(i);
+                    data = rule.applyRule(entry.getKey(), entry.getValue(), target);
+                    i--;
+                } while (data == null && i >= 0);
+
+                if (data == null)
+                {
+                    if (log.isLoggable(Level.SEVERE))
+                    {
+                        log.severe(entry.getValue() + " Unhandled by MetaTagHandler for type " + _type.getName());
+                    }
+                }
+                else
+                {
+                    _mappers.add(data);
+                }
+            }
+        }
+
+        if (_mappers.isEmpty())
+        {
+            return NONE;
+        }
+        else
+        {
+            return new MetadataImpl(_mappers.toArray(new Metadata[_mappers.size()]));
+        }
+    }
+
+    public MetaRuleset ignore(String attribute)
+    {
+        ParameterCheck.notNull("attribute", attribute);
+
+        _attributes.remove(attribute);
+
+        return this;
+    }
+
+    public MetaRuleset ignoreAll()
+    {
+        _attributes.clear();
+
+        return this;
+    }
+
+    private final MetadataTarget _getMetadataTarget()
+    {
+        String key = _type.getName();
+
+        MetadataTarget meta = _metadata.get(key);
+        if (meta == null)
+        {
+            try
+            {
+                meta = new MetadataTargetImpl(_type);
+            }
+            catch (IntrospectionException e)
+            {
+                throw new TagException(_tag, "Error Creating TargetMetadata", e);
+            }
+
+            _metadata.put(key, meta);
+        }
+
+        return meta;
+    }
+
+    private static class NullMetadata extends Metadata
+    {
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            // do nothing
+        }
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaTagHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaTagHandlerImpl.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaTagHandlerImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetaTagHandlerImpl.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.MetaTagHandler;
+import javax.faces.view.facelets.TagConfig;
+
+import org.apache.myfaces.view.facelets.util.ParameterCheck;
+
+/**
+ * A base tag for wiring state to an object instance based on rules populated at the time of creating a MetaRuleset.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetaTagHandler.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public abstract class MetaTagHandlerImpl extends MetaTagHandler
+{
+    public MetaTagHandlerImpl(TagConfig config)
+    {
+        super(config);
+    }
+
+    /**
+     * Extend this method in order to add your own rules.
+     * 
+     * @param type
+     * @return
+     */
+    protected MetaRuleset createMetaRuleset(Class<?> type)
+    {
+        ParameterCheck.notNull("type", type);
+        
+        return new MetaRulesetImpl(this.tag, type);
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataImpl.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataImpl.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.Metadata;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetadataImpl.java,v 1.3 2008/07/13 19:01:36 rlubke Exp $
+ */
+final class MetadataImpl extends Metadata
+{
+    private final Metadata[] _mappers;
+    private final int _size;
+
+    public MetadataImpl(Metadata[] mappers)
+    {
+        _mappers = mappers;
+        _size = mappers.length;
+    }
+
+    public void applyMetadata(FaceletContext ctx, Object instance)
+    {
+        // TODO: PROFILE - Check if saving the _size worth it or if an enhanced for is better
+        for (int i = 0; i < _size; i++)
+        {
+            _mappers[i].applyMetadata(ctx, instance);
+        }
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataTargetImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataTargetImpl.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataTargetImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MetadataTargetImpl.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.view.facelets.MetadataTarget;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetadataTargetImpl.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+final class MetadataTargetImpl extends MetadataTarget
+{
+    private final Map<String, PropertyDescriptor> _pd;
+    
+    private final Class<?> _type;
+
+    public MetadataTargetImpl(Class<?> type) throws IntrospectionException
+    {
+        _type = type;
+        
+        _pd = new HashMap<String, PropertyDescriptor>();
+        for (PropertyDescriptor descriptor : Introspector.getBeanInfo(type).getPropertyDescriptors())
+        {
+            _pd.put(descriptor.getName(), descriptor);
+        }
+    }
+
+    public PropertyDescriptor getProperty(String name)
+    {
+        return _pd.get(name);
+    }
+
+    public Class<?> getPropertyType(String name)
+    {
+        PropertyDescriptor pd = getProperty(name);
+        if (pd != null)
+        {
+            return pd.getPropertyType();
+        }
+        
+        return null;
+    }
+
+    public Method getReadMethod(String name)
+    {
+        PropertyDescriptor pd = getProperty(name);
+        if (pd != null)
+        {
+            return pd.getReadMethod();
+        }
+        
+        return null;
+    }
+
+    public Class<?> getTargetClass()
+    {
+        return _type;
+    }
+
+    public Method getWriteMethod(String name)
+    {
+        PropertyDescriptor pd = getProperty(name);
+        if (pd != null)
+        {
+            return pd.getWriteMethod();
+        }
+        
+        return null;
+    }
+
+    public boolean isTargetInstanceOf(Class<?> type)
+    {
+        return type.isAssignableFrom(_type);
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MethodRule.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MethodRule.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MethodRule.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/MethodRule.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.el.MethodExpression;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+
+/**
+ * Optional Rule for binding Method[Binding|Expression] properties
+ * 
+ * @author Mike Kienenberger
+ * @author Jacob Hookom
+ */
+public final class MethodRule extends MetaRule
+{
+
+    private final String methodName;
+
+    private final Class<?> returnTypeClass;
+
+    private final Class<?>[] params;
+
+    public MethodRule(String methodName, Class<?> returnTypeClass, Class<?>[] params)
+    {
+        this.methodName = methodName;
+        this.returnTypeClass = returnTypeClass;
+        this.params = params;
+    }
+
+    public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+    {
+        if (false == name.equals(this.methodName))
+            return null;
+
+        if (MethodExpression.class.equals(meta.getPropertyType(name)))
+        {
+            Method method = meta.getWriteMethod(name);
+            if (method != null)
+            {
+                return new MethodExpressionMetadata(method, attribute, this.returnTypeClass, this.params);
+            }
+        }
+
+        return null;
+    }
+
+    private class MethodExpressionMetadata extends Metadata
+    {
+        private final Method _method;
+
+        private final TagAttribute _attribute;
+
+        private Class<?>[] _paramList;
+
+        private Class<?> _returnType;
+
+        public MethodExpressionMetadata(Method method, TagAttribute attribute, Class<?> returnType, 
+                                        Class<?>[] paramList)
+        {
+            _method = method;
+            _attribute = attribute;
+            _paramList = paramList;
+            _returnType = returnType;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            MethodExpression expr = _attribute.getMethodExpression(ctx, _returnType, _paramList);
+
+            try
+            {
+                _method.invoke(instance, new Object[] { expr });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new TagAttributeException(_attribute, e.getCause());
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(_attribute, e);
+            }
+        }
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributeImpl.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.Location;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+
+import org.apache.myfaces.view.facelets.el.ELText;
+import org.apache.myfaces.view.facelets.el.TagMethodExpression;
+import org.apache.myfaces.view.facelets.el.TagValueExpression;
+
+/**
+ * Representation of a Tag's attribute in a Facelet File
+ * 
+ * @author Jacob Hookom
+ * @version $Id: TagAttribute.java,v 1.9 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class TagAttributeImpl extends TagAttribute
+{
+
+    private final boolean literal;
+
+    private final String localName;
+
+    private final Location location;
+
+    private final String namespace;
+
+    private final String qName;
+
+    private final String value;
+
+    private String string;
+
+    public TagAttributeImpl(Location location, String ns, String localName, String qName, String value)
+    {
+        this.location = location;
+        this.namespace = ns;
+        this.localName = localName;
+        this.qName = qName;
+        this.value = value;
+        try
+        {
+            this.literal = ELText.isLiteral(this.value);
+        }
+        catch (ELException e)
+        {
+            throw new TagAttributeException(this, e);
+        }
+    }
+
+    /**
+     * If literal, return {@link Boolean#getBoolean(java.lang.String) Boolean.getBoolean(java.lang.String)} passing our
+     * value, otherwise call {@link #getObject(FaceletContext, Class) getObject(FaceletContext, Class)}.
+     * 
+     * @see Boolean#getBoolean(java.lang.String)
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return boolean value
+     */
+    public boolean getBoolean(FaceletContext ctx)
+    {
+        if (this.literal)
+        {
+            return Boolean.valueOf(this.value).booleanValue();
+        }
+        else
+        {
+            return ((Boolean) this.getObject(ctx, Boolean.class)).booleanValue();
+        }
+    }
+
+    /**
+     * If literal, call {@link Integer#parseInt(java.lang.String) Integer.parseInt(String)}, otherwise call
+     * {@link #getObject(FaceletContext, Class) getObject(FaceletContext, Class)}.
+     * 
+     * @see Integer#parseInt(java.lang.String)
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return int value
+     */
+    public int getInt(FaceletContext ctx)
+    {
+        if (this.literal)
+        {
+            return Integer.parseInt(this.value);
+        }
+        else
+        {
+            return ((Number) this.getObject(ctx, Integer.class)).intValue();
+        }
+    }
+
+    /**
+     * Local name of this attribute
+     * 
+     * @return local name of this attribute
+     */
+    public String getLocalName()
+    {
+        return this.localName;
+    }
+
+    /**
+     * The location of this attribute in the FaceletContext
+     * 
+     * @return the TagAttribute's location
+     */
+    public Location getLocation()
+    {
+        return this.location;
+    }
+
+    /**
+     * Create a MethodExpression, using this attribute's value as the expression String.
+     * 
+     * @see ExpressionFactory#createMethodExpression(javax.el.ELContext, java.lang.String, java.lang.Class,
+     *      java.lang.Class[])
+     * @see MethodExpression
+     * @param ctx
+     *            FaceletContext to use
+     * @param type
+     *            expected return type
+     * @param paramTypes
+     *            parameter type
+     * @return a MethodExpression instance
+     */
+    public MethodExpression getMethodExpression(FaceletContext ctx, Class<?> type, Class<?>[] paramTypes)
+    {
+        try
+        {
+            ExpressionFactory f = ctx.getExpressionFactory();
+            return new TagMethodExpression(this, f.createMethodExpression(ctx, this.value, type, paramTypes));
+        }
+        catch (Exception e)
+        {
+            throw new TagAttributeException(this, e);
+        }
+    }
+
+    /**
+     * The resolved Namespace for this attribute
+     * 
+     * @return resolved Namespace
+     */
+    public String getNamespace()
+    {
+        return this.namespace;
+    }
+
+    /**
+     * Delegates to getObject with Object.class as a param
+     * 
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return Object representation of this attribute's value
+     */
+    public Object getObject(FaceletContext ctx)
+    {
+        return this.getObject(ctx, Object.class);
+    }
+
+    /**
+     * The qualified name for this attribute
+     * 
+     * @return the qualified name for this attribute
+     */
+    public String getQName()
+    {
+        return this.qName;
+    }
+
+    /**
+     * Return the literal value of this attribute
+     * 
+     * @return literal value
+     */
+    public String getValue()
+    {
+        return this.value;
+    }
+
+    /**
+     * If literal, then return our value, otherwise delegate to getObject, passing String.class.
+     * 
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return String value of this attribute
+     */
+    public String getValue(FaceletContext ctx)
+    {
+        if (this.literal)
+        {
+            return this.value;
+        }
+        else
+        {
+            return (String) this.getObject(ctx, String.class);
+        }
+    }
+
+    /**
+     * If literal, simply coerce our String literal value using an ExpressionFactory, otherwise create a ValueExpression
+     * and evaluate it.
+     * 
+     * @see ExpressionFactory#coerceToType(java.lang.Object, java.lang.Class)
+     * @see ExpressionFactory#createValueExpression(javax.el.ELContext, java.lang.String, java.lang.Class)
+     * @see ValueExpression
+     * @param ctx
+     *            FaceletContext to use
+     * @param type
+     *            expected return type
+     * @return Object value of this attribute
+     */
+    public Object getObject(FaceletContext ctx, Class<?> type)
+    {
+        if (this.literal)
+        {
+            if (String.class.equals(type))
+            {
+                return this.value;
+            }
+            else
+            {
+                try
+                {
+                    return ctx.getExpressionFactory().coerceToType(this.value, type);
+                }
+                catch (Exception e)
+                {
+                    throw new TagAttributeException(this, e);
+                }
+            }
+        }
+        else
+        {
+            ValueExpression ve = this.getValueExpression(ctx, type);
+            try
+            {
+                return ve.getValue(ctx);
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(this, e);
+            }
+        }
+    }
+
+    /**
+     * Create a ValueExpression, using this attribute's literal value and the passed expected type.
+     * 
+     * @see ExpressionFactory#createValueExpression(javax.el.ELContext, java.lang.String, java.lang.Class)
+     * @see ValueExpression
+     * @param ctx
+     *            FaceletContext to use
+     * @param type
+     *            expected return type
+     * @return ValueExpression instance
+     */
+    public ValueExpression getValueExpression(FaceletContext ctx, Class<?> type)
+    {
+        try
+        {
+            ExpressionFactory f = ctx.getExpressionFactory();
+            return new TagValueExpression(this, f.createValueExpression(ctx, this.value, type));
+        }
+        catch (Exception e)
+        {
+            throw new TagAttributeException(this, e);
+        }
+    }
+
+    /**
+     * If this TagAttribute is literal (not #{..} or ${..})
+     * 
+     * @return true if this attribute is literal
+     */
+    public boolean isLiteral()
+    {
+        return this.literal;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        if (this.string == null)
+        {
+            this.string = this.location + " " + this.qName + "=\"" + this.value + "\"";
+        }
+        return this.string;
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributesImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributesImpl.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributesImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagAttributesImpl.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributes;
+
+/**
+ * A set of TagAttributes, usually representing all attributes on a Tag.
+ * 
+ * TODO: PROFILE - Explore the possibility of using HashMap instead of sorted arrays. 
+ *       The footprint should be higher, but the instanciation and access speed should be faster 
+ *       Instanciation: from O(n log n) to O(1)
+ *       Access: from O(log n) to O(1)
+ * 
+ * @see org.apache.myfaces.view.facelets.tag.Tag
+ * @see org.apache.myfaces.view.facelets.tag.TagAttributeImpl
+ * @author Jacob Hookom
+ * @version $Id: TagAttributes.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class TagAttributesImpl extends TagAttributes
+{
+    private final static TagAttribute[] EMPTY = new TagAttribute[0];
+
+    private final TagAttribute[] _attributes;
+
+    private final String[] _namespaces;
+
+    private final List<TagAttribute[]> _nsattrs;
+
+    /**
+     * 
+     */
+    public TagAttributesImpl(TagAttribute[] attrs)
+    {
+        _attributes = attrs;
+
+        // grab namespaces
+        Set<String> set = new HashSet<String>();
+        for (TagAttribute attribute : _attributes)
+        {
+            set.add(attribute.getNamespace());
+        }
+        
+        _namespaces = set.toArray(new String[set.size()]);
+        Arrays.sort(_namespaces);
+
+        // assign attrs
+        int size = _namespaces.length;
+        List<List<TagAttribute>> temp = new ArrayList<List<TagAttribute>>(size);
+        for (int i = 0; i < size; i++)
+        {
+            temp.add(new ArrayList<TagAttribute>());
+        }
+        
+        for (TagAttribute attribute : _attributes)
+        {
+            temp.get(Arrays.binarySearch(_namespaces, attribute.getNamespace())).add(attribute);
+        }
+        
+        _nsattrs = new ArrayList<TagAttribute[]>(size);
+        for (List<TagAttribute> l : temp)
+        {
+            _nsattrs.add(l.toArray(new TagAttribute[l.size()]));
+        }
+    }
+
+    /**
+     * Return an array of all TagAttributes in this set
+     * 
+     * @return a non-null array of TagAttributes
+     */
+    public TagAttribute[] getAll()
+    {
+        return _attributes;
+    }
+
+    /**
+     * Using no namespace, find the TagAttribute
+     * 
+     * @see #get(String, String)
+     * @param localName
+     *            tag attribute name
+     * @return the TagAttribute found, otherwise null
+     */
+    public TagAttribute get(String localName)
+    {
+        return get("", localName);
+    }
+
+    /**
+     * Find a TagAttribute that matches the passed namespace and local name.
+     * 
+     * @param ns
+     *            namespace of the desired attribute
+     * @param localName
+     *            local name of the attribute
+     * @return a TagAttribute found, otherwise null
+     */
+    public TagAttribute get(String ns, String localName)
+    {
+        if (ns != null && localName != null)
+        {
+            int idx = Arrays.binarySearch(_namespaces, ns);
+            if (idx >= 0)
+            {
+                for (TagAttribute attribute : _nsattrs.get(idx))
+                {
+                    if (localName.equals(attribute.getLocalName()))
+                    {
+                        return attribute;
+                    }
+                }
+            }
+        }
+        
+        return null;
+    }
+
+    /**
+     * Get all TagAttributes for the passed namespace
+     * 
+     * @param namespace
+     *            namespace to search
+     * @return a non-null array of TagAttributes
+     */
+    public TagAttribute[] getAll(String namespace)
+    {
+        int idx = 0;
+        if (namespace == null)
+        {
+            idx = Arrays.binarySearch(_namespaces, "");
+        }
+        else
+        {
+            idx = Arrays.binarySearch(_namespaces, namespace);
+        }
+        
+        if (idx >= 0)
+        {
+            return _nsattrs.get(idx);
+        }
+        
+        return EMPTY;
+    }
+
+    /**
+     * A list of Namespaces found in this set
+     * 
+     * @return a list of Namespaces found in this set
+     */
+    public String[] getNamespaces()
+    {
+        return _namespaces;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    @Override
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        for (TagAttribute attribute : _attributes)
+        {
+            sb.append(attribute);
+            sb.append(' ');
+        }
+        
+        if (sb.length() > 1)
+        {
+            sb.setLength(sb.length() - 1);
+        }
+        
+        return sb.toString();
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagDecorator.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagDecorator.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagDecorator.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import javax.faces.view.facelets.Tag;
+
+/**
+ * Provides the ability to completely change the Tag before it's processed for compiling with the associated TagHandler.
+ * <p /> You could take &lt;input type="text" /> and convert it to &lth:inputText /> before compiling.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: TagDecorator.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public interface TagDecorator
+{
+
+    /**
+     * If handled, return a new Tag instance, otherwise return null
+     * 
+     * @param tag
+     *            tag to be decorated
+     * @return a decorated tag, otherwise null
+     */
+    public Tag decorate(Tag tag);
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerFactory.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerFactory.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerFactory.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+/**
+ * Delegate class for TagLibraries
+ * 
+ * @see TagLibrary
+ * @author Jacob Hookom
+ * @version $Id: TagHandlerFactory.java,v 1.4 2008/07/13 19:01:35 rlubke Exp $
+ */
+interface TagHandlerFactory
+{
+    /**
+     * A new TagHandler instantiated with the passed TagConfig
+     * 
+     * @param cfg
+     *            TagConfiguration information
+     * @return a new TagHandler
+     * @throws FacesException
+     * @throws ELException
+     */
+    public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException;
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagHandlerUtils.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.faces.view.facelets.FaceletHandler;
+
+/**
+ * This class was created to gather some code from latest Facelets not existing in latest JSF 2.0 spec.
+ * Also, since it was created on the fly while converting, it's highly possible that methods in this class
+ * should be moved in a more logical location and/or removed.
+ * 
+ * @author Simon Lessard (latest modification by $Author: slessard $)
+ * @version $Revision: 696523 $ $Date: 2009-03-21 12:31:27 -0400 (mer., 17 sept. 2008) $
+ *
+ * @since 2.0
+ */
+public final class TagHandlerUtils
+{
+
+    /**
+     * From TagHandler: 
+     * protected final <T> Iterator<T> findNextByType(Class<T> type)
+     * 
+     * @param type
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> Collection<T> findNextByType(FaceletHandler nextHandler, Class<T> type)
+    {
+        List<T> found = new ArrayList<T>();
+        if (type.isAssignableFrom(nextHandler.getClass()))
+        {
+            found.add((T)nextHandler);
+        }
+        else if (nextHandler instanceof CompositeFaceletHandler)
+        {
+            for (FaceletHandler handler : ((CompositeFaceletHandler)nextHandler).getHandlers())
+            {
+                if (type.isAssignableFrom(handler.getClass()))
+                {
+                    found.add((T)handler);
+                }
+            }
+        }
+        
+        return found;
+    }
+
+    private TagHandlerUtils()
+    {
+        
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagLibrary.java?rev=761982&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/tag/TagLibrary.java Sat Apr  4 18:44:59 2009
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.myfaces.view.facelets.tag;
+
+import java.lang.reflect.Method;
+
+import javax.faces.FacesException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+
+/**
+ * A library of Tags associated with one or more namespaces.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: TagLibrary.java,v 1.3 2008/07/13 19:01:36 rlubke Exp $
+ */
+public interface TagLibrary
+{
+
+    /**
+     * If this library contains the passed namespace
+     * 
+     * @param ns
+     *            namespace
+     * @return true if the namespace is used in this library
+     */
+    public boolean containsNamespace(String ns);
+
+    /**
+     * If this library contains a TagHandler for the namespace and local name
+     * 
+     * @param ns
+     *            namespace
+     * @param localName
+     *            local name
+     * @return true if handled by this library
+     */
+    public boolean containsTagHandler(String ns, String localName);
+
+    /**
+     * Create a new instance of a TagHandler, using the passed TagConfig
+     * 
+     * @param ns
+     *            namespace
+     * @param localName
+     *            local name
+     * @param tag
+     *            configuration information
+     * @return a new TagHandler instance
+     * @throws FacesException
+     */
+    public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException;
+
+    /**
+     * If this library contains the specified function name
+     * 
+     * @param ns
+     *            namespace
+     * @param name
+     *            function name
+     * @return true if handled
+     */
+    public boolean containsFunction(String ns, String name);
+
+    /**
+     * Return a Method instance for the passed namespace and name
+     * 
+     * @param ns
+     *            namespace
+     * @param name
+     *            function name
+     * @return
+     */
+    public Method createFunction(String ns, String name);
+}



Mime
View raw message