Author: nbelaevski
Date: 2008-01-14 19:29:48 -0500 (Mon, 14 Jan 2008)
New Revision: 5368
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
Log:
http://jira.jboss.com/jira/browse/RF-1676
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2008-01-14
20:19:04 UTC (rev 5367)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2008-01-15
00:29:48 UTC (rev 5368)
@@ -30,10 +30,6 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceRenderer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -183,6 +179,18 @@
*/
public void setRenderer(ResourceRenderer renderer) {
this.renderer = renderer;
+
+ if (renderer instanceof PreprocessingRenderer) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Preprocessing resource " + this);
+ }
+
+ ((PreprocessingRenderer) renderer).preprocess(this, null);
+ } catch (IOException e) {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
}
/**
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java 2008-01-14
20:19:04 UTC (rev 5367)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PreprocessingRenderer.java 2008-01-15
00:29:48 UTC (rev 5368)
@@ -1,35 +0,0 @@
-/**
- * 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;
-}
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-15
00:29:48 UTC (rev 5368)
@@ -0,0 +1,45 @@
+/**
+ * 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;
+
+/**
+ * Renderers that wish to provide special handling for resource being associated with
<code>this</code>
+ * renderer instance can implement this interface.
+ *
+ * Created 14.01.2008
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public interface PreprocessingRenderer {
+
+ /**
+ * Method is called by resource being associated with <code>this</code>
renderer
+ *
+ * @param resource resource that is being associated
+ * @param resourceContext resource context
+ * @throws IOException
+ */
+ 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:19:04 UTC (rev 5367)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2008-01-15
00:29:48 UTC (rev 5368)
@@ -47,6 +47,10 @@
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;
@@ -393,27 +397,12 @@
}
}
- 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) {