Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 95313 invoked from network); 25 Jan 2010 12:52:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Jan 2010 12:52:33 -0000 Received: (qmail 80526 invoked by uid 500); 25 Jan 2010 12:52:33 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 80472 invoked by uid 500); 25 Jan 2010 12:52:33 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 80463 invoked by uid 99); 25 Jan 2010 12:52:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jan 2010 12:52:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jan 2010 12:52:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7287E23889F7; Mon, 25 Jan 2010 12:52:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r902799 - in /sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal: DynamicRepositoryClassLoader.java URLRepositoryClassLoader.java net/JCRURLConnection.java Date: Mon, 25 Jan 2010 12:52:11 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100125125211.7287E23889F7@eris.apache.org> Author: cziegeler Date: Mon Jan 25 12:52:10 2010 New Revision: 902799 URL: http://svn.apache.org/viewvc?rev=902799&view=rev Log: SLING-1316 - Include jackrabbit classloader code to adjust it for Sling needs - code import with first changes. Update to Java 5 code. Modified: sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicRepositoryClassLoader.java sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/URLRepositoryClassLoader.java sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/net/JCRURLConnection.java Modified: sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicRepositoryClassLoader.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicRepositoryClassLoader.java?rev=902799&r1=902798&r2=902799&view=diff ============================================================================== --- sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicRepositoryClassLoader.java (original) +++ sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicRepositoryClassLoader.java Mon Jan 25 12:52:10 2010 @@ -83,7 +83,7 @@ * @see #onEvent(EventIterator) * @see #findClassLoaderResource(String) */ - private Map modTimeCache; + private Map modTimeCache; /** * Flag indicating whether there are loaded classes which have later been @@ -122,7 +122,7 @@ // set fields dirty = false; - modTimeCache = new HashMap(); + modTimeCache = new HashMap(); // register with observation service and path pattern list registerModificationListener(); @@ -152,7 +152,7 @@ // set the configuration and fields dirty = false; - modTimeCache = new HashMap(); + modTimeCache = new HashMap(); // create a repository from the handles - might get a different one setRepository(resetClassPathEntries(old.getRepository())); @@ -277,8 +277,8 @@ } // Check whether any class has changed - for (Iterator iter = getCachedResources(); iter.hasNext();) { - if (expireResource((ClassLoaderResource) iter.next())) { + for (Iterator iter = getCachedResources(); iter.hasNext();) { + if (expireResource(iter.next())) { log.debug("shouldReload: Found expired resource, need reload"); return true; } @@ -475,7 +475,7 @@ log.debug( "onEvent: Item {} has been modified, checking with cache", path); - ClassLoaderResource resource = (ClassLoaderResource) modTimeCache.get(path); + ClassLoaderResource resource = modTimeCache.get(path); if (resource != null) { log.debug("pageModified: Expiring cache entry {}", resource); expireResource(resource); Modified: sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/URLRepositoryClassLoader.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/URLRepositoryClassLoader.java?rev=902799&r1=902798&r2=902799&view=diff ============================================================================== --- sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/URLRepositoryClassLoader.java (original) +++ sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/URLRepositoryClassLoader.java Mon Jan 25 12:52:10 2010 @@ -229,7 +229,7 @@ * @throws ClassNotFoundException If the named class could not be found or * if this class loader has already been destroyed. */ - protected Class findClass(final String name) throws ClassNotFoundException { + protected Class findClass(final String name) throws ClassNotFoundException { if (isDestroyed()) { throw new ClassNotFoundException(name + " (Classloader destroyed)"); @@ -238,10 +238,10 @@ log.debug("findClass: Try to find class {}", name); try { - return (Class) AccessController - .doPrivileged(new PrivilegedExceptionAction() { + return AccessController.doPrivileged( + new PrivilegedExceptionAction>() { - public Object run() throws ClassNotFoundException { + public Class run() throws ClassNotFoundException { return findClassPrivileged(name); } }); @@ -288,15 +288,15 @@ * empty enumeration if no resources are found by this class loader * or if this class loader has already been destroyed. */ - public Enumeration findResources(String name) { + public Enumeration findResources(String name) { if (isDestroyed()) { log.warn("Destroyed class loader cannot find resources"); - return new Enumeration() { + return new Enumeration() { public boolean hasMoreElements() { return false; } - public Object nextElement() { + public URL nextElement() { throw new NoSuchElementException("No Entries"); } }; @@ -304,7 +304,7 @@ log.debug("findResources: Try to find resources for {}", name); - List list = new LinkedList(); + List list = new LinkedList(); for (int i=0; i < repository.length; i++) { final ClassPathEntry cp = repository[i]; log.debug("findResources: Trying {}", cp); @@ -328,8 +328,7 @@ /** * Returns the search path of URLs for loading classes and resources. * This includes the original list of URLs specified to the constructor, - * along with any URLs subsequently appended by the {@link #addURL(URL)} - * and {@link #addHandle(String)} methods. + * along with any URLs subsequently appended by the {@link #addURL(URL)}. * * @return the search path of URLs for loading classes and resources. The * list is empty, if this class loader has already been destroyed. @@ -341,14 +340,14 @@ return new URL[0]; } - List urls = new ArrayList(); + List urls = new ArrayList(); for (int i=0; i < repository.length; i++) { URL url = repository[i].toURL(); if (url != null) { urls.add(url); } } - return (URL[]) urls.toArray(new URL[urls.size()]); + return urls.toArray(new URL[urls.size()]); } /** @@ -423,7 +422,7 @@ * @throws NullPointerException If this class loader has already been * destroyed. */ - /* package */ Iterator getCachedResources() { + /* package */ Iterator getCachedResources() { return cache.values().iterator(); } @@ -607,7 +606,7 @@ * @throws NullPointerException If this class loader has already been * destroyed. */ - private Class findClassPrivileged(String name) throws ClassNotFoundException { + private Class findClassPrivileged(String name) throws ClassNotFoundException { // prepare the name of the class final String path = name.replace('.', '/').concat(".class"); @@ -623,7 +622,7 @@ "findClassPrivileged: Loading class from {}, created {}", res, new Date(res.getLastModificationTime())); - Class c = defineClass(name, res); + Class c = defineClass(name, res); if (c == null) { log.warn("defineClass returned null for class {}", name); throw new ClassNotFoundException(name); @@ -703,12 +702,12 @@ * @throws ClassFormatError If the class bytes read from the resource are * not a valid class. */ - private Class defineClass(String name, ClassLoaderResource res) + private Class defineClass(String name, ClassLoaderResource res) throws IOException, RepositoryException { log.debug("defineClass({}, {})", name, res); - Class clazz = res.getLoadedClass(); + Class clazz = res.getLoadedClass(); if (clazz == null) { /** Modified: sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/net/JCRURLConnection.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/net/JCRURLConnection.java?rev=902799&r1=902798&r2=902799&view=diff ============================================================================== --- sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/net/JCRURLConnection.java (original) +++ sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/net/JCRURLConnection.java Mon Jan 25 12:52:10 2010 @@ -37,7 +37,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The JCRURLConnection is the URLConnection * implementation to access the data addressed by a JCR Repository URL. @@ -194,7 +193,7 @@ * atom. *

* Implementations are free to decide, how to define the content type. But - * they are required to set the type in the {@link #connect(Ticket)}method. + * they are required to set the type in the {@link #connect()}method. * * @see #getContentType() * @see #connect() @@ -207,7 +206,7 @@ * atom. *

* Implementations are free to decide, how to define the content type. But - * they are required to set the type in the {@link #connect(Ticket)}method. + * they are required to set the type in the {@link #connect()}method. * * @see #getContentEncoding() * @see #connect() @@ -219,7 +218,7 @@ * status information of the base atom. *

* Implementations are free to decide, how to define the content length. But - * they are required to set the type in the {@link #connect(Ticket)}method. + * they are required to set the type in the {@link #connect()}method. * * @see #getContentLength() * @see #connect() @@ -231,7 +230,7 @@ *

* Implementations are free to decide, how to define the last modification * time. But they are required to set the type in the - * {@link #connect(Ticket)}method. + * {@link #connect()}method. * * @see #getLastModified() * @see #connect() @@ -378,7 +377,7 @@ } else { lastModified = 0; } - + if (parent.hasProperty("jcr:mimeType")) { contentType = parent.getProperty("jcr:mimeType").getString(); } else { @@ -389,11 +388,9 @@ : TEXT_PLAIN; } } - + if (parent.hasProperty("jcr:encoding")) { contentEncoding = parent.getProperty("jcr:encoding").getString(); - } else { - contentEncoding = null; } log.debug( @@ -567,8 +564,8 @@ * * @see #connect() */ - public Map getHeaderFields() { - Map fieldMap = new HashMap(); + public Map> getHeaderFields() { + Map> fieldMap = new HashMap>(); try { connect(); @@ -770,9 +767,9 @@ /** * Returns an unmodifiable list containing just the given string value. */ - private List toList(String value) { + private List toList(String value) { String[] values = { value }; - List valueList = Arrays.asList(values); + List valueList = Arrays.asList(values); return Collections.unmodifiableList(valueList); } }