Author: cziegeler
Date: Thu Mar 4 12:17:17 2010
New Revision: 918962
URL: http://svn.apache.org/viewvc?rev=918962&view=rev
Log:
SLING-1262 : Add close() method to ResourceResolver and add an empty method to
all implementations (this isn't necessary, but avoid's problems later on)
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolverFactory.java
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
sling/trunk/bundles/servlets/get/src/test/java/org/apache/sling/servlets/get/impl/MockResourceResolver.java
sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
Thu Mar 4 12:17:17 2010
@@ -76,7 +76,7 @@
* method is, that this method may take request properties like the scheme,
* the host header or request parameters into account to resolve the
* resource.
- *
+ *
* @param request The http servlet request object providing more hints at
* how to resolve the <code>absPath</code>. This parameter may
be
* <code>null</code> in which case the implementation should use
@@ -107,7 +107,7 @@
* It is ok for the implementation of this method to just call the
* {...@link #resolve(HttpServletRequest, String)} method with
* <code>null</code> as the request argument.
- *
+ *
* @param absPath The absolute path to be resolved to a resource. If this
* parameter is <code>null</code>, it is assumed to address the
* root of the resource tree. If the path is relative it is
@@ -130,7 +130,7 @@
* the {...@link #resolve(HttpServletRequest, String)} where the
* <code>absPath</code> argument is the result of calling the
* <code>getPathInfo()</code> on the <code>request</code> object.
- *
+ *
* @param request The http servlet request object used to resolve the
* resource for. This must not be <code>null</code>.
* @return The {...@link Resource} addressed by
@@ -161,7 +161,7 @@
* <p>
* This method is intended as the reverse operation of the
* {...@link #resolve(String)} method.
- *
+ *
* @param resourcePath The path for which to return a mapped path.
* @return The mapped path.
*/
@@ -185,7 +185,7 @@
* {...@link #resolve(HttpServletRequest, String)} method. As such the URL
* returned is expected to be an absolute URL including scheme, host, any
* servlet context path and the actual path used to resolve the resource.
- *
+ *
* @param request The http servlet request object which may be used to
apply
* more mapping functionality.
* @param resourcePath The path for which to return a mapped path.
@@ -204,7 +204,7 @@
* loaded. In contrast to the {...@link #resolve(String)} method, this
method
* does not apply any logic to the path, so the path is used as-is to fetch
* the content.
- *
+ *
* @param path The absolute path to the resource object to be loaded. The
* path may contain relative path specifiers like <code>.</code>
* (current location) and <code>..</code> (parent location),
@@ -227,7 +227,7 @@
* a Java Content Repository, the path could be a
* <code>javax.jcr.Item</code> path from which the resource object is
* loaded.
- *
+ *
* @param base The base {...@link Resource} against which a relative path
* argument given by <code>path</code> is resolved. This
* parameter may be <code>null</code> if the <code>path</code>
is
@@ -272,7 +272,7 @@
* reading content from a Java Content Repository, the children could be
the
* {...@link Resource} objects loaded from child items of the
<code>Item</code>
* of the given <code>Resource</code>.
- *
+ *
* @param parent The {...@link Resource Resource} whose children are
requested.
* @return An <code>Iterator</code> of {...@link Resource} objects.
* @throws NullPointerException If <code>parent</code> is
<code>null</code>.
@@ -291,7 +291,7 @@
* create a JCR <code>Query</code> through the <code>QueryManager</code>.
* The result returned is then based on the <code>NodeIterator</code>
* provided by the query result.
- *
+ *
* @param query The query string to use to find the resources.
* @param language The language in which the query is formulated.
* @return An <code>Iterator</code> of {...@link Resource} objects
matching the
@@ -317,7 +317,7 @@
* the column name and the column value is the JCR <code>Value</code>
object
* converted into the respective Java object, such as <code>Boolean</code>
* for a value of property type <em>Boolean</em>.
- *
+ *
* @param query The query string to use to find the resources.
* @param language The language in which the query is formulated.
* @return An <code>Iterator</code> of <code>Map</code> instances providing
@@ -330,4 +330,12 @@
*/
Iterator<Map<String, Object>> queryResources(String query, String
language);
+ /**
+ * Close this resource resolver.
+ * This method should be called by clients when the resource resolver is
not
+ * used anymore. Once this method has been called, the resource resolver is
+ * considered unusable and will throw exceptions if still used.
+ * @since 2.1
+ */
+ void close();
}
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolverFactory.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolverFactory.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolverFactory.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolverFactory.java
Thu Mar 4 12:17:17 2010
@@ -24,8 +24,11 @@
* The <code>ResourceResolverFactory</code> defines the service API to
* get and create <code>ResourceResolver</code>s.
* <p>
+ * As soon as the resource resolver is not used anymore, {...@link
ResourceResolver#close()}
+ * should be called.
*
* WORK IN PROGRESS - see SLING-1262
+ * @since 2.1
*/
public interface ResourceResolverFactory {
@@ -39,6 +42,4 @@
ResourceResolver getResourceResolver(Map<String, Object>
authenticationInfo);
ResourceResolver getAdministrativeResourceResolver(Map<String, Object>
authenticationInfo);
-
- void dispose(ResourceResolver resolver);
}
Modified:
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
(original)
+++
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/sling/MockResourceResolver.java
Thu Mar 4 12:17:17 2010
@@ -159,4 +159,8 @@
public Resource resolve(HttpServletRequest request, String absPath) {
throw new UnsupportedOperationException("Not implemented");
}
+
+ public void close() {
+ // nothing to do
+ }
}
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
(original)
+++
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
Thu Mar 4 12:17:17 2010
@@ -97,6 +97,13 @@
this.resourceMapper = resourceMapper;
}
+ /**
+ * @see org.apache.sling.api.resource.ResourceResolver#close()
+ */
+ public void close() {
+ // TODO - Implement this
+ }
+
// ---------- resolving resources
public Resource resolve(String absPath) {
Modified:
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
(original)
+++
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
Thu Mar 4 12:17:17 2010
@@ -255,6 +255,9 @@
return Arrays.toString(roots);
}
+ public void close() {
+ // nothing to do
+ }
}
private static class TestResource implements Resource {
Modified:
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
(original)
+++
sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
Thu Mar 4 12:17:17 2010
@@ -101,4 +101,7 @@
return null;
}
+ public void close() {
+ // nothing to do
+ }
}
Modified:
sling/trunk/bundles/servlets/get/src/test/java/org/apache/sling/servlets/get/impl/MockResourceResolver.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/get/src/test/java/org/apache/sling/servlets/get/impl/MockResourceResolver.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/bundles/servlets/get/src/test/java/org/apache/sling/servlets/get/impl/MockResourceResolver.java
(original)
+++
sling/trunk/bundles/servlets/get/src/test/java/org/apache/sling/servlets/get/impl/MockResourceResolver.java
Thu Mar 4 12:17:17 2010
@@ -81,4 +81,7 @@
return null;
}
+ public void close() {
+ // nothing to do
+ }
}
Modified:
sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
(original)
+++
sling/trunk/contrib/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/JcrResourceBundleTest.java
Thu Mar 4 12:17:17 2010
@@ -159,6 +159,9 @@
return null;
}
+ public void close() {
+ // nothing to do
+ }
};
createTestContent();
Modified:
sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java
URL:
http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java?rev=918962&r1=918961&r2=918962&view=diff
==============================================================================
---
sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java
(original)
+++
sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java
Thu Mar 4 12:17:17 2010
@@ -96,6 +96,10 @@
public <AdapterType> AdapterType adaptTo(Class<AdapterType> arg0) {
return null;
}
+
+ public void close() {
+ // nothing to do
+ }
}
/** Set a non-public Field */