myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r997646 [2/2] - in /myfaces/extensions/scripting/trunk: ./ extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/
Date Thu, 16 Sep 2010 09:02:33 GMT
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceImpl.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceImpl.java?rev=997646&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceImpl.java
(added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceImpl.java
Thu Sep 16 09:02:32 2010
@@ -0,0 +1,318 @@
+/*
+ *  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.extensions.scripting.jsf2.resources;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.application.ProjectStage;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+
+/**
+ * Default implementation for resources
+ *
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 957739 $ $Date: 2010-06-24 17:27:40 -0500 (Jue, 24 Jun 2010) $
+ */
+public class ResourceImpl extends Resource {
+
+
+    private ResourceMeta _resourceMeta;
+    private ResourceLoader _resourceLoader;
+    private ResourceHandlerSupport _resourceHandlerSupport;
+
+    public ResourceImpl(ResourceMeta resourceMeta,
+                        ResourceLoader resourceLoader, ResourceHandlerSupport support, String
contentType) {
+        _resourceMeta = resourceMeta;
+        _resourceLoader = resourceLoader;
+        _resourceHandlerSupport = support;
+        setLibraryName(resourceMeta.getLibraryName());
+        setResourceName(resourceMeta.getResourceName());
+        setContentType(contentType);
+    }
+
+    public ResourceLoader getResourceLoader() {
+        return _resourceLoader;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        if (couldResourceContainValueExpressions()) {
+            return new ValueExpressionFilterInputStream(
+                    getResourceLoader().getResourceInputStream(_resourceMeta));
+        } else {
+            return getResourceLoader().getResourceInputStream(_resourceMeta);
+        }
+    }
+
+    private boolean couldResourceContainValueExpressions() {
+        if (_resourceMeta.couldResourceContainValueExpressions()) {
+            return true;
+        } else {
+            //By default only css resource contain value expressions
+            String contentType = getContentType();
+
+            return ("text/css".equals(contentType));
+        }
+    }
+
+    private class ValueExpressionFilterInputStream extends InputStream {
+        private PushbackInputStream delegate;
+
+        public ValueExpressionFilterInputStream(InputStream in) {
+            super();
+            delegate = new PushbackInputStream(in, 255);
+        }
+
+        @Override
+        public int read() throws IOException {
+            int c1 = delegate.read();
+
+            if (c1 == -1) return -1;
+
+            if (((char) c1) == '#') {
+                int c2 = delegate.read();
+                if (c2 == -1) return -1;
+                if (((char) c2) == '{') {
+                    //It is a value expression. We need
+                    //to look for a occurrence of } to 
+                    //extract the expression and evaluate it,
+                    //the result should be unread.
+                    List<Integer> expressionList = new ArrayList<Integer>();
+                    int c3 = delegate.read();
+                    while (c3 != -1 && ((char) c3) != '}') {
+                        expressionList.add(c3);
+                        c3 = delegate.read();
+                    }
+
+                    if (c3 == -1) {
+                        //get back the data, because we can't
+                        //extract any value expression
+                        for (int i = 0; i < expressionList.size(); i++) {
+                            delegate.unread(expressionList.get(i));
+                        }
+                        delegate.unread(c2);
+                        return c1;
+                    } else {
+                        //EL expression found. Evaluate it and pushback
+                        //the result into the stream
+                        FacesContext context = FacesContext.getCurrentInstance();
+                        ELContext elContext = context.getELContext();
+                        try {
+                            ValueExpression ve = context.getApplication().
+                                    getExpressionFactory().createValueExpression(
+                                    elContext,
+                                    "#{" + convertToExpression(expressionList) + "}",
+                                    String.class);
+                            String value = (String) ve.getValue(elContext);
+
+                            for (int i = value.length() - 1; i >= 0; i--) {
+                                delegate.unread((int) value.charAt(i));
+                            }
+                        } catch (ELException e) {
+                            ExceptionQueuedEventContext equecontext = new ExceptionQueuedEventContext(context,
e, null);
+                            context.getApplication().publishEvent(context, ExceptionQueuedEvent.class,
equecontext);
+
+                            Logger log = Logger.getLogger(ResourceImpl.class.getName());
+                            if (log.isLoggable(Level.SEVERE))
+                                log.severe("Cannot evaluate EL expression " + convertToExpression(expressionList)
+ " in resource " + getLibraryName() + ":" + getResourceName());
+
+                            delegate.unread(c3);
+                            for (int i = expressionList.size() - 1; i >= 0; i--) {
+                                delegate.unread(expressionList.get(i));
+                            }
+                            delegate.unread(c2);
+                            return c1;
+                        }
+
+                        //read again
+                        return delegate.read();
+                    }
+                } else {
+                    delegate.unread(c2);
+                    return c1;
+                }
+            } else {
+                //just continue
+                return c1;
+            }
+        }
+
+        private String convertToExpression(List<Integer> expressionList) {
+            char[] exprArray = new char[expressionList.size()];
+
+            for (int i = 0; i < expressionList.size(); i++) {
+                exprArray[i] = (char) expressionList.get(i).intValue();
+            }
+            return String.valueOf(exprArray);
+        }
+    }
+
+    @Override
+    public String getRequestPath() {
+        String path;
+        if (_resourceHandlerSupport.isExtensionMapping()) {
+            path = ResourceHandler.RESOURCE_IDENTIFIER + '/' +
+                    getResourceName() + _resourceHandlerSupport.getMapping();
+        } else {
+            String mapping = _resourceHandlerSupport.getMapping();
+            path = ResourceHandler.RESOURCE_IDENTIFIER + '/' + getResourceName();
+            path = (mapping == null) ? path : mapping + path;
+        }
+
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        String metadata = null;
+        boolean useAmp = false;
+        if (getLibraryName() != null) {
+            metadata = "?ln=" + getLibraryName();
+            path = path + metadata;
+            useAmp = true;
+
+            if (!facesContext.isProjectStage(ProjectStage.Production)
+                    && ResourceLoaderUtils.JSF_JS_RESOURCE_NAME.equals(getResourceName())
+                    && ResourceLoaderUtils.JAVAX_FACES_LIBRARY_NAME.equals(getLibraryName()))
{
+                // append &stage=?? for all ProjectStages except Production
+                path = path + "&stage=" + facesContext.getApplication().getProjectStage().toString();
+            }
+        }
+
+        return facesContext.getApplication().getViewHandler().getResourceURL(facesContext,
path);
+    }
+
+    @Override
+    public Map<String, String> getResponseHeaders() {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+
+        if (facesContext.getApplication().getResourceHandler().isResourceRequest(facesContext))
{
+            Map<String, String> headers = new HashMap<String, String>();
+
+            long lastModified;
+            try {
+                lastModified = ResourceLoaderUtils.getResourceLastModified(this.getURL());
+            } catch (IOException e) {
+                lastModified = -1;
+            }
+
+            // Here we have two cases: If the file could contain EL Expressions
+            // the last modified time is the greatest value between application startup and
+            // the value from file.
+            if (this.couldResourceContainValueExpressions() &&
+                    lastModified < _resourceHandlerSupport.getStartupTime()) {
+                lastModified = _resourceHandlerSupport.getStartupTime();
+            } else if (_resourceMeta instanceof AliasResourceMetaImpl &&
+                    lastModified < _resourceHandlerSupport.getStartupTime()) {
+                // If the resource meta is aliased, the last modified time is the greatest

+                // value between application startup and the value from file.
+                lastModified = _resourceHandlerSupport.getStartupTime();
+            }
+
+            if (lastModified >= 0) {
+                headers.put("Last-Modified", ResourceLoaderUtils.formatDateHeader(lastModified));
+
+                long expires;
+                if (facesContext.isProjectStage(ProjectStage.Development)) {
+                    // Force to expire now to prevent caching on development time.
+                    expires = System.currentTimeMillis();
+                } else {
+                    expires = System.currentTimeMillis() + _resourceHandlerSupport.getMaxTimeExpires();
+                }
+                headers.put("Expires", ResourceLoaderUtils.formatDateHeader(expires));
+            }
+
+            return headers;
+        } else {
+            //No need to return headers 
+            return Collections.emptyMap();
+        }
+    }
+
+    @Override
+    public URL getURL() {
+        return getResourceLoader().getResourceURL(_resourceMeta);
+    }
+
+    @Override
+    public boolean userAgentNeedsUpdate(FacesContext context) {
+        // RFC2616 says related to If-Modified-Since header the following:
+        //
+        // "... The If-Modified-Since request-header field is used with a method to 
+        // make it conditional: if the requested variant has not been modified since 
+        // the time specified in this field, an entity will not be returned from 
+        // the server; instead, a 304 (not modified) response will be returned 
+        // without any message-body..."
+        // 
+        // This method is called from ResourceHandlerImpl.handleResourceRequest and if
+        // returns false send a 304 Not Modified response.
+
+        String ifModifiedSinceString = context.getExternalContext().getRequestHeaderMap().get("If-Modified-Since");
+
+        if (ifModifiedSinceString == null) {
+            return true;
+        }
+
+        Long ifModifiedSince = ResourceLoaderUtils.parseDateHeader(ifModifiedSinceString);
+
+        if (ifModifiedSince == null) {
+            return true;
+        }
+
+        Long lastModified;
+        try {
+            lastModified = ResourceLoaderUtils.getResourceLastModified(this.getURL());
+        } catch (IOException exception) {
+            lastModified = -1L;
+        }
+
+        if (lastModified >= 0) {
+            if (this.couldResourceContainValueExpressions() &&
+                    lastModified < _resourceHandlerSupport.getStartupTime()) {
+                lastModified = _resourceHandlerSupport.getStartupTime();
+            }
+
+            // If the lastModified date is lower or equal than ifModifiedSince,
+            // the agent does not need to update.
+            // Note the lastModified time is set at milisecond precision, but when 
+            // the date is parsed and sent on ifModifiedSince, the exceding miliseconds
+            // are trimmed. So, we have to compare trimming this from the calculated
+            // lastModified time.
+            if ((lastModified - (lastModified % 1000)) <= ifModifiedSince) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoader.java?rev=997646&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoader.java
(added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoader.java
Thu Sep 16 09:02:32 2010
@@ -0,0 +1,156 @@
+/*
+ *  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.extensions.scripting.jsf2.resources;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Comparator;
+
+/**
+ * Base class for resource loaders.  Resource loaders can lookup resources 
+ * as URLs from arbitrary locations, including JAR files.
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 882702 $ $Date: 2009-11-20 15:16:07 -0500 (Vie, 20 Nov 2009) $
+ */
+public abstract class ResourceLoader
+{
+    
+    public static final String VERSION_INVALID = "INVALID";
+    
+    private String _prefix;
+    
+    public ResourceLoader(String prefix)
+    {
+        _prefix = prefix;
+    }
+
+    public abstract String getResourceVersion(String path);
+
+    /**
+     * Return the max available version found (if exists) or
+     * return null if no version available. 
+     */
+    public abstract String getLibraryVersion(String path);
+
+    /**
+     * Return the max available version found (if exists) or
+     * return null if no version available. 
+     */
+    public abstract URL getResourceURL(ResourceMeta resourceMeta);
+
+    public abstract InputStream getResourceInputStream(ResourceMeta resourceMeta);
+    
+    public abstract ResourceMeta createResourceMeta(String prefix, String libraryName, String
libraryVersion,
+            String resourceName, String resourceVersion);
+    
+    public abstract boolean libraryExists(String libraryName);
+    
+    private Comparator<String> _versionComparator = null;
+
+    protected Comparator<String> getVersionComparator()
+    {
+        if (_versionComparator == null)
+        {
+            _versionComparator = new VersionComparator();
+        }
+        return _versionComparator;
+    }
+
+    protected void setVersionComparator(Comparator<String> versionComparator)
+    {
+        _versionComparator = versionComparator;
+    }
+
+    public class VersionComparator implements Comparator<String>
+    {
+
+        public int compare(String s1, String s2)
+        {
+            int n1 = 0;
+            int n2 = 0;
+            String o1 = s1;
+            String o2 = s2;
+
+            boolean p1 = true;
+            boolean p2 = true;
+
+            while (n1 == n2 && (p1 || p2))
+            {
+                int i1 = o1.indexOf('_');
+                int i2 = o2.indexOf('_');
+                if (i1 < 0)
+                {
+                    if (o1.length() > 0)
+                    {
+                        p1 = false;
+                        n1 = Integer.valueOf(o1);
+                        o1 = "";
+                    }
+                    else
+                    {
+                        p1 = false;
+                        n1 = 0;
+                    }
+                }
+                else
+                {
+                    n1 = Integer.valueOf(o1.substring(0, i1));
+                    o1 = o1.substring(i1 + 1);
+                }
+                if (i2 < 0)
+                {
+                    if (o2.length() > 0)
+                    {
+                        p2 = false;
+                        n2 = Integer.valueOf(o2);
+                        o2 = "";
+                    }
+                    else
+                    {
+                        p2 = false;
+                        n2 = 0;
+                    }
+                }
+                else
+                {
+                    n2 = Integer.valueOf(o2.substring(0, i2));
+                    o2 = o2.substring(i2 + 1);
+                }
+            }
+
+            if (n1 == n2)
+            {
+                return s1.length() - s2.length();
+            }
+            return n1 - n2;
+        }
+    }
+    
+    public String getPrefix()
+    {
+        return _prefix;
+    }
+
+    public void setPrefix(String prefix)
+    {
+        _prefix = prefix;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoaderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoaderUtils.java?rev=997646&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoaderUtils.java
(added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceLoaderUtils.java
Thu Sep 16 09:02:32 2010
@@ -0,0 +1,125 @@
+/*
+ *  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.extensions.scripting.jsf2.resources;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+public class ResourceLoaderUtils {
+
+    public final static String JAVAX_FACES_LIBRARY_NAME = "javax.faces";
+    public final static String JSF_JS_RESOURCE_NAME = "jsf.js";
+
+    public final static String MYFACES_JS_RESOURCE_NAME = "oamSubmit.js";
+    public final static String MYFACES_JS_RESOURCE_NAME_UNCOMPRESSED = "oamSubmit-uncompressed.js";
+
+    public final static String MYFACES_LIBRARY_NAME = "org.apache.myfaces";
+    private final static String RENDERED_MYFACES_JS = "org.apache.myfaces.RENDERED_MYFACES_JS";
+
+    // TODO: In tomcat and jetty it is implemented a Flyweight pattern when converting
+    // date headers. For now it is better keep this stuff simple.
+    private static final String HTTP_RESPONSE_DATE_HEADER =
+            "EEE, dd MMM yyyy HH:mm:ss zzz";
+
+    private static final String[] HTTP_REQUEST_DATE_HEADER = {
+            "EEE, dd MMM yyyy HH:mm:ss zzz", "EEEEEE, dd-MMM-yy HH:mm:ss zzz",
+            "EEE MMMM d HH:mm:ss yyyy"};
+
+    private static TimeZone __GMT = TimeZone.getTimeZone("GMT");
+
+    public static String formatDateHeader(long value) {
+        SimpleDateFormat format = new SimpleDateFormat(
+                HTTP_RESPONSE_DATE_HEADER,
+                Locale.US);
+        format.setTimeZone(__GMT);
+        return format.format(new Date(value));
+    }
+
+    public static Long parseDateHeader(String value) {
+        Date date = null;
+        for (int i = 0; (date == null) && (i < HTTP_REQUEST_DATE_HEADER.length);
i++) {
+            try {
+                SimpleDateFormat format = new SimpleDateFormat(
+                        HTTP_REQUEST_DATE_HEADER[i], Locale.US);
+                format.setTimeZone(__GMT);
+                date = format.parse(value);
+            } catch (ParseException e) {
+                ;
+            }
+        }
+        if (date == null) {
+            return null;
+        }
+        return new Long(date.getTime());
+    }
+
+    //Taken from trinidad URLUtils
+    public static long getResourceLastModified(URL url) throws IOException {
+        if ("file".equals(url.getProtocol())) {
+            String externalForm = url.toExternalForm();
+            // Remove the "file:"
+            File file = new File(externalForm.substring(5));
+
+            return file.lastModified();
+        } else {
+            return getResourceLastModified(url.openConnection());
+        }
+    }
+
+    //Taken from trinidad URLUtils
+    public static long getResourceLastModified(URLConnection connection) throws IOException
{
+        long modified;
+        if (connection instanceof JarURLConnection) {
+            // The following hack is required to work-around a JDK bug.
+            // getLastModified() on a JAR entry URL delegates to the actual JAR file
+            // rather than the JAR entry.
+            // This opens internally, and does not close, an input stream to the JAR
+            // file.
+            // In turn, you cannot close it by yourself, because it's internal.
+            // The work-around is to get the modification date of the JAR file
+            // manually,
+            // and then close that connection again.
+
+            URL jarFileUrl = ((JarURLConnection) connection).getJarFileURL();
+            URLConnection jarFileConnection = jarFileUrl.openConnection();
+
+            try {
+                modified = jarFileConnection.getLastModified();
+            } finally {
+                try {
+                    jarFileConnection.getInputStream().close();
+                } catch (Exception exception) {
+                    // Ignored
+                }
+            }
+        } else {
+            modified = connection.getLastModified();
+        }
+
+        return modified;
+    }
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMeta.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMeta.java?rev=997646&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMeta.java
(added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMeta.java
Thu Sep 16 09:02:32 2010
@@ -0,0 +1,43 @@
+/*
+ *  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.extensions.scripting.jsf2.resources;
+
+/**
+ * Contains the metadata information to reference a resource 
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 946779 $ $Date: 2010-05-20 15:31:42 -0500 (Jue, 20 May 2010) $
+ */
+public abstract class ResourceMeta
+{
+    
+    public abstract String getLibraryName();
+    
+    public abstract String getResourceName();
+
+    public abstract String getLocalePrefix();
+
+    public abstract String getLibraryVersion();
+
+    public abstract String getResourceVersion();
+    
+    public abstract String getResourceIdentifier();
+    
+    public abstract boolean couldResourceContainValueExpressions();
+}

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMetaImpl.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMetaImpl.java?rev=997646&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMetaImpl.java
(added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/ResourceMetaImpl.java
Thu Sep 16 09:02:32 2010
@@ -0,0 +1,116 @@
+/*
+ *  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.extensions.scripting.jsf2.resources;
+
+/**
+ * Contains the metadata information to reference a resource 
+ * 
+ * @author Leonardo Uribe (latest modification by $Author: lu4242 $)
+ * @version $Revision: 700544 $ $Date: 2008-09-30 13:44:02 -0500 (Mar, 30 Sep 2008) $
+ */
+public class ResourceMetaImpl extends ResourceMeta
+{
+
+    private final String _prefix;
+    private final String _libraryName;
+    private final String _libraryVersion;
+    private final String _resourceName;
+    private final String _resourceVersion;
+    
+    public ResourceMetaImpl(String prefix, String libraryName, String libraryVersion,
+            String resourceName, String resourceVersion)
+    {
+        _prefix = prefix;
+        _libraryName = libraryName;
+        _libraryVersion = libraryVersion;
+        _resourceName = resourceName;
+        _resourceVersion = resourceVersion;
+    }
+
+    public String getLibraryName()
+    {
+        return _libraryName;
+    }    
+    
+    public String getResourceName()
+    {
+        return _resourceName;
+    }    
+
+    public String getLocalePrefix()
+    {
+        return _prefix;
+    }
+
+    public String getLibraryVersion()
+    {
+        return _libraryVersion;
+    }
+
+    public String getResourceVersion()
+    {
+        return _resourceVersion;
+    }
+    
+    @Override
+    public String getResourceIdentifier()
+    {
+        StringBuilder builder = new StringBuilder();
+        boolean firstSlashAdded = false;
+        if (_prefix != null && _prefix.length() > 0)
+        {
+            builder.append(_prefix);
+            firstSlashAdded = true;
+        }
+        if (_libraryName != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_libraryName);
+            firstSlashAdded = true;
+        }
+        if (_libraryVersion != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_libraryVersion);
+            firstSlashAdded = true;
+        }
+        if (_resourceName != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_resourceName);
+            firstSlashAdded = true;
+        }
+        if (_resourceVersion != null)
+        {
+            if (firstSlashAdded) builder.append('/');
+            builder.append(_resourceVersion);
+            builder.append(
+                    _resourceName.substring(_resourceName.lastIndexOf('.')));
+            firstSlashAdded = true;
+        }
+
+        return builder.toString();
+    }
+
+    @Override
+    public boolean couldResourceContainValueExpressions()
+    {
+        return false;
+    }
+}

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandler.java?rev=997646&r1=997645&r2=997646&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandler.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandler.java
Thu Sep 16 09:02:32 2010
@@ -18,10 +18,6 @@
 */
 package org.apache.myfaces.extensions.scripting.jsf2.resources;
 
-import org.apache.myfaces.application.ResourceHandlerImpl;
-import org.apache.myfaces.shared_impl.resource.ResourceHandlerSupport;
-import org.apache.myfaces.shared_impl.resource.ResourceLoader;
-import org.apache.myfaces.shared_impl.resource.ResourceMeta;
 import org.apache.myfaces.extensions.scripting.api.Decorated;
 
 import javax.faces.application.Resource;

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandlerSupport.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandlerSupport.java?rev=997646&r1=997645&r2=997646&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandlerSupport.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceHandlerSupport.java
Thu Sep 16 09:02:32 2010
@@ -18,12 +18,6 @@
 */
 package org.apache.myfaces.extensions.scripting.jsf2.resources;
 
-import org.apache.myfaces.application.DefaultResourceHandlerSupport;
-import org.apache.myfaces.shared_impl.resource.ResourceHandlerSupport;
-import org.apache.myfaces.shared_impl.resource.ClassLoaderResourceLoader;
-import org.apache.myfaces.shared_impl.resource.ExternalContextResourceLoader;
-import org.apache.myfaces.shared_impl.resource.ResourceLoader;
-
 import javax.faces.context.FacesContext;
 
 /**
@@ -39,7 +33,7 @@ import javax.faces.context.FacesContext;
 public class SourceResourceHandlerSupport extends ResourceHandlerSupport {
 
     private ResourceLoader[] _supportResourceLoaders;
-    private ResourceHandlerSupport _defaultSupport = new DefaultResourceHandlerSupport();
+    private BaseResourceHandlerSupport _defaultSupport = new BaseResourceHandlerSupport();
 
     @Override
     /**

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceLoader.java?rev=997646&r1=997645&r2=997646&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceLoader.java
(original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf2/resources/SourceResourceLoader.java
Thu Sep 16 09:02:32 2010
@@ -18,12 +18,8 @@
 */
 package org.apache.myfaces.extensions.scripting.jsf2.resources;
 
-import org.apache.myfaces.shared_impl.resource.ExternalContextResourceLoader;
-import org.apache.myfaces.shared_impl.resource.ResourceLoader;
-import org.apache.myfaces.shared_impl.resource.ResourceMeta;
 import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
 
-import javax.faces.context.FacesContext;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;

Modified: myfaces/extensions/scripting/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/pom.xml?rev=997646&r1=997645&r2=997646&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/pom.xml (original)
+++ myfaces/extensions/scripting/trunk/pom.xml Thu Sep 16 09:02:32 2010
@@ -42,7 +42,7 @@
     <parent>
         <groupId>org.apache.myfaces</groupId>
         <artifactId>myfaces</artifactId>
-        <version>7</version>
+        <version>9</version>
     </parent>
 
     <modules>



Mime
View raw message