You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:46:39 UTC

[sling-org-apache-sling-jcr-classloader] annotated tag org.apache.sling.jcr.classloader-3.0.0 created (now d6d46cc)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git.


      at d6d46cc  (tag)
 tagging a7f9dc1491bf89958a9c2a153dd9c934eb17988f (commit)
      by Carsten Ziegeler
      on Tue Nov 24 16:00:22 2009 +0000

- Log -----------------------------------------------------------------
org.apache.sling.jcr.classloader-3.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 9609c02  Import initial Sling source
     new a0c6294  Ignore Eclipse and build artifacts
     new 04ddd72  Fix scm settings
     new ca2435c  Ignore Eclipse .settings
     new 9dfa564  Fix license headers.
     new c9cb58c  Fix license headers.
     new 09b3323  Fix license headers.
     new 2b850ab  SLING-18 scr plugin isn't enabled in jackrabbit-classloader, scripting-core and scripting-jsp
     new 9aa1c77  Remove sling module versions from parent pom to make release management easier. Add some more versions of dependencies to parent pom.
     new eafdadf  SLING-83 Move modules according to the new module structure
     new 35062bd  SLING-83 Fix SVN location, project name and java packages
     new d5ebe13  SLING-83: Fix relative paths to parent poms.
     new 81ea614  SLING-83 make artifactId fully qualified
     new c4dadf9  Add version attribute to package exports
     new 6eb3033  Ensure the Repository Classloader facade is also an URLClassLoader (just like the RepositoryClassLoader itself)
     new 019a135  Clean up code, remove unused imports etc.
     new 930a6c0  SLING-176 Include jackrabbit-jcr-commons classes in the bundle as jcr/api does not provide them any more.
     new 6a2d9a9  Use OSGi core and cmpendium jars from Felix project.
     new 23bd3b9  SLING-204 - add svn ignore patterns for intellij
     new d332a16  SLING-317 - rename /classes to /var/classes
     new 1d30440  Move licence and notice to top level dir.
     new e73f2bf  Add incubator disclaimer.
     new 19ef98b  Go back to simpler notice file format.
     new 33c124c  Eclude maven-eclipse.xml generated by the maven eclipse plugin.
     new 8f8460b  SLING-442: Clean up exports, imports, dependencies and used plugins.
     new d9ad7c5  SLING-479 Fix @scr.tags:   - normalize metadata attribute settings to "no"   - ensure proper metadata and ds attributes are set   - create metatype.properties files where required   - fix metatype.properties files
     new 5914833  SLING-483: Add excludes for javadocs (WiP)
     new 256033c  SLING-495 - NOTICE files generated using mknotice script
     new 0ba9480  SLING-495 - NOTICE files updated according to changes in revision 662927
     new ede0ef1  SLING-495 - NOTICE files regenerated with revision 663097 changes
     new 1e54dd4  Use released version of parent pom.
     new 74074ba  Use released versions (or soon to be released versions).
     new 46c8880  [maven-release-plugin] prepare release org.apache.sling.jcr.classloader-2.0.0-incubator
     new cd4e1cc  [maven-release-plugin] prepare for next development iteration
     new d578763  Set version to next development version.
     new 9d580ae  Fix reference to parent pom.
     new 37da054  SLING-521: Restore more notice files.
     new f1aeeac  SLING-471 Apply patch by Niklas Gustavsson (slightly modified)
     new 01df96a  SLING-521: Separate between notice files for bin and src dists.
     new 4b46564  SLING-521: Separate between notice files for bin and src dists.
     new b628ff4  Change copyright year to 2008.
     new e10ce9b  Update to released versions.
     new 0606f94  [maven-release-plugin] prepare release org.apache.sling.jcr.classloader-2.0.2-incubator
     new 69a580b  [maven-release-plugin] prepare for next development iteration
     new 5efcf8d  Use latest snapshots again to make project buildable.
     new 220cd0d  Use released versions.
     new 004b5c2  Use released parent pom where possible.
     new 554dfbe  SLING-555 : Update all poms to use the latest parent pom; update parent pom to include the incubator repo for plugins and use latest plugins.
     new dade028  SLING-769 Explicit Jackrabbit Dependency Version
     new c07b5e1  SLING-769 Revert Jackrabbit dependency to 1.4.x because the 1.4.1 classloader is the same as the 1.5 classloader (Jackrabbit loves to release new versions without changes)
     new 005f341  SLING-808 : Increase version to 5-incubator-SNAPSHOT
     new 972ae25  Update notice files to include 2009 in copyright statement.
     new ad2d9df  SLING-811 Reduce DependencyManagement in the parent pom and add explicit versions to the modules
     new c8cc0b9  SLING-829 Cosmetics to the bundle/project names
     new ce93f86  SLING-829 Ensure Apache Sling prefix on all configuration names
     new 022db7d  SLING-858 - Let the SCR plugin create correct bind/unbind implementations for us.
     new 870ab6a  SLING-865 : Move to bundles
     new c03c85d  SLING-865 : Adjust reactor pom and svn information in each module.
     new bcbf408  SLING-865 : Adjust path to parent pom and add profiles for samples and contrib
     new 6b3c079  Use release parent pom
     new df7745a  [maven-release-plugin] prepare release org.apache.sling.jcr.classloader-2.0.4-incubator
     new dc1b1db  [maven-release-plugin] prepare for next development iteration
     new e31b679  Use next dev version of parent pom
     new e727d40  Set parent pom to released version.
     new 0a4435b  Move Sling to new TLP location
     new 468500e  SLING-1011 : Remove disclaimer file.
     new 332a7ae  SLING-1011 : Adjust svn location
     new dfa43d2  SLING-1011 : Remove disclaimer from readme's, adjust links to webite, fix versions in poms.
     new e415dca  SLING-1033 Upgrade to Sling parent POM 6 (and ensure web app has the leglize stuff, too)
     new da33ba2  SLING-1048 : Implement the dynamic class loader provider interface and deprecate the repository class loader interface.
     new 31a142c  Use provided parent class loader instead of own class loader
     new dea3efa  Experimental class loader writer for scripting engines.
     new 51c755a  Fix typo which disabled the last modified check.
     new a94152b  Fix wrong org.apache.sling.commons.classloader version number
     new 8f135ba  Update to latest Sling releases.
     new dd74c87  [maven-release-plugin] prepare release org.apache.sling.jcr.classloader-2.0.6
     new e976428  [maven-release-plugin] prepare for next development iteration
     new 4c0188f  SLING-1150 : Session is not closed in getLastModified SLING-1146 : DynamicClassLoaderProvider and ClassLoaderWriter should not be a service factory and refactored session handling SLING-1151 : Don't export jackrabbit classes
     new 0a7b91e  SLING-1152 : Remove deprecated interface RepositoryClassLoaderProvider (and implementations)
     new 0cc78a3  Update to latest release.
     new 7c38541  SLING-1191 : Dynamic class loader providers are not reloaded when bundles are updated/installed etc. Add new release method to the dynamic class loader provider. This allows a provider to react on bundle/class loader changes.
     new 5d497cc  Prepare release.
     new 653ab3d  [maven-release-plugin] prepare release org.apache.sling.jcr.classloader-3.0.0
     new a7f9dc1  [maven-scm] copy for tag org.apache.sling.jcr.classloader-3.0.0

The 84 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-jcr-classloader] 07/08: [maven-release-plugin] prepare release org.apache.sling.jcr.classloader-3.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit 653ab3de2bfdf3109444f90af581fb3ba4bfe80f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Nov 24 15:59:44 2009 +0000

    [maven-release-plugin] prepare release org.apache.sling.jcr.classloader-3.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader@883739 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 68b9c93..5fe0135 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
     </parent>
 
     <artifactId>org.apache.sling.jcr.classloader</artifactId>
-    <version>3.0.0-SNAPSHOT</version>
+    <version>3.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Repository ClassLoader</name>
@@ -37,9 +37,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/classloader</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.classloader-3.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.classloader-3.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.classloader-3.0.0</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-classloader] 08/08: [maven-scm] copy for tag org.apache.sling.jcr.classloader-3.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit a7f9dc1491bf89958a9c2a153dd9c934eb17988f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Nov 24 16:00:22 2009 +0000

    [maven-scm] copy for tag org.apache.sling.jcr.classloader-3.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.classloader-3.0.0@883741 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-classloader] 06/08: Prepare release.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit 5d497cc5fa279034ccb6fcb5852d4851b83e9fbb
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Nov 24 15:58:14 2009 +0000

    Prepare release.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader@883738 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 4bcb96c..68b9c93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,7 +97,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.classloader</artifactId>
-            <version>1.1.0-SNAPSHOT</version>
+            <version>1.1.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-classloader] 05/08: SLING-1191 : Dynamic class loader providers are not reloaded when bundles are updated/installed etc. Add new release method to the dynamic class loader provider. This allows a provider to react on bundle/class loader changes.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit 7c385410fefce9d54cc44f6c25077e8a9a9e86d1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Nov 17 11:12:48 2009 +0000

    SLING-1191 : Dynamic class loader providers are not reloaded when bundles are updated/installed etc.
    Add new release method to the dynamic class loader provider. This allows a provider to react on bundle/class loader changes.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader@881245 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                             |  3 +--
 .../internal/DynamicClassLoaderProviderImpl.java    | 21 ++++++++++-----------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/pom.xml b/pom.xml
index 8476901..4bcb96c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,6 @@
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
         <version>7</version>
-        <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 
     <artifactId>org.apache.sling.jcr.classloader</artifactId>
@@ -98,7 +97,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.classloader</artifactId>
-            <version>1.0.0</version>
+            <version>1.1.0-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git a/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java b/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
index 8dd5f3c..7befe0d 100644
--- a/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
+++ b/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
@@ -87,8 +87,6 @@ public class DynamicClassLoaderProviderImpl
 
     private String[] classPath;
 
-    private RepositoryClassLoaderFacade facade;
-
     /** @scr.reference policy="dynamic" */
     private MimeTypeService mimeTypeService;
 
@@ -116,15 +114,20 @@ public class DynamicClassLoaderProviderImpl
      * @see org.apache.sling.commons.classloader.DynamicClassLoaderProvider#getClassLoader(ClassLoader)
      */
     public ClassLoader getClassLoader(final ClassLoader parent) {
-        if ( this.facade == null ) {
-            this.facade = new RepositoryClassLoaderFacade(this, parent, this.getClassPaths());
-        }
-
-        return this.facade;
+        return new RepositoryClassLoaderFacade(this, parent, this.getClassPaths());
     }
 
+    /**
+     * @see org.apache.sling.commons.classloader.DynamicClassLoaderProvider#release(java.lang.ClassLoader)
+     */
+    public void release(ClassLoader classLoader) {
+        if ( classLoader instanceof RepositoryClassLoaderFacade ) {
+            ((RepositoryClassLoaderFacade)classLoader).destroy();
+        }
+    }
     //---------- SCR Integration ----------------------------------------------
 
+
     /**
      * @see org.apache.sling.commons.classloader.ClassLoaderWriter#delete(java.lang.String)
      */
@@ -415,10 +418,6 @@ public class DynamicClassLoaderProviderImpl
      * @param componentContext
      */
     protected void deactivate(final ComponentContext componentContext) {
-        if ( this.facade != null) {
-            this.facade.destroy();
-            this.facade = null;
-        }
         if ( this.readSession != null ) {
             this.readSession.logout();
             this.readSession = null;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-classloader] 03/08: SLING-1152 : Remove deprecated interface RepositoryClassLoaderProvider (and implementations)

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit 0a7b91efa9d825a9ccbf011ba209d486d1218087
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Oct 12 08:58:00 2009 +0000

    SLING-1152 : Remove deprecated interface RepositoryClassLoaderProvider (and implementations)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader@824267 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  5 +-
 .../classloader/RepositoryClassLoaderProvider.java | 35 ---------
 .../internal/BundleProxyClassLoader.java           | 76 -------------------
 .../RepositoryClassLoaderProviderImpl.java         | 86 ----------------------
 .../OSGI-INF/metatype/metatype.properties          |  7 --
 5 files changed, 1 insertion(+), 208 deletions(-)

diff --git a/pom.xml b/pom.xml
index 6a0958a..4d5b550 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
     </parent>
 
     <artifactId>org.apache.sling.jcr.classloader</artifactId>
-    <version>2.0.7-SNAPSHOT</version>
+    <version>3.0.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Repository ClassLoader</name>
@@ -58,9 +58,6 @@
                         <Bundle-Category>
                             sling,jcr,jackrabbit
                         </Bundle-Category>
-                        <Export-Package>
-                            org.apache.sling.jcr.classloader;version=${pom.version}
-                        </Export-Package>
                         <Private-Package>
                             org.apache.sling.jcr.classloader.internal.*,
                             org.apache.jackrabbit;
diff --git a/src/main/java/org/apache/sling/jcr/classloader/RepositoryClassLoaderProvider.java b/src/main/java/org/apache/sling/jcr/classloader/RepositoryClassLoaderProvider.java
deleted file mode 100644
index 66af2f4..0000000
--- a/src/main/java/org/apache/sling/jcr/classloader/RepositoryClassLoaderProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sling.jcr.classloader;
-
-import javax.jcr.RepositoryException;
-
-/**
- * The <code>RepositoryClassLoaderProvider</code>
- *
- * @deprecated Use the {@link org.apache.sling.commons.classloader.DynamicClassLoaderManager}
- * instead.
- */
-@Deprecated
-public interface RepositoryClassLoaderProvider {
-
-    ClassLoader getClassLoader(String owner) throws RepositoryException;
-    void ungetClassLoader(ClassLoader classLoader);
-
-}
diff --git a/src/main/java/org/apache/sling/jcr/classloader/internal/BundleProxyClassLoader.java b/src/main/java/org/apache/sling/jcr/classloader/internal/BundleProxyClassLoader.java
deleted file mode 100644
index 8bb76c1..0000000
--- a/src/main/java/org/apache/sling/jcr/classloader/internal/BundleProxyClassLoader.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sling.jcr.classloader.internal;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-
-import org.osgi.framework.Bundle;
-
-/**
- * The <code>BundleProxyDelegate</code> TODO
- */
-/* package */ class BundleProxyClassLoader extends ClassLoader {
-
-    private Bundle bundle;
-    private ClassLoader parent;
-
-    public BundleProxyClassLoader(Bundle bundle) {
-        this.bundle = bundle;
-    }
-
-    public BundleProxyClassLoader(Bundle bundle, ClassLoader parent) {
-        super(parent);
-        this.parent = parent;
-        this.bundle = bundle;
-    }
-
-    // Note: Both ClassLoader.getResources(...) and bundle.getResources(...) consult
-    // the boot classloader. As a result, BundleProxyClassLoader.getResources(...)
-    // might return duplicate results from the boot classloader. Prior to Java 5
-    // Classloader.getResources was marked final. If your target environment requires
-    // at least Java 5 you can prevent the occurence of duplicate boot classloader
-    // resources by overriding ClassLoader.getResources(...) instead of
-    // ClassLoader.findResources(...).
-    @SuppressWarnings("unchecked")
-    public Enumeration<URL> findResources(String name) throws IOException {
-        return this.bundle.getResources(name);
-    }
-
-    public URL findResource(String name) {
-        return this.bundle.getResource(name);
-    }
-
-    public Class<?> findClass(String name) throws ClassNotFoundException {
-        return this.bundle.loadClass(name);
-    }
-
-    public URL getResource(String name) {
-        return (this.parent == null) ? this.findResource(name) : super.getResource(name);
-    }
-
-    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
-        Class<?> clazz = (this.parent == null) ? this.findClass(name) : super.loadClass(name, false);
-        if (resolve) {
-            super.resolveClass(clazz);
-        }
-        return clazz;
-    }
-}
diff --git a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java b/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java
deleted file mode 100644
index 389a585..0000000
--- a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sling.jcr.classloader.internal;
-
-import org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider;
-import org.osgi.framework.Bundle;
-import org.osgi.service.component.ComponentContext;
-
-/**
- * The <code>RepositoryClassLoaderProviderImpl</code> TODO
- *
- * @scr.component inherit="false" label="%deprecatedloader.name"
- *      description="%deprecatedloader.description"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- * @scr.property name="service.description"
- *      value="Provides Repository ClassLoaders"
- * @scr.service servicefactory="true" interface="RepositoryClassLoaderProvider"
- * @scr.property nameRef="DynamicClassLoaderProviderImpl.CLASS_PATH_PROP" valueRefs0="DynamicClassLoaderProviderImpl.CLASS_PATH_DEFAULT"
- * @scr.property nameRef="DynamicClassLoaderProviderImpl.OWNER_PROP" valueRef="DynamicClassLoaderProviderImpl.OWNER_DEFAULT"
- * @scr.reference name="repository" interface="org.apache.sling.jcr.api.SlingRepository"
- * @scr.reference name="mimeTypeService" policy="dynamic" interface="org.apache.sling.commons.mime.MimeTypeService"
- */
-public class RepositoryClassLoaderProviderImpl
-        extends DynamicClassLoaderProviderImpl
-        implements RepositoryClassLoaderProvider {
-
-    private BundleProxyClassLoader parent;
-
-    private RepositoryClassLoaderFacade classLoaderFacade;
-
-    /**
-     * @see org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider#getClassLoader(java.lang.String)
-     */
-    public ClassLoader getClassLoader(String owner) {
-        if (this.classLoaderFacade == null) {
-            this.classLoaderFacade = new RepositoryClassLoaderFacade(this, this.parent,
-                this.getClassPaths());
-        }
-
-        return this.classLoaderFacade;
-    }
-
-    /**
-     * @see org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider#ungetClassLoader(java.lang.ClassLoader)
-     */
-    public void ungetClassLoader(ClassLoader classLoader) {
-        // nothing to do
-    }
-
-    protected void activate(ComponentContext componentContext) {
-        super.activate(componentContext);
-        final Bundle owner = componentContext.getUsingBundle();
-
-        // if there is no using bundle, we have an error !!
-        if (owner == null) {
-            throw new IllegalStateException("Using Bundle expected. Is this a servicefactory component ?");
-        }
-        this.parent = new BundleProxyClassLoader(owner, null);
-    }
-
-    @SuppressWarnings("unchecked")
-    protected void deactivate(ComponentContext componentContext) {
-        if ( this.classLoaderFacade != null ) {
-            this.classLoaderFacade.destroy();
-            this.classLoaderFacade = null;
-        }
-        this.parent = null;
-        super.deactivate(componentContext);
-    }
-}
diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties
index 49b1383..247648b 100644
--- a/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ b/src/main/resources/OSGI-INF/metatype/metatype.properties
@@ -22,13 +22,6 @@
 # descriptions as used in the metatype.xml descriptor generated by the
 # the Sling SCR plugin
 
-deprecatedloader.name = Apache Sling Repository Class Loader Factory
-deprecatedloader.description = Configuration for the Repository Class Loader Factory. This \
- configuration applies to all clients of the factory even though each Bundle \
- using the factory retrieves its own factory. The class path of the created \
- Repository Class Loaders is configurable and the class loaders delegate use \
- the bundle asking for the factory as the parent class loader.
-
 loader.name = Apache Sling Repository Class Loader Factory
 loader.description = Configuration for the Repository Class Loader. The class path of the created \
  Repository Class Loaders is configurable.

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-classloader] 04/08: Update to latest release.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit 0cc78a3954f35e5adc01d5af28ee87c62cd1d728
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Oct 14 06:39:29 2009 +0000

    Update to latest release.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader@825023 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 4d5b550..8476901 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,7 +98,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.classloader</artifactId>
-            <version>0.9.0</version>
+            <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-classloader] 02/08: SLING-1150 : Session is not closed in getLastModified SLING-1146 : DynamicClassLoaderProvider and ClassLoaderWriter should not be a service factory and refactored session handling SLING-1151 : Don't export jackrabbit classes

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit 4c0188fd212b88b577d4ebd372a4e7961a18b939
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Oct 12 08:53:33 2009 +0000

    SLING-1150 : Session is not closed in getLastModified
    SLING-1146 : DynamicClassLoaderProvider and ClassLoaderWriter should not be a service factory and refactored session handling
    SLING-1151 : Don't export jackrabbit classes
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader@824266 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  24 +-
 ...pl.java => DynamicClassLoaderProviderImpl.java} | 165 ++++----
 .../internal/RepositoryClassLoaderFacade.java      |  73 +---
 .../RepositoryClassLoaderProviderImpl.java         | 425 ++-------------------
 .../OSGI-INF/metatype/metatype.properties          |   8 +-
 5 files changed, 138 insertions(+), 557 deletions(-)

diff --git a/pom.xml b/pom.xml
index d643d20..6a0958a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>6</version>
+        <version>7</version>
         <relativePath>../../../parent/pom.xml</relativePath>
     </parent>
 
@@ -59,14 +59,14 @@
                             sling,jcr,jackrabbit
                         </Bundle-Category>
                         <Export-Package>
-                            org.apache.sling.jcr.classloader;version=${pom.version},
-                            org.apache.jackrabbit.classloader;
-                            org.apache.jackrabbit.net;version=1.4
+                            org.apache.sling.jcr.classloader;version=${pom.version}
                         </Export-Package>
                         <Private-Package>
                             org.apache.sling.jcr.classloader.internal.*,
                             org.apache.jackrabbit;
+                            org.apache.jackrabbit.classloader;
                             org.apache.jackrabbit.name;
+                            org.apache.jackrabbit.net;
                             org.apache.jackrabbit.util;split-package:=merge-first
                         </Private-Package>
                     </instructions>
@@ -88,31 +88,38 @@
         </plugins>
     </reporting>
     <dependencies>
+       <dependency>
+           <groupId>javax.jcr</groupId>
+           <artifactId>jcr</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.jcr.api</artifactId>
             <version>2.0.2-incubator</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.classloader</artifactId>
             <version>0.9.0</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.mime</artifactId>
             <version>2.1.0-incubator</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-classloader</artifactId>
-            <version>1.4.1</version>
+            <version>1.5.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-jcr-commons</artifactId>
-            <version>1.4.2</version>
+            <version>1.6.0</version>
             <scope>compile</scope>
         </dependency>
         <dependency>
@@ -127,13 +134,14 @@
             <groupId>commons-collections</groupId>
             <artifactId>commons-collections</artifactId>
             <version>3.2.1</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.felix</groupId>
+            <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.apache.felix</groupId>
+            <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
     </dependencies>
diff --git a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java b/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
similarity index 76%
copy from src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java
copy to src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
index 8187c3a..8dd5f3c 100644
--- a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java
+++ b/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
@@ -25,7 +25,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Dictionary;
-import java.util.Iterator;
 
 import javax.jcr.Item;
 import javax.jcr.Node;
@@ -34,50 +33,52 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 
-import org.apache.commons.collections.BidiMap;
-import org.apache.commons.collections.bidimap.DualHashBidiMap;
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
 import org.apache.sling.commons.classloader.DynamicClassLoaderProvider;
 import org.apache.sling.commons.mime.MimeTypeService;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider;
-import org.osgi.framework.Bundle;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The <code>RepositoryClassLoaderProviderImpl</code> TODO
+ * The <code>DynamicClassLoaderProviderImpl</code> TODO
  *
- * @scr.component immediate="false" label="%loader.name"
+ * @scr.component label="%loader.name"
  *      description="%loader.description"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.property name="service.description"
  *      value="Provides Repository ClassLoaders"
- * @scr.service servicefactory="true"
+ * @scr.service interface="DynamicClassLoaderProvider"
+ * @scr.service interface="ClassLoaderWriter"
  */
-public class RepositoryClassLoaderProviderImpl
-        implements RepositoryClassLoaderProvider, DynamicClassLoaderProvider, ClassLoaderWriter {
+public class DynamicClassLoaderProviderImpl
+        implements DynamicClassLoaderProvider, ClassLoaderWriter {
 
     /** default log */
-    private static final Logger log = LoggerFactory.getLogger(RepositoryClassLoaderFacade.class);
+    private final Logger log = LoggerFactory.getLogger(RepositoryClassLoaderFacade.class);
 
     /**
-     * @scr.property values0="/var/classes"
+     * @scr.property valueRefs0="CLASS_PATH_DEFAULT"
      */
     public static final String CLASS_PATH_PROP = "classpath";
 
+    public static final String CLASS_PATH_DEFAULT = "/var/classes";
+
     /**
      * @scr.property valueRef="OWNER_DEFAULT"
      */
     public static final String OWNER_PROP = "owner";
 
-    // JSP Class Loader class path will be injected to the class loader !
-    private static final String[] CLASS_PATH_DEFAULT = { };
+    /** Default class loader owner. */
+    public static final String OWNER_DEFAULT = "admin";
+
+    /** The owner of the class loader / jcr user. */
+    private String classLoaderOwner;
 
-    private static final String OWNER_DEFAULT = "admin";
 
-    private BidiMap loaders = new DualHashBidiMap();
+    /** JSP Class Loader class path will be injected to the class loader. */
+    private static final String[] CLASS_PATH_EMPTY = { };
 
     /**
      * @scr.reference
@@ -86,44 +87,26 @@ public class RepositoryClassLoaderProviderImpl
 
     private String[] classPath;
 
-    private String classLoaderOwner;
-
-    private BundleProxyClassLoader parent;
+    private RepositoryClassLoaderFacade facade;
 
     /** @scr.reference policy="dynamic" */
     private MimeTypeService mimeTypeService;
 
-    public ClassLoader getClassLoader(String owner) {
-        String classLoaderOwner = this.getClassLoaderOwner(owner);
-        RepositoryClassLoaderFacade loader =
-            (RepositoryClassLoaderFacade) this.loaders.get(classLoaderOwner);
-        if (loader == null) {
-            loader = new RepositoryClassLoaderFacade(this, this.parent,
-                classLoaderOwner, this.classPath);
-            this.loaders.put(classLoaderOwner, loader);
-        }
-
-        return loader;
-    }
+    /** The read session. */
+    private Session readSession;
 
-    public void ungetClassLoader(ClassLoader classLoader) {
-        // nothing to do
-    }
-
-    //---------- Support for RepositoryClassLoaderFacade ----------------------
-
-    /* package */ Session getSession(String owner) throws RepositoryException {
+    Session getSession() throws RepositoryException {
         // get an administrative session for potentiall impersonation
-        Session admin = this.repository.loginAdministrative(null);
+        final Session admin = this.repository.loginAdministrative(null);
 
         // do use the admin session, if the admin's user id is the same as owner
-        if (admin.getUserID().equals(owner)) {
+        if (admin.getUserID().equals(this.getOwnerId())) {
             return admin;
         }
 
         // else impersonate as the owner and logout the admin session again
         try {
-            return admin.impersonate(new SimpleCredentials(owner, new char[0]));
+            return admin.impersonate(new SimpleCredentials(this.getOwnerId(), new char[0]));
         } finally {
             admin.logout();
         }
@@ -133,17 +116,11 @@ public class RepositoryClassLoaderProviderImpl
      * @see org.apache.sling.commons.classloader.DynamicClassLoaderProvider#getClassLoader(ClassLoader)
      */
     public ClassLoader getClassLoader(final ClassLoader parent) {
-        // we just make up a unique identifier
-        final String classLoaderOwner = "DynamicClassLoaderProvider:" + parent.hashCode();
-        RepositoryClassLoaderFacade loader =
-            (RepositoryClassLoaderFacade) this.loaders.get(classLoaderOwner);
-        if (loader == null) {
-            loader = new RepositoryClassLoaderFacade(this, parent,
-                    this.classLoaderOwner, this.classPath);
-            this.loaders.put(classLoaderOwner, loader);
+        if ( this.facade == null ) {
+            this.facade = new RepositoryClassLoaderFacade(this, parent, this.getClassPaths());
         }
 
-        return loader;
+        return this.facade;
     }
 
     //---------- SCR Integration ----------------------------------------------
@@ -156,7 +133,7 @@ public class RepositoryClassLoaderProviderImpl
         Node parentNode = null;
         Session session = null;
         try {
-            session = getSession(this.classLoaderOwner);
+            session = getSession();
             if (session.itemExists(name)) {
                 Item fileItem = session.getItem(name);
                 parentNode = fileItem.getParent();
@@ -194,7 +171,7 @@ public class RepositoryClassLoaderProviderImpl
             oldName = cleanPath(oldName);
             newName = cleanPath(newName);
 
-            session = this.getSession(this.classLoaderOwner);
+            session = this.getSession();
             session.getWorkspace().move(oldName, newName);
             return true;
         } catch (RepositoryException re) {
@@ -251,7 +228,7 @@ public class RepositoryClassLoaderProviderImpl
         return false;
     }
 
-    private static void checkNode(Node node, String path) {
+    private void checkNode(Node node, String path) {
         if (node != null && node.isModified()) {
             try {
                 node.refresh(false);
@@ -279,11 +256,11 @@ public class RepositoryClassLoaderProviderImpl
 
     private static class RepositoryOutputStream extends ByteArrayOutputStream {
 
-        private final RepositoryClassLoaderProviderImpl repositoryOutputProvider;
+        private final DynamicClassLoaderProviderImpl repositoryOutputProvider;
 
         private final String fileName;
 
-        RepositoryOutputStream(RepositoryClassLoaderProviderImpl repositoryOutputProvider,
+        RepositoryOutputStream(DynamicClassLoaderProviderImpl repositoryOutputProvider,
                 String fileName) {
             this.repositoryOutputProvider = repositoryOutputProvider;
             this.fileName = fileName;
@@ -295,7 +272,7 @@ public class RepositoryClassLoaderProviderImpl
             Node parentNode = null;
             Session session = null;
             try {
-                session = repositoryOutputProvider.getSession(repositoryOutputProvider.classLoaderOwner);
+                session = repositoryOutputProvider.getSession();
                 final int lastPos = fileName.lastIndexOf('/');
                 if ( lastPos != -1 ) {
                     repositoryOutputProvider.mkdirs(session, fileName.substring(0, lastPos));
@@ -366,11 +343,11 @@ public class RepositoryClassLoaderProviderImpl
 
                 parentNode.save();
             } catch (RepositoryException re) {
-                log.error("Cannot write file " + fileName, re);
+                repositoryOutputProvider.log.error("Cannot write file " + fileName, re);
                 throw new IOException("Cannot write file " + fileName
                     + ", reason: " + re.toString());
             } finally {
-                checkNode(parentNode, fileName);
+                repositoryOutputProvider.checkNode(parentNode, fileName);
                 if ( session != null ) {
                     session.logout();
                 }
@@ -386,7 +363,7 @@ public class RepositoryClassLoaderProviderImpl
         final String path = cleanPath(fileName) + "/jcr:content/jcr:data";
         Session session = null;
         try {
-            session = getSession(this.classLoaderOwner);
+            session = this.getReadSession();
             if ( session.itemExists(path) ) {
                 final Property prop = (Property)session.getItem(path);
                 return prop.getStream();
@@ -395,10 +372,6 @@ public class RepositoryClassLoaderProviderImpl
         } catch (RepositoryException re) {
             throw (IOException) new IOException(
                         "Failed to get InputStream for " + fileName).initCause(re);
-        } finally {
-            if ( session != null ) {
-                session.logout();
-            }
         }
     }
 
@@ -409,7 +382,7 @@ public class RepositoryClassLoaderProviderImpl
         final String path = cleanPath(fileName) + "/jcr:content/jcr:lastModified";
         Session session = null;
         try {
-            session = getSession(this.classLoaderOwner);
+            session = this.getReadSession();
             if ( session.itemExists(path) ) {
                 final Property prop = (Property)session.getItem(path);
                 return prop.getLong();
@@ -422,40 +395,64 @@ public class RepositoryClassLoaderProviderImpl
         return -1;
     }
 
-    protected void activate(ComponentContext componentContext) {
+    /**
+     * Activate this component.
+     * @param componentContext
+     */
+    protected void activate(final ComponentContext componentContext) {
         @SuppressWarnings("unchecked")
         Dictionary properties = componentContext.getProperties();
 
         Object prop = properties.get(CLASS_PATH_PROP);
-        this.classPath = (prop instanceof String[]) ? (String[]) prop : CLASS_PATH_DEFAULT;
+        this.classPath = (prop instanceof String[]) ? (String[]) prop : CLASS_PATH_EMPTY;
 
         prop = properties.get(OWNER_PROP);
         this.classLoaderOwner = (prop instanceof String)? (String) prop : OWNER_DEFAULT;
+    }
 
-        Bundle owner = componentContext.getUsingBundle();
-
-        // if there is no using bundle, we have an error !!
-        if (owner == null) {
-            throw new IllegalStateException("Using Bundle expected. Is this a servicefactory component ?");
+    /**
+     * Deactivate this component
+     * @param componentContext
+     */
+    protected void deactivate(final ComponentContext componentContext) {
+        if ( this.facade != null) {
+            this.facade.destroy();
+            this.facade = null;
+        }
+        if ( this.readSession != null ) {
+            this.readSession.logout();
+            this.readSession = null;
         }
-
-        this.parent = new BundleProxyClassLoader(owner, null);
     }
 
-    @SuppressWarnings("unchecked")
-    protected void deactivate(ComponentContext componentContext) {
-        for (Iterator ci=this.loaders.values().iterator(); ci.hasNext(); ) {
-            RepositoryClassLoaderFacade cl = (RepositoryClassLoaderFacade) ci.next();
-            cl.destroy();
-            ci.remove();
-        }
+    /**
+     * Return the owner id
+     */
+    protected String getOwnerId() {
+        return this.classLoaderOwner;
+    }
 
-        this.parent = null;
+    /**
+     * Return the configured class paths
+     */
+    protected String[] getClassPaths() {
+        return this.classPath;
     }
 
-    //---------- internal -----------------------------------------------------
+    public synchronized Session getReadSession() throws RepositoryException {
+        // check current session
+        if (this.readSession != null) {
+            if (this.readSession.isLive()) {
+                return this.readSession;
+            }
 
-    private String getClassLoaderOwner(String userId) {
-        return this.classLoaderOwner;
+            // current session is not live anymore, drop
+            this.readSession.logout();
+            this.readSession = null;
+        }
+
+        // no session currently, acquire and return
+        this.readSession = this.getSession();
+        return this.readSession;
     }
 }
diff --git a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderFacade.java b/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderFacade.java
index 9324105..f33a834 100644
--- a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderFacade.java
+++ b/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderFacade.java
@@ -24,7 +24,6 @@ import java.net.URLClassLoader;
 import java.util.Enumeration;
 
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 
 import org.apache.jackrabbit.classloader.DynamicRepositoryClassLoader;
 import org.slf4j.Logger;
@@ -36,21 +35,18 @@ import org.slf4j.LoggerFactory;
 class RepositoryClassLoaderFacade extends URLClassLoader {
 
     /** default log */
-    private static final Logger log = LoggerFactory.getLogger(RepositoryClassLoaderFacade.class);
+    private final Logger log = LoggerFactory.getLogger(RepositoryClassLoaderFacade.class);
 
     private static final URL[] NO_URLS = new URL[0];
 
-    private RepositoryClassLoaderProviderImpl classLoaderProvider;
+    private DynamicClassLoaderProviderImpl classLoaderProvider;
     private ClassLoader parent;
-    private String sessionOwner;
-    private Session session;
     private String[] classPath;
     private DynamicRepositoryClassLoader delegate;
 
     public RepositoryClassLoaderFacade(
-            RepositoryClassLoaderProviderImpl classLoaderProvider,
+            DynamicClassLoaderProviderImpl classLoaderProvider,
             ClassLoader parent,
-            String sessionOwner,
             String[] classPath) {
 
         // no parent class loader, we delegate to repository class loaders
@@ -59,26 +55,6 @@ class RepositoryClassLoaderFacade extends URLClassLoader {
         this.classLoaderProvider = classLoaderProvider;
         this.parent = parent;
         this.classPath = classPath;
-        this.sessionOwner = sessionOwner;
-    }
-
-    public void addPath(String path) {
-        // create new class path
-        String[] newClassPath = new String[this.classPath.length+1];
-        System.arraycopy(this.classPath, 0, newClassPath, 0, this.classPath.length);
-        newClassPath[this.classPath.length] = path;
-        this.classPath = newClassPath;
-
-        // destroy the delegate and have a new one created
-        if (this.delegate != null) {
-            DynamicRepositoryClassLoader oldLoader = this.delegate;
-            this.delegate = null;
-            oldLoader.destroy();
-        }
-    }
-
-    public String[] getClassPath() {
-        return this.classPath.clone();
     }
 
     @Override
@@ -117,54 +93,25 @@ class RepositoryClassLoaderFacade extends URLClassLoader {
         }
     }
 
-    //---------- Reference counting support -----------------------------------
-
-    /* package */ void destroy() {
+    void destroy() {
         if (this.delegate != null) {
             this.delegate.destroy();
             this.delegate = null;
         }
-
-        if (this.session != null) {
-            this.session.logout();
-            this.session = null;
-        }
     }
 
     //---------- internal -----------------------------------------------------
 
-    private Session getSession() throws RepositoryException {
-        // check current session
-        if (this.session != null) {
-            if (this.session.isLive()) {
-                return this.session;
-            }
+    private synchronized DynamicRepositoryClassLoader getDelegateClassLoader() throws RepositoryException {
+        if ( this.delegate == null ) {
+            this.delegate = new DynamicRepositoryClassLoader( this.classLoaderProvider.getReadSession(), this.classPath, this.parent);
 
-            // drop delegate
-            if (this.delegate != null) {
-                this.delegate.destroy();
-                this.delegate = null;
-            }
-
-            // current session is not live anymore, drop
-            this.session.logout();
-            this.session = null;
-        }
-
-        // no session currently, acquire and return
-        this.session = this.classLoaderProvider.getSession(this.sessionOwner);
-        return this.session;
-    }
-
-    private DynamicRepositoryClassLoader getDelegateClassLoader() throws RepositoryException {
-        if (this.delegate != null) {
+        } else {
             if (this.delegate.isDirty()) {
-                this.delegate = this.delegate.reinstantiate(this.getSession(), this.parent);
+                this.delegate = this.delegate.reinstantiate(this.classLoaderProvider.getReadSession(), this.parent);
             }
-        } else {
-            this.delegate = new DynamicRepositoryClassLoader(this.getSession(), this.classPath, this.parent);
-        }
 
+        }
         return this.delegate;
     }
 
diff --git a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java b/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java
index 8187c3a..389a585 100644
--- a/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java
+++ b/src/main/java/org/apache/sling/jcr/classloader/internal/RepositoryClassLoaderProviderImpl.java
@@ -18,444 +18,69 @@
  */
 package org.apache.sling.jcr.classloader.internal;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Dictionary;
-import java.util.Iterator;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-
-import org.apache.commons.collections.BidiMap;
-import org.apache.commons.collections.bidimap.DualHashBidiMap;
-import org.apache.sling.commons.classloader.ClassLoaderWriter;
-import org.apache.sling.commons.classloader.DynamicClassLoaderProvider;
-import org.apache.sling.commons.mime.MimeTypeService;
-import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider;
 import org.osgi.framework.Bundle;
 import org.osgi.service.component.ComponentContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * The <code>RepositoryClassLoaderProviderImpl</code> TODO
  *
- * @scr.component immediate="false" label="%loader.name"
- *      description="%loader.description"
+ * @scr.component inherit="false" label="%deprecatedloader.name"
+ *      description="%deprecatedloader.description"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.property name="service.description"
  *      value="Provides Repository ClassLoaders"
- * @scr.service servicefactory="true"
+ * @scr.service servicefactory="true" interface="RepositoryClassLoaderProvider"
+ * @scr.property nameRef="DynamicClassLoaderProviderImpl.CLASS_PATH_PROP" valueRefs0="DynamicClassLoaderProviderImpl.CLASS_PATH_DEFAULT"
+ * @scr.property nameRef="DynamicClassLoaderProviderImpl.OWNER_PROP" valueRef="DynamicClassLoaderProviderImpl.OWNER_DEFAULT"
+ * @scr.reference name="repository" interface="org.apache.sling.jcr.api.SlingRepository"
+ * @scr.reference name="mimeTypeService" policy="dynamic" interface="org.apache.sling.commons.mime.MimeTypeService"
  */
 public class RepositoryClassLoaderProviderImpl
-        implements RepositoryClassLoaderProvider, DynamicClassLoaderProvider, ClassLoaderWriter {
-
-    /** default log */
-    private static final Logger log = LoggerFactory.getLogger(RepositoryClassLoaderFacade.class);
-
-    /**
-     * @scr.property values0="/var/classes"
-     */
-    public static final String CLASS_PATH_PROP = "classpath";
-
-    /**
-     * @scr.property valueRef="OWNER_DEFAULT"
-     */
-    public static final String OWNER_PROP = "owner";
-
-    // JSP Class Loader class path will be injected to the class loader !
-    private static final String[] CLASS_PATH_DEFAULT = { };
-
-    private static final String OWNER_DEFAULT = "admin";
-
-    private BidiMap loaders = new DualHashBidiMap();
-
-    /**
-     * @scr.reference
-     */
-    private SlingRepository repository;
-
-    private String[] classPath;
-
-    private String classLoaderOwner;
+        extends DynamicClassLoaderProviderImpl
+        implements RepositoryClassLoaderProvider {
 
     private BundleProxyClassLoader parent;
 
-    /** @scr.reference policy="dynamic" */
-    private MimeTypeService mimeTypeService;
-
-    public ClassLoader getClassLoader(String owner) {
-        String classLoaderOwner = this.getClassLoaderOwner(owner);
-        RepositoryClassLoaderFacade loader =
-            (RepositoryClassLoaderFacade) this.loaders.get(classLoaderOwner);
-        if (loader == null) {
-            loader = new RepositoryClassLoaderFacade(this, this.parent,
-                classLoaderOwner, this.classPath);
-            this.loaders.put(classLoaderOwner, loader);
-        }
-
-        return loader;
-    }
-
-    public void ungetClassLoader(ClassLoader classLoader) {
-        // nothing to do
-    }
-
-    //---------- Support for RepositoryClassLoaderFacade ----------------------
-
-    /* package */ Session getSession(String owner) throws RepositoryException {
-        // get an administrative session for potentiall impersonation
-        Session admin = this.repository.loginAdministrative(null);
-
-        // do use the admin session, if the admin's user id is the same as owner
-        if (admin.getUserID().equals(owner)) {
-            return admin;
-        }
-
-        // else impersonate as the owner and logout the admin session again
-        try {
-            return admin.impersonate(new SimpleCredentials(owner, new char[0]));
-        } finally {
-            admin.logout();
-        }
-    }
+    private RepositoryClassLoaderFacade classLoaderFacade;
 
     /**
-     * @see org.apache.sling.commons.classloader.DynamicClassLoaderProvider#getClassLoader(ClassLoader)
+     * @see org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider#getClassLoader(java.lang.String)
      */
-    public ClassLoader getClassLoader(final ClassLoader parent) {
-        // we just make up a unique identifier
-        final String classLoaderOwner = "DynamicClassLoaderProvider:" + parent.hashCode();
-        RepositoryClassLoaderFacade loader =
-            (RepositoryClassLoaderFacade) this.loaders.get(classLoaderOwner);
-        if (loader == null) {
-            loader = new RepositoryClassLoaderFacade(this, parent,
-                    this.classLoaderOwner, this.classPath);
-            this.loaders.put(classLoaderOwner, loader);
-        }
-
-        return loader;
-    }
-
-    //---------- SCR Integration ----------------------------------------------
-
-    /**
-     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#delete(java.lang.String)
-     */
-    public boolean delete(String name) {
-        name = cleanPath(name);
-        Node parentNode = null;
-        Session session = null;
-        try {
-            session = getSession(this.classLoaderOwner);
-            if (session.itemExists(name)) {
-                Item fileItem = session.getItem(name);
-                parentNode = fileItem.getParent();
-                fileItem.remove();
-                parentNode.save();
-                return true;
-            }
-        } catch (RepositoryException re) {
-            log.error("Cannot remove " + name, re);
-        } finally {
-            checkNode(parentNode, name);
-            if ( session != null ) {
-                session.logout();
-            }
-        }
-
-        // fall back to false if item does not exist or in case of error
-        return false;
-    }
-
-    /**
-     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getOutputStream(java.lang.String)
-     */
-    public OutputStream getOutputStream(String name) {
-        final String path = cleanPath(name);
-        return new RepositoryOutputStream(this, path);
-    }
-
-    /**
-     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#rename(java.lang.String, java.lang.String)
-     */
-    public boolean rename(String oldName, String newName) {
-        Session session = null;
-        try {
-            oldName = cleanPath(oldName);
-            newName = cleanPath(newName);
-
-            session = this.getSession(this.classLoaderOwner);
-            session.getWorkspace().move(oldName, newName);
-            return true;
-        } catch (RepositoryException re) {
-            log.error("Cannot rename " + oldName + " to " + newName, re);
-        } finally {
-            if ( session != null ) {
-                session.logout();
-            }
-        }
-
-        // fallback to false in case of error or non-existence of oldFileName
-        return false;
-    }
-
-    /**
-     * Creates a folder hierarchy in the repository.
-     */
-    private boolean mkdirs(final Session session, String path) {
-        Node parentNode = null;
-        try {
-            // quick test
-            if (session.itemExists(path) && session.getItem(path).isNode()) {
-                return true;
-            }
-
-            // check path walking it down
-            Node current = session.getRootNode();
-            String[] names = path.split("/");
-            for (int i = 0; i < names.length; i++) {
-                if (names[i] == null || names[i].length() == 0) {
-                    continue;
-                } else if (current.hasNode(names[i])) {
-                    current = current.getNode(names[i]);
-                } else {
-                    if (parentNode == null) {
-                        parentNode = current;
-                    }
-                    current = current.addNode(names[i], "nt:folder");
-                }
-            }
-
-            if (parentNode != null) {
-                parentNode.save();
-                return true;
-            }
-
-        } catch (RepositoryException re) {
-            log.error("Cannot create folder path " + path, re);
-        } finally {
-            checkNode(parentNode, path);
-        }
-
-        // false in case of error or no need to create
-        return false;
-    }
-
-    private static void checkNode(Node node, String path) {
-        if (node != null && node.isModified()) {
-            try {
-                node.refresh(false);
-            } catch (RepositoryException re) {
-                log.error("Cannot refresh node for " + path
-                    + " after failed save", re);
-            }
-        }
-    }
-
-    private String cleanPath(String path) {
-        // replace backslash by slash
-        path = path.replace('\\', '/');
-
-        // cut off trailing slash
-        while (path.endsWith("/")) {
-            path = path.substring(0, path.length() - 1);
-        }
-
-        if ( this.classPath == null || this.classPath.length == 0 ) {
-            return path;
-        }
-        return this.classPath[0] + path;
-    }
-
-    private static class RepositoryOutputStream extends ByteArrayOutputStream {
-
-        private final RepositoryClassLoaderProviderImpl repositoryOutputProvider;
-
-        private final String fileName;
-
-        RepositoryOutputStream(RepositoryClassLoaderProviderImpl repositoryOutputProvider,
-                String fileName) {
-            this.repositoryOutputProvider = repositoryOutputProvider;
-            this.fileName = fileName;
-        }
-
-        public void close() throws IOException {
-            super.close();
-
-            Node parentNode = null;
-            Session session = null;
-            try {
-                session = repositoryOutputProvider.getSession(repositoryOutputProvider.classLoaderOwner);
-                final int lastPos = fileName.lastIndexOf('/');
-                if ( lastPos != -1 ) {
-                    repositoryOutputProvider.mkdirs(session, fileName.substring(0, lastPos));
-                }
-                Node fileNode = null;
-                Node contentNode = null;
-                if (session.itemExists(fileName)) {
-                    Item item = session.getItem(fileName);
-                    if (item.isNode()) {
-                        Node node = item.isNode()
-                                ? (Node) item
-                                : item.getParent();
-                        if ("jcr:content".equals(node.getName())) {
-                            // replace the content properties of the jcr:content
-                            // node
-                            parentNode = node;
-                            contentNode = node;
-                        } else if (node.isNodeType("nt:file")) {
-                            // try to set the content properties of jcr:content
-                            // node
-                            parentNode = node;
-                            contentNode = node.getNode("jcr:content");
-                        } else { // fileName is a node
-                            // try to set the content properties of the node
-                            parentNode = node;
-                            contentNode = node;
-                        }
-                    } else {
-                        // replace property with an nt:file node (if possible)
-                        parentNode = item.getParent();
-                        String name = item.getName();
-                        fileNode = parentNode.addNode(name, "nt:file");
-                        item.remove();
-                    }
-                } else {
-                    int lastSlash = fileName.lastIndexOf('/');
-                    if (lastSlash <= 0) {
-                        parentNode = session.getRootNode();
-                    } else {
-                        Item parent = session.getItem(fileName.substring(0,
-                            lastSlash));
-                        if (!parent.isNode()) {
-                            // TODO: fail
-                        }
-                        parentNode = (Node) parent;
-                    }
-                    String name = fileName.substring(lastSlash + 1);
-                    fileNode = parentNode.addNode(name, "nt:file");
-                }
-
-                // if we have a file node, create the contentNode
-                if (fileNode != null) {
-                    contentNode = fileNode.addNode("jcr:content", "nt:resource");
-                }
-
-                final MimeTypeService mtService = this.repositoryOutputProvider.mimeTypeService;
-
-                String mimeType = (mtService == null ? null : mtService.getMimeType(fileName));
-                if (mimeType == null) {
-                    mimeType = "application/octet-stream";
-                }
-
-                contentNode.setProperty("jcr:lastModified",
-                    System.currentTimeMillis());
-                contentNode.setProperty("jcr:data", new ByteArrayInputStream(
-                    buf, 0, size()));
-                contentNode.setProperty("jcr:mimeType", mimeType);
-
-                parentNode.save();
-            } catch (RepositoryException re) {
-                log.error("Cannot write file " + fileName, re);
-                throw new IOException("Cannot write file " + fileName
-                    + ", reason: " + re.toString());
-            } finally {
-                checkNode(parentNode, fileName);
-                if ( session != null ) {
-                    session.logout();
-                }
-            }
+    public ClassLoader getClassLoader(String owner) {
+        if (this.classLoaderFacade == null) {
+            this.classLoaderFacade = new RepositoryClassLoaderFacade(this, this.parent,
+                this.getClassPaths());
         }
-    }
 
-    /**
-     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getInputStream(java.lang.String)
-     */
-    public InputStream getInputStream(String fileName)
-    throws IOException {
-        final String path = cleanPath(fileName) + "/jcr:content/jcr:data";
-        Session session = null;
-        try {
-            session = getSession(this.classLoaderOwner);
-            if ( session.itemExists(path) ) {
-                final Property prop = (Property)session.getItem(path);
-                return prop.getStream();
-            }
-            throw new FileNotFoundException("Unable to find " + fileName);
-        } catch (RepositoryException re) {
-            throw (IOException) new IOException(
-                        "Failed to get InputStream for " + fileName).initCause(re);
-        } finally {
-            if ( session != null ) {
-                session.logout();
-            }
-        }
+        return this.classLoaderFacade;
     }
 
     /**
-     * @see org.apache.sling.commons.classloader.ClassLoaderWriter#getLastModified(java.lang.String)
+     * @see org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider#ungetClassLoader(java.lang.ClassLoader)
      */
-    public long getLastModified(String fileName) {
-        final String path = cleanPath(fileName) + "/jcr:content/jcr:lastModified";
-        Session session = null;
-        try {
-            session = getSession(this.classLoaderOwner);
-            if ( session.itemExists(path) ) {
-                final Property prop = (Property)session.getItem(path);
-                return prop.getLong();
-            }
-        } catch (RepositoryException se) {
-            log.error("Cannot get last modification time for " + fileName, se);
-        }
-
-        // fallback to "non-existant" in case of problems
-        return -1;
+    public void ungetClassLoader(ClassLoader classLoader) {
+        // nothing to do
     }
 
     protected void activate(ComponentContext componentContext) {
-        @SuppressWarnings("unchecked")
-        Dictionary properties = componentContext.getProperties();
-
-        Object prop = properties.get(CLASS_PATH_PROP);
-        this.classPath = (prop instanceof String[]) ? (String[]) prop : CLASS_PATH_DEFAULT;
-
-        prop = properties.get(OWNER_PROP);
-        this.classLoaderOwner = (prop instanceof String)? (String) prop : OWNER_DEFAULT;
-
-        Bundle owner = componentContext.getUsingBundle();
+        super.activate(componentContext);
+        final Bundle owner = componentContext.getUsingBundle();
 
         // if there is no using bundle, we have an error !!
         if (owner == null) {
             throw new IllegalStateException("Using Bundle expected. Is this a servicefactory component ?");
         }
-
         this.parent = new BundleProxyClassLoader(owner, null);
     }
 
     @SuppressWarnings("unchecked")
     protected void deactivate(ComponentContext componentContext) {
-        for (Iterator ci=this.loaders.values().iterator(); ci.hasNext(); ) {
-            RepositoryClassLoaderFacade cl = (RepositoryClassLoaderFacade) ci.next();
-            cl.destroy();
-            ci.remove();
+        if ( this.classLoaderFacade != null ) {
+            this.classLoaderFacade.destroy();
+            this.classLoaderFacade = null;
         }
-
         this.parent = null;
-    }
-
-    //---------- internal -----------------------------------------------------
-
-    private String getClassLoaderOwner(String userId) {
-        return this.classLoaderOwner;
+        super.deactivate(componentContext);
     }
 }
diff --git a/src/main/resources/OSGI-INF/metatype/metatype.properties b/src/main/resources/OSGI-INF/metatype/metatype.properties
index af0a38d..49b1383 100644
--- a/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ b/src/main/resources/OSGI-INF/metatype/metatype.properties
@@ -22,13 +22,17 @@
 # descriptions as used in the metatype.xml descriptor generated by the
 # the Sling SCR plugin
 
-loader.name = Apache Sling Repository Class Loader Factory
-loader.description = Configuration for the Repository Class Loader Factory. This \
+deprecatedloader.name = Apache Sling Repository Class Loader Factory
+deprecatedloader.description = Configuration for the Repository Class Loader Factory. This \
  configuration applies to all clients of the factory even though each Bundle \
  using the factory retrieves its own factory. The class path of the created \
  Repository Class Loaders is configurable and the class loaders delegate use \
  the bundle asking for the factory as the parent class loader.
 
+loader.name = Apache Sling Repository Class Loader Factory
+loader.description = Configuration for the Repository Class Loader. The class path of the created \
+ Repository Class Loaders is configurable.
+
 classpath.name = Class Path
 classpath.description = The class path in the repository to use as the class \
  path for all created Repository Class Loaders. All Class Loaders are configured \

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-classloader] 01/08: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.classloader-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-classloader.git

commit e976428050e6c41c3d22460ba1e6b8bdc9d5e867
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Oct 7 13:21:46 2009 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader@822717 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index ed824c5..d643d20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
     </parent>
 
     <artifactId>org.apache.sling.jcr.classloader</artifactId>
-    <version>2.0.6</version>
+    <version>2.0.7-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Repository ClassLoader</name>
@@ -38,9 +38,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.classloader-2.0.6</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.classloader-2.0.6</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.classloader-2.0.6</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/classloader</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/classloader</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.