Author: nbelaevski
Date: 2008-01-14 15:19:04 -0500 (Mon, 14 Jan 2008)
New Revision: 5367
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
Log:
Resource preregistraion added
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java 2008-01-14
20:19:04 UTC (rev 5367)
@@ -0,0 +1,35 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.resource;
+
+import java.io.IOException;
+
+/**
+ *
+ * Created 14.01.2008
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public interface PreprocessingRenderer {
+ public void preprocess(InternetResource resource, ResourceContext resourceContext)
throws IOException;
+}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2008-01-14
20:13:38 UTC (rev 5366)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2008-01-14
20:19:04 UTC (rev 5367)
@@ -47,10 +47,6 @@
import javax.servlet.ServletContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.resource.ResourceRenderer;
import org.ajax4jsf.util.base64.Codec;
import org.ajax4jsf.webapp.WebXml;
import org.apache.commons.digester.Digester;
@@ -397,12 +393,27 @@
}
}
+ private long time = 0;
+
public void addResource(InternetResource resource) {
resources.put(resource.getKey(), resource);
ResourceRenderer renderer = resource.getRenderer(null);
if (renderer == null) {
setRenderer(resource, resource.getKey());
}
+
+ renderer = resource.getRenderer(null);
+ if (renderer instanceof PreprocessingRenderer) {
+ long l = System.currentTimeMillis();
+ try {
+ ((PreprocessingRenderer) renderer).preprocess(resource, null);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ time += System.currentTimeMillis() - l;
+ System.out.println("ResourceBuilderImpl.addResource() " + time);
+ }
}
public void addResource(String key, InternetResource resource) {
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2008-01-14
20:13:38 UTC (rev 5366)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2008-01-14
20:19:04 UTC (rev 5367)
@@ -45,7 +45,7 @@
* @author shura
*
*/
-public class TemplateCSSRenderer extends StyleRenderer {
+public class TemplateCSSRenderer extends StyleRenderer implements PreprocessingRenderer
{
private static final String COMPILED_TEMPLATE_PROPERTY = "compiled-template";
@@ -157,4 +157,9 @@
return value;
}
+ public void preprocess(InternetResource resource,
+ ResourceContext resourceContext) throws IOException {
+
+ getTemplate(resource, resourceContext);
+ }
}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2008-01-14
20:13:38 UTC (rev 5366)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2008-01-14
20:19:04 UTC (rev 5367)
@@ -29,17 +29,13 @@
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceRenderer;
-
/**
* Class for create and send resources from template ( at most, used for CSS files )
* @author shura (latest modification by $Author: nick_belaevski $)
* @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
*
+ * @deprecated
*/
public class TemplateCSSResource implements InternetResource {
Show replies by date