Author: nbelaevski
Date: 2008-02-06 19:21:32 -0500 (Wed, 06 Feb 2008)
New Revision: 5885
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/util/
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/util/URLToStreamHelper.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
Log:
http://jira.jboss.com/jira/browse/RF-1284
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2008-02-06
19:18:44 UTC (rev 5884)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ResourceBuilderImpl.java 2008-02-07
00:21:32 UTC (rev 5885)
@@ -47,10 +47,7 @@
import javax.servlet.ServletContext;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.resource.InternetResource;
-import org.ajax4jsf.resource.InternetResourceBuilder;
-import org.ajax4jsf.resource.ResourceNotFoundException;
-import org.ajax4jsf.resource.ResourceRenderer;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
import org.ajax4jsf.util.base64.Codec;
import org.ajax4jsf.webapp.WebXml;
import org.apache.commons.digester.Digester;
@@ -154,7 +151,7 @@
+ resourceConfig.toExternalForm());
}
- InputStream in = resourceConfig.openStream();
+ InputStream in = URLToStreamHelper.urlToStream(resourceConfig);
try {
Digester digester = new Digester();
digester.setValidating(false);
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/util/URLToStreamHelper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/util/URLToStreamHelper.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/util/URLToStreamHelper.java 2008-02-07
00:21:32 UTC (rev 5885)
@@ -0,0 +1,59 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.resource.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Utility class to solve JAR locking issue using {@link
URLConnection#setUseCaches(boolean)} method.
+ * Contains one utility method that gets {@link InputStream} from {@link URL} with
caching disabled.
+ *
+ * Created 07.02.2008
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public final class URLToStreamHelper {
+
+ private static final Log log = LogFactory.getLog(URLToStreamHelper.class);
+
+ private URLToStreamHelper() {
+ super();
+ }
+
+ public static final InputStream urlToStream(URL url) throws IOException {
+ URLConnection connection = url.openConnection();
+ try {
+ connection.setUseCaches(false);
+ } catch (IllegalArgumentException e) {
+ log.error(e.getLocalizedMessage(), e);
+ }
+
+ return connection.getInputStream();
+ }
+}
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2008-02-06
19:18:44 UTC (rev 5884)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2008-02-07
00:21:32 UTC (rev 5885)
@@ -39,12 +39,10 @@
import javax.faces.el.ValueBinding;
import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
import org.ajax4jsf.util.ELUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-import org.richfaces.skin.SkinNotFoundException;
/**
* Implementation of {@link SkinFactory} with building skins from properties
@@ -159,7 +157,7 @@
URL url = (URL) properties.nextElement();
InputStream propertyStream = null;
try {
- propertyStream = url.openStream();
+ propertyStream = URLToStreamHelper.urlToStream(url);
defaultProperties.load(propertyStream);
} catch (IOException e) {
// DO Nothing...
@@ -294,7 +292,7 @@
URL url = (URL) properties.nextElement();
InputStream propertyStream = null;
try {
- propertyStream = url.openStream();
+ propertyStream = URLToStreamHelper.urlToStream(url);
skinProperties.load(propertyStream);
loadedPropertiesCount++;
} catch (IOException e) {