myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sless...@apache.org
Subject svn commit: r740940 [4/9] - in /myfaces/core/branches/2_0_0: api/src/main/java/javax/faces/webapp/pdl/facelets/ api/src/main/resources/META-INF/ impl/src/main/java/com/ impl/src/main/java/com/sun/ impl/src/main/java/com/sun/facelets/ impl/src/main/java...
Date Wed, 04 Feb 2009 23:55:29 GMT
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/ELText.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/ELText.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/ELText.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/ELText.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,443 @@
+/**
+ * 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 com.sun.facelets.el;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.context.ResponseWriter;
+
+import com.sun.facelets.util.FastWriter;
+
+/**
+ * Handles parsing EL Strings in accordance with the EL-API Specification. The parser accepts either <code>${..}</code>
+ * or <code>#{..}</code>.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: ELText.java,v 1.8 2008/07/13 19:01:42 rlubke Exp $
+ */
+public class ELText
+{
+
+    private static final class LiteralValueExpression extends ValueExpression
+    {
+
+        /**
+         * 
+         */
+        private static final long serialVersionUID = 1L;
+
+        private final String text;
+
+        public LiteralValueExpression(String text)
+        {
+            this.text = text;
+        }
+
+        public boolean isLiteralText()
+        {
+            return false;
+        }
+
+        public int hashCode()
+        {
+            return 0;
+        }
+
+        public String getExpressionString()
+        {
+            return this.text;
+        }
+
+        public boolean equals(Object obj)
+        {
+            return false;
+        }
+
+        public void setValue(ELContext context, Object value)
+        {
+        }
+
+        public boolean isReadOnly(ELContext context)
+        {
+            return false;
+        }
+
+        public Object getValue(ELContext context)
+        {
+            return null;
+        }
+
+        public Class getType(ELContext context)
+        {
+            return null;
+        }
+
+        public Class getExpectedType()
+        {
+            return null;
+        }
+
+    }
+
+    private static final class ELTextComposite extends ELText
+    {
+        private final ELText[] txt;
+
+        public ELTextComposite(ELText[] txt)
+        {
+            super(null);
+            this.txt = txt;
+        }
+
+        public void write(Writer out, ELContext ctx) throws ELException, IOException
+        {
+            for (int i = 0; i < this.txt.length; i++)
+            {
+                this.txt[i].write(out, ctx);
+            }
+        }
+
+        public void writeText(ResponseWriter out, ELContext ctx) throws ELException, IOException
+        {
+            for (int i = 0; i < this.txt.length; i++)
+            {
+                this.txt[i].writeText(out, ctx);
+            }
+        }
+
+        public String toString(ELContext ctx)
+        {
+            StringBuffer sb = new StringBuffer();
+            for (int i = 0; i < this.txt.length; i++)
+            {
+                sb.append(this.txt[i].toString(ctx));
+            }
+            return sb.toString();
+        }
+
+        /*
+         * public String toString(ELContext ctx) { StringBuffer sb = new StringBuffer(); for (int i = 0; i <
+         * this.txt.length; i++) { sb.append(this.txt[i].toString(ctx)); } return sb.toString(); }
+         */
+
+        public String toString()
+        {
+            StringBuffer sb = new StringBuffer();
+            for (int i = 0; i < this.txt.length; i++)
+            {
+                sb.append(this.txt[i].toString());
+            }
+            return sb.toString();
+        }
+
+        public boolean isLiteral()
+        {
+            return false;
+        }
+
+        public ELText apply(ExpressionFactory factory, ELContext ctx)
+        {
+            int len = this.txt.length;
+            ELText[] nt = new ELText[len];
+            for (int i = 0; i < len; i++)
+            {
+                nt[i] = this.txt[i].apply(factory, ctx);
+            }
+            return new ELTextComposite(nt);
+        }
+    }
+
+    private static final class ELTextVariable extends ELText
+    {
+        private final ValueExpression ve;
+
+        public ELTextVariable(ValueExpression ve)
+        {
+            super(ve.getExpressionString());
+            this.ve = ve;
+        }
+
+        public boolean isLiteral()
+        {
+            return false;
+        }
+
+        public ELText apply(ExpressionFactory factory, ELContext ctx)
+        {
+            return new ELTextVariable(factory.createValueExpression(ctx, this.ve.getExpressionString(), String.class));
+        }
+
+        public void write(Writer out, ELContext ctx) throws ELException, IOException
+        {
+            Object v = this.ve.getValue(ctx);
+            if (v != null)
+            {
+                out.write((String) v);
+            }
+        }
+
+        public String toString(ELContext ctx) throws ELException
+        {
+            Object v = this.ve.getValue(ctx);
+            if (v != null)
+            {
+                return v.toString();
+            }
+
+            return null;
+        }
+
+        public void writeText(ResponseWriter out, ELContext ctx) throws ELException, IOException
+        {
+            Object v = this.ve.getValue(ctx);
+            if (v != null)
+            {
+                out.writeText((String) v, null);
+            }
+        }
+    }
+
+    protected final String literal;
+
+    public ELText(String literal)
+    {
+        this.literal = literal;
+    }
+
+    /**
+     * If it's literal text
+     * 
+     * @return true if the String is literal (doesn't contain <code>#{..}</code> or <code>${..}</code>)
+     */
+    public boolean isLiteral()
+    {
+        return true;
+    }
+
+    /**
+     * Return an instance of <code>this</code> that is applicable given the ELContext and ExpressionFactory state.
+     * 
+     * @param factory
+     *            the ExpressionFactory to use
+     * @param ctx
+     *            the ELContext to use
+     * @return an ELText instance
+     */
+    public ELText apply(ExpressionFactory factory, ELContext ctx)
+    {
+        return this;
+    }
+
+    /**
+     * Allow this instance to write to the passed Writer, given the ELContext state
+     * 
+     * @param out
+     *            Writer to write to
+     * @param ctx
+     *            current ELContext state
+     * @throws ELException
+     * @throws IOException
+     */
+    public void write(Writer out, ELContext ctx) throws ELException, IOException
+    {
+        out.write(this.literal);
+    }
+
+    public void writeText(ResponseWriter out, ELContext ctx) throws ELException, IOException
+    {
+        out.writeText(this.literal, null);
+    }
+
+    /**
+     * Evaluates the ELText to a String
+     * 
+     * @param ctx
+     *            current ELContext state
+     * @throws ELException
+     * @return the evaluated String
+     */
+    public String toString(ELContext ctx) throws ELException
+    {
+        return this.literal;
+    }
+
+    public String toString()
+    {
+        return this.literal;
+    }
+
+    /**
+     * Parses the passed string to determine if it's literal or not
+     * 
+     * @param in
+     *            input String
+     * @return true if the String is literal (doesn't contain <code>#{..}</code> or <code>${..}</code>)
+     */
+    public static boolean isLiteral(String in)
+    {
+        ELText txt = parse(in);
+        return txt == null || txt.isLiteral();
+    }
+
+    /**
+     * Factory method for creating an unvalidated ELText instance. NOTE: All expressions in the passed String are
+     * treated as {@link com.sun.facelets.el.LiteralValueExpression LiteralValueExpressions}.
+     * 
+     * @param in
+     *            String to parse
+     * @return ELText instance that knows if the String was literal or not
+     * @throws javax.el.ELException
+     */
+    public static ELText parse(String in) throws ELException
+    {
+        return parse(null, null, in);
+    }
+
+    /**
+     * Factory method for creating a validated ELText instance. When an Expression is hit, it will use the
+     * ExpressionFactory to create a ValueExpression instance, resolving any functions at that time. <p/> Variables and
+     * properties will not be evaluated.
+     * 
+     * @param fact
+     *            ExpressionFactory to use
+     * @param ctx
+     *            ELContext to validate against
+     * @param in
+     *            String to parse
+     * @return ELText that can be re-applied later
+     * @throws javax.el.ELException
+     */
+    public static ELText parse(ExpressionFactory fact, ELContext ctx, String in) throws ELException
+    {
+        char[] ca = in.toCharArray();
+        int i = 0;
+        char c = 0;
+        int len = ca.length;
+        int end = len - 1;
+        boolean esc = false;
+        int vlen = 0;
+
+        StringBuffer buff = new StringBuffer(128);
+        List text = new ArrayList();
+        ELText t = null;
+        ValueExpression ve = null;
+
+        while (i < len)
+        {
+            c = ca[i];
+            if ('\\' == c)
+            {
+                esc = !esc;
+                if (esc && i < end && (ca[i + 1] == '$' || ca[i + 1] == '#'))
+                {
+                    i++;
+                    continue;
+                }
+            }
+            else if (!esc && ('$' == c || '#' == c))
+            {
+                if (i < end)
+                {
+                    if ('{' == ca[i + 1])
+                    {
+                        if (buff.length() > 0)
+                        {
+                            text.add(new ELText(buff.toString()));
+                            buff.setLength(0);
+                        }
+                        vlen = findVarLength(ca, i);
+                        if (ctx != null && fact != null)
+                        {
+                            ve = fact.createValueExpression(ctx, new String(ca, i, vlen), String.class);
+                            t = new ELTextVariable(ve);
+                        }
+                        else
+                        {
+                            t = new ELTextVariable(new LiteralValueExpression(new String(ca, i, vlen)));
+                        }
+                        text.add(t);
+                        i += vlen;
+                        continue;
+                    }
+                }
+            }
+            esc = false;
+            buff.append(c);
+            i++;
+        }
+
+        if (buff.length() > 0)
+        {
+            text.add(new ELText(new String(buff.toString())));
+            buff.setLength(0);
+        }
+
+        if (text.size() == 0)
+        {
+            return null;
+        }
+        else if (text.size() == 1)
+        {
+            return (ELText) text.get(0);
+        }
+        else
+        {
+            ELText[] ta = (ELText[]) text.toArray(new ELText[text.size()]);
+            return new ELTextComposite(ta);
+        }
+    }
+
+    private static int findVarLength(char[] ca, int s) throws ELException
+    {
+        int i = s;
+        int len = ca.length;
+        char c = 0;
+        int str = 0;
+        while (i < len)
+        {
+            c = ca[i];
+            if ('\\' == c && i < len - 1)
+            {
+                i++;
+            }
+            else if ('\'' == c || '"' == c)
+            {
+                if (str == c)
+                {
+                    str = 0;
+                }
+                else
+                {
+                    str = c;
+                }
+            }
+            else if (str == 0 && ('}' == c))
+            {
+                return i - s + 1;
+            }
+            i++;
+        }
+        throw new ELException("EL Expression Unbalanced: ... " + new String(ca, s, i - s));
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyELContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyELContext.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyELContext.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyELContext.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,294 @@
+/**
+ * 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 com.sun.facelets.el;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.PropertyNotWritableException;
+import javax.el.VariableMapper;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.VariableResolver;
+
+/**
+ * 
+ * 
+ * @author Jacob Hookom
+ * @version $Id: LegacyELContext.java,v 1.8 2008/07/13 19:01:42 rlubke Exp $
+ * @deprecated
+ */
+public final class LegacyELContext extends ELContext
+{
+
+    private static final String[] IMPLICIT_OBJECTS = new String[] { "application", "applicationScope", "cookie",
+                                                                   "facesContext", "header", "headerValues",
+                                                                   "initParam", "param", "paramValues", "request",
+                                                                   "requestScope", "session", "sessionScope", "view" };
+
+    private final static FunctionMapper functions = new EmptyFunctionMapper();
+
+    private final FacesContext faces;
+
+    private final ELResolver resolver;
+
+    private final VariableMapper variables;
+
+    public LegacyELContext(FacesContext faces)
+    {
+        this.faces = faces;
+        this.resolver = new LegacyELResolver();
+        this.variables = new DefaultVariableMapper();
+    }
+
+    public ELResolver getELResolver()
+    {
+        return this.resolver;
+    }
+
+    public FunctionMapper getFunctionMapper()
+    {
+        return functions;
+    }
+
+    public VariableMapper getVariableMapper()
+    {
+        return this.variables;
+    }
+
+    public FacesContext getFacesContext()
+    {
+        return this.faces;
+    }
+
+    private final class LegacyELResolver extends ELResolver
+    {
+
+        public Class getCommonPropertyType(ELContext context, Object base)
+        {
+            return Object.class;
+        }
+
+        public Iterator getFeatureDescriptors(ELContext context, Object base)
+        {
+            return Collections.EMPTY_LIST.iterator();
+        }
+
+        private VariableResolver getVariableResolver()
+        {
+            return faces.getApplication().getVariableResolver();
+        }
+
+        private PropertyResolver getPropertyResolver()
+        {
+            return faces.getApplication().getPropertyResolver();
+        }
+
+        public Class getType(ELContext context, Object base, Object property)
+        {
+            if (property == null)
+            {
+                return null;
+            }
+            try
+            {
+                context.setPropertyResolved(true);
+                if (base == null)
+                {
+                    Object obj = this.getVariableResolver().resolveVariable(faces, property.toString());
+                    return (obj != null) ? obj.getClass() : null;
+                }
+                else
+                {
+                    if (base instanceof List || base.getClass().isArray())
+                    {
+                        return this.getPropertyResolver().getType(base, Integer.parseInt(property.toString()));
+                    }
+                    else
+                    {
+                        return this.getPropertyResolver().getType(base, property);
+                    }
+                }
+            }
+            catch (PropertyNotFoundException e)
+            {
+                throw new javax.el.PropertyNotFoundException(e.getMessage(), e.getCause());
+            }
+            catch (EvaluationException e)
+            {
+                throw new ELException(e.getMessage(), e.getCause());
+            }
+        }
+
+        public Object getValue(ELContext context, Object base, Object property)
+        {
+            if (property == null)
+            {
+                return null;
+            }
+            try
+            {
+                context.setPropertyResolved(true);
+                if (base == null)
+                {
+                    return this.getVariableResolver().resolveVariable(faces, property.toString());
+                }
+                else
+                {
+                    if (base instanceof List || base.getClass().isArray())
+                    {
+                        return this.getPropertyResolver().getValue(base, Integer.parseInt(property.toString()));
+                    }
+                    else
+                    {
+                        return this.getPropertyResolver().getValue(base, property);
+                    }
+                }
+            }
+            catch (PropertyNotFoundException e)
+            {
+                throw new javax.el.PropertyNotFoundException(e.getMessage(), e.getCause());
+            }
+            catch (EvaluationException e)
+            {
+                throw new ELException(e.getMessage(), e.getCause());
+            }
+        }
+
+        public boolean isReadOnly(ELContext context, Object base, Object property)
+        {
+            if (property == null)
+            {
+                return true;
+            }
+            try
+            {
+                context.setPropertyResolved(true);
+                if (base == null)
+                {
+                    return false; // what can I do?
+                }
+                else
+                {
+                    if (base instanceof List || base.getClass().isArray())
+                    {
+                        return this.getPropertyResolver().isReadOnly(base, Integer.parseInt(property.toString()));
+                    }
+                    else
+                    {
+                        return this.getPropertyResolver().isReadOnly(base, property);
+                    }
+                }
+            }
+            catch (PropertyNotFoundException e)
+            {
+                throw new javax.el.PropertyNotFoundException(e.getMessage(), e.getCause());
+            }
+            catch (EvaluationException e)
+            {
+                throw new ELException(e.getMessage(), e.getCause());
+            }
+        }
+
+        public void setValue(ELContext context, Object base, Object property, Object value)
+        {
+            if (property == null)
+            {
+                throw new PropertyNotWritableException("Null Property");
+            }
+            try
+            {
+                context.setPropertyResolved(true);
+                if (base == null)
+                {
+                    if (Arrays.binarySearch(IMPLICIT_OBJECTS, property.toString()) >= 0)
+                    {
+                        throw new PropertyNotWritableException("Implicit Variable Not Setable: " + property);
+                    }
+                    else
+                    {
+                        Map scope = this.resolveScope(property.toString());
+                        this.getPropertyResolver().setValue(scope, property, value);
+                    }
+                }
+                else
+                {
+                    if (base instanceof List || base.getClass().isArray())
+                    {
+                        this.getPropertyResolver().setValue(base, Integer.parseInt(property.toString()), value);
+                    }
+                    else
+                    {
+                        this.getPropertyResolver().setValue(base, property, value);
+                    }
+                }
+            }
+            catch (PropertyNotFoundException e)
+            {
+                throw new javax.el.PropertyNotFoundException(e.getMessage(), e.getCause());
+            }
+            catch (EvaluationException e)
+            {
+                throw new ELException(e.getMessage(), e.getCause());
+            }
+
+        }
+
+        private final Map resolveScope(String var)
+        {
+            ExternalContext ext = faces.getExternalContext();
+
+            // cycle through the scopes to find a match, if no
+            // match is found, then return the requestScope
+            Map map = ext.getRequestMap();
+            if (!map.containsKey(var))
+            {
+                map = ext.getSessionMap();
+                if (!map.containsKey(var))
+                {
+                    map = ext.getApplicationMap();
+                    if (!map.containsKey(var))
+                    {
+                        map = ext.getRequestMap();
+                    }
+                }
+            }
+            return map;
+        }
+    }
+
+    private final static class EmptyFunctionMapper extends FunctionMapper
+    {
+
+        public Method resolveFunction(String prefix, String localName)
+        {
+            return null;
+        }
+
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyMethodBinding.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyMethodBinding.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyMethodBinding.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyMethodBinding.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,91 @@
+/**
+ * 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 com.sun.facelets.el;
+
+import java.io.Serializable;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.MethodNotFoundException;
+
+/**
+ * For legacy ActionSources
+ * 
+ * @author Jacob Hookom
+ * @version $Id: LegacyMethodBinding.java,v 1.7 2008/07/13 19:01:43 rlubke Exp $
+ * @deprecated
+ */
+public final class LegacyMethodBinding extends MethodBinding implements Serializable
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final MethodExpression m;
+
+    public LegacyMethodBinding(MethodExpression m)
+    {
+        this.m = m;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.el.MethodBinding#getType(javax.faces.context.FacesContext)
+     */
+    public Class getType(FacesContext context) throws MethodNotFoundException
+    {
+        try
+        {
+            return m.getMethodInfo(ELAdaptor.getELContext(context)).getReturnType();
+        }
+        catch (javax.el.MethodNotFoundException e)
+        {
+            throw new MethodNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.el.MethodBinding#invoke(javax.faces.context.FacesContext, java.lang.Object[])
+     */
+    public Object invoke(FacesContext context, Object[] params) throws EvaluationException, MethodNotFoundException
+    {
+        try
+        {
+            return m.invoke(ELAdaptor.getELContext(context), params);
+        }
+        catch (javax.el.MethodNotFoundException e)
+        {
+            throw new MethodNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    public String getExpressionString()
+    {
+        return m.getExpressionString();
+    }
+}
\ No newline at end of file

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyValueBinding.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyValueBinding.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyValueBinding.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/LegacyValueBinding.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,141 @@
+/**
+ * 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 com.sun.facelets.el;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+
+/**
+ * 
+ * 
+ * @author Jacob Hookom
+ * @version $Id: LegacyValueBinding.java,v 1.6 2008/07/13 19:01:43 rlubke Exp $
+ * @deprecated
+ */
+public final class LegacyValueBinding extends ValueBinding implements Externalizable
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private ValueExpression delegate;
+
+    public LegacyValueBinding()
+    {
+        super();
+    }
+
+    public LegacyValueBinding(ValueExpression ve)
+    {
+        this.delegate = ve;
+    }
+
+    public Object getValue(FacesContext context) throws EvaluationException, PropertyNotFoundException
+    {
+        ELContext ctx = ELAdaptor.getELContext(context);
+        try
+        {
+            return this.delegate.getValue(ctx);
+        }
+        catch (javax.el.PropertyNotFoundException e)
+        {
+            throw new PropertyNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    public void setValue(FacesContext context, Object value) throws EvaluationException, PropertyNotFoundException
+    {
+        ELContext ctx = ELAdaptor.getELContext(context);
+        try
+        {
+            this.delegate.setValue(ctx, value);
+        }
+        catch (PropertyNotWritableException e)
+        {
+            throw new PropertyNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (javax.el.PropertyNotFoundException e)
+        {
+            throw new PropertyNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    public boolean isReadOnly(FacesContext context) throws EvaluationException, PropertyNotFoundException
+    {
+        ELContext ctx = ELAdaptor.getELContext(context);
+        try
+        {
+            return this.delegate.isReadOnly(ctx);
+        }
+        catch (javax.el.PropertyNotFoundException e)
+        {
+            throw new PropertyNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    public Class getType(FacesContext context) throws EvaluationException, PropertyNotFoundException
+    {
+        ELContext ctx = ELAdaptor.getELContext(context);
+        try
+        {
+            return this.delegate.getType(ctx);
+        }
+        catch (javax.el.PropertyNotFoundException e)
+        {
+            throw new PropertyNotFoundException(e.getMessage(), e.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new EvaluationException(e.getMessage(), e.getCause());
+        }
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+    {
+        this.delegate = (ValueExpression) in.readObject();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException
+    {
+        out.writeObject(this.delegate);
+    }
+
+    public String getExpressionString()
+    {
+        return this.delegate.getExpressionString();
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagMethodExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagMethodExpression.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagMethodExpression.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagMethodExpression.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,132 @@
+/**
+ * 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 com.sun.facelets.el;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodInfo;
+import javax.el.MethodNotFoundException;
+import javax.el.PropertyNotFoundException;
+
+import com.sun.facelets.tag.TagAttribute;
+
+/**
+ * 
+ * 
+ * @author Jacob Hookom
+ * @version $Id: TagMethodExpression.java,v 1.7 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class TagMethodExpression extends MethodExpression implements Externalizable
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private String attr;
+    private MethodExpression orig;
+
+    public TagMethodExpression()
+    {
+        super();
+    }
+
+    public TagMethodExpression(TagAttribute attr, MethodExpression orig)
+    {
+        this.attr = attr.toString();
+        this.orig = orig;
+    }
+
+    public MethodInfo getMethodInfo(ELContext context)
+    {
+        try
+        {
+            return this.orig.getMethodInfo(context);
+        }
+        catch (PropertyNotFoundException pnfe)
+        {
+            throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
+        }
+        catch (MethodNotFoundException mnfe)
+        {
+            throw new MethodNotFoundException(this.attr + ": " + mnfe.getMessage(), mnfe.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
+        }
+    }
+
+    public Object invoke(ELContext context, Object[] params)
+    {
+        try
+        {
+            return this.orig.invoke(context, params);
+        }
+        catch (PropertyNotFoundException pnfe)
+        {
+            throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
+        }
+        catch (MethodNotFoundException mnfe)
+        {
+            throw new MethodNotFoundException(this.attr + ": " + mnfe.getMessage(), mnfe.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
+        }
+    }
+
+    public String getExpressionString()
+    {
+        return this.orig.getExpressionString();
+    }
+
+    public boolean equals(Object obj)
+    {
+        return this.orig.equals(obj);
+    }
+
+    public int hashCode()
+    {
+        return this.orig.hashCode();
+    }
+
+    public boolean isLiteralText()
+    {
+        return this.orig.isLiteralText();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException
+    {
+        out.writeObject(this.orig);
+        out.writeUTF(this.attr);
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+    {
+        this.orig = (MethodExpression) in.readObject();
+        this.attr = in.readUTF();
+    }
+
+    public String toString()
+    {
+        return this.attr + ": " + this.orig;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagValueExpression.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagValueExpression.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagValueExpression.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/TagValueExpression.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,165 @@
+/**
+ * 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 com.sun.facelets.el;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.PropertyNotFoundException;
+import javax.el.PropertyNotWritableException;
+import javax.el.ValueExpression;
+
+import com.sun.facelets.tag.TagAttribute;
+
+/**
+ * 
+ * 
+ * @author Jacob Hookom
+ * @version $Id: TagValueExpression.java,v 1.7 2008/07/13 19:01:42 rlubke Exp $
+ */
+public final class TagValueExpression extends ValueExpression implements Externalizable
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private ValueExpression orig;
+
+    private String attr;
+
+    public TagValueExpression()
+    {
+        super();
+    }
+
+    public TagValueExpression(TagAttribute attr, ValueExpression orig)
+    {
+        this.attr = attr.toString();
+        this.orig = orig;
+    }
+
+    public Class getExpectedType()
+    {
+        return this.orig.getExpectedType();
+    }
+
+    public Class getType(ELContext context)
+    {
+        try
+        {
+            return this.orig.getType(context);
+        }
+        catch (PropertyNotFoundException pnfe)
+        {
+            throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
+        }
+    }
+
+    public Object getValue(ELContext context)
+    {
+        try
+        {
+            return this.orig.getValue(context);
+        }
+        catch (PropertyNotFoundException pnfe)
+        {
+            throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
+        }
+    }
+
+    public boolean isReadOnly(ELContext context)
+    {
+        try
+        {
+            return this.orig.isReadOnly(context);
+        }
+        catch (PropertyNotFoundException pnfe)
+        {
+            throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
+        }
+    }
+
+    public void setValue(ELContext context, Object value)
+    {
+        try
+        {
+            this.orig.setValue(context, value);
+        }
+        catch (PropertyNotFoundException pnfe)
+        {
+            throw new PropertyNotFoundException(this.attr + ": " + pnfe.getMessage(), pnfe.getCause());
+        }
+        catch (PropertyNotWritableException pnwe)
+        {
+            throw new PropertyNotWritableException(this.attr + ": " + pnwe.getMessage(), pnwe.getCause());
+        }
+        catch (ELException e)
+        {
+            throw new ELException(this.attr + ": " + e.getMessage(), e.getCause());
+        }
+    }
+
+    public boolean equals(Object obj)
+    {
+        return this.orig.equals(obj);
+    }
+
+    public String getExpressionString()
+    {
+        return this.orig.getExpressionString();
+    }
+
+    public int hashCode()
+    {
+        return this.orig.hashCode();
+    }
+
+    public boolean isLiteralText()
+    {
+        return this.orig.isLiteralText();
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+    {
+        this.orig = (ValueExpression) in.readObject();
+        this.attr = in.readUTF();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException
+    {
+        out.writeObject(this.orig);
+        out.writeUTF(this.attr);
+    }
+
+    public String toString()
+    {
+        return this.attr + ": " + this.orig;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/VariableMapperWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/VariableMapperWrapper.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/VariableMapperWrapper.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/VariableMapperWrapper.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,87 @@
+/**
+ * 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 com.sun.facelets.el;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+
+/**
+ * Utility class for wrapping another VariableMapper with a new context, represented by a {@link java.util.Map Map}.
+ * Modifications occur to the Map instance, but resolve against the wrapped VariableMapper if the Map doesn't contain
+ * the ValueExpression requested.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: VariableMapperWrapper.java,v 1.7 2008/07/13 19:01:43 rlubke Exp $
+ */
+public final class VariableMapperWrapper extends VariableMapper
+{
+
+    private final VariableMapper target;
+
+    private Map vars;
+
+    /**
+	 * 
+	 */
+    public VariableMapperWrapper(VariableMapper orig)
+    {
+        super();
+        this.target = orig;
+    }
+
+    /**
+     * First tries to resolve agains the inner Map, then the wrapped ValueExpression.
+     * 
+     * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
+     */
+    public ValueExpression resolveVariable(String variable)
+    {
+        ValueExpression ve = null;
+        try
+        {
+            if (this.vars != null)
+            {
+                ve = (ValueExpression) this.vars.get(variable);
+            }
+            if (ve == null)
+            {
+                return this.target.resolveVariable(variable);
+            }
+            return ve;
+        }
+        catch (StackOverflowError e)
+        {
+            throw new ELException("Could not Resolve Variable [Overflow]: " + variable, e);
+        }
+    }
+
+    /**
+     * Set the ValueExpression on the inner Map instance.
+     * 
+     * @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
+     */
+    public ValueExpression setVariable(String variable, ValueExpression expression)
+    {
+        if (this.vars == null)
+        {
+            this.vars = new HashMap();
+        }
+        return (ValueExpression) this.vars.put(variable, expression);
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/package.html?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/el/package.html Wed Feb  4 23:55:25 2009
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ 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.
+
+ $Id: package.html,v 1.3 2008/07/13 19:01:43 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+A collection of classes to support EL integration.
+</body>
+</html>
\ No newline at end of file

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFacelet.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFacelet.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFacelet.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFacelet.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,346 @@
+/**
+ * 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 com.sun.facelets.impl;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.net.URL;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import com.sun.facelets.Facelet;
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+import com.sun.facelets.tag.jsf.ComponentSupport;
+
+/**
+ * Default Facelet implementation.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: DefaultFacelet.java,v 1.11 2008/07/13 19:01:52 rlubke Exp $
+ */
+final class DefaultFacelet extends Facelet
+{
+
+    private static final Logger log = Logger.getLogger("facelets.facelet");
+
+    private final static String APPLIED_KEY = "com.sun.facelets.APPLIED";
+
+    private final String alias;
+
+    private final ExpressionFactory elFactory;
+
+    private final DefaultFaceletFactory factory;
+
+    private final long createTime;
+
+    private final long refreshPeriod;
+
+    private final Map relativePaths;
+
+    private final FaceletHandler root;
+
+    private final URL src;
+
+    public DefaultFacelet(DefaultFaceletFactory factory, ExpressionFactory el, URL src, String alias,
+                          FaceletHandler root)
+    {
+        this.factory = factory;
+        this.elFactory = el;
+        this.src = src;
+        this.root = root;
+        this.alias = alias;
+        this.createTime = System.currentTimeMillis();
+        this.refreshPeriod = this.factory.getRefreshPeriod();
+        this.relativePaths = new WeakHashMap();
+    }
+
+    /**
+     * @see com.sun.facelets.Facelet#apply(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+     */
+    public void apply(FacesContext facesContext, UIComponent parent) throws IOException, FacesException,
+            FaceletException, ELException
+    {
+        DefaultFaceletContext ctx = new DefaultFaceletContext(facesContext, this);
+        this.refresh(parent);
+        ComponentSupport.markForDeletion(parent);
+        this.root.apply(ctx, parent);
+        ComponentSupport.finalizeForDeletion(parent);
+        this.markApplied(parent);
+    }
+
+    private final void refresh(UIComponent c)
+    {
+        if (this.refreshPeriod > 0)
+        {
+
+            // finally remove any children marked as deleted
+            int sz = c.getChildCount();
+            if (sz > 0)
+            {
+                UIComponent cc = null;
+                List cl = c.getChildren();
+                ApplyToken token;
+                while (--sz >= 0)
+                {
+                    cc = (UIComponent) cl.get(sz);
+                    if (!cc.isTransient())
+                    {
+                        token = (ApplyToken) cc.getAttributes().get(APPLIED_KEY);
+                        if (token != null && token.time < this.createTime && token.alias.equals(this.alias))
+                        {
+                            if (log.isLoggable(Level.INFO))
+                            {
+                                DateFormat df = SimpleDateFormat.getTimeInstance();
+                                log.info("Facelet[" + this.alias + "] was modified @ "
+                                        + df.format(new Date(this.createTime)) + ", flushing component applied @ "
+                                        + df.format(new Date(token.time)));
+                            }
+                            cl.remove(sz);
+                        }
+                    }
+                }
+            }
+
+            // remove any facets marked as deleted
+            if (c.getFacets().size() > 0)
+            {
+                Collection col = c.getFacets().values();
+                UIComponent fc;
+                ApplyToken token;
+                for (Iterator itr = col.iterator(); itr.hasNext();)
+                {
+                    fc = (UIComponent) itr.next();
+                    if (!fc.isTransient())
+                    {
+                        token = (ApplyToken) fc.getAttributes().get(APPLIED_KEY);
+                        if (token != null && token.time < this.createTime && token.alias.equals(this.alias))
+                        {
+                            if (log.isLoggable(Level.INFO))
+                            {
+                                DateFormat df = SimpleDateFormat.getTimeInstance();
+                                log.info("Facelet[" + this.alias + "] was modified @ "
+                                        + df.format(new Date(this.createTime)) + ", flushing component applied @ "
+                                        + df.format(new Date(token.time)));
+                            }
+                            itr.remove();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private final void markApplied(UIComponent parent)
+    {
+        if (this.refreshPeriod > 0)
+        {
+            Iterator itr = parent.getFacetsAndChildren();
+            UIComponent c;
+            Map attr;
+            ApplyToken token = new ApplyToken(this.alias, System.currentTimeMillis() + this.refreshPeriod);
+            while (itr.hasNext())
+            {
+                c = (UIComponent) itr.next();
+                if (!c.isTransient())
+                {
+                    attr = c.getAttributes();
+                    if (!attr.containsKey(APPLIED_KEY))
+                    {
+                        attr.put(APPLIED_KEY, token);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Return the alias name for error messages and logging
+     * 
+     * @return alias name
+     */
+    public String getAlias()
+    {
+        return this.alias;
+    }
+
+    /**
+     * Return this Facelet's ExpressionFactory instance
+     * 
+     * @return internal ExpressionFactory instance
+     */
+    public ExpressionFactory getExpressionFactory()
+    {
+        return this.elFactory;
+    }
+
+    /**
+     * The time when this Facelet was created, NOT the URL source code
+     * 
+     * @return final timestamp of when this Facelet was created
+     */
+    public long getCreateTime()
+    {
+        return this.createTime;
+    }
+
+    /**
+     * Delegates resolution to DefaultFaceletFactory reference. Also, caches URLs for relative paths.
+     * 
+     * @param path
+     *            a relative url path
+     * @return URL pointing to destination
+     * @throws IOException
+     *             if there is a problem creating the URL for the path specified
+     */
+    private URL getRelativePath(String path) throws IOException
+    {
+        URL url = (URL) this.relativePaths.get(path);
+        if (url == null)
+        {
+            url = this.factory.resolveURL(this.src, path);
+            this.relativePaths.put(path, url);
+        }
+        return url;
+    }
+
+    /**
+     * The URL this Facelet was created from.
+     * 
+     * @return the URL this Facelet was created from
+     */
+    public URL getSource()
+    {
+        return this.src;
+    }
+
+    /**
+     * Given the passed FaceletContext, apply our child FaceletHandlers to the passed parent
+     * 
+     * @see FaceletHandler#apply(FaceletContext, UIComponent)
+     * @param ctx
+     *            the FaceletContext to use for applying our FaceletHandlers
+     * @param parent
+     *            the parent component to apply changes to
+     * @throws IOException
+     * @throws FacesException
+     * @throws FaceletException
+     * @throws ELException
+     */
+    private void include(DefaultFaceletContext ctx, UIComponent parent) throws IOException, FacesException,
+            FaceletException, ELException
+    {
+        this.refresh(parent);
+        this.root.apply(new DefaultFaceletContext(ctx, this), parent);
+        this.markApplied(parent);
+    }
+
+    /**
+     * Used for delegation by the DefaultFaceletContext. First pulls the URL from {@link #getRelativePath(String)
+     * getRelativePath(String)}, then calls {@link #include(FaceletContext, UIComponent, URL) include(FaceletContext,
+     * UIComponent, URL)}.
+     * 
+     * @see FaceletContext#includeFacelet(UIComponent, String)
+     * @param ctx
+     *            FaceletContext to pass to the included Facelet
+     * @param parent
+     *            UIComponent to apply changes to
+     * @param path
+     *            relative path to the desired Facelet from the FaceletContext
+     * @throws IOException
+     * @throws FacesException
+     * @throws FaceletException
+     * @throws ELException
+     */
+    public void include(DefaultFaceletContext ctx, UIComponent parent, String path) throws IOException, FacesException,
+            FaceletException, ELException
+    {
+        URL url = this.getRelativePath(path);
+        this.include(ctx, parent, url);
+    }
+
+    /**
+     * Grabs a DefaultFacelet from referenced DefaultFaceletFacotry
+     * 
+     * @see DefaultFaceletFactory#getFacelet(URL)
+     * @param ctx
+     *            FaceletContext to pass to the included Facelet
+     * @param parent
+     *            UIComponent to apply changes to
+     * @param url
+     *            URL source to include Facelet from
+     * @throws IOException
+     * @throws FacesException
+     * @throws FaceletException
+     * @throws ELException
+     */
+    public void include(DefaultFaceletContext ctx, UIComponent parent, URL url) throws IOException, FacesException,
+            FaceletException, ELException
+    {
+        DefaultFacelet f = (DefaultFacelet) this.factory.getFacelet(url);
+        f.include(ctx, parent);
+    }
+
+    private static class ApplyToken implements Externalizable
+    {
+        public String alias;
+
+        public long time;
+
+        public ApplyToken()
+        {
+        }
+
+        public ApplyToken(String alias, long time)
+        {
+            this.alias = alias;
+            this.time = time;
+        }
+
+        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+        {
+            this.alias = in.readUTF();
+            this.time = in.readLong();
+        }
+
+        public void writeExternal(ObjectOutput out) throws IOException
+        {
+            out.writeUTF(this.alias);
+            out.writeLong(this.time);
+        }
+    }
+
+    public String toString()
+    {
+        return this.alias;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletContext.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletContext.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletContext.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletContext.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,401 @@
+/**
+ * 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 com.sun.facelets.impl;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.TemplateClient;
+import com.sun.facelets.el.DefaultVariableMapper;
+import com.sun.facelets.el.ELAdaptor;
+
+import javax.el.*;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+
+/**
+ * Default FaceletContext implementation.
+ * 
+ * A single FaceletContext is used for all Facelets involved in an invocation of
+ * {@link com.sun.facelets.Facelet#apply(FacesContext, UIComponent) Facelet#apply(FacesContext, UIComponent)}. This
+ * means that included Facelets are treated the same as the JSP include directive.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: DefaultFaceletContext.java,v 1.4.4.3 2006/03/25 01:01:53 jhook Exp $
+ */
+final class DefaultFaceletContext extends FaceletContext
+{
+
+    private final FacesContext faces;
+
+    private final ELContext ctx;
+
+    private final DefaultFacelet facelet;
+    private final List faceletHierarchy;
+
+    private VariableMapper varMapper;
+
+    private FunctionMapper fnMapper;
+
+    private final Map ids;
+    private final Map prefixes;
+    private String prefix;
+    // TODO: change to StringBuilder when JDK1.5 support is available in Facelets
+    private final StringBuffer uniqueIdBuilder = new StringBuffer(30);
+
+    public DefaultFaceletContext(DefaultFaceletContext ctx, DefaultFacelet facelet)
+    {
+        this.ctx = ctx.ctx;
+        this.clients = ctx.clients;
+        this.faces = ctx.faces;
+        this.fnMapper = ctx.fnMapper;
+        this.ids = ctx.ids;
+        this.prefixes = ctx.prefixes;
+        this.varMapper = ctx.varMapper;
+        this.faceletHierarchy = new ArrayList(ctx.faceletHierarchy.size() + 1);
+        this.faceletHierarchy.addAll(ctx.faceletHierarchy);
+        this.faceletHierarchy.add(facelet);
+        this.facelet = facelet;
+    }
+
+    public DefaultFaceletContext(FacesContext faces, DefaultFacelet facelet)
+    {
+        this.ctx = ELAdaptor.getELContext(faces);
+        this.ids = new HashMap();
+        this.prefixes = new HashMap();
+        this.clients = new ArrayList(5);
+        this.faces = faces;
+        this.faceletHierarchy = new ArrayList(1);
+        this.faceletHierarchy.add(facelet);
+        this.facelet = facelet;
+        this.varMapper = this.ctx.getVariableMapper();
+        if (this.varMapper == null)
+        {
+            this.varMapper = new DefaultVariableMapper();
+        }
+        this.fnMapper = this.ctx.getFunctionMapper();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#getFacesContext()
+     */
+    public FacesContext getFacesContext()
+    {
+        return this.faces;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#getExpressionFactory()
+     */
+    public ExpressionFactory getExpressionFactory()
+    {
+        return this.facelet.getExpressionFactory();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#setVariableMapper(javax.el.VariableMapper)
+     */
+    public void setVariableMapper(VariableMapper varMapper)
+    {
+        // Assert.param("varMapper", varMapper);
+        this.varMapper = varMapper;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#setFunctionMapper(javax.el.FunctionMapper)
+     */
+    public void setFunctionMapper(FunctionMapper fnMapper)
+    {
+        // Assert.param("fnMapper", fnMapper);
+        this.fnMapper = fnMapper;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent, java.lang.String)
+     */
+    public void includeFacelet(UIComponent parent, String relativePath) throws IOException, FacesException, ELException
+    {
+        this.facelet.include(this, parent, relativePath);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.el.ELContext#getFunctionMapper()
+     */
+    public FunctionMapper getFunctionMapper()
+    {
+        return this.fnMapper;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.el.ELContext#getVariableMapper()
+     */
+    public VariableMapper getVariableMapper()
+    {
+        return this.varMapper;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.el.ELContext#getContext(java.lang.Class)
+     */
+    public Object getContext(Class key)
+    {
+        return this.ctx.getContext(key);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
+     */
+    public void putContext(Class key, Object contextObject)
+    {
+        this.ctx.putContext(key, contextObject);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#generateUniqueId(java.lang.String)
+     */
+    public String generateUniqueId(String base)
+    {
+
+        if (prefix == null)
+        {
+            // TODO: change to StringBuilder when JDK1.5 support is available
+            StringBuffer builder = new StringBuffer(faceletHierarchy.size() * 30);
+            for (int i = 0; i < faceletHierarchy.size(); i++)
+            {
+                DefaultFacelet facelet = (DefaultFacelet) faceletHierarchy.get(i);
+                builder.append(facelet.getAlias());
+            }
+            Integer prefixInt = new Integer(builder.toString().hashCode());
+
+            Integer cnt = (Integer) prefixes.get(prefixInt);
+            if (cnt == null)
+            {
+                this.prefixes.put(prefixInt, new Integer(0));
+                prefix = prefixInt.toString();
+            }
+            else
+            {
+                int i = cnt.intValue() + 1;
+                this.prefixes.put(prefixInt, new Integer(i));
+                prefix = prefixInt + "_" + i;
+            }
+        }
+
+        Integer cnt = (Integer) this.ids.get(base);
+        if (cnt == null)
+        {
+            this.ids.put(base, new Integer(0));
+            uniqueIdBuilder.delete(0, uniqueIdBuilder.length());
+            uniqueIdBuilder.append(prefix);
+            uniqueIdBuilder.append("_");
+            uniqueIdBuilder.append(base);
+            return uniqueIdBuilder.toString();
+        }
+        else
+        {
+            int i = cnt.intValue() + 1;
+            this.ids.put(base, new Integer(i));
+            uniqueIdBuilder.delete(0, uniqueIdBuilder.length());
+            uniqueIdBuilder.append(prefix);
+            uniqueIdBuilder.append("_");
+            uniqueIdBuilder.append(base);
+            uniqueIdBuilder.append("_");
+            uniqueIdBuilder.append(i);
+            return uniqueIdBuilder.toString();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#getAttribute(java.lang.String)
+     */
+    public Object getAttribute(String name)
+    {
+        if (this.varMapper != null)
+        {
+            ValueExpression ve = this.varMapper.resolveVariable(name);
+            if (ve != null)
+            {
+                return ve.getValue(this);
+            }
+        }
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#setAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setAttribute(String name, Object value)
+    {
+        if (this.varMapper != null)
+        {
+            if (value == null)
+            {
+                this.varMapper.setVariable(name, null);
+            }
+            else
+            {
+                this.varMapper.setVariable(name, this.facelet.getExpressionFactory()
+                        .createValueExpression(value, Object.class));
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see javax.faces.webapp.pdl.facelets.FaceletContext#includeFacelet(javax.faces.component.UIComponent, java.net.URL)
+     */
+    public void includeFacelet(UIComponent parent, URL absolutePath) throws IOException, FacesException, ELException
+    {
+        this.facelet.include(this, parent, absolutePath);
+    }
+
+    public ELResolver getELResolver()
+    {
+        return this.ctx.getELResolver();
+    }
+
+    private final List clients;
+
+    public void popClient(TemplateClient client)
+    {
+        if (!this.clients.isEmpty())
+        {
+            Iterator itr = this.clients.iterator();
+            while (itr.hasNext())
+            {
+                if (itr.next().equals(client))
+                {
+                    itr.remove();
+                    return;
+                }
+            }
+        }
+        throw new IllegalStateException(client + " not found");
+    }
+
+    public void pushClient(final TemplateClient client)
+    {
+        this.clients.add(0, new TemplateManager(this.facelet, client, true));
+    }
+
+    public void extendClient(final TemplateClient client)
+    {
+        this.clients.add(new TemplateManager(this.facelet, client, false));
+    }
+
+    public boolean includeDefinition(UIComponent parent, String name) throws IOException, FaceletException,
+            FacesException, ELException
+    {
+        boolean found = false;
+        TemplateManager client;
+
+        for (int i = 0, size = this.clients.size(); i < size && !found; i++)
+        {
+            client = ((TemplateManager) this.clients.get(i));
+            if (client.equals(this.facelet))
+                continue;
+            found = client.apply(this, parent, name);
+        }
+
+        return found;
+    }
+
+    private final static class TemplateManager implements TemplateClient
+    {
+        private final DefaultFacelet owner;
+
+        private final TemplateClient target;
+
+        private final boolean root;
+
+        private final Set names = new HashSet();
+
+        public TemplateManager(DefaultFacelet owner, TemplateClient target, boolean root)
+        {
+            this.owner = owner;
+            this.target = target;
+            this.root = root;
+        }
+
+        public boolean apply(FaceletContext ctx, UIComponent parent, String name) throws IOException, FacesException,
+                FaceletException, ELException
+        {
+            String testName = (name != null) ? name : "facelets._NULL_DEF_";
+            if (this.names.contains(testName))
+            {
+                return false;
+            }
+            else
+            {
+                this.names.add(testName);
+                boolean found = false;
+                found = this.target.apply(new DefaultFaceletContext((DefaultFaceletContext) ctx, this.owner), parent,
+                                          name);
+                this.names.remove(testName);
+                return found;
+            }
+        }
+
+        public boolean equals(Object o)
+        {
+            // System.out.println(this.owner.getAlias() + " == " +
+            // ((DefaultFacelet) o).getAlias());
+            return this.owner == o || this.target == o;
+        }
+
+        public boolean isRoot()
+        {
+            return this.root;
+        }
+    }
+
+    public boolean isPropertyResolved()
+    {
+        return this.ctx.isPropertyResolved();
+    }
+
+    public void setPropertyResolved(boolean resolved)
+    {
+        this.ctx.setPropertyResolved(resolved);
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletFactory.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletFactory.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletFactory.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultFaceletFactory.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,260 @@
+/**
+ * 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 com.sun.facelets.impl;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import com.sun.facelets.Facelet;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import com.sun.facelets.FaceletFactory;
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+import com.sun.facelets.compiler.Compiler;
+import com.sun.facelets.util.ParameterCheck;
+import com.sun.facelets.util.Resource;
+
+/**
+ * Default FaceletFactory implementation.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: DefaultFaceletFactory.java,v 1.10 2007/04/09 01:13:17 youngm Exp $
+ */
+public final class DefaultFaceletFactory extends FaceletFactory
+{
+
+    protected final static Logger log = Logger.getLogger("facelets.factory");
+
+    private final Compiler compiler;
+
+    private Map facelets;
+
+    private Map relativeLocations;
+
+    private final ResourceResolver resolver;
+
+    private final URL baseUrl;
+
+    private final long refreshPeriod;
+
+    public DefaultFaceletFactory(Compiler compiler, ResourceResolver resolver) throws IOException
+    {
+        this(compiler, resolver, -1);
+    }
+
+    public DefaultFaceletFactory(Compiler compiler, ResourceResolver resolver, long refreshPeriod)
+    {
+        ParameterCheck.notNull("compiler", compiler);
+        ParameterCheck.notNull("resolver", resolver);
+        this.compiler = compiler;
+        this.facelets = new HashMap();
+        this.relativeLocations = new HashMap();
+        this.resolver = resolver;
+        this.baseUrl = resolver.resolveUrl("/");
+        // this.location = url;
+        log.fine("Using ResourceResolver: " + resolver);
+        this.refreshPeriod = (refreshPeriod >= 0) ? refreshPeriod * 1000 : -1;
+        log.fine("Using Refresh Period: " + this.refreshPeriod);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.FaceletFactory#getFacelet(java.lang.String)
+     */
+    public Facelet getFacelet(String uri) throws IOException, FaceletException, FacesException, ELException
+    {
+        URL url = (URL) this.relativeLocations.get(uri);
+        if (url == null)
+        {
+            url = this.resolveURL(this.baseUrl, uri);
+            if (url != null)
+            {
+                Map newLoc = new HashMap(this.relativeLocations);
+                newLoc.put(uri, url);
+                this.relativeLocations = newLoc;
+            }
+            else
+            {
+                throw new IOException("'" + uri + "' not found.");
+            }
+        }
+        return this.getFacelet(url);
+    }
+
+    /**
+     * Resolves a path based on the passed URL. If the path starts with '/', then resolve the path against
+     * {@link javax.faces.context.ExternalContext#getResource(java.lang.String)
+     * javax.faces.context.ExternalContext#getResource(java.lang.String)}. Otherwise create a new URL via
+     * {@link URL#URL(java.net.URL, java.lang.String) URL(URL, String)}.
+     * 
+     * @param source
+     *            base to resolve from
+     * @param path
+     *            relative path to the source
+     * @return resolved URL
+     * @throws IOException
+     */
+    public URL resolveURL(URL source, String path) throws IOException
+    {
+        if (path.startsWith("/"))
+        {
+            URL url = this.resolver.resolveUrl(path);
+            if (url == null)
+            {
+                throw new FileNotFoundException(path + " Not Found in ExternalContext as a Resource");
+            }
+            return url;
+        }
+        else
+        {
+            return new URL(source, path);
+        }
+    }
+
+    /**
+     * Create a Facelet from the passed URL. This method checks if the cached Facelet needs to be refreshed before
+     * returning. If so, uses the passed URL to build a new instance;
+     * 
+     * @param url
+     *            source url
+     * @return Facelet instance
+     * @throws IOException
+     * @throws FaceletException
+     * @throws FacesException
+     * @throws ELException
+     */
+    public Facelet getFacelet(URL url) throws IOException, FaceletException, FacesException, ELException
+    {
+        ParameterCheck.notNull("url", url);
+        String key = url.toString();
+        DefaultFacelet f = (DefaultFacelet) this.facelets.get(key);
+        if (f == null || this.needsToBeRefreshed(f))
+        {
+            f = this.createFacelet(url);
+            if (this.refreshPeriod != 0)
+            {
+                Map newLoc = new HashMap(this.facelets);
+                newLoc.put(key, f);
+                this.facelets = newLoc;
+            }
+        }
+        return f;
+    }
+
+    /**
+     * Template method for determining if the Facelet needs to be refreshed.
+     * 
+     * @param facelet
+     *            Facelet that could have expired
+     * @return true if it needs to be refreshed
+     */
+    protected boolean needsToBeRefreshed(DefaultFacelet facelet)
+    {
+        // if set to 0, constantly reload-- nocache
+        if (this.refreshPeriod == 0)
+            return true;
+        // if set to -1, never reload
+        if (this.refreshPeriod == -1)
+            return false;
+        long ttl = facelet.getCreateTime() + this.refreshPeriod;
+        URL url = facelet.getSource();
+        InputStream is = null;
+        if (System.currentTimeMillis() > ttl)
+        {
+            try
+            {
+                URLConnection conn = url.openConnection();
+                is = conn.getInputStream();
+                long atl = conn.getLastModified();
+                return atl == 0 || atl > ttl;
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Error Checking Last Modified for " + facelet.getAlias(), e);
+            }
+            finally
+            {
+                if (is != null)
+                {
+                    try
+                    {
+                        is.close();
+                    }
+                    catch (Exception e)
+                    {
+                        // do nothing
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Uses the internal Compiler reference to build a Facelet given the passed URL.
+     * 
+     * @param url
+     *            source
+     * @return a Facelet instance
+     * @throws IOException
+     * @throws FaceletException
+     * @throws FacesException
+     * @throws ELException
+     */
+    private DefaultFacelet createFacelet(URL url) throws IOException, FaceletException, FacesException, ELException
+    {
+        if (log.isLoggable(Level.FINE))
+        {
+            log.fine("Creating Facelet for: " + url);
+        }
+        String alias = "/" + url.getFile().replaceFirst(this.baseUrl.getFile(), "");
+        try
+        {
+            FaceletHandler h = this.compiler.compile(url, alias);
+            DefaultFacelet f = new DefaultFacelet(this, this.compiler.createExpressionFactory(), url, alias, h);
+            return f;
+        }
+        catch (FileNotFoundException fnfe)
+        {
+            throw new FileNotFoundException("Facelet " + alias + " not found at: " + url.toExternalForm());
+        }
+    }
+
+    /**
+     * Compiler this factory uses
+     * 
+     * @return final Compiler instance
+     */
+    public Compiler getCompiler()
+    {
+        return this.compiler;
+    }
+
+    public long getRefreshPeriod()
+    {
+        return refreshPeriod;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultResourceResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultResourceResolver.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultResourceResolver.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/DefaultResourceResolver.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,50 @@
+/**
+ * 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 com.sun.facelets.impl;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import com.sun.facelets.util.Resource;
+
+public class DefaultResourceResolver implements ResourceResolver
+{
+
+    public DefaultResourceResolver()
+    {
+        super();
+    }
+
+    public URL resolveUrl(String path)
+    {
+        try
+        {
+            return Resource.getResourceUrl(FacesContext.getCurrentInstance(), path);
+        }
+        catch (IOException e)
+        {
+            throw new FacesException(e);
+        }
+    }
+
+    public String toString()
+    {
+        return "DefaultResourceResolver";
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/ResourceResolver.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/ResourceResolver.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/ResourceResolver.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/ResourceResolver.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,22 @@
+/**
+ * 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 com.sun.facelets.impl;
+
+import java.net.URL;
+
+public interface ResourceResolver
+{
+    public URL resolveUrl(String path);
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/package.html?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/impl/package.html Wed Feb  4 23:55:25 2009
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ 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.
+
+ $Id: package.html,v 1.3 2008/07/13 19:01:52 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+Default implementation of the Facelets API.
+</body>
+</html>
\ No newline at end of file

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/package.html
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/package.html?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/package.html (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/package.html Wed Feb  4 23:55:25 2009
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<!--
+ 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.
+
+ $Id: package.html,v 1.3 2008/07/13 19:01:40 rlubke Exp $
+-->
+</head>
+<body bgcolor="white">
+Public Facelet API.  Most developers should be able to utilizing the framework using
+the public classes and interfaces.
+<p/>
+An application that wishes to use Facelets as a ViewHandler, they must specify the
+following in their <code>faces-config.xml</code> (@see com.sun.facelets.FaceletViewHandler).
+<pre><code>
+&lt;application>
+  &lt;view-handler>com.sun.facelets.FaceletViewHandler&lt;/view-handler>
+&lt;/application>
+</code></pre>
+<p/>
+Below is sample code for using Facelets at the API level with JavaServer Faces.
+<pre><code>
+// get the view to render
+FacesContext context = FacesContext.getCurrentInstance();
+UIViewRoot viewToRender = context.getViewRoot();
+
+// grab our FaceletFactory and create a Facelet
+FaceletFactory factory = FaceletFactory.getInstance();
+Facelet f = factory.getFacelet(viewToRender.getViewId());
+
+// populate UIViewRoot
+f.apply(context, viewToRender);
+</code></pre>
+</body>
+</html>
\ No newline at end of file



Mime
View raw message