Author: alexsmirnov
Date: 2007-07-05 16:50:37 -0400 (Thu, 05 Jul 2007)
New Revision: 1508
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html
trunk/framework/impl/src/main/resources/META-INF/resources-config.xml
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html
trunk/ui/core/src/main/config/resources/resources-config.xml
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java
trunk/framework/test/src/test/java/DnDScriptTest.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java
trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java
trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
Log:
refactoring packages and classes in the implementation project
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-07-05 19:11:50
UTC (rev 1507)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-07-05 20:50:37
UTC (rev 1508)
@@ -21,7 +21,7 @@
package org.ajax4jsf.dnd;
-import org.ajax4jsf.framework.resource.ClientScript;
+import org.ajax4jsf.resource.ClientScript;
/**
* @author shura
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -24,7 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.ajax4jsf.framework.resource.ClientScript;
+import org.ajax4jsf.resource.ClientScript;
/**
* Resource for AJAX client-side script. Render one time per page.
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ImageCacheScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -21,7 +21,7 @@
package org.ajax4jsf.framework.ajax;
-import org.ajax4jsf.framework.resource.ClientScript;
+import org.ajax4jsf.resource.ClientScript;
/**
* Resource for Drag ' Drop client javascript
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -41,7 +41,7 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.ajax.PushEventsCounter;
import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.resource.InternetResourceService;
+import org.ajax4jsf.resource.InternetResourceService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/PrototypeBasedRendererBase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -26,9 +26,9 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.PrototypeScript;
import org.ajax4jsf.renderkit.HeaderResourceProducer;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.PrototypeScript;
/**
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/RendererUtils.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -40,9 +40,9 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlDimensions;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.Java2Dresource;
/**
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,175 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceRenderer;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:07 $
- *
- */
-public abstract class BaseResourceRenderer implements ResourceRenderer {
-
- public void encode(InternetResource resource, FacesContext context,
- Object data) throws IOException {
- this.encodeBegin(resource, context, data, Collections.EMPTY_MAP);
- this.encodeEnd(resource, context, data);
- }
-
- public void encode(InternetResource resource, FacesContext context,
- Object data, Map attributes) throws IOException {
- this.encodeBegin(resource, context, data, attributes);
- this.encodeEnd(resource, context, data);
- }
-
- public void encodeBegin(InternetResource resource, FacesContext context,
- Object data, Map attributes) throws IOException {
- if (null != getTag()) {
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(getTag(), null);
- String attrs[][] = getCommonAttrs();
- if (null != getHrefAttr()) {
- writer.writeAttribute(getHrefAttr(), resource.getUri(context,
- data), null);
- }
- if (null != attrs) {
- for (int i = 0; i < attrs.length; i++) {
- writer.writeAttribute(attrs[i][0], attrs[i][1], null);
- }
- }
- for (Iterator iter = attributes.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry attr = (Map.Entry) iter.next();
- writer.writeAttribute(attr.getKey().toString(),
- attr.getValue(), null);
- }
- }
- this.customEncode(resource, context, data);
- }
-
- public void encodeEnd(InternetResource resource, FacesContext context,
- Object data) throws IOException {
- if (null != getTag()) {
- ResponseWriter writer = context.getResponseWriter();
- writer.endElement(getTag());
-
- }
- }
-
- /**
- * Template method for customaize encoding for component. can insert size
- * etc. attributes, child tags etc.
- *
- * @param resource
- * @param context
- * @param component
- * @throws IOException
- */
- protected void customEncode(InternetResource resource,
- FacesContext context, Object data) throws IOException {
- // TODO if concrete renderer need
-
- }
-
- protected abstract String getTag();
-
- protected abstract String getHrefAttr();
-
- protected abstract String[][] getCommonAttrs();
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.resource.ResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
- * org.ajax4jsf.resource.ResourceContext)
- */
- public int send(InternetResource base, ResourceContext context)
- throws IOException {
- InputStream in = base.getResourceAsStream(context);
- OutputStream out = context.getOutputStream();
- if (null == in) {
- String message = Messages.getMessage(
- Messages.NO_INPUT_STREAM_ERROR, base.getKey());
- throw new IOException(message);
- }
- int total = sendStream(in, out);
-
- return total;
- }
-
- /**
- * @param in
- * @param out
- * @return
- * @throws IOException
- */
- protected int sendStream(InputStream in, OutputStream out)
- throws IOException {
- int total = 0;
- byte[] buffer = new byte[InternetResourceBase.BUFFER_SIZE];
- int length;
- try {
- for (length = in.read(buffer); length > 0; length = in.read(buffer)) {
- out.write(buffer, 0, length);
- total += length;
- }
- } finally {
- in.close();
- out.flush();
- out.close();
- }
- return total;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#requireFacesContext()
- */
- public boolean requireFacesContext() {
- // TODO Auto-generated method stub
- return false;
- }
-
- public Object getData(InternetResource base, FacesContext context,
- Object data) {
- // By default, resource dot't provide any data. Can be used in
- // Template-based or other
- // configurable resources ( like weblets configuration ).
- return null;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,43 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.resource;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.resource.InternetResource;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com
- * created 01.05.2007
- *
- */
-public class CacheKey {
- private Object resourceData;
- private HttpServletRequest request;
- private HttpServletResponse response;
- private InternetResource resource;
- public CacheKey(Object resourceData,
- HttpServletRequest request, HttpServletResponse response,
- InternetResource resource) {
- super();
- this.resourceData = resourceData;
- this.request = request;
- this.response = response;
- this.resource = resource;
- }
- public Object getResourceData() {
- return resourceData;
- }
- public HttpServletRequest getRequest() {
- return request;
- }
- public HttpServletResponse getResponse() {
- return response;
- }
- public InternetResource getResource() {
- return resource;
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,153 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
- *
- */
-public class CachedResourceContext extends ResourceContext {
- private ResourceContext parent;
- private CacheContent content;
-
- /**
- * @param parent
- */
- public CachedResourceContext(ResourceContext parent) {
- this.setCacheEnabled(true);
- this.parent = parent;
- this.content = new CacheContent();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- return content.getOutputStream();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
- */
- public String getPathInfo() {
- return this.parent.getPathInfo();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
- */
- public String getQueryString() {
- return this.parent.getQueryString();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getRequestParameter(java.lang.String)
- */
- public String getRequestParameter(String data_parameter) {
- return this.parent.getRequestParameter(data_parameter);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getResourceAsStream(java.lang.String)
- */
- public InputStream getResourceAsStream(String path) {
- return this.parent.getResourceAsStream(path);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
- */
- public Object getSessionAttribute(String name) {
- return this.parent.getSessionAttribute(name);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
- */
- public void setDateHeader(String name, long value) {
- this.content.setDateHeader(name,value);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
java.lang.String)
- */
- public void setHeader(String name, String value) {
- this.content.setHeader(name,value);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
- */
- public void setIntHeader(String name, int value) {
- this.content.setIntHeader(name,value);
- }
-
- /**
- * @return Returns the content.
- */
- CacheContent getContent() {
- return this.content;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getWriter()
- */
- public PrintWriter getWriter() throws IOException {
- return content.getWriter();
- }
-
- public void setContentType(String contentType) {
- this.content.setContentType(contentType);
- }
-
- public Object getResourceData() {
- return parent.getResourceData();
- }
-
- public void setResourceData(Object codec) {
- parent.setResourceData(codec);
-
- }
-
- public String getInitParameter(String name) {
- return parent.getInitParameter(name);
- }
-
- public String getServletPath() {
- return parent.getServletPath();
- }
-
- public void release() {
- super.release();
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,181 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-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.ResourceNotFoundException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Resource for AJAX client-side script. Render one time per page.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/01/26 14:15:18 $
- *
- */
-public abstract class ClientScript extends JarResource {
-
- private static final Log log = LogFactory.getLog(ClientScript.class);
-
- protected boolean usePrototype = false;
- /**
- * Set JavaScript renderer and modification time to application-startup time.
- */
- public ClientScript() {
- super();
- setRenderer(new ScriptRenderer());
- InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
- String key = this.getClass().getName();
- try {
- // Search already registered resource for this class.
- InternetResource resource = resourceBuilder.getResource(key);
- this.setKey(resource.getKey());
- } catch(ResourceNotFoundException ex){
- // If script not registered, append it to builder.
- setLastModified(new Date(resourceBuilder.getStartTime()));
- resourceBuilder.addResource(key,this);
- }
- String script ;
- if (getJavaScript().startsWith("/")) {
- // remove lead / for classloader covention.
- script = getJavaScript().substring(1);
- } else {
- script = this.getClass().getPackage().getName().replace('.',
'/')+"/"
- + getJavaScript();
- }
- setPath(script);
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#getLastModified()
- */
- public Date getLastModified(ResourceContext resourceContext) {
-
- if (isCacheable(null)) {
- return super.getLastModified(resourceContext);
- } else {
- return new Date(System.currentTimeMillis()+1000L);
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return true;
- }
-
- /**
- * @return Returns the javaScript.
- */
- public abstract String getJavaScript();
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map attributes) throws IOException
{
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encode(context, data, attributes);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
- }
-
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#encodeBegin(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map attrs) throws
IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encodeBegin(context, component, attrs);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO, getKey()));
- }
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#encodeEnd(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void encodeEnd(FacesContext context, Object component) throws IOException {
- if (isNotAjaxRequest(context)) {
- super.encodeEnd(context, component);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO, getKey()));
- }
- }
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- if (isNotAjaxRequest(context)) {
- encodePrototype(context);
- super.encode(context, data);
- }else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
- }
- }
-
- /**
- * @return Returns the usePrototype.
- */
- protected boolean isUsePrototype() {
- return usePrototype;
- }
-
-
- private boolean isNotAjaxRequest(FacesContext context){
- return true;//! AjaxRendererUtils.isAjaxRequest(context);
- }
-
- private void encodePrototype(FacesContext context) throws IOException{
- if (isUsePrototype()) {
- InternetResourceBuilder.getInstance().createResource(null,PrototypeScript.class.getName()).encode(context,null);
- }
-
- }
-
-
- /**
- * @param usePrototype the usePrototype to set
- */
- public void setUsePrototype(boolean usePrototype) {
- this.usePrototype = usePrototype;
- }
-
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,223 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.lang.reflect.Method;
-
-import javax.faces.FacesException;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
- *
- */
-public class FacesResourceContext extends ResourceContext {
-
- FacesContext facesContext;
-
- ExternalContext externalContext;
-
- HttpServletResponse response;
-
- /**
- * @param facesContext
- */
- public FacesResourceContext(FacesContext facesContext) {
-
- this.facesContext = facesContext;
- this.externalContext = facesContext.getExternalContext();
- Object facesResponse = externalContext.getResponse();
- if (facesResponse instanceof HttpServletResponse) {
- this.response = (HttpServletResponse) facesResponse;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
- * java.lang.String)
- */
- public void setHeader(String name, String value) {
- if (null != response) {
- response.setHeader(name, value);
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String,
- * int)
- */
- public void setIntHeader(String name, int value) {
- if (null != response) {
- response.setIntHeader(name, value);
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String,
- * long)
- */
- public void setDateHeader(String name, long value) {
- if (null != response) {
- response.setDateHeader(name, value);
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- if (null != response) {
- return response.getOutputStream();
-
- } else {
- // May be non-servlet (Portlet?) environment. Try to use reflection
- OutputStream stream = null;
- Object response = externalContext.getResponse();
- try {
- Method gW = response.getClass()
- .getMethod("getOutputStream", new Class[0]);
- stream = (OutputStream) gW.invoke(response, new Object[0]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- return stream;
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getWriter()
- */
- public PrintWriter getWriter() throws IOException {
- if (null != response) {
- return response.getWriter();
-
- } else {
- // May be non-servlet (Portlet?) environment. Try to use reflection
- PrintWriter writer = null;
- Object response = externalContext.getResponse();
- try {
- Method gW = response.getClass()
- .getMethod("getWriter", new Class[0]);
- writer = (PrintWriter) gW.invoke(response, new Object[0]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- return writer;
-
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
- */
- public String getQueryString() {
- return ((HttpServletRequest) externalContext.getRequest())
- .getQueryString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
- */
- public String getPathInfo() {
- return externalContext.getRequestPathInfo();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
- */
- public Object getSessionAttribute(String name) {
- return externalContext.getSessionMap().get(name);
- }
-
- public InputStream getResourceAsStream(String path) {
-
- return externalContext.getResourceAsStream(path);
- }
-
- public String getRequestParameter(String data_parameter) {
-
- return (String) externalContext.getRequestParameterMap().get(
- data_parameter);
- }
-
- public void setContentType(String contentType) {
- response.setContentType(contentType);
-
- }
-
- public String getInitParameter(String name) {
- // TODO Auto-generated method stub
- return externalContext.getInitParameter(name);
- }
-
- public String getServletPath() {
- // TODO Auto-generated method stub
- return externalContext.getRequestServletPath();
- }
-
- public void release() {
- super.release();
- externalContext = null;
- response = null;
- facesContext.release();
- }
-
- // added by nick 11.01.2007 - getters for contexts added
- public FacesContext getFacesContext() {
- return facesContext;
- }
-
- public ExternalContext getExternalContext() {
- return externalContext;
- }
- // by nick
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,69 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.ajax4jsf.framework.util.image.GIFEncoder;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
- *
- */
-public class GifRenderer extends ImageRenderer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/gif";
- }
-
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- // ImageIO.write(image,"gif",context.getOutputStream());
- GIFEncoder encoder = new GIFEncoder();
- DataOutputStream out = new DataOutputStream(context.getOutputStream());
- try {
- encoder.encode((BufferedImage) image, out);
- out.flush();
- out.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_ARGB;
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
- *
- */
-public class HTMLRenderer extends BaseResourceRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- // TODO Auto-generated method stub
- return "span";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "text/html";
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
- */
- protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
- // Encode style in page - read from resource.
- ResourceContext resourceContext = new FacesResourceContext(context);
- InputStream in = resource.getResourceAsStream(resourceContext);
- StringBuffer buff = new StringBuffer();
- int input;
- while((input = in.read())>0){
- buff.append((char)input);
- }
- in.close();
- // MyFaces & RI have different beahvior for style element, in RI best use
writeComment ?
- // TODO - detect page content type ?
- context.getResponseWriter().writeText(buff,resource.getKey());
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,101 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.awt.Dimension;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:06 $
- *
- */
-public abstract class ImageRenderer extends BaseResourceRenderer {
-
- private static final String _tag = "img";
- private static final String _hrefAttr = "src";
- private static final String[][] _commonAttrs = {
-
- };
- /**
- * @return Returns the commonAttrs.
- */
- protected String[][] getCommonAttrs() {
- return null ; //_commonAttrs;
- }
-
- /**
- * @return Returns the hrefAttr.
- */
- protected String getHrefAttr() {
- return _hrefAttr;
- }
-
- /**
- * @return Returns the tag.
- */
- protected String getTag() {
- return _tag;
- }
-
- /**
- * Send {@link BufferedImage} to response in concrete format (GIF,Jpeg,PNG)
- * @param context - current faces context.
- * @param image - imaje to send
- */
- public abstract void sendImage(ResourceContext context,RenderedImage image) throws
IOException;
-
- /**
- * @return type of image for create {@link BufferedImage}
- */
- public abstract int getImageType();
-
- /**
- * Create blank {@link BufferedImage} for paint.
- * Type of image determined by current renderer.
- * @param width
- * @param height
- * @return new image
- */
- public BufferedImage createImage(int width,int height){
- return new BufferedImage(width,height,getImageType());
- }
-
- protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
- if (resource instanceof Java2Dresource) {
- Java2Dresource j2d = (Java2Dresource) resource;
- Dimension dim = j2d.getDimensions(context, data);
- ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute("width", String.valueOf(dim.width),
"width");
- writer.writeAttribute("height", String.valueOf(dim.height),
"height");
- }
- }
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,429 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-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;
-
-/**
- * Base class for all Html page resources - images, scripts, styles etc. Realise
- * as "brige" pattern - different subclasses for different resource source
- * (static,jar,soft generator ) and customaized with differernt renderers for
- * image, script, style ( linked ir inline ). must operate with different
- * sources - application context, classpath, software generator.
- *
- * @author shura (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:15 $
- *
- */
-public abstract class InternetResourceBase implements InternetResource {
-
- private static final Log log = LogFactory
- .getLog(InternetResourceBase.class);
-
- static final int BUFFER_SIZE = 1024;
-
- // Hours
-
- private int contentLength = -1;
-
- private Date lastModified;
-
- private Date expired;
-
- private boolean cacheable = true;
-
- private boolean sessionAware = true;
-
- private ResourceRenderer renderer = null;
-
- private Map customProperties = new HashMap();
-
- private String key;
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentLength()
- */
- public int getContentLength(ResourceContext resourceContext) {
- return contentLength;
- }
-
- /**
- * @param contentLength
- * The contentLength to set.
- */
- protected void setContentLength(int contentLength) {
- this.contentLength = contentLength;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getExpired()
- */
- public Date getExpired(ResourceContext resourceContext) {
- return expired;
- }
-
- /**
- * @param expired
- * The expired to set.
- */
- public void setExpired(Date expired) {
- this.expired = expired;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getLastModified()
- */
- public Date getLastModified(ResourceContext resourceContext) {
-
- if (null != lastModified) {
- return lastModified;
- } else {
- return new Date(System.currentTimeMillis());
- }
- }
-
- /**
- * @param lastModified
- * The lastModified to set.
- */
- public void setLastModified(Date lastModified) {
- this.lastModified = lastModified;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#isCacheable()
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return cacheable;
- }
-
- /**
- * @param cacheable
- * The cacheable to set.
- */
- public void setCacheable(boolean cacheable) {
- this.cacheable = cacheable;
- }
-
- /**
- * @return Returns the sessionAware.
- */
- public boolean isSessionAware() {
- return requireFacesContext();
- }
-
- /**
- * @param sessionAware
- * The sessionAware to set.
- */
- public void setSessionAware(boolean sessionAware) {
- this.sessionAware = sessionAware;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentType()
- */
- public String getContentType(ResourceContext resourceContext) {
- return getRenderer(null).getContentType();
- }
-
- /**
- * @return Returns the renderer.
- */
- public ResourceRenderer getRenderer(ResourceContext resourceContext) {
- return renderer;
- }
-
- /**
- * @param renderer
- * The renderer to set.
- */
- public void setRenderer(ResourceRenderer renderer) {
- this.renderer = renderer;
- }
-
- /**
- * Key for wich resource registered in resource builder.
- *
- * @return Returns the key.
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Set registration key ( by {@link InternetResourceBuilder} for this
- * resource.
- *
- * @param key
- * The key to set.
- */
- public void setKey(String key) {
- this.key = key;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public String getUri(final FacesContext context, Object data) {
- return InternetResourceBuilder.getInstance().getUri(this, context,
- getDataToStore(context, data));
- }
-
- /**
- * Template method to construct resource-specific data ( to store in
- * resource URI ). If resource must store any data in session or other
- * cache, it must be done here. Since lightweight realisation, information
- * for restore such data muct be returned by this method.
- *
- * @param context -
- * current faces context.
- * @param data -
- * data for build information, usually current
- * {@link javax.faces.component.UIComponent}
- * @return - any {@link java.io.Serializable} object, or null.
- */
- protected Object getDataToStore(FacesContext context, Object data) {
- return getRenderer(null).getData(this, context, data);
- }
-
- /**
- * Restore data object from resource URI request parameter ( same object as
- * returned in getDataToStore method )
- *
- * @param context
- * @return restored data, or null.
- */
- protected Object restoreData(ResourceContext context) {
-
- Object data = context.getResourceData();
- if (data instanceof byte[]) {
- byte[] objectArray = (byte[]) data;
- data = deserializeData(objectArray);
- }
- return data;
-
- }
-
- /**
- * Deserialize parameters object from byte array. By default, used Java
- * de-serialisation from ObjectOutputStream , but implementations can
- * override this method ( togewer with getDataToStore ) for implement short
- * version.
- *
- * @param objectArray
- * @return
- * @throws IOException
- * @throws ClassNotFoundException
- */
- protected Object deserializeData(byte[] objectArray) {
- return objectArray;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.chameleon.resource.InternetResource#getResourceAsStream()
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- throw new UnsupportedOperationException(Messages.getMessage(
- Messages.METHOD_NOT_IMPLEMENTED, "getResourceAsStream"));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
- */
- public Object getProperty(Object key) {
- // TODO Auto-generated method stub
- return customProperties.get(key);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object,
- * java.lang.Object)
- */
- public void setProperty(Object key, Object value) {
- customProperties.put(key, value);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO, getKey()));
- }
- getRenderer(null).encode(this, context, data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
- * java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map attributes)
- throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO_2,
- getKey(), attributes));
- }
- getRenderer(null).encodeBegin(this, context, data, attributes);
- getRenderer(null).encodeEnd(this, context, data);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map attrs)
- throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_BEGIN_HTML_INFO,
- getKey(), attrs));
- }
- getRenderer(null).encodeBegin(this, context, component, attrs);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent, java.util.Map)
- */
- public void encodeEnd(FacesContext context, Object component)
- throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_END_HTML_INFO,
- getKey()));
- }
- getRenderer(null).encodeEnd(this, context, component);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#send(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void send(ResourceContext context) throws IOException {
- if (log.isDebugEnabled()) {
- log
- .debug(Messages.getMessage(Messages.SEND_CONTENT_INFO,
- getKey()));
- }
- int total = getRenderer(null).send(this, context);
- // For cacheable resources, store size.
- if (isCacheable(null)) {
- setContentLength(total);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.chameleon.resource.InternetResource#sendHeaders(javax.servlet.http.HttpServletResponse)
- */
- public void sendHeaders(ResourceContext context) {
- boolean cached = context.isCacheEnabled() && isCacheable(null);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SET_RESPONSE_HEADERS_INFO,
- getKey()));
- }
- // context.setHeader("Content-Type",getContentType());
- context.setContentType(getContentType(null));
- if (getContentLength(context) > 0) {
- context.setIntHeader("Content-Length", getContentLength(context));
- } else {
- // context.setHeader("Transfer-Encoding", "chunked");
- }
- Date lastModified = getLastModified(context);
- if (lastModified != null) {
- context.setDateHeader("Last-Modified", lastModified.getTime());
- }
- if (cached) {
- Date expired = getExpired(context);
- if (expired != null) {
- context.setDateHeader("Expires", expired.getTime());
- } else {
- context.setDateHeader("Expires", System.currentTimeMillis()
- + DEFAULT_EXPIRE);
- context.setHeader("Cache-control", "max-age="
- + (DEFAULT_EXPIRE / 1000));
- }
- } else {
- context.setHeader("Cache-control", "max-age=0, no-store,
no-cache");
- context.setHeader("Pragma", "no-cache");
- context.setIntHeader("Expires", 0);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
- */
- public boolean requireFacesContext() {
- // by default, send data in ordinary Http request.
- return getRenderer(null).requireFacesContext();
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,385 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.context.FacesContext;
-import javax.faces.context.FacesContextFactory;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.cache.Cache;
-import org.ajax4jsf.cache.CacheConfigurationLoader;
-import org.ajax4jsf.cache.CacheException;
-import org.ajax4jsf.cache.CacheFactory;
-import org.ajax4jsf.cache.CacheLoader;
-import org.ajax4jsf.cache.CacheManager;
-import org.ajax4jsf.cache.ServletContextInitMap;
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-public class InternetResourceService implements CacheLoader, CacheConfigurationLoader {
- private static final Log log = LogFactory
- .getLog(InternetResourceService.class);
-
- static final String ENABLE_CACHING_PARAMETER = "enable-cache";
-
- private static final String RESOURCE_LIFECYCLE_PARAMETER =
"org.ajax4jsf.RESOURCE_LIFECYCLE";
-
- private FilterConfig filterConfig;
-
- private boolean cacheEnabled = true;
-
- private Cache cache = null;
-
- //private ServletCacheAdministrator cacheAdmin;
-
- private FacesContextFactory contextFactory;
-
- // private RenderKitFactory renderKitFactory;
- private String lifecycleClass;
-
- private ResourceLifecycle lifecycle;
-
- private InternetResourceBuilder resourceBuilder;
-
- private WebXml webXml;
-
- public InternetResourceService() {
- }
-
- public void setCacheEnabled(boolean b) {
- cacheEnabled = b;
- }
-
- public void init(FilterConfig config) throws ServletException {
- filterConfig = config;
- ServletContext servletContext = config.getServletContext();
- if ("false".equalsIgnoreCase(config
- .getInitParameter(ENABLE_CACHING_PARAMETER))) {
- setCacheEnabled(false);
- // this.cacheEnabled = false;
- //this.cacheAdmin = null;
- } else {
- //this.cacheAdmin = ServletCacheAdministrator.getInstance(
- // servletContext, cacheProperties);
- try {
- CacheManager cacheManager = CacheManager.getInstance();
- Map env = new ServletContextInitMap(servletContext);
- CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
- this.cache = cacheFactory.createCache(env, this, this);
- } catch (CacheException e) {
- throw new FacesException(e.getMessage(), e);
- }
- }
- // Create Resource-specific Faces Lifecycle instance.
- lifecycleClass = servletContext
- .getInitParameter(RESOURCE_LIFECYCLE_PARAMETER);
- if (lifecycleClass != null) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- Class clazz = classLoader.loadClass(lifecycleClass);
- lifecycle = (ResourceLifecycle) clazz.newInstance();
- } catch (Exception e) {
- throw new FacesException(
- "Error create instance of resource Lifecycle "
- + lifecycleClass, e);
- }
- } else {
- lifecycle = new ResourceLifecycle();
- }
- webXml = new WebXml();
- webXml.init(servletContext,filterConfig.getFilterName());
- if (log.isDebugEnabled()) {
- log.debug("Resources service initialized");
- }
- }
-
- public boolean serviceResource(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse) throws ServletException,
- IOException {
- String resourceKey = webXml
- .getFacesResourceKey(httpServletRequest);
- if (null != resourceKey) {
- serviceResource(resourceKey, httpServletRequest,
- httpServletResponse);
- return true;
- }
- return false;
- }
-
- public void serviceResource(String resourceKey, HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- InternetResource resource;// getInternetResource(request);
- try {
- resource = getResourceBuilder().getResourceForKey(resourceKey);
- } catch (ResourceNotFoundException e) {
- throw new ServletException(e);
- }
- Object resourceDataForKey = getResourceBuilder()
- .getResourceDataForKey(resourceKey);
- if (resource.isCacheable(null) && this.cacheEnabled) {
- // Test for client request modification time.
- try {
- long ifModifiedSince = request
- .getDateHeader("If-Modified-Since");
- if (ifModifiedSince >= 0) {
- // Test for modification. 1000 ms due to round
- // modification
- // time to seconds.
- long lastModified = resource.getLastModified(null)
- .getTime() - 1000;
- if (lastModified <= ifModifiedSince) {
- response.setStatus(304);
- return;
- }
- }
- } catch (IllegalArgumentException e) {
- log
- .warn(
- Messages
- .getMessage(Messages.PARSING_IF_MODIFIED_SINCE_WARNING),
- e);
- }
- String cacheKey = resourceKey;// + "?" +
- // request.getQueryString();
- // TODO - select session/application scope.
- //Cache cache = cacheAdmin.getAppScopeCache(getServletContext());
-// try {
- // TODO - use last modified/expires time
-
- CacheKey key = new CacheKey(resourceDataForKey, request, response, resource);
-
- CacheContent content;
- try {
- content = (CacheContent) cache
- .get(cacheKey, key);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.GET_CONTENT_FROM_CACHE_INFO, cacheKey));
- }
- content.sendHeaders(response);
- // Correct expires date for resource.
- Date expired = resource.getExpired(null);
- if (expired != null) {
- response.setDateHeader("Expires", expired.getTime());
- } else {
- response.setDateHeader("Expires", System
- .currentTimeMillis()
- + InternetResource.DEFAULT_EXPIRE);
- }
- if (!request.getMethod().equals("HEAD")) {
- content.send(response);
- }/*
- } catch (NeedsRefreshException e) {
- try {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.CONTENT_NOT_FOUND_ERROR, cacheKey));
- }
- CachedResourceContext context = (CachedResourceContext) sendResource(
- resource, request, response, resourceDataForKey);
- // TODO - set refresh interval ?
- cache.put(cacheKey, context.getContent());
- } catch (Exception ex) {
- //cache.cancelUpdate(cacheKey);
- log.error(
- Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
- ex);
- throw new ServletException(Messages.getMessage(
- Messages.SEND_RESOURCE_ERROR_2, ex.getMessage()),
- ex);
- }
- }*/
- } catch (CacheException e) {
- log.error(
- Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
- e);
- throw new ServletException(Messages.getMessage(
- Messages.SEND_RESOURCE_ERROR_2, e.getMessage()),
- e);
- }
- } else {
- sendResource(resource, request, response, resourceDataForKey);
- }
- }
-
- /**
- * @param resource
- * @param request
- * @param response
- * @throws IOException
- */
- protected ResourceContext sendResource(InternetResource resource,
- HttpServletRequest request, HttpServletResponse response,
- Object data) throws IOException {
- ResourceContext resourceContext = getResourceContext(resource, request,
- response);
- resourceContext.setResourceData(data);
- getLifecycle().send(resourceContext, resource);
- resourceContext.release();
- return resourceContext;
- }
-
- /**
- * @param resource
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws FacesException
- */
- protected ResourceContext getResourceContext(InternetResource resource,
- HttpServletRequest request, HttpServletResponse response)
- throws FacesException {
- FacesContext facesContext = null;
- ResourceContext resourceContext;
- if (resource.requireFacesContext()) {
- facesContext = getFacesContext(request, response);
- resourceContext = new FacesResourceContext(facesContext);
- } else {
- resourceContext = new ServletResourceContext(getServletContext(),
- request, response);
- }
- if (resource.isCacheable(null) && this.cacheEnabled) {
- resourceContext = new CachedResourceContext(resourceContext);
- }
- return resourceContext;
- }
-
- /**
- * Get properties file from classpath
- *
- * @param name
- * @return
- */
- protected Properties getProperties(String name) {
- Properties properties = new Properties();
- InputStream props = BaseFilter.class.getResourceAsStream(name);
- if (null != props) {
- try {
- properties.load(props);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
- name), e);
- } finally {
- try {
- props.close();
- } catch (IOException e) {
- // Can be ignored
- }
- }
- }
- return properties;
-
- }
-
- /**
- * @return Returns the servletContext.
- */
- protected ServletContext getServletContext() {
- return filterConfig.getServletContext();
- }
-
- /**
- * @return the lifecycle
- * @throws ServletException
- */
- protected ResourceLifecycle getLifecycle() throws FacesException {
- return lifecycle;
- }
-
- /**
- * @return the contextFactory
- */
- protected synchronized FacesContextFactory getContextFactory() {
- if (contextFactory == null) {
- contextFactory = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
- }
-
- return contextFactory;
- }
-
- protected FacesContext getFacesContext(ServletRequest request,
- ServletResponse response) throws FacesException {
- return getContextFactory().getFacesContext(getServletContext(),
- request, response, getLifecycle());
- }
-
- /**
- * @return the resourceBuilder
- */
- protected InternetResourceBuilder getResourceBuilder() {
- if (resourceBuilder == null) {
- // Create resource builder for this filter.
- resourceBuilder = InternetResourceBuilder.getInstance();
- }
- return resourceBuilder;
- }
-
- public Object load(Object key, Object context) throws CacheException {
- CacheKey cacheKey = (CacheKey) context;
-
- CachedResourceContext resourceContext = (CachedResourceContext)
getResourceContext(cacheKey.getResource(), cacheKey.getRequest(),
- cacheKey.getResponse());
- resourceContext.setResourceData(cacheKey.getResourceData());
- try {
- getLifecycle().send(resourceContext, cacheKey.getResource());
- } catch (IOException e) {
- throw new CacheException(e.getMessage(), e);
- }
- resourceContext.release();
-
- // TODO - set refresh interval ?
- //cache.put(cacheKey, resourceContext.getContent());
- return resourceContext.getContent();
- }
-
- public Properties loadProperties(String name) {
- return getProperties(name);
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,73 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.InputStream;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * Class stoped all resources in application classpath.
- * TODO - set last midified & expired values.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:00 $
- *
- */
-public class JarResource extends InternetResourceBase {
-
- /**
- * Default place for all static resources in Jar.
- * to avoid access to any class in application, only allowed subpackages for
- * META-INF/resources
- */
- public static final String RESOURCES_ROOT="META-INF/resources";
-
- private String path;
-
- public JarResource(){
-
- }
-
- public JarResource(String path) {
- this.path = path;
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return loader.getResourceAsStream(path);
- }
-
- public String getPath() {
- return path;
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,135 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.ResourceContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/01 15:31:57 $
- *
- */
-public class Java2Dresource extends InternetResourceBase {
- private static final Log log = LogFactory.getLog(Java2Dresource.class);
-
- /**
- * Primary calculation of image dimensions - used when HTML code is
- * generated to render IMG's width and height Subclasses should override
- * this method to provide correct sizes of rendered images
- *
- * @param facesContext
- * @return dimensions of the image to be displayed on page
- */
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- return new Dimension(1, 1);
- }
-
- /**
- * Secondary calculation is used basically by {@link getImage} method
- *
- * @param resourceContext
- * @return
- */
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return new Dimension(1, 1);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- // TODO Auto-generated method stub
- return super.getResourceAsStream(context);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.resource.InternetResourceBase#send(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void send(ResourceContext context) throws IOException {
- ImageRenderer renderer = (ImageRenderer) getRenderer(null);
- try {
- RenderedImage image = getImage(context);
- if (null != image) {
- renderer.sendImage(context, image);
-
- }
- } catch (Exception e) {
- throw new FacesException(Messages
- .getMessage(Messages.SEND_IMAGE_ERROR_2), e);
- }
- }
-
- /**
- * Create {@link RenderedImage} for send to client. can be used as Java2d or
- * Java Advanced Imaging.
- *
- * @param context
- * @return image to send.
- */
- protected RenderedImage getImage(ResourceContext context) {
- ImageRenderer renderer = (ImageRenderer) getRenderer(null);
- Dimension imageDimensions = getDimensions(context);
- BufferedImage image = null;
- if (imageDimensions.getHeight() > 0.0
- && imageDimensions.getWidth() > 0.0) {
- image = renderer.createImage(imageDimensions.width,
- imageDimensions.height);
- Graphics2D graphics = image.createGraphics();
- paint(context, graphics);
- graphics.dispose();
-
- }
- return image;
- }
-
- /**
- * Template method for create image as Applet-like paint.
- *
- * @param context -
- * current resource context.
- * @param graphics2D -
- * graphics to paint.
- */
- protected void paint(ResourceContext context, Graphics2D graphics2D) {
- // TODO Auto-generated method stub
-
- }
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
- *
- */
-public class JpegRenderer extends ImageRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/jpeg";
- }
-
- public void sendImage(ResourceContext context, RenderedImage image) throws IOException
{
- OutputStream outputStream = context.getOutputStream();
- try {
- ImageIO.write(image, "jpeg", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_RGB;
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,88 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
- *
- */
-public class LogfileRenderer extends BaseResourceRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- // TODO Auto-generated method stub
- return "pre";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "text/plain";
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
- */
- protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
- // Encode style in page - read from resource.
- ResourceContext resourceContext = new FacesResourceContext(context);
- InputStream in = resource.getResourceAsStream(resourceContext);
- StringBuffer buff = new StringBuffer();
- int input;
- while((input = in.read())>0){
- buff.append((char)input);
- }
- in.close();
- // MyFaces & RI have different beahvior for style element, in RI best use
writeComment ?
- // TODO - detect page content type ?
- context.getResponseWriter().writeText(buff,resource.getKey());
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 20.11.2006
- *
- */
-public class MimeRenderer extends BaseResourceRenderer {
-
- private String contentType = null;
-
- public MimeRenderer() {
-
- }
-
- public MimeRenderer(String contentType) {
- super();
- this.contentType = contentType;
- }
-
- public String getContentType() {
- return this.contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
-
-
- protected String getTag() {
- return null;
- }
-
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return null;
- }
-
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return null;
- }
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,80 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for resources, rendered only one time in page ( JavaScript, CSS )
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
- *
- */
-public abstract class OneTimeRenderer extends BaseResourceRenderer {
-
- private static final Log log = LogFactory.getLog(OneTimeRenderer.class);
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.BaseResourceRenderer#encodeBegin(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
- */
- public void encodeBegin(InternetResource resource, FacesContext context, Object data,
Map attributes) throws IOException {
-
- if (!isRendered(resource,context)) {
- super.encodeBegin(resource, context, data, attributes);
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO_2,
resource.getKey()));
- }
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.BaseResourceRenderer#encodeEnd(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
- */
- public void encodeEnd(InternetResource resource, FacesContext context, Object data)
throws IOException {
- // TODO Auto-generated method stub
- if (!isRendered(resource,context)) {
- super.encodeEnd(resource, context, data);
- context.getExternalContext().getRequestMap().put(resource.getKey(),Boolean.TRUE);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.MARK_AS_RENDERED_INFO, resource.getKey()));
- }
- } else if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO_2,
resource.getKey()));
- }
- }
-
- /**
- * Detect for resource rendered status. For cacheable, show key parameter in request
Map.
- * @param resource
- * @param context
- * @return - true, if resource already rendered.
- */
- private boolean isRendered(InternetResource resource, FacesContext context){
- return null != context.getExternalContext().getRequestMap().get(resource.getKey()); //
resource.isCacheable() &&
- }
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,125 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.IndexColorModel;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
- *
- */
-public class Png8Renderer extends ImageRenderer {
-
- /**
- * Default web safe colors color model
- */
- public static IndexColorModel webColorModel;
-
- // Build web safe 6x6x6 cube color model.
- static {
- byte[] webLevels = { 0, 51, 102, (byte) 153, (byte) 204, (byte) 255 };
- byte[] r = new byte[256];
- byte[] g = new byte[256];
- byte[] b = new byte[256];
- r[0] = g[0] = b[0] = 0;
- for (int i = 0; i < webLevels.length; i++) {
- for (int j = 0; j < webLevels.length; j++) {
- for (int k = 0; k < webLevels.length; k++) {
- int colorNum = i * webLevels.length * webLevels.length + j
- * webLevels.length + k + 1;
- r[colorNum] = webLevels[i];
- g[colorNum] = webLevels[j];
- b[colorNum] = webLevels[k];
- }
- }
- }
- webColorModel = new IndexColorModel(8, webLevels.length
- * webLevels.length * webLevels.length + 1, r, g, b, 0);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.resource.ImageRenderer#sendImage(org.ajax4jsf.resource.ResourceContext,
- * java.awt.image.RenderedImage)
- */
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- OutputStream outputStream = context.getOutputStream();
- // PNGEncodeParam param = new PNGEncodeParam.Palette();
- // param.setBitDepth(8);
- // param.setInterlacing(true);
- // String[] encoders = ImageCodec.getEncoderNames(image,null);
- // ImageEncoder encoder =
- // ImageCodec.createImageEncoder("png",context.getOutputStream(),param);
- // encoder.encode(image);
- try {
- ImageIO.write(image, "png", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#getImageType()
- */
- public int getImageType() {
- return BufferedImage.TYPE_BYTE_INDEXED;
- // return BufferedImage.TYPE_INT_ARGB;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ImageRenderer#createImage(int, int)
- */
- public BufferedImage createImage(int width, int height) {
-
- // return new BufferedImage(width,height,getImageType());//,colorModel);
- return new BufferedImage(width, height, getImageType(), webColorModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/png";
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,63 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:05 $
- *
- */
-public class PngRenderer extends ImageRenderer {
-
- public void sendImage(ResourceContext context, RenderedImage image)
- throws IOException {
- OutputStream outputStream = context.getOutputStream();
- try {
- ImageIO.write(image, "png", outputStream);
- outputStream.flush();
- outputStream.close();
-
- } catch (Exception e) {
- // IE can unexpected close connection
- }
- }
-
- public String getContentType() {
- // TODO Auto-generated method stub
- return "image/png";
- }
-
- public int getImageType() {
- // TODO Auto-generated method stub
- return BufferedImage.TYPE_INT_ARGB;
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,36 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
- *
- */
-public class PrototypeScript extends ClientScript {
-
- public String getJavaScript() {
- return "scripts/prototype.js";
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,589 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.StreamCorruptedException;
-import java.io.StringReader;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.zip.Deflater;
-import java.util.zip.Inflater;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.imageio.ImageIO;
-import javax.servlet.ServletContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.util.base64.Codec;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.resource.ResourceRenderer;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Produce instances of InternetResource's for any types - jar resource, dynamic
- * created image, component-incapsulated etc. Realised as singleton class to
- * support cache, configuration etc.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
- *
- */
-public class ResourceBuilderImpl extends InternetResourceBuilder {
-
- private static final Log log = LogFactory.getLog(ResourceBuilderImpl.class);
-
- private static final String DATA_SEPARATOR = "/DATA/";
-
- private static Map renderers;
-
- private static ResourceRenderer defaultRenderer = new MimeRenderer(null);
-
- /**
- * keep resources instances . TODO - put this map to application-scope
- * attribute, for support clastering environment.
- */
- private Map resources = Collections.synchronizedMap(new HashMap());
-
- private long _startTime;
-
- private Codec codec;
-
- static {
- renderers = new HashMap();
- // append known renderers for extentions.
- renderers.put(".gif", new GifRenderer());
- ResourceRenderer renderer = new JpegRenderer();
- renderers.put(".jpeg", renderer);
- renderers.put(".jpg", renderer);
- renderers.put(".png", new PngRenderer());
- renderers.put(".js", new ScriptRenderer());
- renderers.put(".css", new StyleRenderer());
- renderers.put(".log", new LogfileRenderer());
- renderers.put(".html", new HTMLRenderer());
- renderers.put(".xhtml", new MimeRenderer("application/xhtml+xml"));
- renderers.put(".xml", new MimeRenderer("text/xml"));
- renderers.put(".xcss", new TemplateCSSRenderer());
- // renderers.put(".htc",new BehaviorRenderer());
- // set in-memory caching ImageIO
- ImageIO.setUseCache(false);
-
- }
-
- public WebXml getWebXml(FacesContext context) {
- WebXml webXml = (WebXml)
context.getExternalContext().getApplicationMap().get(WebXml.CONTEXT_ATTRIBUTE);
- if (null == webXml) {
- throw new FacesException(
- "Resources framework is not initialised, check web.xml for Filter
configuration");
- }
- return webXml;
- }
-
- public ResourceBuilderImpl() {
- super();
- _startTime = System.currentTimeMillis();
- codec = new Codec();
- }
-
- /**
- * @throws FacesException
- */
- protected void registerResources() throws FacesException {
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Enumeration e = loader
- .getResources("META-INF/resources-config.xml");
- while (e.hasMoreElements()) {
- URL resource = (URL) e.nextElement();
- registerConfig(resource);
- }
- } catch (IOException e) {
- throw new FacesException(e);
- }
- }
-
- private void registerConfig(URL resourceConfig) {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Process resources configuration file
"+resourceConfig.toExternalForm());
- }
-
- InputStream in = resourceConfig.openStream();
- try {
- Digester digester = new Digester();
- digester.setValidating(false);
- digester.setEntityResolver(new EntityResolver() {
- // Dummi resolver - alvays do nothing
- public InputSource resolveEntity(String publicId,
- String systemId) throws SAXException, IOException {
- return new InputSource(new StringReader(""));
- }
- });
- digester.setNamespaceAware(false);
- digester.setUseContextClassLoader(true);
- digester.push(this);
- digester.addObjectCreate("resource-config/resource", "class",
- JarResource.class);
- digester.addObjectCreate("resource-config/resource/renderer",
- "class", HTMLRenderer.class);
- digester.addCallMethod(
- "resource-config/resource/renderer/content-type",
- "setContentType", 0);
- digester.addSetNext("resource-config/resource/renderer",
- "setRenderer", ResourceRenderer.class.getName());
- digester.addCallMethod("resource-config/resource/name",
- "setKey", 0);
- digester.addCallMethod("resource-config/resource/path",
- "setPath", 0);
- digester.addCallMethod("resource-config/resource/cacheable",
- "setCacheable", 0);
- digester.addCallMethod(
- "resource-config/resource/session-aware",
- "setSessionAware", 0);
- digester.addCallMethod("resource-config/resource/property",
- "setProperty", 2);
- digester.addCallParam("resource-config/resource/property/name",
- 0);
- digester.addCallParam(
- "resource-config/resource/property/value", 1);
- digester.addCallMethod("resource-config/resource/content-type",
- "setContentType", 0);
- digester.addSetNext("resource-config/resource", "addResource",
- InternetResource.class.getName());
- digester.parse(in);
- } finally {
- in.close();
- }
- } catch (IOException e) {
- throw new FacesException(e);
- } catch (SAXException e) {
- throw new FacesException(e);
- }
- }
-
- /**
- */
- public void init()
- throws FacesException {
- // TODO - mace codec configurable.
- registerResources();
- }
-
- /**
- * Base point for creating resource. Must detect type and build
- * appropriate instance. Currently - make static resource for ordinary
- * request, or instance of class.
- *
- * @param base
- * base object for resource ( resourcess in classpath
- * will be get relative to it package )
- * @param path
- * key - path to resource, resource class name etc.
- * @return
- * @throws FacesException
- */
- public InternetResource createResource(Object base, String path)
- throws FacesException {
- // TODO - detect type of resource ( for example, resources location path
- // in Skin
- try {
- return getResource(path);
- } catch (ResourceNotFoundException e) {
- try {
- return getResource(buildKey(base, path));
- } catch (ResourceNotFoundException e1) {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_INFO,
- path));
- }
- }
- }
- // path - is class name ?
- InternetResource res;
- try {
- Class resourceClass = Class.forName(path);
- res = createDynamicResource(path, resourceClass);
- } catch (Exception e) {
- try {
- res = createJarResource(base, path);
- } catch (ResourceNotFoundException ex) {
- res = createStaticResource(path);
- }
- // TODO - if resource not found, create static ?
- }
- return res;
- }
-
- private String buildKey(Object base, String path) {
- if (path.startsWith("/")) {
- return path.substring(1);
- }
- if (null == base) {
- return path;
- }
- StringBuffer packageName = new StringBuffer(base.getClass()
- .getPackage().getName().replace('.', '/'));
- return packageName.append("/").append(path).toString();
- }
-
- public String getUri(InternetResource resource, FacesContext context,
- Object storeData) {
- StringBuffer uri = new StringBuffer();//
ResourceServlet.DEFAULT_SERVLET_PATH).append("/");
- uri.append(resource.getKey());
- // append serialized data as Base-64 encoded request string.
- if (storeData != null) {
- try {
- byte[] objectData;
- if (!(storeData instanceof byte[])) {
- ByteArrayOutputStream dataSteram = new ByteArrayOutputStream(
- 1024);
- ObjectOutputStream objStream = new ObjectOutputStream(
- dataSteram);
- objStream.writeObject(storeData);
- objStream.flush();
- objStream.close();
- dataSteram.close();
- objectData = dataSteram.toByteArray();
- } else {
- objectData = (byte[]) storeData;
- }
- uri.append(DATA_SEPARATOR);
- byte[] dataArray = encrypt(objectData);
- uri.append(new String(dataArray, "ISO-8859-1"));
-
- // / byte[] objectData = dataSteram.toByteArray();
- // / uri.append("?").append(new
- // String(Base64.encodeBase64(objectData),
- // / "ISO-8859-1"));
- } catch (Exception e) {
- // Ignore errors, log it
- log.error(Messages
- .getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e);
- }
- }
- String resourceURL = getWebXml(context).getFacesResourceURL(context,
- uri.toString());//
context.getApplication().getViewHandler().getResourceURL(context,uri.toString());
- if (resource.isSessionAware()) {
- resourceURL = context.getExternalContext().encodeResourceURL(
- resourceURL);
- }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
- resource.getKey(), resourceURL));
- }
- return resourceURL;// context.getExternalContext().encodeResourceURL(resourceURL);
-
- }
-
- /**
- * @param key
- * @return
- */
- public InternetResource getResourceForKey(String key)
- throws ResourceNotFoundException {
-
- int data = key.indexOf(DATA_SEPARATOR);
- if (data >= 0) {
- key = key.substring(0, data);
- }
- return getResource(key);
- }
-
- public Object getResourceDataForKey(String key) {
- Object data = null;
- String dataString = null;
- int dataStart = key.indexOf(DATA_SEPARATOR);
- if (dataStart >= 0) {
- dataString = key.substring(dataStart + DATA_SEPARATOR.length());
- }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.RESTORE_DATA_FROM_RESOURCE_URI_INFO, key,
- dataString));
- }
- if (dataString != null) {
- // dataString =
- // dataString.substring(dataStart+ResourceServlet.DATA_PARAMETER.length()+1);
- byte[] objectArray = null;
- try {
- byte[] dataArray = dataString.getBytes("ISO-8859-1");
- objectArray = decrypt(dataArray);
-
- ObjectInputStream in = new ObjectInputStream(
- new ByteArrayInputStream(objectArray));
- data = in.readObject();
- } catch (StreamCorruptedException e) {
- data = objectArray;
- } catch (IOException e) {
- log.error(Messages
- .getMessage(Messages.DESERIALIZE_DATA_INPUT_ERROR), e);
- } catch (ClassNotFoundException e) {
- log.error(Messages
- .getMessage(Messages.DATA_CLASS_NOT_FOUND_ERROR), e);
- }
- }
- return data;
- }
-
- public InternetResource getResource(String path)
- throws ResourceNotFoundException {
-
- InternetResource internetResource = (InternetResource) resources
- .get(path);
- if (null == internetResource) {
- throw new ResourceNotFoundException("Resource not registered : "
- + path);
- } else {
- return internetResource;
- }
- }
-
- public void addResource(InternetResource resource) {
- resources.put(resource.getKey(), resource);
- ResourceRenderer renderer = resource.getRenderer(null);
- if (renderer == null) {
- setRenderer(resource, resource.getKey());
- }
- }
-
- public void addResource(String key, InternetResource resource) {
- resources.put(key, resource);
- resource.setKey(key);
- // TODO - set renderer ?
- }
-
-// public String getFacesResourceKey(HttpServletRequest request) {
-// return getWebXml(context).getFacesResourceKey(request);
-// }
-
- public String getFacesResourceURL(FacesContext context, String Url) {
- return getWebXml(context).getFacesResourceURL(context, Url);
- }
-
- /**
- * Build resource for link to static context in webapp.
- *
- * @param path
- * @return
- * @throws FacesException
- */
- protected InternetResource createStaticResource(String path)
- throws ResourceNotFoundException, FacesException {
- FacesContext context = FacesContext.getCurrentInstance();
- if (null != context) {
- if (context.getExternalContext().getContext() instanceof ServletContext) {
- ServletContext servletContext = (ServletContext) context
- .getExternalContext().getContext();
- InputStream in = servletContext.getResourceAsStream(path);
- if (null != in) {
- InternetResourceBase res = new StaticResource(path);
- setRenderer(res, path);
- res.setLastModified(new Date(getStartTime()));
- addResource(path, res);
- try {
- in.close();
- } catch (IOException e) {
- }
- return res;
- }
- }
- }
- throw new ResourceNotFoundException(Messages.getMessage(
- Messages.STATIC_RESOURCE_NOT_FOUND_ERROR, path));
- }
-
- private void setRenderer(InternetResource res, String path)
- throws FacesException {
- int lastPoint = path.lastIndexOf('.');
- if (lastPoint > 0) {
- String ext = path.substring(lastPoint);
- ResourceRenderer resourceRenderer = (ResourceRenderer) renderers
- .get(ext);
- if (null != resourceRenderer) {
- res.setRenderer(resourceRenderer);
- } else {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.NO_RESOURCE_REGISTERED_ERROR_2, path,
- renderers.keySet()));
- }
-
- // String mimeType = servletContext.getMimeType(path);
- res.setRenderer(defaultRenderer);
- }
- }
- }
-
- /**
- * Create resurce to send from classpath relative to base class.
- *
- * @param base
- * @param path
- * @return
- * @throws FacesException
- */
- protected InternetResource createJarResource(Object base, String path)
- throws ResourceNotFoundException, FacesException {
- String key = buildKey(base, path);
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (null != loader.getResource(key)) {
- JarResource res = new JarResource(key);
- setRenderer(res, path);
- res.setLastModified(new Date(getStartTime()));
- addResource(key, res);
- return res;
- } else {
- throw new ResourceNotFoundException(Messages.getMessage(
- Messages.NO_RESOURCE_EXISTS_ERROR, key));
- }
-
- }
-
- /**
- * Create resource by instatiate given class.
- *
- * @param path
- * @param instatiate
- * @return
- */
- protected InternetResource createDynamicResource(String path,
- Class instatiate) throws ResourceNotFoundException {
- if (InternetResource.class.isAssignableFrom(instatiate)) {
- InternetResource resource;
- try {
- resource = (InternetResource) instatiate.newInstance();
- addResource(path, resource);
- } catch (Exception e) {
- String message = Messages.getMessage(
- Messages.INSTANTIATE_RESOURCE_ERROR, instatiate
- .toString());
- log.error(message, e);
- throw new ResourceNotFoundException(message, e);
- }
- return resource;
- }
- throw new FacesException(Messages
- .getMessage(Messages.INSTANTIATE_CLASS_ERROR));
- }
-
- /**
- * Create resource by instatiate {@link UserResource} class with given
- * properties ( or got from cache ).
- *
- * @param cacheable
- * @param session
- * @param mime
- * @return
- * @throws FacesException
- */
- public InternetResource createUserResource(boolean cacheable,
- boolean session, String mime) throws FacesException {
- String path = getUserResourceKey(cacheable, session, mime);
- InternetResource userResource;
- try {
- userResource = getResource(path);
- } catch (ResourceNotFoundException e) {
- userResource = new UserResource(cacheable, session, mime);
- addResource(path, userResource);
- }
- return userResource;
- }
-
- /**
- * Generate resource key for user-generated resource with given
- * properties.
- *
- * @param cacheable
- * @param session
- * @param mime
- * @return
- */
- private String getUserResourceKey(boolean cacheable, boolean session,
- String mime) {
- StringBuffer pathBuffer = new StringBuffer(UserResource.class.getName());
- pathBuffer.append(cacheable ? "/c" : "/n");
- pathBuffer.append(session ? "/s" : "/n");
- if (null != mime) {
- pathBuffer.append('/').append(mime.hashCode());
- }
- String path = pathBuffer.toString();
- return path;
- }
-
- /**
- * @return Returns the startTime for application.
- */
- public long getStartTime() {
- return _startTime;
- }
-
- protected byte[] encrypt(byte[] src) {
- try {
- Deflater compressor = new Deflater(Deflater.BEST_SPEED);
- byte[] compressed = new byte[src.length + 100];
- compressor.setInput(src);
- compressor.finish();
- int totalOut = compressor.deflate(compressed);
- byte[] zipsrc = new byte[totalOut];
- System.arraycopy(compressed, 0, zipsrc, 0, totalOut);
- compressor.end();
- return codec.encode(zipsrc);
- } catch (Exception e) {
- throw new FacesException("Error encode resource data", e);
- }
- }
-
- protected byte[] decrypt(byte[] src) {
- try {
- byte[] zipsrc = codec.decode(src);
- Inflater decompressor = new Inflater();
- byte[] uncompressed = new byte[zipsrc.length * 5];
- decompressor.setInput(zipsrc);
- int totalOut = decompressor.inflate(uncompressed);
- byte[] out = new byte[totalOut];
- System.arraycopy(uncompressed, 0, out, 0, totalOut);
- decompressor.end();
- return out;
- } catch (Exception e) {
- throw new FacesException("Error decode resource data", e);
- }
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,92 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-
-import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseListener;
-import javax.faces.lifecycle.Lifecycle;
-
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * Lifecycle for simulate faces request processing for resource.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:56 $
- *
- */
-public class ResourceLifecycle extends Lifecycle {
-
- /* (non-Javadoc)
- * @see
javax.faces.lifecycle.Lifecycle#addPhaseListener(javax.faces.event.PhaseListener)
- */
- public void addPhaseListener(PhaseListener arg0) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#execute(javax.faces.context.FacesContext)
- */
- public void execute(FacesContext arg0) throws FacesException {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#getPhaseListeners()
- */
- public PhaseListener[] getPhaseListeners() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see
javax.faces.lifecycle.Lifecycle#removePhaseListener(javax.faces.event.PhaseListener)
- */
- public void removePhaseListener(PhaseListener arg0) {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see javax.faces.lifecycle.Lifecycle#render(javax.faces.context.FacesContext)
- */
- public void render(FacesContext arg0) throws FacesException {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @param context
- * @param resource
- * @throws IOException
- */
- public void send(ResourceContext resourceContext, InternetResource resource) throws
IOException{
- resource.sendHeaders(resourceContext);
- resource.send(resourceContext);
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,150 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.javascript.JSMin;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
- *
- */
-public class ScriptRenderer extends OneTimeRenderer {
-
- private static final String COMPRESS_SCRIPTS_PARAMETER =
"org.ajax4jsf.COMPRESS_SCRIPT";
-
- private static final Log _log = LogFactory.getLog(ScriptRenderer.class);
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- // TODO Auto-generated method stub
- return "script";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- // TODO Auto-generated method stub
- return "src";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- // TODO Auto-generated method stub
- return new String[][]{{"type",getContentType()}};
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO - use configurable encoding ?
- return "text/javascript";
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
org.ajax4jsf.resource.ResourceContext)
- */
- public int send(InternetResource base, ResourceContext context) throws IOException {
- InputStream in = base.getResourceAsStream(context);
- if (null == in) {
- String message = Messages.getMessage(
- Messages.NO_INPUT_STREAM_ERROR, base.getKey());
- throw new IOException(message);
- }
- OutputStream out = context.getOutputStream();
- // Compress JavaScript output by JSMin ( true by default )
- if( !
"false".equalsIgnoreCase(context.getInitParameter(COMPRESS_SCRIPTS_PARAMETER))){
- CountingOutputStream countingStream = new CountingOutputStream(out);
- JSMin jsmin = new JSMin(in,countingStream);
- try {
- jsmin.jsmin();
- } catch (Exception e) {
- _log.error("Error send script to client for resource "+base.getKey(), e);
- } finally {
- in.close();
- countingStream.flush();
- countingStream.close();
- }
- int written = countingStream.getWritten();
- if(_log.isDebugEnabled()){
- _log.debug("Send "+written+" bytes to client for JavaScript resource
"+base.getKey());
- }
- return written;
- } else {
- return sendStream(in, out);
- }
- }
-
-
-}
-
-class CountingOutputStream extends OutputStream {
- private OutputStream outputStream;
- private int written = 0;
-
- CountingOutputStream(OutputStream outputStream) {
- super();
- this.outputStream = outputStream;
- }
-
- public void close() throws IOException {
- outputStream.close();
- }
-
- public void flush() throws IOException {
- outputStream.flush();
- }
-
- public void write(byte[] b, int off, int len) throws IOException {
- outputStream.write(b, off, len);
- written += len;
- }
-
- public void write(byte[] b) throws IOException {
- outputStream.write(b);
- written += b.length;
- }
-
- public void write(int b) throws IOException {
- outputStream.write(b);
- written++;
- }
-
- int getWritten() {
- return written;
- }
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,143 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
- *
- */
-public class ServletResourceContext extends ResourceContext {
-
- private ServletContext context;
- private HttpServletRequest request;
-
- private HttpServletResponse response;
-
- /**
- * @param request
- * @param response
- */
- public ServletResourceContext(ServletContext context, HttpServletRequest request,
HttpServletResponse response) {
- this.context = context;
- this.request = request;
- this.response = response;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
java.lang.String)
- */
- public void setHeader(String name, String value) {
- response.setHeader(name,value);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
- */
- public void setIntHeader(String name, int value) {
- response.setIntHeader(name,value);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
- */
- public void setDateHeader(String name, long value) {
- response.setDateHeader(name,value);
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- // TODO Auto-generated method stub
- return response.getOutputStream();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
- */
- public String getQueryString() {
- return request.getQueryString();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
- */
- public String getPathInfo() {
- return request.getPathInfo();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
- */
- public Object getSessionAttribute(String name) {
- return request.getSession(false).getAttribute(name);
- }
-
- public InputStream getResourceAsStream(String path) {
- // TODO Auto-generated method stub
- return context.getResourceAsStream(path);
- }
-
- public String getRequestParameter(String data_parameter) {
- // TODO Auto-generated method stub
- return request.getParameter(data_parameter);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceContext#getWriter()
- */
- public PrintWriter getWriter() throws IOException {
- // TODO Auto-generated method stub
- return response.getWriter();
- }
-
- public void setContentType(String contentType) {
- response.setContentType(contentType);
- }
-
- public String getInitParameter(String name) {
- // TODO Auto-generated method stub
- return context.getInitParameter(name);
- }
-
- public String getServletPath() {
- // TODO Auto-generated method stub
- return request.getServletPath();
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,43 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SmartPositionScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- // TODO Auto-generated method stub
- return "scripts/smartposition.js";
- }
-
- protected boolean isUsePrototype() {
-
- return true;
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,103 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.InputStream;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
- *
- */
-public class StaticResource extends InternetResourceBase {
-
- private String path;
- private byte[] resourceData = null;
-
- /**
- *
- */
- public StaticResource() {
- super();
- }
-
-
-
- public StaticResource(String path){
- this.path = path;
- setCacheable(true);
- }
-
-
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- return context.getResourceAsStream(path);
- }
-
-
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return true;
- }
-
-
-
- public String getUri(FacesContext context, Object data) {
- // perform all encodings, suitable for JSF specification.
- String src = context.getApplication().getViewHandler().getResourceURL(context,path);
- return context.getExternalContext().encodeResourceURL(src);
- }
-
- public void encode(FacesContext context, Object data) {
- // TODO Auto-generated method stub
-
- }
-
-
-
- /**
- * @return the path
- */
- public String getPath() {
- return path;
- }
-
-
-
- /**
- * @param path the path to set
- */
- public void setPath(String path) {
- this.path = path;
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,82 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-
-/**
- * Render style element with content in page. Warning - not use for head link element,
- * it must be rendered separate.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
- *
- */
-public class StyleRenderer extends OneTimeRenderer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
- */
- protected String getTag() {
- return "link";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
- */
- protected String getHrefAttr() {
- return "href";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
- */
- protected String[][] getCommonAttrs() {
- return new
String[][]{{"type","text/css"},{"rel","stylesheet"}};
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
- */
- public String getContentType() {
- // TODO use configurable encoding ?
- return "text/css";
- }
-
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
- */
- /*
- protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
- // Encode style in page - read from resource.
- ResourceContext resourceContext = new FacesResourceContext(context);
- InputStream in = resource.getResourceAsStream(resourceContext);
- StringBuffer buff = new StringBuffer();
- int input;
- while((input = in.read())>0){
- buff.append((char)input);
- }
- in.close();
- // MyFaces & RI have different beahvior for style element, in RI best use
writeComment ?
- // TODO - detect page content type ?
- context.getResponseWriter().writeText(buff,resource.getKey());
- }
-*/
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,137 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-
-import org.ajax4jsf.framework.renderer.RendererBase;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author shura
- *
- */
-public class TemplateCSSRenderer extends StyleRenderer {
-
- private static final String COMPILED_TEMPLATE_PROPERTY = "compiled-template";
-
- private RendererBase renderer = new RendererBase() {
-
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
- return UIComponent.class;
- }
-
- };
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
org.ajax4jsf.resource.ResourceContext)
- */
- public int send(InternetResource base, ResourceContext context) throws IOException {
- PreparedTemplate template = null;
- template = getTemplate(base, context);
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if(null != facesContext) {
- // Create responseWriter.
- String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
- if (null == defaultRenderKitId) {
- defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- RenderKitFactory renderKitFactory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
- // TODO - handle response encoding
- ResponseWriter responseWriter =
renderKit.createResponseWriter(context.getWriter(),null,"UTF-8");
- facesContext.setResponseWriter(responseWriter);
- responseWriter.startDocument();
- // TODO - parameters and mock renderer/component ?
- // for first time, this template only allow skin or faces variables interaction
- template.encode(renderer,facesContext,null);
- responseWriter.endDocument();
- responseWriter.flush();
- responseWriter.close();
- } else {
- throw new FacesException("FacesContext for resource from template
"+base.getKey()+" is null");
- }
- return 0;
- }
-
- /**
- * @param base
- * @param context
- * @return
- * @throws IOException
- */
- public PreparedTemplate getTemplate(InternetResource base, ResourceContext context)
throws IOException {
- PreparedTemplate template;
- // if(base.isCacheable()){
- template = (PreparedTemplate) base.getProperty(COMPILED_TEMPLATE_PROPERTY);
- // }
- if(null == template){
- HtmlCompiler compiler = new HtmlCompiler();
- InputStream resourceAsStream = base.getResourceAsStream(context);
- template = compiler.compile(resourceAsStream, base.getKey());
- base.setProperty(COMPILED_TEMPLATE_PROPERTY, template);
- resourceAsStream.close();
- }
- return template;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.BaseResourceRenderer#requireFacesContext()
- */
- public boolean requireFacesContext() {
- return true;
- }
-
- public Object getData(InternetResource base, FacesContext context, Object data) {
- ResourceContext resourceContext = new FacesResourceContext(context);
- PreparedTemplate template;
- try {
- template = getTemplate(base, resourceContext);
- } catch (IOException e) {
- return null;
- }
- UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
- TemplateContext templateContext = new TemplateContext(null,context,component);
- Object value = template.getValue(templateContext);
- if(null == value){
- int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
- value = ByteBuffer.allocate(4).putInt(hashCode).array();
- }
- return value;
- }
-
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,295 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Date;
-import java.util.Map;
-
-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 $
- *
- */
-public class TemplateCSSResource implements InternetResource {
-
- private String templateName;
- private InternetResource _resource;
- private static TemplateCSSRenderer templateCSSRenderer = new TemplateCSSRenderer();
-
- public TemplateCSSResource(){
-
- }
- /**
- * @param templateName
- */
- public TemplateCSSResource(String templateName) {
- super();
- setPath(templateName);
- }
- /**
- * @param templateName
- * @throws FacesException
- */
- public void setPath(String templateName) throws FacesException {
- // remove leaded / - as need for ClassLoader.getResource call.
- this.templateName =
templateName.startsWith("/")?templateName.substring(1):templateName;
- // Self-register resource in system.
- _resource =
InternetResourceBuilder.getInstance().createResource(null,this.templateName);
- _resource.setRenderer(templateCSSRenderer);
- try {
- // Attempt to compile template at init time. Due to client-side caching,
- // without registering resources requests can be not call rendering template.
- templateCSSRenderer.getTemplate(_resource, null);
- } catch (Exception e) {
- // Do nothing - template will be compiled at rendering time.
- // TODO log error.
- }
- }
-
- /**
- * @param context
- * @param data
- * @param attributes
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
- */
- public void encode(FacesContext context, Object data, Map attributes) throws IOException
{
- _resource.encode(context, data, attributes);
- }
-
- /**
- * @param context
- * @param data
- * @throws IOException
- * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void encode(FacesContext context, Object data) throws IOException {
- _resource.encode(context, data);
- }
-
- /**
- * @param context
- * @param component
- * @param attrs
- * @throws IOException
- * @see
org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
- */
- public void encodeBegin(FacesContext context, Object component, Map attrs) throws
IOException {
- _resource.encodeBegin(context, component, attrs);
- }
-
- /**
- * @param context
- * @param component
- * @throws IOException
- * @see
org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void encodeEnd(FacesContext context, Object component) throws IOException {
- _resource.encodeEnd(context, component);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getContentLength(ResourceContext)
- */
- public int getContentLength(ResourceContext resourceContext) {
- return _resource.getContentLength(resourceContext);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getContentType(ResourceContext)
- */
- public String getContentType(ResourceContext resourceContext) {
- return _resource.getContentType(null);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getExpired(ResourceContext)
- */
- public Date getExpired(ResourceContext resourceContext) {
- return _resource.getExpired(null);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getKey()
- */
- public String getKey() {
- return _resource.getKey();
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getLastModified(ResourceContext)
- */
- public Date getLastModified(ResourceContext resourceContext) {
- return _resource.getLastModified(null);
- }
-
- /**
- * @param key
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
- */
- public Object getProperty(Object key) {
- return _resource.getProperty(key);
- }
-
- /**
- * @param context
- * @return
- * @see
org.ajax4jsf.resource.InternetResource#getResourceAsStream(org.ajax4jsf.resource.ResourceContext)
- */
- public InputStream getResourceAsStream(ResourceContext context) {
- return _resource.getResourceAsStream(context);
- }
-
- /**
- * @param context
- * @param data
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public String getUri(FacesContext context, Object data) {
- return _resource.getUri(context, data);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#isCacheable(ResourceContext)
- */
- public boolean isCacheable(ResourceContext resourceContext) {
- return _resource.isCacheable(null);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#isSessionAware()
- */
- public boolean isSessionAware() {
- return _resource.isSessionAware();
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
- */
- public boolean requireFacesContext() {
- return _resource.requireFacesContext();
- }
-
- /**
- * @param context
- * @throws IOException
- * @see
org.ajax4jsf.resource.InternetResource#send(org.ajax4jsf.resource.ResourceContext)
- */
- public void send(ResourceContext context) throws IOException {
- _resource.send(context);
- }
-
- /**
- * @param response
- * @see
org.ajax4jsf.resource.InternetResource#sendHeaders(org.ajax4jsf.resource.ResourceContext)
- */
- public void sendHeaders(ResourceContext response) {
- _resource.sendHeaders(response);
- }
-
- /**
- * @param key
- * @see org.ajax4jsf.resource.InternetResource#setKey(java.lang.String)
- */
- public void setKey(String key) {
- _resource.setKey(key);
- }
-
- /**
- * @param key
- * @param value
- * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object,
java.lang.Object)
- */
- public void setProperty(Object key, Object value) {
- _resource.setProperty(key, value);
- }
-
- /**
- * @param renderer
- * @see
org.ajax4jsf.resource.InternetResource#setRenderer(org.ajax4jsf.resource.ResourceRenderer)
- */
- public void setRenderer(ResourceRenderer renderer) {
- _resource.setRenderer(renderer);
- }
-
- /**
- * @return
- * @see org.ajax4jsf.resource.InternetResource#getRenderer(ResourceContext)
- */
- public ResourceRenderer getRenderer(ResourceContext resourceContext) {
- return _resource.getRenderer(null);
- }
-
- /**
- * @param cacheable
- * @see org.ajax4jsf.resource.InternetResource#setCacheable(boolean)
- */
- public void setCacheable(boolean cacheable) {
- _resource.setCacheable(cacheable);
- }
-
- /**
- * @param expired
- * @see org.ajax4jsf.resource.InternetResource#setExpired(java.util.Date)
- */
- public void setExpired(Date expired) {
- _resource.setExpired(expired);
- }
-
- /**
- * @param lastModified
- * @see org.ajax4jsf.resource.InternetResource#setLastModified(java.util.Date)
- */
- public void setLastModified(Date lastModified) {
- _resource.setLastModified(lastModified);
- }
-
- /**
- * @param sessionAware
- * @see org.ajax4jsf.resource.InternetResource#setSessionAware(boolean)
- */
- public void setSessionAware(boolean sessionAware) {
- _resource.setSessionAware(sessionAware);
- }
-}
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,138 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.framework.resource;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.resource.ResourceComponent;
-import org.ajax4jsf.resource.ResourceContext;
-
-/**
- * @author shura
- *
- */
-public class UserResource extends InternetResourceBase {
-
- private String contentType;
- /**
- *
- */
- public UserResource(boolean cacheable, boolean session, String mime) {
- super();
- setCacheable(cacheable);
- setSessionAware(session);
- setContentType(mime);
- }
- /**
- * @return Returns the contentType.
- */
- public String getContentType(ResourceContext resourceContext) {
- return contentType;
- }
- /**
- * @param contentType The contentType to set.
- */
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public Object getDataToStore(FacesContext context, Object data) {
- UriData dataToStore = null;
- if (data instanceof ResourceComponent) {
- ResourceComponent resource = (ResourceComponent) data;
- dataToStore = new UriData();
- dataToStore.value = resource.getValue();
- dataToStore.createContent =
UIComponentBase.saveAttachedState(context,resource.getCreateContent());
- if (data instanceof UIComponent) {
- UIComponent component = (UIComponent) data;
- ValueBinding expires = component.getValueBinding("expires");
- if (null != expires) {
- dataToStore.expires = UIComponentBase.saveAttachedState(context,expires);
- }
- ValueBinding lastModified = component.getValueBinding("lastModified");
- if (null != lastModified) {
- dataToStore.modified = UIComponentBase.saveAttachedState(context,lastModified);
- }
- }
- }
- return dataToStore;
- }
- /* (non-Javadoc)
- * @see
org.ajax4jsf.resource.InternetResourceBase#send(org.ajax4jsf.resource.ResourceContext)
- */
- public void send(ResourceContext context) throws IOException {
- UriData data = (UriData) restoreData(context);
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (null != data && null != facesContext ) {
- // Send headers
- if(data.expires != null){
- ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.expires);
- Date expires = (Date) binding.getValue(facesContext);
- context.setDateHeader("Expires",expires.getTime());
- }
- if(data.modified != null){
- ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.modified);
- Date modified = (Date) binding.getValue(facesContext);
- context.setDateHeader("Last-Modified",modified.getTime());
- }
- // Send content
- OutputStream out = context.getOutputStream();
- MethodBinding send = (MethodBinding)
UIComponentBase.restoreAttachedState(facesContext,data.createContent);
- send.invoke(facesContext,new Object[]{out,data.value});
- }
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.resource.InternetResourceBase#requireFacesContext()
- */
- public boolean requireFacesContext() {
- // TODO Auto-generated method stub
- return true;
- }
-
- public static class UriData implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1258987L;
-
- private Object value;
-
- private Object createContent;
-
- private Object expires;
-
- private Object modified;
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,34 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-
-
-
-
- <meta content="text/html; charset=Windows-1251"
http-equiv="content-type">
-
-
-
-
- <title>Internet Resources</title>
-</head>
-
-
-<body>
-
-
-<h1>Package for manipulate page resources ( images, scripts, styles,
-applets etc ) at Java Server Faces render Phase and at request phase of
-concrete resource.</h1>
-
-Note: The resource framework implements the Lightweight design patter.
-Therefore, the resource classes should not contain data depends of
-the particular request. The data is taken from the {@link javax.context.FacesContext}
-and {@link javax.component.UIComponent}, that is passed as a parameter
-when html is generated.
-For passing the data with URI, the {@link InternetResourceBase} class
-has getDataToSave method. It is invoked when the generation is taken place.
-The returned object is serialized. Then, restoreData method de-serialize it back.
-The {@link InternetResourceBuilder} class controls this process.
-</body>
-</html>
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/BaseResourceRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/BaseResourceRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,175 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceRenderer;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:07 $
+ *
+ */
+public abstract class BaseResourceRenderer implements ResourceRenderer {
+
+ public void encode(InternetResource resource, FacesContext context,
+ Object data) throws IOException {
+ this.encodeBegin(resource, context, data, Collections.EMPTY_MAP);
+ this.encodeEnd(resource, context, data);
+ }
+
+ public void encode(InternetResource resource, FacesContext context,
+ Object data, Map attributes) throws IOException {
+ this.encodeBegin(resource, context, data, attributes);
+ this.encodeEnd(resource, context, data);
+ }
+
+ public void encodeBegin(InternetResource resource, FacesContext context,
+ Object data, Map attributes) throws IOException {
+ if (null != getTag()) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(getTag(), null);
+ String attrs[][] = getCommonAttrs();
+ if (null != getHrefAttr()) {
+ writer.writeAttribute(getHrefAttr(), resource.getUri(context,
+ data), null);
+ }
+ if (null != attrs) {
+ for (int i = 0; i < attrs.length; i++) {
+ writer.writeAttribute(attrs[i][0], attrs[i][1], null);
+ }
+ }
+ for (Iterator iter = attributes.entrySet().iterator(); iter
+ .hasNext();) {
+ Map.Entry attr = (Map.Entry) iter.next();
+ writer.writeAttribute(attr.getKey().toString(),
+ attr.getValue(), null);
+ }
+ }
+ this.customEncode(resource, context, data);
+ }
+
+ public void encodeEnd(InternetResource resource, FacesContext context,
+ Object data) throws IOException {
+ if (null != getTag()) {
+ ResponseWriter writer = context.getResponseWriter();
+ writer.endElement(getTag());
+
+ }
+ }
+
+ /**
+ * Template method for customaize encoding for component. can insert size
+ * etc. attributes, child tags etc.
+ *
+ * @param resource
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ protected void customEncode(InternetResource resource,
+ FacesContext context, Object data) throws IOException {
+ // TODO if concrete renderer need
+
+ }
+
+ protected abstract String getTag();
+
+ protected abstract String getHrefAttr();
+
+ protected abstract String[][] getCommonAttrs();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.resource.ResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
+ * org.ajax4jsf.resource.ResourceContext)
+ */
+ public int send(InternetResource base, ResourceContext context)
+ throws IOException {
+ InputStream in = base.getResourceAsStream(context);
+ OutputStream out = context.getOutputStream();
+ if (null == in) {
+ String message = Messages.getMessage(
+ Messages.NO_INPUT_STREAM_ERROR, base.getKey());
+ throw new IOException(message);
+ }
+ int total = sendStream(in, out);
+
+ return total;
+ }
+
+ /**
+ * @param in
+ * @param out
+ * @return
+ * @throws IOException
+ */
+ protected int sendStream(InputStream in, OutputStream out)
+ throws IOException {
+ int total = 0;
+ byte[] buffer = new byte[InternetResourceBase.BUFFER_SIZE];
+ int length;
+ try {
+ for (length = in.read(buffer); length > 0; length = in.read(buffer)) {
+ out.write(buffer, 0, length);
+ total += length;
+ }
+ } finally {
+ in.close();
+ out.flush();
+ out.close();
+ }
+ return total;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceRenderer#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Object getData(InternetResource base, FacesContext context,
+ Object data) {
+ // By default, resource dot't provide any data. Can be used in
+ // Template-based or other
+ // configurable resources ( like weblets configuration ).
+ return null;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java (from rev
1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CacheKey.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package org.ajax4jsf.resource;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.resource.InternetResource;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class CacheKey {
+ private Object resourceData;
+ private HttpServletRequest request;
+ private HttpServletResponse response;
+ private InternetResource resource;
+ public CacheKey(Object resourceData,
+ HttpServletRequest request, HttpServletResponse response,
+ InternetResource resource) {
+ super();
+ this.resourceData = resourceData;
+ this.request = request;
+ this.response = response;
+ this.resource = resource;
+ }
+ public Object getResourceData() {
+ return resourceData;
+ }
+ public HttpServletRequest getRequest() {
+ return request;
+ }
+ public HttpServletResponse getResponse() {
+ return response;
+ }
+ public InternetResource getResource() {
+ return resource;
+ }
+
+}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/CachedResourceContext.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CachedResourceContext.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,153 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
+ *
+ */
+public class CachedResourceContext extends ResourceContext {
+ private ResourceContext parent;
+ private CacheContent content;
+
+ /**
+ * @param parent
+ */
+ public CachedResourceContext(ResourceContext parent) {
+ this.setCacheEnabled(true);
+ this.parent = parent;
+ this.content = new CacheContent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ return content.getOutputStream();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
+ */
+ public String getPathInfo() {
+ return this.parent.getPathInfo();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
+ */
+ public String getQueryString() {
+ return this.parent.getQueryString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getRequestParameter(java.lang.String)
+ */
+ public String getRequestParameter(String data_parameter) {
+ return this.parent.getRequestParameter(data_parameter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getResourceAsStream(java.lang.String)
+ */
+ public InputStream getResourceAsStream(String path) {
+ return this.parent.getResourceAsStream(path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
+ */
+ public Object getSessionAttribute(String name) {
+ return this.parent.getSessionAttribute(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
+ */
+ public void setDateHeader(String name, long value) {
+ this.content.setDateHeader(name,value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ this.content.setHeader(name,value);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
+ */
+ public void setIntHeader(String name, int value) {
+ this.content.setIntHeader(name,value);
+ }
+
+ /**
+ * @return Returns the content.
+ */
+ CacheContent getContent() {
+ return this.content;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getWriter()
+ */
+ public PrintWriter getWriter() throws IOException {
+ return content.getWriter();
+ }
+
+ public void setContentType(String contentType) {
+ this.content.setContentType(contentType);
+ }
+
+ public Object getResourceData() {
+ return parent.getResourceData();
+ }
+
+ public void setResourceData(Object codec) {
+ parent.setResourceData(codec);
+
+ }
+
+ public String getInitParameter(String name) {
+ return parent.getInitParameter(name);
+ }
+
+ public String getServletPath() {
+ return parent.getServletPath();
+ }
+
+ public void release() {
+ super.release();
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ClientScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,181 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.util.Date;
+import java.util.Map;
+
+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.ResourceNotFoundException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * Resource for AJAX client-side script. Render one time per page.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/01/26 14:15:18 $
+ *
+ */
+public abstract class ClientScript extends JarResource {
+
+ private static final Log log = LogFactory.getLog(ClientScript.class);
+
+ protected boolean usePrototype = false;
+ /**
+ * Set JavaScript renderer and modification time to application-startup time.
+ */
+ public ClientScript() {
+ super();
+ setRenderer(new ScriptRenderer());
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+ String key = this.getClass().getName();
+ try {
+ // Search already registered resource for this class.
+ InternetResource resource = resourceBuilder.getResource(key);
+ this.setKey(resource.getKey());
+ } catch(ResourceNotFoundException ex){
+ // If script not registered, append it to builder.
+ setLastModified(new Date(resourceBuilder.getStartTime()));
+ resourceBuilder.addResource(key,this);
+ }
+ String script ;
+ if (getJavaScript().startsWith("/")) {
+ // remove lead / for classloader covention.
+ script = getJavaScript().substring(1);
+ } else {
+ script = this.getClass().getPackage().getName().replace('.',
'/')+"/"
+ + getJavaScript();
+ }
+ setPath(script);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#getLastModified()
+ */
+ public Date getLastModified(ResourceContext resourceContext) {
+
+ if (isCacheable(null)) {
+ return super.getLastModified(resourceContext);
+ } else {
+ return new Date(System.currentTimeMillis()+1000L);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return true;
+ }
+
+ /**
+ * @return Returns the javaScript.
+ */
+ public abstract String getJavaScript();
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
+ */
+ public void encode(FacesContext context, Object data, Map attributes) throws IOException
{
+ if (isNotAjaxRequest(context)) {
+ encodePrototype(context);
+ super.encode(context, data, attributes);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#encodeBegin(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
+ */
+ public void encodeBegin(FacesContext context, Object component, Map attrs) throws
IOException {
+ if (isNotAjaxRequest(context)) {
+ encodePrototype(context);
+ super.encodeBegin(context, component, attrs);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO, getKey()));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#encodeEnd(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void encodeEnd(FacesContext context, Object component) throws IOException {
+ if (isNotAjaxRequest(context)) {
+ super.encodeEnd(context, component);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO, getKey()));
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#encode(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void encode(FacesContext context, Object data) throws IOException {
+ if (isNotAjaxRequest(context)) {
+ encodePrototype(context);
+ super.encode(context, data);
+ }else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODING_HTML_INFO, getKey()));
+ }
+ }
+
+ /**
+ * @return Returns the usePrototype.
+ */
+ protected boolean isUsePrototype() {
+ return usePrototype;
+ }
+
+
+ private boolean isNotAjaxRequest(FacesContext context){
+ return true;//! AjaxRendererUtils.isAjaxRequest(context);
+ }
+
+ private void encodePrototype(FacesContext context) throws IOException{
+ if (isUsePrototype()) {
+ InternetResourceBuilder.getInstance().createResource(null,PrototypeScript.class.getName()).encode(context,null);
+ }
+
+ }
+
+
+ /**
+ * @param usePrototype the usePrototype to set
+ */
+ public void setUsePrototype(boolean usePrototype) {
+ this.usePrototype = usePrototype;
+ }
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/FacesResourceContext.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/FacesResourceContext.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,223 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+
+import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
+ *
+ */
+public class FacesResourceContext extends ResourceContext {
+
+ FacesContext facesContext;
+
+ ExternalContext externalContext;
+
+ HttpServletResponse response;
+
+ /**
+ * @param facesContext
+ */
+ public FacesResourceContext(FacesContext facesContext) {
+
+ this.facesContext = facesContext;
+ this.externalContext = facesContext.getExternalContext();
+ Object facesResponse = externalContext.getResponse();
+ if (facesResponse instanceof HttpServletResponse) {
+ this.response = (HttpServletResponse) facesResponse;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
+ * java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ if (null != response) {
+ response.setHeader(name, value);
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String,
+ * int)
+ */
+ public void setIntHeader(String name, int value) {
+ if (null != response) {
+ response.setIntHeader(name, value);
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String,
+ * long)
+ */
+ public void setDateHeader(String name, long value) {
+ if (null != response) {
+ response.setDateHeader(name, value);
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ if (null != response) {
+ return response.getOutputStream();
+
+ } else {
+ // May be non-servlet (Portlet?) environment. Try to use reflection
+ OutputStream stream = null;
+ Object response = externalContext.getResponse();
+ try {
+ Method gW = response.getClass()
+ .getMethod("getOutputStream", new Class[0]);
+ stream = (OutputStream) gW.invoke(response, new Object[0]);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ return stream;
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getWriter()
+ */
+ public PrintWriter getWriter() throws IOException {
+ if (null != response) {
+ return response.getWriter();
+
+ } else {
+ // May be non-servlet (Portlet?) environment. Try to use reflection
+ PrintWriter writer = null;
+ Object response = externalContext.getResponse();
+ try {
+ Method gW = response.getClass()
+ .getMethod("getWriter", new Class[0]);
+ writer = (PrintWriter) gW.invoke(response, new Object[0]);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ return writer;
+
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
+ */
+ public String getQueryString() {
+ return ((HttpServletRequest) externalContext.getRequest())
+ .getQueryString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
+ */
+ public String getPathInfo() {
+ return externalContext.getRequestPathInfo();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
+ */
+ public Object getSessionAttribute(String name) {
+ return externalContext.getSessionMap().get(name);
+ }
+
+ public InputStream getResourceAsStream(String path) {
+
+ return externalContext.getResourceAsStream(path);
+ }
+
+ public String getRequestParameter(String data_parameter) {
+
+ return (String) externalContext.getRequestParameterMap().get(
+ data_parameter);
+ }
+
+ public void setContentType(String contentType) {
+ response.setContentType(contentType);
+
+ }
+
+ public String getInitParameter(String name) {
+ // TODO Auto-generated method stub
+ return externalContext.getInitParameter(name);
+ }
+
+ public String getServletPath() {
+ // TODO Auto-generated method stub
+ return externalContext.getRequestServletPath();
+ }
+
+ public void release() {
+ super.release();
+ externalContext = null;
+ response = null;
+ facesContext.release();
+ }
+
+ // added by nick 11.01.2007 - getters for contexts added
+ public FacesContext getFacesContext() {
+ return facesContext;
+ }
+
+ public ExternalContext getExternalContext() {
+ return externalContext;
+ }
+ // by nick
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/GifRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/GifRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.ajax4jsf.framework.util.image.GIFEncoder;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
+ *
+ */
+public class GifRenderer extends ImageRenderer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/gif";
+ }
+
+ public void sendImage(ResourceContext context, RenderedImage image)
+ throws IOException {
+ // ImageIO.write(image,"gif",context.getOutputStream());
+ GIFEncoder encoder = new GIFEncoder();
+ DataOutputStream out = new DataOutputStream(context.getOutputStream());
+ try {
+ encoder.encode((BufferedImage) image, out);
+ out.flush();
+ out.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ public int getImageType() {
+ // TODO Auto-generated method stub
+ return BufferedImage.TYPE_INT_ARGB;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/HTMLRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/HTMLRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,88 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
+ *
+ */
+public class HTMLRenderer extends BaseResourceRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ // TODO Auto-generated method stub
+ return "span";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "text/html";
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
+ */
+ protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
+ // Encode style in page - read from resource.
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ InputStream in = resource.getResourceAsStream(resourceContext);
+ StringBuffer buff = new StringBuffer();
+ int input;
+ while((input = in.read())>0){
+ buff.append((char)input);
+ }
+ in.close();
+ // MyFaces & RI have different beahvior for style element, in RI best use
writeComment ?
+ // TODO - detect page content type ?
+ context.getResponseWriter().writeText(buff,resource.getKey());
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ImageRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,101 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:06 $
+ *
+ */
+public abstract class ImageRenderer extends BaseResourceRenderer {
+
+ private static final String _tag = "img";
+ private static final String _hrefAttr = "src";
+ private static final String[][] _commonAttrs = {
+
+ };
+ /**
+ * @return Returns the commonAttrs.
+ */
+ protected String[][] getCommonAttrs() {
+ return null ; //_commonAttrs;
+ }
+
+ /**
+ * @return Returns the hrefAttr.
+ */
+ protected String getHrefAttr() {
+ return _hrefAttr;
+ }
+
+ /**
+ * @return Returns the tag.
+ */
+ protected String getTag() {
+ return _tag;
+ }
+
+ /**
+ * Send {@link BufferedImage} to response in concrete format (GIF,Jpeg,PNG)
+ * @param context - current faces context.
+ * @param image - imaje to send
+ */
+ public abstract void sendImage(ResourceContext context,RenderedImage image) throws
IOException;
+
+ /**
+ * @return type of image for create {@link BufferedImage}
+ */
+ public abstract int getImageType();
+
+ /**
+ * Create blank {@link BufferedImage} for paint.
+ * Type of image determined by current renderer.
+ * @param width
+ * @param height
+ * @return new image
+ */
+ public BufferedImage createImage(int width,int height){
+ return new BufferedImage(width,height,getImageType());
+ }
+
+ protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
+ if (resource instanceof Java2Dresource) {
+ Java2Dresource j2d = (Java2Dresource) resource;
+ Dimension dim = j2d.getDimensions(context, data);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeAttribute("width", String.valueOf(dim.width),
"width");
+ writer.writeAttribute("height", String.valueOf(dim.height),
"height");
+ }
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBase.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,429 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+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;
+
+/**
+ * Base class for all Html page resources - images, scripts, styles etc. Realise
+ * as "brige" pattern - different subclasses for different resource source
+ * (static,jar,soft generator ) and customaized with differernt renderers for
+ * image, script, style ( linked ir inline ). must operate with different
+ * sources - application context, classpath, software generator.
+ *
+ * @author shura (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:15 $
+ *
+ */
+public abstract class InternetResourceBase implements InternetResource {
+
+ private static final Log log = LogFactory
+ .getLog(InternetResourceBase.class);
+
+ static final int BUFFER_SIZE = 1024;
+
+ // Hours
+
+ private int contentLength = -1;
+
+ private Date lastModified;
+
+ private Date expired;
+
+ private boolean cacheable = true;
+
+ private boolean sessionAware = true;
+
+ private ResourceRenderer renderer = null;
+
+ private Map customProperties = new HashMap();
+
+ private String key;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentLength()
+ */
+ public int getContentLength(ResourceContext resourceContext) {
+ return contentLength;
+ }
+
+ /**
+ * @param contentLength
+ * The contentLength to set.
+ */
+ protected void setContentLength(int contentLength) {
+ this.contentLength = contentLength;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getExpired()
+ */
+ public Date getExpired(ResourceContext resourceContext) {
+ return expired;
+ }
+
+ /**
+ * @param expired
+ * The expired to set.
+ */
+ public void setExpired(Date expired) {
+ this.expired = expired;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getLastModified()
+ */
+ public Date getLastModified(ResourceContext resourceContext) {
+
+ if (null != lastModified) {
+ return lastModified;
+ } else {
+ return new Date(System.currentTimeMillis());
+ }
+ }
+
+ /**
+ * @param lastModified
+ * The lastModified to set.
+ */
+ public void setLastModified(Date lastModified) {
+ this.lastModified = lastModified;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#isCacheable()
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return cacheable;
+ }
+
+ /**
+ * @param cacheable
+ * The cacheable to set.
+ */
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ /**
+ * @return Returns the sessionAware.
+ */
+ public boolean isSessionAware() {
+ return requireFacesContext();
+ }
+
+ /**
+ * @param sessionAware
+ * The sessionAware to set.
+ */
+ public void setSessionAware(boolean sessionAware) {
+ this.sessionAware = sessionAware;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getContentType()
+ */
+ public String getContentType(ResourceContext resourceContext) {
+ return getRenderer(null).getContentType();
+ }
+
+ /**
+ * @return Returns the renderer.
+ */
+ public ResourceRenderer getRenderer(ResourceContext resourceContext) {
+ return renderer;
+ }
+
+ /**
+ * @param renderer
+ * The renderer to set.
+ */
+ public void setRenderer(ResourceRenderer renderer) {
+ this.renderer = renderer;
+ }
+
+ /**
+ * Key for wich resource registered in resource builder.
+ *
+ * @return Returns the key.
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Set registration key ( by {@link InternetResourceBuilder} for this
+ * resource.
+ *
+ * @param key
+ * The key to set.
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public String getUri(final FacesContext context, Object data) {
+ return InternetResourceBuilder.getInstance().getUri(this, context,
+ getDataToStore(context, data));
+ }
+
+ /**
+ * Template method to construct resource-specific data ( to store in
+ * resource URI ). If resource must store any data in session or other
+ * cache, it must be done here. Since lightweight realisation, information
+ * for restore such data muct be returned by this method.
+ *
+ * @param context -
+ * current faces context.
+ * @param data -
+ * data for build information, usually current
+ * {@link javax.faces.component.UIComponent}
+ * @return - any {@link java.io.Serializable} object, or null.
+ */
+ protected Object getDataToStore(FacesContext context, Object data) {
+ return getRenderer(null).getData(this, context, data);
+ }
+
+ /**
+ * Restore data object from resource URI request parameter ( same object as
+ * returned in getDataToStore method )
+ *
+ * @param context
+ * @return restored data, or null.
+ */
+ protected Object restoreData(ResourceContext context) {
+
+ Object data = context.getResourceData();
+ if (data instanceof byte[]) {
+ byte[] objectArray = (byte[]) data;
+ data = deserializeData(objectArray);
+ }
+ return data;
+
+ }
+
+ /**
+ * Deserialize parameters object from byte array. By default, used Java
+ * de-serialisation from ObjectOutputStream , but implementations can
+ * override this method ( togewer with getDataToStore ) for implement short
+ * version.
+ *
+ * @param objectArray
+ * @return
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ protected Object deserializeData(byte[] objectArray) {
+ return objectArray;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.chameleon.resource.InternetResource#getResourceAsStream()
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ throw new UnsupportedOperationException(Messages.getMessage(
+ Messages.METHOD_NOT_IMPLEMENTED, "getResourceAsStream"));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
+ */
+ public Object getProperty(Object key) {
+ // TODO Auto-generated method stub
+ return customProperties.get(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object,
+ * java.lang.Object)
+ */
+ public void setProperty(Object key, Object value) {
+ customProperties.put(key, value);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ public void encode(FacesContext context, Object data) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO, getKey()));
+ }
+ getRenderer(null).encode(this, context, data);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
+ * java.lang.Object, java.util.Map)
+ */
+ public void encode(FacesContext context, Object data, Map attributes)
+ throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_HTML_INFO_2,
+ getKey(), attributes));
+ }
+ getRenderer(null).encodeBegin(this, context, data, attributes);
+ getRenderer(null).encodeEnd(this, context, data);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent, java.util.Map)
+ */
+ public void encodeBegin(FacesContext context, Object component, Map attrs)
+ throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_BEGIN_HTML_INFO,
+ getKey(), attrs));
+ }
+ getRenderer(null).encodeBegin(this, context, component, attrs);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent, java.util.Map)
+ */
+ public void encodeEnd(FacesContext context, Object component)
+ throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_END_HTML_INFO,
+ getKey()));
+ }
+ getRenderer(null).encodeEnd(this, context, component);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#send(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void send(ResourceContext context) throws IOException {
+ if (log.isDebugEnabled()) {
+ log
+ .debug(Messages.getMessage(Messages.SEND_CONTENT_INFO,
+ getKey()));
+ }
+ int total = getRenderer(null).send(this, context);
+ // For cacheable resources, store size.
+ if (isCacheable(null)) {
+ setContentLength(total);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.chameleon.resource.InternetResource#sendHeaders(javax.servlet.http.HttpServletResponse)
+ */
+ public void sendHeaders(ResourceContext context) {
+ boolean cached = context.isCacheEnabled() && isCacheable(null);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SET_RESPONSE_HEADERS_INFO,
+ getKey()));
+ }
+ // context.setHeader("Content-Type",getContentType());
+ context.setContentType(getContentType(null));
+ if (getContentLength(context) > 0) {
+ context.setIntHeader("Content-Length", getContentLength(context));
+ } else {
+ // context.setHeader("Transfer-Encoding", "chunked");
+ }
+ Date lastModified = getLastModified(context);
+ if (lastModified != null) {
+ context.setDateHeader("Last-Modified", lastModified.getTime());
+ }
+ if (cached) {
+ Date expired = getExpired(context);
+ if (expired != null) {
+ context.setDateHeader("Expires", expired.getTime());
+ } else {
+ context.setDateHeader("Expires", System.currentTimeMillis()
+ + DEFAULT_EXPIRE);
+ context.setHeader("Cache-control", "max-age="
+ + (DEFAULT_EXPIRE / 1000));
+ }
+ } else {
+ context.setHeader("Cache-control", "max-age=0, no-store,
no-cache");
+ context.setHeader("Pragma", "no-cache");
+ context.setIntHeader("Expires", 0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ // by default, send data in ordinary Http request.
+ return getRenderer(null).requireFacesContext();
+ }
+
+}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/InternetResourceService.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,385 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.cache.Cache;
+import org.ajax4jsf.cache.CacheConfigurationLoader;
+import org.ajax4jsf.cache.CacheException;
+import org.ajax4jsf.cache.CacheFactory;
+import org.ajax4jsf.cache.CacheLoader;
+import org.ajax4jsf.cache.CacheManager;
+import org.ajax4jsf.cache.ServletContextInitMap;
+import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.CacheContent;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class InternetResourceService implements CacheLoader, CacheConfigurationLoader {
+ private static final Log log = LogFactory
+ .getLog(InternetResourceService.class);
+
+ static final String ENABLE_CACHING_PARAMETER = "enable-cache";
+
+ private static final String RESOURCE_LIFECYCLE_PARAMETER =
"org.ajax4jsf.RESOURCE_LIFECYCLE";
+
+ private FilterConfig filterConfig;
+
+ private boolean cacheEnabled = true;
+
+ private Cache cache = null;
+
+ //private ServletCacheAdministrator cacheAdmin;
+
+ private FacesContextFactory contextFactory;
+
+ // private RenderKitFactory renderKitFactory;
+ private String lifecycleClass;
+
+ private ResourceLifecycle lifecycle;
+
+ private InternetResourceBuilder resourceBuilder;
+
+ private WebXml webXml;
+
+ public InternetResourceService() {
+ }
+
+ public void setCacheEnabled(boolean b) {
+ cacheEnabled = b;
+ }
+
+ public void init(FilterConfig config) throws ServletException {
+ filterConfig = config;
+ ServletContext servletContext = config.getServletContext();
+ if ("false".equalsIgnoreCase(config
+ .getInitParameter(ENABLE_CACHING_PARAMETER))) {
+ setCacheEnabled(false);
+ // this.cacheEnabled = false;
+ //this.cacheAdmin = null;
+ } else {
+ //this.cacheAdmin = ServletCacheAdministrator.getInstance(
+ // servletContext, cacheProperties);
+ try {
+ CacheManager cacheManager = CacheManager.getInstance();
+ Map env = new ServletContextInitMap(servletContext);
+ CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
+ this.cache = cacheFactory.createCache(env, this, this);
+ } catch (CacheException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+ // Create Resource-specific Faces Lifecycle instance.
+ lifecycleClass = servletContext
+ .getInitParameter(RESOURCE_LIFECYCLE_PARAMETER);
+ if (lifecycleClass != null) {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ try {
+ Class clazz = classLoader.loadClass(lifecycleClass);
+ lifecycle = (ResourceLifecycle) clazz.newInstance();
+ } catch (Exception e) {
+ throw new FacesException(
+ "Error create instance of resource Lifecycle "
+ + lifecycleClass, e);
+ }
+ } else {
+ lifecycle = new ResourceLifecycle();
+ }
+ webXml = new WebXml();
+ webXml.init(servletContext,filterConfig.getFilterName());
+ if (log.isDebugEnabled()) {
+ log.debug("Resources service initialized");
+ }
+ }
+
+ public boolean serviceResource(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse) throws ServletException,
+ IOException {
+ String resourceKey = webXml
+ .getFacesResourceKey(httpServletRequest);
+ if (null != resourceKey) {
+ serviceResource(resourceKey, httpServletRequest,
+ httpServletResponse);
+ return true;
+ }
+ return false;
+ }
+
+ public void serviceResource(String resourceKey, HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ InternetResource resource;// getInternetResource(request);
+ try {
+ resource = getResourceBuilder().getResourceForKey(resourceKey);
+ } catch (ResourceNotFoundException e) {
+ throw new ServletException(e);
+ }
+ Object resourceDataForKey = getResourceBuilder()
+ .getResourceDataForKey(resourceKey);
+ if (resource.isCacheable(null) && this.cacheEnabled) {
+ // Test for client request modification time.
+ try {
+ long ifModifiedSince = request
+ .getDateHeader("If-Modified-Since");
+ if (ifModifiedSince >= 0) {
+ // Test for modification. 1000 ms due to round
+ // modification
+ // time to seconds.
+ long lastModified = resource.getLastModified(null)
+ .getTime() - 1000;
+ if (lastModified <= ifModifiedSince) {
+ response.setStatus(304);
+ return;
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ log
+ .warn(
+ Messages
+ .getMessage(Messages.PARSING_IF_MODIFIED_SINCE_WARNING),
+ e);
+ }
+ String cacheKey = resourceKey;// + "?" +
+ // request.getQueryString();
+ // TODO - select session/application scope.
+ //Cache cache = cacheAdmin.getAppScopeCache(getServletContext());
+// try {
+ // TODO - use last modified/expires time
+
+ CacheKey key = new CacheKey(resourceDataForKey, request, response, resource);
+
+ CacheContent content;
+ try {
+ content = (CacheContent) cache
+ .get(cacheKey, key);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.GET_CONTENT_FROM_CACHE_INFO, cacheKey));
+ }
+ content.sendHeaders(response);
+ // Correct expires date for resource.
+ Date expired = resource.getExpired(null);
+ if (expired != null) {
+ response.setDateHeader("Expires", expired.getTime());
+ } else {
+ response.setDateHeader("Expires", System
+ .currentTimeMillis()
+ + InternetResource.DEFAULT_EXPIRE);
+ }
+ if (!request.getMethod().equals("HEAD")) {
+ content.send(response);
+ }/*
+ } catch (NeedsRefreshException e) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.CONTENT_NOT_FOUND_ERROR, cacheKey));
+ }
+ CachedResourceContext context = (CachedResourceContext) sendResource(
+ resource, request, response, resourceDataForKey);
+ // TODO - set refresh interval ?
+ cache.put(cacheKey, context.getContent());
+ } catch (Exception ex) {
+ //cache.cancelUpdate(cacheKey);
+ log.error(
+ Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
+ ex);
+ throw new ServletException(Messages.getMessage(
+ Messages.SEND_RESOURCE_ERROR_2, ex.getMessage()),
+ ex);
+ }
+ }*/
+ } catch (CacheException e) {
+ log.error(
+ Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
+ e);
+ throw new ServletException(Messages.getMessage(
+ Messages.SEND_RESOURCE_ERROR_2, e.getMessage()),
+ e);
+ }
+ } else {
+ sendResource(resource, request, response, resourceDataForKey);
+ }
+ }
+
+ /**
+ * @param resource
+ * @param request
+ * @param response
+ * @throws IOException
+ */
+ protected ResourceContext sendResource(InternetResource resource,
+ HttpServletRequest request, HttpServletResponse response,
+ Object data) throws IOException {
+ ResourceContext resourceContext = getResourceContext(resource, request,
+ response);
+ resourceContext.setResourceData(data);
+ getLifecycle().send(resourceContext, resource);
+ resourceContext.release();
+ return resourceContext;
+ }
+
+ /**
+ * @param resource
+ * @param request
+ * @param response
+ * @return
+ * @throws ServletException
+ * @throws FacesException
+ */
+ protected ResourceContext getResourceContext(InternetResource resource,
+ HttpServletRequest request, HttpServletResponse response)
+ throws FacesException {
+ FacesContext facesContext = null;
+ ResourceContext resourceContext;
+ if (resource.requireFacesContext()) {
+ facesContext = getFacesContext(request, response);
+ resourceContext = new FacesResourceContext(facesContext);
+ } else {
+ resourceContext = new ServletResourceContext(getServletContext(),
+ request, response);
+ }
+ if (resource.isCacheable(null) && this.cacheEnabled) {
+ resourceContext = new CachedResourceContext(resourceContext);
+ }
+ return resourceContext;
+ }
+
+ /**
+ * Get properties file from classpath
+ *
+ * @param name
+ * @return
+ */
+ protected Properties getProperties(String name) {
+ Properties properties = new Properties();
+ InputStream props = BaseFilter.class.getResourceAsStream(name);
+ if (null != props) {
+ try {
+ properties.load(props);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
+ name), e);
+ } finally {
+ try {
+ props.close();
+ } catch (IOException e) {
+ // Can be ignored
+ }
+ }
+ }
+ return properties;
+
+ }
+
+ /**
+ * @return Returns the servletContext.
+ */
+ protected ServletContext getServletContext() {
+ return filterConfig.getServletContext();
+ }
+
+ /**
+ * @return the lifecycle
+ * @throws ServletException
+ */
+ protected ResourceLifecycle getLifecycle() throws FacesException {
+ return lifecycle;
+ }
+
+ /**
+ * @return the contextFactory
+ */
+ protected synchronized FacesContextFactory getContextFactory() {
+ if (contextFactory == null) {
+ contextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ }
+
+ return contextFactory;
+ }
+
+ protected FacesContext getFacesContext(ServletRequest request,
+ ServletResponse response) throws FacesException {
+ return getContextFactory().getFacesContext(getServletContext(),
+ request, response, getLifecycle());
+ }
+
+ /**
+ * @return the resourceBuilder
+ */
+ protected InternetResourceBuilder getResourceBuilder() {
+ if (resourceBuilder == null) {
+ // Create resource builder for this filter.
+ resourceBuilder = InternetResourceBuilder.getInstance();
+ }
+ return resourceBuilder;
+ }
+
+ public Object load(Object key, Object context) throws CacheException {
+ CacheKey cacheKey = (CacheKey) context;
+
+ CachedResourceContext resourceContext = (CachedResourceContext)
getResourceContext(cacheKey.getResource(), cacheKey.getRequest(),
+ cacheKey.getResponse());
+ resourceContext.setResourceData(cacheKey.getResourceData());
+ try {
+ getLifecycle().send(resourceContext, cacheKey.getResource());
+ } catch (IOException e) {
+ throw new CacheException(e.getMessage(), e);
+ }
+ resourceContext.release();
+
+ // TODO - set refresh interval ?
+ //cache.put(cacheKey, resourceContext.getContent());
+ return resourceContext.getContent();
+ }
+
+ public Properties loadProperties(String name) {
+ return getProperties(name);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JarResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,73 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.InputStream;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * Class stoped all resources in application classpath.
+ * TODO - set last midified & expired values.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:00 $
+ *
+ */
+public class JarResource extends InternetResourceBase {
+
+ /**
+ * Default place for all static resources in Jar.
+ * to avoid access to any class in application, only allowed subpackages for
+ * META-INF/resources
+ */
+ public static final String RESOURCES_ROOT="META-INF/resources";
+
+ private String path;
+
+ public JarResource(){
+
+ }
+
+ public JarResource(String path) {
+ this.path = path;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return loader.getResourceAsStream(path);
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Java2Dresource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Java2Dresource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,135 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.ResourceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/01 15:31:57 $
+ *
+ */
+public class Java2Dresource extends InternetResourceBase {
+ private static final Log log = LogFactory.getLog(Java2Dresource.class);
+
+ /**
+ * Primary calculation of image dimensions - used when HTML code is
+ * generated to render IMG's width and height Subclasses should override
+ * this method to provide correct sizes of rendered images
+ *
+ * @param facesContext
+ * @return dimensions of the image to be displayed on page
+ */
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return new Dimension(1, 1);
+ }
+
+ /**
+ * Secondary calculation is used basically by {@link getImage} method
+ *
+ * @param resourceContext
+ * @return
+ */
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return new Dimension(1, 1);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ // TODO Auto-generated method stub
+ return super.getResourceAsStream(context);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.resource.InternetResourceBase#send(javax.faces.context.FacesContext,
+ * java.lang.Object)
+ */
+ public void send(ResourceContext context) throws IOException {
+ ImageRenderer renderer = (ImageRenderer) getRenderer(null);
+ try {
+ RenderedImage image = getImage(context);
+ if (null != image) {
+ renderer.sendImage(context, image);
+
+ }
+ } catch (Exception e) {
+ throw new FacesException(Messages
+ .getMessage(Messages.SEND_IMAGE_ERROR_2), e);
+ }
+ }
+
+ /**
+ * Create {@link RenderedImage} for send to client. can be used as Java2d or
+ * Java Advanced Imaging.
+ *
+ * @param context
+ * @return image to send.
+ */
+ protected RenderedImage getImage(ResourceContext context) {
+ ImageRenderer renderer = (ImageRenderer) getRenderer(null);
+ Dimension imageDimensions = getDimensions(context);
+ BufferedImage image = null;
+ if (imageDimensions.getHeight() > 0.0
+ && imageDimensions.getWidth() > 0.0) {
+ image = renderer.createImage(imageDimensions.width,
+ imageDimensions.height);
+ Graphics2D graphics = image.createGraphics();
+ paint(context, graphics);
+ graphics.dispose();
+
+ }
+ return image;
+ }
+
+ /**
+ * Template method for create image as Applet-like paint.
+ *
+ * @param context -
+ * current resource context.
+ * @param graphics2D -
+ * graphics to paint.
+ */
+ protected void paint(ResourceContext context, Graphics2D graphics2D) {
+ // TODO Auto-generated method stub
+
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/JpegRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JpegRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:03 $
+ *
+ */
+public class JpegRenderer extends ImageRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/jpeg";
+ }
+
+ public void sendImage(ResourceContext context, RenderedImage image) throws IOException
{
+ OutputStream outputStream = context.getOutputStream();
+ try {
+ ImageIO.write(image, "jpeg", outputStream);
+ outputStream.flush();
+ outputStream.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ public int getImageType() {
+ // TODO Auto-generated method stub
+ return BufferedImage.TYPE_INT_RGB;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/LogfileRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/LogfileRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,88 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
+ *
+ */
+public class LogfileRenderer extends BaseResourceRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ // TODO Auto-generated method stub
+ return "pre";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "text/plain";
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
+ */
+ protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
+ // Encode style in page - read from resource.
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ InputStream in = resource.getResourceAsStream(resourceContext);
+ StringBuffer buff = new StringBuffer();
+ int input;
+ while((input = in.read())>0){
+ buff.append((char)input);
+ }
+ in.close();
+ // MyFaces & RI have different beahvior for style element, in RI best use
writeComment ?
+ // TODO - detect page content type ?
+ context.getResponseWriter().writeText(buff,resource.getKey());
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/MimeRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/MimeRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 20.11.2006
+ *
+ */
+public class MimeRenderer extends BaseResourceRenderer {
+
+ private String contentType = null;
+
+ public MimeRenderer() {
+
+ }
+
+ public MimeRenderer(String contentType) {
+ super();
+ this.contentType = contentType;
+ }
+
+ public String getContentType() {
+ return this.contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+
+
+ protected String getTag() {
+ return null;
+ }
+
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/OneTimeRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/OneTimeRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,80 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.InternetResource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for resources, rendered only one time in page ( JavaScript, CSS )
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:02 $
+ *
+ */
+public abstract class OneTimeRenderer extends BaseResourceRenderer {
+
+ private static final Log log = LogFactory.getLog(OneTimeRenderer.class);
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.BaseResourceRenderer#encodeBegin(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object, java.util.Map)
+ */
+ public void encodeBegin(InternetResource resource, FacesContext context, Object data,
Map attributes) throws IOException {
+
+ if (!isRendered(resource,context)) {
+ super.encodeBegin(resource, context, data, attributes);
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_BEGIN_HTML_INFO_2,
resource.getKey()));
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.BaseResourceRenderer#encodeEnd(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public void encodeEnd(InternetResource resource, FacesContext context, Object data)
throws IOException {
+ // TODO Auto-generated method stub
+ if (!isRendered(resource,context)) {
+ super.encodeEnd(resource, context, data);
+ context.getExternalContext().getRequestMap().put(resource.getKey(),Boolean.TRUE);
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.MARK_AS_RENDERED_INFO, resource.getKey()));
+ }
+ } else if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.SKIP_ENCODE_END_HTML_INFO_2,
resource.getKey()));
+ }
+ }
+
+ /**
+ * Detect for resource rendered status. For cacheable, show key parameter in request
Map.
+ * @param resource
+ * @param context
+ * @return - true, if resource already rendered.
+ */
+ private boolean isRendered(InternetResource resource, FacesContext context){
+ return null != context.getExternalContext().getRequestMap().get(resource.getKey()); //
resource.isCacheable() &&
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/Png8Renderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/Png8Renderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,125 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.awt.image.BufferedImage;
+import java.awt.image.IndexColorModel;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
+ *
+ */
+public class Png8Renderer extends ImageRenderer {
+
+ /**
+ * Default web safe colors color model
+ */
+ public static IndexColorModel webColorModel;
+
+ // Build web safe 6x6x6 cube color model.
+ static {
+ byte[] webLevels = { 0, 51, 102, (byte) 153, (byte) 204, (byte) 255 };
+ byte[] r = new byte[256];
+ byte[] g = new byte[256];
+ byte[] b = new byte[256];
+ r[0] = g[0] = b[0] = 0;
+ for (int i = 0; i < webLevels.length; i++) {
+ for (int j = 0; j < webLevels.length; j++) {
+ for (int k = 0; k < webLevels.length; k++) {
+ int colorNum = i * webLevels.length * webLevels.length + j
+ * webLevels.length + k + 1;
+ r[colorNum] = webLevels[i];
+ g[colorNum] = webLevels[j];
+ b[colorNum] = webLevels[k];
+ }
+ }
+ }
+ webColorModel = new IndexColorModel(8, webLevels.length
+ * webLevels.length * webLevels.length + 1, r, g, b, 0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.resource.ImageRenderer#sendImage(org.ajax4jsf.resource.ResourceContext,
+ * java.awt.image.RenderedImage)
+ */
+ public void sendImage(ResourceContext context, RenderedImage image)
+ throws IOException {
+ OutputStream outputStream = context.getOutputStream();
+ // PNGEncodeParam param = new PNGEncodeParam.Palette();
+ // param.setBitDepth(8);
+ // param.setInterlacing(true);
+ // String[] encoders = ImageCodec.getEncoderNames(image,null);
+ // ImageEncoder encoder =
+ // ImageCodec.createImageEncoder("png",context.getOutputStream(),param);
+ // encoder.encode(image);
+ try {
+ ImageIO.write(image, "png", outputStream);
+ outputStream.flush();
+ outputStream.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ImageRenderer#getImageType()
+ */
+ public int getImageType() {
+ return BufferedImage.TYPE_BYTE_INDEXED;
+ // return BufferedImage.TYPE_INT_ARGB;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ImageRenderer#createImage(int, int)
+ */
+ public BufferedImage createImage(int width, int height) {
+
+ // return new BufferedImage(width,height,getImageType());//,colorModel);
+ return new BufferedImage(width, height, getImageType(), webColorModel);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/png";
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PngRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PngRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,63 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:05 $
+ *
+ */
+public class PngRenderer extends ImageRenderer {
+
+ public void sendImage(ResourceContext context, RenderedImage image)
+ throws IOException {
+ OutputStream outputStream = context.getOutputStream();
+ try {
+ ImageIO.write(image, "png", outputStream);
+ outputStream.flush();
+ outputStream.close();
+
+ } catch (Exception e) {
+ // IE can unexpected close connection
+ }
+ }
+
+ public String getContentType() {
+ // TODO Auto-generated method stub
+ return "image/png";
+ }
+
+ public int getImageType() {
+ // TODO Auto-generated method stub
+ return BufferedImage.TYPE_INT_ARGB;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/PrototypeScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/PrototypeScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,36 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:59 $
+ *
+ */
+public class PrototypeScript extends ClientScript {
+
+ public String getJavaScript() {
+ return "scripts/prototype.js";
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceBuilderImpl.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,589 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.StreamCorruptedException;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.Deflater;
+import java.util.zip.Inflater;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.imageio.ImageIO;
+import javax.servlet.ServletContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.framework.util.base64.Codec;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.ajax4jsf.resource.ResourceRenderer;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * Produce instances of InternetResource's for any types - jar resource, dynamic
+ * created image, component-incapsulated etc. Realised as singleton class to
+ * support cache, configuration etc.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
+ *
+ */
+public class ResourceBuilderImpl extends InternetResourceBuilder {
+
+ private static final Log log = LogFactory.getLog(ResourceBuilderImpl.class);
+
+ private static final String DATA_SEPARATOR = "/DATA/";
+
+ private static Map renderers;
+
+ private static ResourceRenderer defaultRenderer = new MimeRenderer(null);
+
+ /**
+ * keep resources instances . TODO - put this map to application-scope
+ * attribute, for support clastering environment.
+ */
+ private Map resources = Collections.synchronizedMap(new HashMap());
+
+ private long _startTime;
+
+ private Codec codec;
+
+ static {
+ renderers = new HashMap();
+ // append known renderers for extentions.
+ renderers.put(".gif", new GifRenderer());
+ ResourceRenderer renderer = new JpegRenderer();
+ renderers.put(".jpeg", renderer);
+ renderers.put(".jpg", renderer);
+ renderers.put(".png", new PngRenderer());
+ renderers.put(".js", new ScriptRenderer());
+ renderers.put(".css", new StyleRenderer());
+ renderers.put(".log", new LogfileRenderer());
+ renderers.put(".html", new HTMLRenderer());
+ renderers.put(".xhtml", new MimeRenderer("application/xhtml+xml"));
+ renderers.put(".xml", new MimeRenderer("text/xml"));
+ renderers.put(".xcss", new TemplateCSSRenderer());
+ // renderers.put(".htc",new BehaviorRenderer());
+ // set in-memory caching ImageIO
+ ImageIO.setUseCache(false);
+
+ }
+
+ public WebXml getWebXml(FacesContext context) {
+ WebXml webXml = (WebXml)
context.getExternalContext().getApplicationMap().get(WebXml.CONTEXT_ATTRIBUTE);
+ if (null == webXml) {
+ throw new FacesException(
+ "Resources framework is not initialised, check web.xml for Filter
configuration");
+ }
+ return webXml;
+ }
+
+ public ResourceBuilderImpl() {
+ super();
+ _startTime = System.currentTimeMillis();
+ codec = new Codec();
+ }
+
+ /**
+ * @throws FacesException
+ */
+ protected void registerResources() throws FacesException {
+ try {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Enumeration e = loader
+ .getResources("META-INF/resources-config.xml");
+ while (e.hasMoreElements()) {
+ URL resource = (URL) e.nextElement();
+ registerConfig(resource);
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ private void registerConfig(URL resourceConfig) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Process resources configuration file
"+resourceConfig.toExternalForm());
+ }
+
+ InputStream in = resourceConfig.openStream();
+ try {
+ Digester digester = new Digester();
+ digester.setValidating(false);
+ digester.setEntityResolver(new EntityResolver() {
+ // Dummi resolver - alvays do nothing
+ public InputSource resolveEntity(String publicId,
+ String systemId) throws SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+ });
+ digester.setNamespaceAware(false);
+ digester.setUseContextClassLoader(true);
+ digester.push(this);
+ digester.addObjectCreate("resource-config/resource", "class",
+ JarResource.class);
+ digester.addObjectCreate("resource-config/resource/renderer",
+ "class", HTMLRenderer.class);
+ digester.addCallMethod(
+ "resource-config/resource/renderer/content-type",
+ "setContentType", 0);
+ digester.addSetNext("resource-config/resource/renderer",
+ "setRenderer", ResourceRenderer.class.getName());
+ digester.addCallMethod("resource-config/resource/name",
+ "setKey", 0);
+ digester.addCallMethod("resource-config/resource/path",
+ "setPath", 0);
+ digester.addCallMethod("resource-config/resource/cacheable",
+ "setCacheable", 0);
+ digester.addCallMethod(
+ "resource-config/resource/session-aware",
+ "setSessionAware", 0);
+ digester.addCallMethod("resource-config/resource/property",
+ "setProperty", 2);
+ digester.addCallParam("resource-config/resource/property/name",
+ 0);
+ digester.addCallParam(
+ "resource-config/resource/property/value", 1);
+ digester.addCallMethod("resource-config/resource/content-type",
+ "setContentType", 0);
+ digester.addSetNext("resource-config/resource", "addResource",
+ InternetResource.class.getName());
+ digester.parse(in);
+ } finally {
+ in.close();
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ } catch (SAXException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ /**
+ */
+ public void init()
+ throws FacesException {
+ // TODO - mace codec configurable.
+ registerResources();
+ }
+
+ /**
+ * Base point for creating resource. Must detect type and build
+ * appropriate instance. Currently - make static resource for ordinary
+ * request, or instance of class.
+ *
+ * @param base
+ * base object for resource ( resourcess in classpath
+ * will be get relative to it package )
+ * @param path
+ * key - path to resource, resource class name etc.
+ * @return
+ * @throws FacesException
+ */
+ public InternetResource createResource(Object base, String path)
+ throws FacesException {
+ // TODO - detect type of resource ( for example, resources location path
+ // in Skin
+ try {
+ return getResource(path);
+ } catch (ResourceNotFoundException e) {
+ try {
+ return getResource(buildKey(base, path));
+ } catch (ResourceNotFoundException e1) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_INFO,
+ path));
+ }
+ }
+ }
+ // path - is class name ?
+ InternetResource res;
+ try {
+ Class resourceClass = Class.forName(path);
+ res = createDynamicResource(path, resourceClass);
+ } catch (Exception e) {
+ try {
+ res = createJarResource(base, path);
+ } catch (ResourceNotFoundException ex) {
+ res = createStaticResource(path);
+ }
+ // TODO - if resource not found, create static ?
+ }
+ return res;
+ }
+
+ private String buildKey(Object base, String path) {
+ if (path.startsWith("/")) {
+ return path.substring(1);
+ }
+ if (null == base) {
+ return path;
+ }
+ StringBuffer packageName = new StringBuffer(base.getClass()
+ .getPackage().getName().replace('.', '/'));
+ return packageName.append("/").append(path).toString();
+ }
+
+ public String getUri(InternetResource resource, FacesContext context,
+ Object storeData) {
+ StringBuffer uri = new StringBuffer();//
ResourceServlet.DEFAULT_SERVLET_PATH).append("/");
+ uri.append(resource.getKey());
+ // append serialized data as Base-64 encoded request string.
+ if (storeData != null) {
+ try {
+ byte[] objectData;
+ if (!(storeData instanceof byte[])) {
+ ByteArrayOutputStream dataSteram = new ByteArrayOutputStream(
+ 1024);
+ ObjectOutputStream objStream = new ObjectOutputStream(
+ dataSteram);
+ objStream.writeObject(storeData);
+ objStream.flush();
+ objStream.close();
+ dataSteram.close();
+ objectData = dataSteram.toByteArray();
+ } else {
+ objectData = (byte[]) storeData;
+ }
+ uri.append(DATA_SEPARATOR);
+ byte[] dataArray = encrypt(objectData);
+ uri.append(new String(dataArray, "ISO-8859-1"));
+
+ // / byte[] objectData = dataSteram.toByteArray();
+ // / uri.append("?").append(new
+ // String(Base64.encodeBase64(objectData),
+ // / "ISO-8859-1"));
+ } catch (Exception e) {
+ // Ignore errors, log it
+ log.error(Messages
+ .getMessage(Messages.QUERY_STRING_BUILDING_ERROR), e);
+ }
+ }
+ String resourceURL = getWebXml(context).getFacesResourceURL(context,
+ uri.toString());//
context.getApplication().getViewHandler().getResourceURL(context,uri.toString());
+ if (resource.isSessionAware()) {
+ resourceURL = context.getExternalContext().encodeResourceURL(
+ resourceURL);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.BUILD_RESOURCE_URI_INFO,
+ resource.getKey(), resourceURL));
+ }
+ return resourceURL;// context.getExternalContext().encodeResourceURL(resourceURL);
+
+ }
+
+ /**
+ * @param key
+ * @return
+ */
+ public InternetResource getResourceForKey(String key)
+ throws ResourceNotFoundException {
+
+ int data = key.indexOf(DATA_SEPARATOR);
+ if (data >= 0) {
+ key = key.substring(0, data);
+ }
+ return getResource(key);
+ }
+
+ public Object getResourceDataForKey(String key) {
+ Object data = null;
+ String dataString = null;
+ int dataStart = key.indexOf(DATA_SEPARATOR);
+ if (dataStart >= 0) {
+ dataString = key.substring(dataStart + DATA_SEPARATOR.length());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.RESTORE_DATA_FROM_RESOURCE_URI_INFO, key,
+ dataString));
+ }
+ if (dataString != null) {
+ // dataString =
+ // dataString.substring(dataStart+ResourceServlet.DATA_PARAMETER.length()+1);
+ byte[] objectArray = null;
+ try {
+ byte[] dataArray = dataString.getBytes("ISO-8859-1");
+ objectArray = decrypt(dataArray);
+
+ ObjectInputStream in = new ObjectInputStream(
+ new ByteArrayInputStream(objectArray));
+ data = in.readObject();
+ } catch (StreamCorruptedException e) {
+ data = objectArray;
+ } catch (IOException e) {
+ log.error(Messages
+ .getMessage(Messages.DESERIALIZE_DATA_INPUT_ERROR), e);
+ } catch (ClassNotFoundException e) {
+ log.error(Messages
+ .getMessage(Messages.DATA_CLASS_NOT_FOUND_ERROR), e);
+ }
+ }
+ return data;
+ }
+
+ public InternetResource getResource(String path)
+ throws ResourceNotFoundException {
+
+ InternetResource internetResource = (InternetResource) resources
+ .get(path);
+ if (null == internetResource) {
+ throw new ResourceNotFoundException("Resource not registered : "
+ + path);
+ } else {
+ return internetResource;
+ }
+ }
+
+ public void addResource(InternetResource resource) {
+ resources.put(resource.getKey(), resource);
+ ResourceRenderer renderer = resource.getRenderer(null);
+ if (renderer == null) {
+ setRenderer(resource, resource.getKey());
+ }
+ }
+
+ public void addResource(String key, InternetResource resource) {
+ resources.put(key, resource);
+ resource.setKey(key);
+ // TODO - set renderer ?
+ }
+
+// public String getFacesResourceKey(HttpServletRequest request) {
+// return getWebXml(context).getFacesResourceKey(request);
+// }
+
+ public String getFacesResourceURL(FacesContext context, String Url) {
+ return getWebXml(context).getFacesResourceURL(context, Url);
+ }
+
+ /**
+ * Build resource for link to static context in webapp.
+ *
+ * @param path
+ * @return
+ * @throws FacesException
+ */
+ protected InternetResource createStaticResource(String path)
+ throws ResourceNotFoundException, FacesException {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (null != context) {
+ if (context.getExternalContext().getContext() instanceof ServletContext) {
+ ServletContext servletContext = (ServletContext) context
+ .getExternalContext().getContext();
+ InputStream in = servletContext.getResourceAsStream(path);
+ if (null != in) {
+ InternetResourceBase res = new StaticResource(path);
+ setRenderer(res, path);
+ res.setLastModified(new Date(getStartTime()));
+ addResource(path, res);
+ try {
+ in.close();
+ } catch (IOException e) {
+ }
+ return res;
+ }
+ }
+ }
+ throw new ResourceNotFoundException(Messages.getMessage(
+ Messages.STATIC_RESOURCE_NOT_FOUND_ERROR, path));
+ }
+
+ private void setRenderer(InternetResource res, String path)
+ throws FacesException {
+ int lastPoint = path.lastIndexOf('.');
+ if (lastPoint > 0) {
+ String ext = path.substring(lastPoint);
+ ResourceRenderer resourceRenderer = (ResourceRenderer) renderers
+ .get(ext);
+ if (null != resourceRenderer) {
+ res.setRenderer(resourceRenderer);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.NO_RESOURCE_REGISTERED_ERROR_2, path,
+ renderers.keySet()));
+ }
+
+ // String mimeType = servletContext.getMimeType(path);
+ res.setRenderer(defaultRenderer);
+ }
+ }
+ }
+
+ /**
+ * Create resurce to send from classpath relative to base class.
+ *
+ * @param base
+ * @param path
+ * @return
+ * @throws FacesException
+ */
+ protected InternetResource createJarResource(Object base, String path)
+ throws ResourceNotFoundException, FacesException {
+ String key = buildKey(base, path);
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (null != loader.getResource(key)) {
+ JarResource res = new JarResource(key);
+ setRenderer(res, path);
+ res.setLastModified(new Date(getStartTime()));
+ addResource(key, res);
+ return res;
+ } else {
+ throw new ResourceNotFoundException(Messages.getMessage(
+ Messages.NO_RESOURCE_EXISTS_ERROR, key));
+ }
+
+ }
+
+ /**
+ * Create resource by instatiate given class.
+ *
+ * @param path
+ * @param instatiate
+ * @return
+ */
+ protected InternetResource createDynamicResource(String path,
+ Class instatiate) throws ResourceNotFoundException {
+ if (InternetResource.class.isAssignableFrom(instatiate)) {
+ InternetResource resource;
+ try {
+ resource = (InternetResource) instatiate.newInstance();
+ addResource(path, resource);
+ } catch (Exception e) {
+ String message = Messages.getMessage(
+ Messages.INSTANTIATE_RESOURCE_ERROR, instatiate
+ .toString());
+ log.error(message, e);
+ throw new ResourceNotFoundException(message, e);
+ }
+ return resource;
+ }
+ throw new FacesException(Messages
+ .getMessage(Messages.INSTANTIATE_CLASS_ERROR));
+ }
+
+ /**
+ * Create resource by instatiate {@link UserResource} class with given
+ * properties ( or got from cache ).
+ *
+ * @param cacheable
+ * @param session
+ * @param mime
+ * @return
+ * @throws FacesException
+ */
+ public InternetResource createUserResource(boolean cacheable,
+ boolean session, String mime) throws FacesException {
+ String path = getUserResourceKey(cacheable, session, mime);
+ InternetResource userResource;
+ try {
+ userResource = getResource(path);
+ } catch (ResourceNotFoundException e) {
+ userResource = new UserResource(cacheable, session, mime);
+ addResource(path, userResource);
+ }
+ return userResource;
+ }
+
+ /**
+ * Generate resource key for user-generated resource with given
+ * properties.
+ *
+ * @param cacheable
+ * @param session
+ * @param mime
+ * @return
+ */
+ private String getUserResourceKey(boolean cacheable, boolean session,
+ String mime) {
+ StringBuffer pathBuffer = new StringBuffer(UserResource.class.getName());
+ pathBuffer.append(cacheable ? "/c" : "/n");
+ pathBuffer.append(session ? "/s" : "/n");
+ if (null != mime) {
+ pathBuffer.append('/').append(mime.hashCode());
+ }
+ String path = pathBuffer.toString();
+ return path;
+ }
+
+ /**
+ * @return Returns the startTime for application.
+ */
+ public long getStartTime() {
+ return _startTime;
+ }
+
+ protected byte[] encrypt(byte[] src) {
+ try {
+ Deflater compressor = new Deflater(Deflater.BEST_SPEED);
+ byte[] compressed = new byte[src.length + 100];
+ compressor.setInput(src);
+ compressor.finish();
+ int totalOut = compressor.deflate(compressed);
+ byte[] zipsrc = new byte[totalOut];
+ System.arraycopy(compressed, 0, zipsrc, 0, totalOut);
+ compressor.end();
+ return codec.encode(zipsrc);
+ } catch (Exception e) {
+ throw new FacesException("Error encode resource data", e);
+ }
+ }
+
+ protected byte[] decrypt(byte[] src) {
+ try {
+ byte[] zipsrc = codec.decode(src);
+ Inflater decompressor = new Inflater();
+ byte[] uncompressed = new byte[zipsrc.length * 5];
+ decompressor.setInput(zipsrc);
+ int totalOut = decompressor.inflate(uncompressed);
+ byte[] out = new byte[totalOut];
+ System.arraycopy(uncompressed, 0, out, 0, totalOut);
+ decompressor.end();
+ return out;
+ } catch (Exception e) {
+ throw new FacesException("Error decode resource data", e);
+ }
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ResourceLifecycle.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceLifecycle.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,92 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * Lifecycle for simulate faces request processing for resource.
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:56 $
+ *
+ */
+public class ResourceLifecycle extends Lifecycle {
+
+ /* (non-Javadoc)
+ * @see
javax.faces.lifecycle.Lifecycle#addPhaseListener(javax.faces.event.PhaseListener)
+ */
+ public void addPhaseListener(PhaseListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#execute(javax.faces.context.FacesContext)
+ */
+ public void execute(FacesContext arg0) throws FacesException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#getPhaseListeners()
+ */
+ public PhaseListener[] getPhaseListeners() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.lifecycle.Lifecycle#removePhaseListener(javax.faces.event.PhaseListener)
+ */
+ public void removePhaseListener(PhaseListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.lifecycle.Lifecycle#render(javax.faces.context.FacesContext)
+ */
+ public void render(FacesContext arg0) throws FacesException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * @param context
+ * @param resource
+ * @throws IOException
+ */
+ public void send(ResourceContext resourceContext, InternetResource resource) throws
IOException{
+ resource.sendHeaders(resourceContext);
+ resource.send(resourceContext);
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ScriptRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ScriptRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,150 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.javascript.JSMin;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:04 $
+ *
+ */
+public class ScriptRenderer extends OneTimeRenderer {
+
+ private static final String COMPRESS_SCRIPTS_PARAMETER =
"org.ajax4jsf.COMPRESS_SCRIPT";
+
+ private static final Log _log = LogFactory.getLog(ScriptRenderer.class);
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ // TODO Auto-generated method stub
+ return "script";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ // TODO Auto-generated method stub
+ return "src";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ // TODO Auto-generated method stub
+ return new String[][]{{"type",getContentType()}};
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO - use configurable encoding ?
+ return "text/javascript";
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
org.ajax4jsf.resource.ResourceContext)
+ */
+ public int send(InternetResource base, ResourceContext context) throws IOException {
+ InputStream in = base.getResourceAsStream(context);
+ if (null == in) {
+ String message = Messages.getMessage(
+ Messages.NO_INPUT_STREAM_ERROR, base.getKey());
+ throw new IOException(message);
+ }
+ OutputStream out = context.getOutputStream();
+ // Compress JavaScript output by JSMin ( true by default )
+ if( !
"false".equalsIgnoreCase(context.getInitParameter(COMPRESS_SCRIPTS_PARAMETER))){
+ CountingOutputStream countingStream = new CountingOutputStream(out);
+ JSMin jsmin = new JSMin(in,countingStream);
+ try {
+ jsmin.jsmin();
+ } catch (Exception e) {
+ _log.error("Error send script to client for resource "+base.getKey(), e);
+ } finally {
+ in.close();
+ countingStream.flush();
+ countingStream.close();
+ }
+ int written = countingStream.getWritten();
+ if(_log.isDebugEnabled()){
+ _log.debug("Send "+written+" bytes to client for JavaScript resource
"+base.getKey());
+ }
+ return written;
+ } else {
+ return sendStream(in, out);
+ }
+ }
+
+
+}
+
+class CountingOutputStream extends OutputStream {
+ private OutputStream outputStream;
+ private int written = 0;
+
+ CountingOutputStream(OutputStream outputStream) {
+ super();
+ this.outputStream = outputStream;
+ }
+
+ public void close() throws IOException {
+ outputStream.close();
+ }
+
+ public void flush() throws IOException {
+ outputStream.flush();
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ outputStream.write(b, off, len);
+ written += len;
+ }
+
+ public void write(byte[] b) throws IOException {
+ outputStream.write(b);
+ written += b.length;
+ }
+
+ public void write(int b) throws IOException {
+ outputStream.write(b);
+ written++;
+ }
+
+ int getWritten() {
+ return written;
+ }
+}
Copied:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ServletResourceContext.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ServletResourceContext.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,143 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:01 $
+ *
+ */
+public class ServletResourceContext extends ResourceContext {
+
+ private ServletContext context;
+ private HttpServletRequest request;
+
+ private HttpServletResponse response;
+
+ /**
+ * @param request
+ * @param response
+ */
+ public ServletResourceContext(ServletContext context, HttpServletRequest request,
HttpServletResponse response) {
+ this.context = context;
+ this.request = request;
+ this.response = response;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setHeader(java.lang.String,
java.lang.String)
+ */
+ public void setHeader(String name, String value) {
+ response.setHeader(name,value);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setIntHeader(java.lang.String, int)
+ */
+ public void setIntHeader(String name, int value) {
+ response.setIntHeader(name,value);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#setDateHeader(java.lang.String, long)
+ */
+ public void setDateHeader(String name, long value) {
+ response.setDateHeader(name,value);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getOutputStream()
+ */
+ public OutputStream getOutputStream() throws IOException {
+ // TODO Auto-generated method stub
+ return response.getOutputStream();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getQueryString()
+ */
+ public String getQueryString() {
+ return request.getQueryString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getPathInfo()
+ */
+ public String getPathInfo() {
+ return request.getPathInfo();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getSessionAttribute(java.lang.String)
+ */
+ public Object getSessionAttribute(String name) {
+ return request.getSession(false).getAttribute(name);
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ // TODO Auto-generated method stub
+ return context.getResourceAsStream(path);
+ }
+
+ public String getRequestParameter(String data_parameter) {
+ // TODO Auto-generated method stub
+ return request.getParameter(data_parameter);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceContext#getWriter()
+ */
+ public PrintWriter getWriter() throws IOException {
+ // TODO Auto-generated method stub
+ return response.getWriter();
+ }
+
+ public void setContentType(String contentType) {
+ response.setContentType(contentType);
+ }
+
+ public String getInitParameter(String name) {
+ // TODO Auto-generated method stub
+ return context.getInitParameter(name);
+ }
+
+ public String getServletPath() {
+ // TODO Auto-generated method stub
+ return request.getServletPath();
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/SmartPositionScript.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/SmartPositionScript.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SmartPositionScript extends ClientScript {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ClientScript#getJavaScript()
+ */
+ public String getJavaScript() {
+ // TODO Auto-generated method stub
+ return "scripts/smartposition.js";
+ }
+
+ protected boolean isUsePrototype() {
+
+ return true;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StaticResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StaticResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,103 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.InputStream;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: nick_belaevski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/01/11 16:52:14 $
+ *
+ */
+public class StaticResource extends InternetResourceBase {
+
+ private String path;
+ private byte[] resourceData = null;
+
+ /**
+ *
+ */
+ public StaticResource() {
+ super();
+ }
+
+
+
+ public StaticResource(String path){
+ this.path = path;
+ setCacheable(true);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#getResourceAsStream(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ return context.getResourceAsStream(path);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#isCacheable()
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return true;
+ }
+
+
+
+ public String getUri(FacesContext context, Object data) {
+ // perform all encodings, suitable for JSF specification.
+ String src = context.getApplication().getViewHandler().getResourceURL(context,path);
+ return context.getExternalContext().encodeResourceURL(src);
+ }
+
+ public void encode(FacesContext context, Object data) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+
+ /**
+ * @return the path
+ */
+ public String getPath() {
+ return path;
+ }
+
+
+
+ /**
+ * @param path the path to set
+ */
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/StyleRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/StyleRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+
+
+/**
+ * Render style element with content in page. Warning - not use for head link element,
+ * it must be rendered separate.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:56:58 $
+ *
+ */
+public class StyleRenderer extends OneTimeRenderer {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getTag()
+ */
+ protected String getTag() {
+ return "link";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getHrefAttr()
+ */
+ protected String getHrefAttr() {
+ return "href";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#getCommonAttrs()
+ */
+ protected String[][] getCommonAttrs() {
+ return new
String[][]{{"type","text/css"},{"rel","stylesheet"}};
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.ResourceRenderer#getContentType()
+ */
+ public String getContentType() {
+ // TODO use configurable encoding ?
+ return "text/css";
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.resource.InternetResource,
javax.faces.context.FacesContext, java.lang.Object)
+ */
+ /*
+ protected void customEncode(InternetResource resource, FacesContext context, Object
data) throws IOException {
+ // Encode style in page - read from resource.
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ InputStream in = resource.getResourceAsStream(resourceContext);
+ StringBuffer buff = new StringBuffer();
+ int input;
+ while((input = in.read())>0){
+ buff.append((char)input);
+ }
+ in.close();
+ // MyFaces & RI have different beahvior for style element, in RI best use
writeComment ?
+ // TODO - detect page content type ?
+ context.getResponseWriter().writeText(buff,resource.getKey());
+ }
+*/
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSRenderer.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,137 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+
+import org.ajax4jsf.framework.renderer.RendererBase;
+import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
+import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
+import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author shura
+ *
+ */
+public class TemplateCSSRenderer extends StyleRenderer {
+
+ private static final String COMPILED_TEMPLATE_PROPERTY = "compiled-template";
+
+ private RendererBase renderer = new RendererBase() {
+
+ protected Class getComponentClass() {
+ // TODO Auto-generated method stub
+ return UIComponent.class;
+ }
+
+ };
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.BaseResourceRenderer#send(org.ajax4jsf.resource.InternetResource,
org.ajax4jsf.resource.ResourceContext)
+ */
+ public int send(InternetResource base, ResourceContext context) throws IOException {
+ PreparedTemplate template = null;
+ template = getTemplate(base, context);
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if(null != facesContext) {
+ // Create responseWriter.
+ String defaultRenderKitId = facesContext.getApplication().getDefaultRenderKitId();
+ if (null == defaultRenderKitId) {
+ defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+ }
+ RenderKitFactory renderKitFactory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = renderKitFactory.getRenderKit(facesContext,defaultRenderKitId);
+ // TODO - handle response encoding
+ ResponseWriter responseWriter =
renderKit.createResponseWriter(context.getWriter(),null,"UTF-8");
+ facesContext.setResponseWriter(responseWriter);
+ responseWriter.startDocument();
+ // TODO - parameters and mock renderer/component ?
+ // for first time, this template only allow skin or faces variables interaction
+ template.encode(renderer,facesContext,null);
+ responseWriter.endDocument();
+ responseWriter.flush();
+ responseWriter.close();
+ } else {
+ throw new FacesException("FacesContext for resource from template
"+base.getKey()+" is null");
+ }
+ return 0;
+ }
+
+ /**
+ * @param base
+ * @param context
+ * @return
+ * @throws IOException
+ */
+ public PreparedTemplate getTemplate(InternetResource base, ResourceContext context)
throws IOException {
+ PreparedTemplate template;
+ // if(base.isCacheable()){
+ template = (PreparedTemplate) base.getProperty(COMPILED_TEMPLATE_PROPERTY);
+ // }
+ if(null == template){
+ HtmlCompiler compiler = new HtmlCompiler();
+ InputStream resourceAsStream = base.getResourceAsStream(context);
+ template = compiler.compile(resourceAsStream, base.getKey());
+ base.setProperty(COMPILED_TEMPLATE_PROPERTY, template);
+ resourceAsStream.close();
+ }
+ return template;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.BaseResourceRenderer#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ return true;
+ }
+
+ public Object getData(InternetResource base, FacesContext context, Object data) {
+ ResourceContext resourceContext = new FacesResourceContext(context);
+ PreparedTemplate template;
+ try {
+ template = getTemplate(base, resourceContext);
+ } catch (IOException e) {
+ return null;
+ }
+ UIComponent component = (UIComponent) (data instanceof UIComponent ? data:null);
+ TemplateContext templateContext = new TemplateContext(null,context,component);
+ Object value = template.getValue(templateContext);
+ if(null == value){
+ int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
+ value = ByteBuffer.allocate(4).putInt(hashCode).array();
+ }
+ return value;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
(from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/TemplateCSSResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,295 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.Map;
+
+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 $
+ *
+ */
+public class TemplateCSSResource implements InternetResource {
+
+ private String templateName;
+ private InternetResource _resource;
+ private static TemplateCSSRenderer templateCSSRenderer = new TemplateCSSRenderer();
+
+ public TemplateCSSResource(){
+
+ }
+ /**
+ * @param templateName
+ */
+ public TemplateCSSResource(String templateName) {
+ super();
+ setPath(templateName);
+ }
+ /**
+ * @param templateName
+ * @throws FacesException
+ */
+ public void setPath(String templateName) throws FacesException {
+ // remove leaded / - as need for ClassLoader.getResource call.
+ this.templateName =
templateName.startsWith("/")?templateName.substring(1):templateName;
+ // Self-register resource in system.
+ _resource =
InternetResourceBuilder.getInstance().createResource(null,this.templateName);
+ _resource.setRenderer(templateCSSRenderer);
+ try {
+ // Attempt to compile template at init time. Due to client-side caching,
+ // without registering resources requests can be not call rendering template.
+ templateCSSRenderer.getTemplate(_resource, null);
+ } catch (Exception e) {
+ // Do nothing - template will be compiled at rendering time.
+ // TODO log error.
+ }
+ }
+
+ /**
+ * @param context
+ * @param data
+ * @param attributes
+ * @throws IOException
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
+ */
+ public void encode(FacesContext context, Object data, Map attributes) throws IOException
{
+ _resource.encode(context, data, attributes);
+ }
+
+ /**
+ * @param context
+ * @param data
+ * @throws IOException
+ * @see org.ajax4jsf.resource.InternetResource#encode(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void encode(FacesContext context, Object data) throws IOException {
+ _resource.encode(context, data);
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param attrs
+ * @throws IOException
+ * @see
org.ajax4jsf.resource.InternetResource#encodeBegin(javax.faces.context.FacesContext,
java.lang.Object, java.util.Map)
+ */
+ public void encodeBegin(FacesContext context, Object component, Map attrs) throws
IOException {
+ _resource.encodeBegin(context, component, attrs);
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @throws IOException
+ * @see
org.ajax4jsf.resource.InternetResource#encodeEnd(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public void encodeEnd(FacesContext context, Object component) throws IOException {
+ _resource.encodeEnd(context, component);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getContentLength(ResourceContext)
+ */
+ public int getContentLength(ResourceContext resourceContext) {
+ return _resource.getContentLength(resourceContext);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getContentType(ResourceContext)
+ */
+ public String getContentType(ResourceContext resourceContext) {
+ return _resource.getContentType(null);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getExpired(ResourceContext)
+ */
+ public Date getExpired(ResourceContext resourceContext) {
+ return _resource.getExpired(null);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getKey()
+ */
+ public String getKey() {
+ return _resource.getKey();
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getLastModified(ResourceContext)
+ */
+ public Date getLastModified(ResourceContext resourceContext) {
+ return _resource.getLastModified(null);
+ }
+
+ /**
+ * @param key
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getProperty(java.lang.Object)
+ */
+ public Object getProperty(Object key) {
+ return _resource.getProperty(key);
+ }
+
+ /**
+ * @param context
+ * @return
+ * @see
org.ajax4jsf.resource.InternetResource#getResourceAsStream(org.ajax4jsf.resource.ResourceContext)
+ */
+ public InputStream getResourceAsStream(ResourceContext context) {
+ return _resource.getResourceAsStream(context);
+ }
+
+ /**
+ * @param context
+ * @param data
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getUri(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public String getUri(FacesContext context, Object data) {
+ return _resource.getUri(context, data);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#isCacheable(ResourceContext)
+ */
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return _resource.isCacheable(null);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#isSessionAware()
+ */
+ public boolean isSessionAware() {
+ return _resource.isSessionAware();
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ return _resource.requireFacesContext();
+ }
+
+ /**
+ * @param context
+ * @throws IOException
+ * @see
org.ajax4jsf.resource.InternetResource#send(org.ajax4jsf.resource.ResourceContext)
+ */
+ public void send(ResourceContext context) throws IOException {
+ _resource.send(context);
+ }
+
+ /**
+ * @param response
+ * @see
org.ajax4jsf.resource.InternetResource#sendHeaders(org.ajax4jsf.resource.ResourceContext)
+ */
+ public void sendHeaders(ResourceContext response) {
+ _resource.sendHeaders(response);
+ }
+
+ /**
+ * @param key
+ * @see org.ajax4jsf.resource.InternetResource#setKey(java.lang.String)
+ */
+ public void setKey(String key) {
+ _resource.setKey(key);
+ }
+
+ /**
+ * @param key
+ * @param value
+ * @see org.ajax4jsf.resource.InternetResource#setProperty(java.lang.Object,
java.lang.Object)
+ */
+ public void setProperty(Object key, Object value) {
+ _resource.setProperty(key, value);
+ }
+
+ /**
+ * @param renderer
+ * @see
org.ajax4jsf.resource.InternetResource#setRenderer(org.ajax4jsf.resource.ResourceRenderer)
+ */
+ public void setRenderer(ResourceRenderer renderer) {
+ _resource.setRenderer(renderer);
+ }
+
+ /**
+ * @return
+ * @see org.ajax4jsf.resource.InternetResource#getRenderer(ResourceContext)
+ */
+ public ResourceRenderer getRenderer(ResourceContext resourceContext) {
+ return _resource.getRenderer(null);
+ }
+
+ /**
+ * @param cacheable
+ * @see org.ajax4jsf.resource.InternetResource#setCacheable(boolean)
+ */
+ public void setCacheable(boolean cacheable) {
+ _resource.setCacheable(cacheable);
+ }
+
+ /**
+ * @param expired
+ * @see org.ajax4jsf.resource.InternetResource#setExpired(java.util.Date)
+ */
+ public void setExpired(Date expired) {
+ _resource.setExpired(expired);
+ }
+
+ /**
+ * @param lastModified
+ * @see org.ajax4jsf.resource.InternetResource#setLastModified(java.util.Date)
+ */
+ public void setLastModified(Date lastModified) {
+ _resource.setLastModified(lastModified);
+ }
+
+ /**
+ * @param sessionAware
+ * @see org.ajax4jsf.resource.InternetResource#setSessionAware(boolean)
+ */
+ public void setSessionAware(boolean sessionAware) {
+ _resource.setSessionAware(sessionAware);
+ }
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java (from
rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/UserResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,138 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.resource.ResourceComponent;
+import org.ajax4jsf.resource.ResourceContext;
+
+/**
+ * @author shura
+ *
+ */
+public class UserResource extends InternetResourceBase {
+
+ private String contentType;
+ /**
+ *
+ */
+ public UserResource(boolean cacheable, boolean session, String mime) {
+ super();
+ setCacheable(cacheable);
+ setSessionAware(session);
+ setContentType(mime);
+ }
+ /**
+ * @return Returns the contentType.
+ */
+ public String getContentType(ResourceContext resourceContext) {
+ return contentType;
+ }
+ /**
+ * @param contentType The contentType to set.
+ */
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext,
java.lang.Object)
+ */
+ public Object getDataToStore(FacesContext context, Object data) {
+ UriData dataToStore = null;
+ if (data instanceof ResourceComponent) {
+ ResourceComponent resource = (ResourceComponent) data;
+ dataToStore = new UriData();
+ dataToStore.value = resource.getValue();
+ dataToStore.createContent =
UIComponentBase.saveAttachedState(context,resource.getCreateContent());
+ if (data instanceof UIComponent) {
+ UIComponent component = (UIComponent) data;
+ ValueBinding expires = component.getValueBinding("expires");
+ if (null != expires) {
+ dataToStore.expires = UIComponentBase.saveAttachedState(context,expires);
+ }
+ ValueBinding lastModified = component.getValueBinding("lastModified");
+ if (null != lastModified) {
+ dataToStore.modified = UIComponentBase.saveAttachedState(context,lastModified);
+ }
+ }
+ }
+ return dataToStore;
+ }
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.resource.InternetResourceBase#send(org.ajax4jsf.resource.ResourceContext)
+ */
+ public void send(ResourceContext context) throws IOException {
+ UriData data = (UriData) restoreData(context);
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (null != data && null != facesContext ) {
+ // Send headers
+ if(data.expires != null){
+ ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.expires);
+ Date expires = (Date) binding.getValue(facesContext);
+ context.setDateHeader("Expires",expires.getTime());
+ }
+ if(data.modified != null){
+ ValueBinding binding = (ValueBinding)
UIComponentBase.restoreAttachedState(facesContext,data.modified);
+ Date modified = (Date) binding.getValue(facesContext);
+ context.setDateHeader("Last-Modified",modified.getTime());
+ }
+ // Send content
+ OutputStream out = context.getOutputStream();
+ MethodBinding send = (MethodBinding)
UIComponentBase.restoreAttachedState(facesContext,data.createContent);
+ send.invoke(facesContext,new Object[]{out,data.value});
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.resource.InternetResourceBase#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ public static class UriData implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1258987L;
+
+ private Object value;
+
+ private Object createContent;
+
+ private Object expires;
+
+ private Object modified;
+ }
+
+}
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached (from rev 1507,
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached)
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/CachedResourceBuilder.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/CachedResourceBuilder.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.io.IOException;
import java.io.InputStream;
@@ -29,8 +29,8 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.resource.ResourceNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/DualLRUMap.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/DualLRUMap.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.util.HashMap;
import java.util.Map;
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/ResourceBean.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBean.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.io.Serializable;
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/ResourceBytesDataBean.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceBytesDataBean.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
import java.util.Arrays;
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/ResourceDataBean.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/cached/ResourceDataBean.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.framework.resource.cached;
+package org.ajax4jsf.resource.cached;
/**
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html (from rev
1507, trunk/framework/impl/src/main/java/org/ajax4jsf/framework/resource/package.html)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/package.html 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+
+
+
+
+ <meta content="text/html; charset=Windows-1251"
http-equiv="content-type">
+
+
+
+
+ <title>Internet Resources</title>
+</head>
+
+
+<body>
+
+
+<h1>Package for manipulate page resources ( images, scripts, styles,
+applets etc ) at Java Server Faces render Phase and at request phase of
+concrete resource.</h1>
+
+Note: The resource framework implements the Lightweight design patter.
+Therefore, the resource classes should not contain data depends of
+the particular request. The data is taken from the {@link javax.context.FacesContext}
+and {@link javax.component.UIComponent}, that is passed as a parameter
+when html is generated.
+For passing the data with URI, the {@link InternetResourceBase} class
+has getDataToSave method. It is invoked when the generation is taken place.
+The returned object is serialized. Then, restoreData method de-serialize it back.
+The {@link InternetResourceBuilder} class controls this process.
+</body>
+</html>
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -32,10 +32,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/SliderArrowBase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -29,9 +29,9 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
public abstract class SliderArrowBase extends Java2Dresource{
Modified: trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-05 19:11:50
UTC (rev 1507)
+++ trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-07-05 20:50:37
UTC (rev 1508)
@@ -6,7 +6,7 @@
<faces-config>
<factory>
- <render-kit-factory>org.ajax4jsf.renderkit.ChameleonRenderKitFactory</render-kit-factory>
+ <render-kit-factory>org.ajax4jsf.framework.renderer.ChameleonRenderKitFactory</render-kit-factory>
<lifecycle-factory>org.ajax4jsf.framework.DebugLifecycleFactory</lifecycle-factory>
</factory>
<application>
@@ -18,7 +18,7 @@
<state-manager>org.ajax4jsf.framework.ajax.AjaxStateManager</state-manager>
</application>
<lifecycle>
- <phase-listener>org.ajax4jsf.renderkit.AjaxPhaseListener</phase-listener>
+
<phase-listener>org.ajax4jsf.framework.renderer.AjaxPhaseListener</phase-listener>
<phase-listener>org.ajax4jsf.framework.ajax.InitPhaseListener</phase-listener>
</lifecycle>
<managed-bean>
@@ -55,7 +55,7 @@
</description>
<component-family>javax.faces.ViewRoot</component-family>
<renderer-type>javax.faces.ViewRoot</renderer-type>
-
<renderer-class>org.ajax4jsf.renderkit.AjaxViewRootRenderer</renderer-class>
+
<renderer-class>org.ajax4jsf.framework.renderer.AjaxViewRootRenderer</renderer-class>
</renderer>
<!--
<renderer>
Copied: trunk/framework/impl/src/main/resources/META-INF/resources-config.xml (from rev
1507, trunk/ui/core/src/main/config/resources/resources-config.xml)
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/resources-config.xml
(rev 0)
+++ trunk/framework/impl/src/main/resources/META-INF/resources-config.xml 2007-07-05
20:50:37 UTC (rev 1508)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resource-config>
+ <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
+ <name>org.ajax4jsf.framework.ajax.AjaxScript</name>
+ </resource>
+ <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
+ <name>ajax.js</name>
+ </resource>
+ <resource class="org.ajax4jsf.resource.PrototypeScript">
+ <name>prototype.js</name>
+ </resource>
+ <resource class="org.ajax4jsf.dnd.DnDScript">
+ <name>dnd.js</name>
+ </resource>
+ <resource >
+ <name>form.js</name>
+ <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
+ <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
+ </resource>
+ <resource >
+ <name>org/ajax4jsf/renderers/ajax/scripts/form.js</name>
+ <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
+ <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
+ </resource>
+</resource-config>
Modified:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java
===================================================================
---
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockFacesResourceContext.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -28,7 +28,7 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.FacesResourceContext;
+import org.ajax4jsf.resource.FacesResourceContext;
import org.apache.shale.test.mock.MockHttpServletResponse;
import com.gargoylesoftware.htmlunit.KeyValuePair;
Modified: trunk/framework/test/src/test/java/DnDScriptTest.java
===================================================================
--- trunk/framework/test/src/test/java/DnDScriptTest.java 2007-07-05 19:11:50 UTC (rev
1507)
+++ trunk/framework/test/src/test/java/DnDScriptTest.java 2007-07-05 20:50:37 UTC (rev
1508)
@@ -22,7 +22,7 @@
import java.io.IOException;
import org.ajax4jsf.dnd.DnDScript;
-import org.ajax4jsf.framework.resource.FacesResourceContext;
+import org.ajax4jsf.resource.FacesResourceContext;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java
===================================================================
---
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/CSSTemplateTestCase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -26,9 +26,11 @@
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.resource.FacesResourceContext;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.TemplateCSSResource;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.shale.test.mock.MockPrintWriter;
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java
===================================================================
---
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/InternetResourceServiceTestCase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -25,6 +25,7 @@
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.InternetResourceService;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.shale.test.mock.MockServletOutputStream;
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java
===================================================================
---
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/MockCacheableResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -24,6 +24,8 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import org.ajax4jsf.resource.InternetResourceBase;
+import org.ajax4jsf.resource.LogfileRenderer;
import org.ajax4jsf.resource.ResourceContext;
/**
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java
===================================================================
---
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ParametersEncodingTestCase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -2,6 +2,7 @@
import java.util.Arrays;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
public class ParametersEncodingTestCase extends AbstractAjax4JsfTestCase {
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java
===================================================================
---
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/framework/resource/ResourceServiceThreadsTestCase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -25,6 +25,7 @@
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.InternetResourceService;
import org.ajax4jsf.tests.AbstractThreadedAjax4JsfTestCase;
import org.apache.shale.test.mock.MockHttpServletRequest;
import org.apache.shale.test.mock.MockHttpServletResponse;
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DataFilterSliderDaoImpl.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,7 +1,12 @@
package org.richfaces.demo.datafilterslider;
-import java.util.*;
import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
/**
* Created by IntelliJ IDEA.
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/datafilterslider/DemoInventoryList.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,15 +1,13 @@
package org.richfaces.demo.datafilterslider;
-import org.richfaces.component.UIDataFltrSlider;
+import java.util.ArrayList;
+import java.util.List;
-import javax.faces.event.ActionEvent;
-import javax.faces.context.FacesContext;
import javax.faces.component.UIData;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.math.BigDecimal;
+import javax.faces.event.ActionEvent;
+import org.richfaces.component.UIDataFltrSlider;
+
public class DemoInventoryList {
DataFilterSliderDao dataFilterSliderDao = DataFilterSliderDaoImpl.getInstance();
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/dnd/EventBean.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -1,9 +1,9 @@
package org.richfaces.demo.dnd;
- import org.ajax4jsf.dnd.event.DropEvent;
- import org.ajax4jsf.dnd.event.DropListener;
- import org.ajax4jsf.dnd.Dropzone;
+ import org.richfaces.component.Dropzone;
+import org.richfaces.event.DropEvent;
+import org.richfaces.event.DropListener;
public class EventBean implements DropListener {
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Album.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -4,7 +4,7 @@
import java.util.Iterator;
import java.util.Map;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Album implements TreeNode {
/**
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Artist.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -4,7 +4,7 @@
import java.util.Iterator;
import java.util.Map;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Artist implements TreeNode {
private long id;
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -8,7 +8,7 @@
import java.util.Map;
import java.util.StringTokenizer;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Library implements TreeNode {
/**
Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Song.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.Iterator;
-import org.richfaces.component.TreeNode;
+import org.richfaces.model.TreeNode;
public class Song implements TreeNode {
/**
Deleted: trunk/ui/core/src/main/config/resources/resources-config.xml
===================================================================
--- trunk/ui/core/src/main/config/resources/resources-config.xml 2007-07-05 19:11:50 UTC
(rev 1507)
+++ trunk/ui/core/src/main/config/resources/resources-config.xml 2007-07-05 20:50:37 UTC
(rev 1508)
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resource-config>
- <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
- <name>org.ajax4jsf.framework.ajax.AjaxScript</name>
- </resource>
- <resource class="org.ajax4jsf.framework.ajax.AjaxScript">
- <name>ajax.js</name>
- </resource>
- <resource class="org.ajax4jsf.resource.PrototypeScript">
- <name>prototype.js</name>
- </resource>
- <resource class="org.ajax4jsf.dnd.DnDScript">
- <name>dnd.js</name>
- </resource>
- <resource >
- <name>form.js</name>
- <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
- <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
- </resource>
- <resource >
- <name>org/ajax4jsf/renderers/ajax/scripts/form.js</name>
- <path>/org/ajax4jsf/renderkit/html/scripts/form.js</path>
- <renderer class="org.ajax4jsf.resource.ScriptRenderer"/>
- </resource>
-</resource-config>
Modified:
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
===================================================================
---
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -42,11 +42,11 @@
import javax.faces.el.ValueBinding;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.resource.Java2Dresource;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.event.DataFilterSliderAdapter;
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java
===================================================================
---
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DraggableRendererContributor.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -31,7 +31,7 @@
import org.ajax4jsf.dnd.DnDScript;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.resource.PrototypeScript;
+import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DragEvent;
Modified:
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java
===================================================================
---
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/drag-drop/src/main/java/org/richfaces/renderkit/DropzoneRendererContributor.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -30,11 +30,11 @@
import org.ajax4jsf.dnd.DnDScript;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.resource.PrototypeScript;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.resource.PrototypeScript;
import org.richfaces.component.Draggable;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DropEvent;
Modified:
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
===================================================================
---
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -27,10 +27,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
Modified:
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
---
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -24,11 +24,11 @@
import com.gargoylesoftware.htmlunit.KeyValuePair;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.html.*;
-import org.ajax4jsf.framework.resource.Java2Dresource;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.renderkit.html.images.SliderArrowImage;
Modified:
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java
===================================================================
---
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/inputnumber-spinner/src/main/java/org/richfaces/renderkit/html/images/buttons/SpinnerButtonImage.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -25,10 +25,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified:
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
===================================================================
---
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -24,11 +24,11 @@
import com.gargoylesoftware.htmlunit.KeyValuePair;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.html.*;
-import org.ajax4jsf.framework.resource.Java2Dresource;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.renderkit.html.images.background.SpinnerButtonGradient;
Modified:
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java
===================================================================
---
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/images/MenuNodeImage.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -9,10 +9,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified:
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
===================================================================
---
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -40,10 +40,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
Modified:
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
---
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -41,10 +41,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.ajax4jsf.tests.MockViewRoot;
Modified:
trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java
===================================================================
---
trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/paint2D/src/main/java/org/richfaces/renderkit/html/Paint2DResource.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -34,12 +34,12 @@
import javax.faces.context.FacesContext;
import javax.faces.el.MethodBinding;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.ImageRenderer;
-import org.ajax4jsf.framework.resource.InternetResourceBase;
-import org.ajax4jsf.framework.resource.JpegRenderer;
-import org.ajax4jsf.framework.resource.PngRenderer;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
+import org.ajax4jsf.resource.ImageRenderer;
+import org.ajax4jsf.resource.InternetResourceBase;
+import org.ajax4jsf.resource.JpegRenderer;
+import org.ajax4jsf.resource.PngRenderer;
import org.ajax4jsf.resource.ResourceContext;
import org.ajax4jsf.resource.ResourceRenderer;
import org.apache.commons.logging.Log;
Modified:
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java
===================================================================
---
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/BevelSeparatorImage.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -21,11 +21,11 @@
package org.richfaces.renderkit.html.images;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.component.UISeparator;
import org.richfaces.skin.Skin;
Modified:
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java
===================================================================
---
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/separator/src/main/java/org/richfaces/renderkit/html/images/SimpleSeparatorImage.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -21,11 +21,11 @@
package org.richfaces.renderkit.html.images;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.component.UISeparator;
import org.richfaces.skin.Skin;
Modified:
trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java
===================================================================
---
trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/separator/src/test/java/org/richfaces/component/SeparatorComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -27,10 +27,10 @@
import javax.faces.component.html.HtmlOutputText;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import com.gargoylesoftware.htmlunit.Page;
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -29,10 +29,10 @@
import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
-import org.ajax4jsf.framework.resource.TemplateCSSResource;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.TemplateCSSResource;
import org.richfaces.component.AjaxSuggestionEvent;
import org.richfaces.component.UISuggestionBox;
import org.richfaces.skin.Skin;
@@ -80,8 +80,8 @@
* Additional scripts.
*/
private final InternetResource[] additionalScripts = {
- new org.ajax4jsf.framework.resource.PrototypeScript(),
- new org.ajax4jsf.framework.resource.SmartPositionScript(),
+ new org.ajax4jsf.resource.PrototypeScript(),
+ new org.ajax4jsf.resource.SmartPositionScript(),
getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
getResource("scripts/scriptaculo.js"),
getResource("scripts/suggestionbox.js")};
Modified:
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java
===================================================================
---
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/tabPanel/src/main/java/org/richfaces/renderkit/images/TabStripeImage.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -21,10 +21,10 @@
package org.richfaces.renderkit.images;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified:
trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
---
trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -25,10 +25,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
Modified:
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java
===================================================================
---
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/toolBar/src/main/java/org/richfaces/renderkit/html/images/ToolBarSeparatorImage.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -26,11 +26,11 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
import org.ajax4jsf.framework.util.HtmlDimensions;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.component.UIToolBar;
import org.richfaces.component.UIToolBarGroup;
import org.richfaces.skin.Skin;
Modified:
trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
===================================================================
---
trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -25,10 +25,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import junit.framework.Assert;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import javax.faces.component.UICommand;
Modified:
trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java
===================================================================
---
trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java 2007-07-05
19:11:50 UTC (rev 1507)
+++
trunk/ui/tree/src/main/java/org/richfaces/renderkit/html/images/TreeImageBase.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -26,10 +26,10 @@
import javax.faces.context.FacesContext;
-import org.ajax4jsf.framework.resource.GifRenderer;
-import org.ajax4jsf.framework.resource.Java2Dresource;
import org.ajax4jsf.framework.util.HtmlColor;
+import org.ajax4jsf.resource.GifRenderer;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java
===================================================================
--- trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-05
19:11:50 UTC (rev 1507)
+++ trunk/ui/tree/src/test/java/org/richfaces/component/TreeComponentTest.java 2007-07-05
20:50:37 UTC (rev 1508)
@@ -38,10 +38,10 @@
import javax.faces.event.PhaseId;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceBuilderImpl;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
import org.richfaces.component.state.events.ExpandAllCommandEvent;