You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2010/01/26 11:47:51 UTC
svn commit: r903164 -
/sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
Author: cziegeler
Date: Tue Jan 26 10:47:50 2010
New Revision: 903164
URL: http://svn.apache.org/viewvc?rev=903164&view=rev
Log:
SLING-1311 : Rare exception "Servlet class not found" during compilation into the repository - synchronized path creation.
Modified:
sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
Modified: sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java?rev=903164&r1=903163&r2=903164&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java (original)
+++ sling/trunk/bundles/jcr/classloader/src/main/java/org/apache/sling/jcr/classloader/internal/DynamicClassLoaderProviderImpl.java Tue Jan 26 10:47:50 2010
@@ -69,6 +69,9 @@
public static final String CLASS_PATH_DEFAULT = "/var/classes";
+ /** Node type for packages/folders. */
+ private static final String NT_FOLDER = "nt:folder";
+
/**
* @scr.property valueRef="OWNER_DEFAULT"
*/
@@ -89,6 +92,7 @@
*/
private SlingRepository repository;
+ /** The configured class paths. */
private String[] classPath;
/** @scr.reference policy="dynamic" */
@@ -97,6 +101,9 @@
/** The read session. */
private Session readSession;
+ /**
+ * Return a new session (for writing).
+ */
Session getSession() throws RepositoryException {
// get an administrative session for potentiall impersonation
final Session admin = this.repository.loginAdministrative(null);
@@ -192,12 +199,16 @@
return false;
}
- private static final String NT_FOLDER = "nt:folder";
-
/**
* Creates a folder hierarchy in the repository.
+ * We synchronize this method to reduce potential conflics.
+ * Although each write uses its own session it might occur
+ * that more than one session tries to create the same path
+ * (or parent path) at the same time. By synchronizing this
+ * we avoid this situation - however this method is written
+ * in a failsafe manner anyway.
*/
- private boolean mkdirs(final Session session, String path) {
+ private synchronized boolean mkdirs(final Session session, String path) {
try {
// quick test
if (session.itemExists(path) && session.getItem(path).isNode()) {
@@ -253,6 +264,11 @@
return false;
}
+ /**
+ * Helper method to clean the path.
+ * It replaces backslashes with slashes and cuts off trailing spaces.
+ * It uses the first configured class path to access the path.
+ */
private String cleanPath(String path) {
// replace backslash by slash
path = path.replace('\\', '/');
@@ -409,7 +425,7 @@
/**
* Activate this component.
- * @param componentContext
+ * @param componentContext The component context.
*/
protected void activate(final ComponentContext componentContext) {
@SuppressWarnings("unchecked")
@@ -424,7 +440,7 @@
/**
* Deactivate this component
- * @param componentContext
+ * @param componentContext The component context.
*/
protected void deactivate(final ComponentContext componentContext) {
if ( this.readSession != null ) {
@@ -447,6 +463,9 @@
return this.classPath;
}
+ /**
+ * Return the read session.
+ */
public synchronized Session getReadSession() throws RepositoryException {
// check current session
if (this.readSession != null) {