incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r809506 - in /sling/trunk/installer/jcr/jcrinstall: ./ src/main/java/org/apache/sling/jcr/jcrinstall/impl/ src/main/resources/OSGI-INF/metatype/ src/test/java/org/apache/sling/jcr/jcrinstall/impl/
Date Mon, 31 Aug 2009 08:54:32 GMT
Author: bdelacretaz
Date: Mon Aug 31 08:54:32 2009
New Revision: 809506

URL: http://svn.apache.org/viewvc?rev=809506&view=rev
Log:
SLING-1078 - remove dependency on o.a.s.jcr.resource

Modified:
    sling/trunk/installer/jcr/jcrinstall/pom.xml
    sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
    sling/trunk/installer/jcr/jcrinstall/src/main/resources/OSGI-INF/metatype/metatype.properties
    sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java

Modified: sling/trunk/installer/jcr/jcrinstall/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/pom.xml?rev=809506&r1=809505&r2=809506&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/pom.xml (original)
+++ sling/trunk/installer/jcr/jcrinstall/pom.xml Mon Aug 31 08:54:32 2009
@@ -58,6 +58,7 @@
                 <Private-Package>org.apache.sling.jcr.jcrinstall.impl.*</Private-Package>
                 <Sling-Nodetypes>SLING-INF/nodetypes/osgiconfig.cnd</Sling-Nodetypes>
                 <Sling-Namespaces>sling=http://sling.apache.org/jcr/sling/1.0</Sling-Namespaces>
+                <Embed-Dependency>*;artifactId=org.apache.sling.commons.osgi</Embed-Dependency>
             </instructions>
         </configuration>
       </plugin>
@@ -75,12 +76,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
-      <artifactId>org.apache.sling.jcr.resource</artifactId>
+      <artifactId>org.apache.sling.jcr.api</artifactId>
       <version>2.0.2-incubator</version>
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
-      <artifactId>org.apache.sling.jcr.api</artifactId>
+      <artifactId>org.apache.sling.commons.osgi</artifactId>
       <version>2.0.2-incubator</version>
     </dependency>
     <dependency>

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java?rev=809506&r1=809505&r2=809506&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
(original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
Mon Aug 31 08:54:32 2009
@@ -29,9 +29,8 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
-import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
 import org.apache.sling.osgi.installer.InstallableResource;
 import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.apache.sling.runmode.RunMode;
@@ -86,12 +85,6 @@
      */
     private OsgiInstaller installer;
     
-    /**	This class looks for installable resources under the search
-     * 	paths of the Sling ResourceResolver (by default: /libs and /apps)
-     * 	@scr.reference
-     */
-    private JcrResourceResolverFactory resourceResolverFactory;
-    
     /** Default regexp for watched folders */
     public static final String DEFAULT_FOLDER_NAME_REGEXP = ".*/install$";
 
@@ -104,6 +97,15 @@
      *  @scr.property valueRef="DEFAULT_FOLDER_MAX_DEPTH" type="Integer"
      */
     public static final String PROP_INSTALL_FOLDER_MAX_DEPTH = "sling.jcrinstall.folder.max.depth";
+    
+    /**	Configurable search path. We could get it from the ResourceResolver, but
+     * 	introducing a dependency on this just to get those values is too much
+     * 	for this module that's meant to bootstrap other services.
+     * 
+     * 	@scr.property values.1="/apps" values.2="/libs"
+     */
+    public static final String PROP_SEARCH_PATH = "sling.jcrinstall.search.path";
+    public static final String [] DEFAULT_SEARCH_PATH = { "/apps/", "/libs/" };
 
     public static final int DEFAULT_FOLDER_MAX_DEPTH = 4;
     private int maxWatchedFolderDepth;
@@ -144,14 +146,21 @@
     	converters.add(new FileNodeConverter());
     	converters.add(new ConfigNodeConverter());
     	
-    	// Get root paths for installable resources, from ResourceResolver
-    	final ResourceResolver rr = resourceResolverFactory.getResourceResolver(session);
-    	final String [] roots = rr.getSearchPath();
-    	for(int i=0; i < roots.length; i++) {
-    		if(!roots[i].startsWith("/")) {
-    			roots[i] = "/" + roots[i];
-     		}
-    		log.info("Using root folder {} (provided by ResourceResolver)", roots[i]);
+    	// Get search paths, and make sure each part starts and ends with a /
+        String [] roots = OsgiUtil.toStringArray(context.getProperties().get(PROP_SEARCH_PATH));
+        if (roots == null) {
+        	roots = DEFAULT_SEARCH_PATH;
+        }
+        for (int i = 0; i < roots.length; i++) {
+            if (!roots[i].startsWith("/")) {
+            	roots[i] = "/" + roots[i];
+            }
+            if (!roots[i].endsWith("/")) {
+            	roots[i] += "/";
+            }
+        }
+        for(int i = 0; i < roots.length; i++) {
+    		log.info("Configured root folder: {}", roots[i]);
     	}
     	
     	// Configurable max depth, system property (via bundle context) overrides default value

Modified: sling/trunk/installer/jcr/jcrinstall/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=809506&r1=809505&r2=809506&view=diff
==============================================================================
--- sling/trunk/installer/jcr/jcrinstall/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ sling/trunk/installer/jcr/jcrinstall/src/main/resources/OSGI-INF/metatype/metatype.properties
Mon Aug 31 08:54:32 2009
@@ -36,4 +36,9 @@
   having a name that match this regular expression (under the root paths, which are defined
\  
   by the ResourceResolver search path) for resources to install. Folders having names \
   that match this expression, followed by dotted run mode selectors (like "install.author.production")
\
-  are also included.   
\ No newline at end of file
+  are also included.   
+  
+sling.jcrinstall.search.path.name = Search Path
+sling.jcrinstall.search.path.description = List of paths under which jcrinstall looks \
+  for installable resources. Combined with the installations folders name regexp \
+  to select folders for scanning. 
\ No newline at end of file

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=809506&r1=809505&r2=809506&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
Mon Aug 31 08:54:32 2009
@@ -25,13 +25,11 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import javax.jcr.Session;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.jcr.api.SlingRepository;
-import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
 import org.apache.sling.osgi.installer.OsgiInstaller;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -90,13 +88,6 @@
         }
     }
     
-    static class MockJcrResourceResolverFactory implements JcrResourceResolverFactory {
-
-        public ResourceResolver getResourceResolver(Session arg0) {
-            return new MockResourceResolver();
-        }
-    }
-    
     /** Set a non-public Field */
     static void setField(Object target, String fieldName, Object value) throws SecurityException,
NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
         final Field f = target.getClass().getDeclaredField(fieldName);
@@ -108,7 +99,6 @@
     static JcrInstaller getJcrInstaller(SlingRepository repository, OsgiInstaller osgiInstaller)
throws Exception {
         final JcrInstaller installer = new JcrInstaller();
         setField(installer, "repository", repository);
-        setField(installer, "resourceResolverFactory", new MockJcrResourceResolverFactory());
         setField(installer, "installer", osgiInstaller);
         setField(installer, "runMode", new MockRunMode(RUN_MODES));
 
@@ -172,4 +162,4 @@
         }
         throw new Exception("JcrInstaller thread did not signal its end (timeout=" + timeoutMsec
+ " msec)"); 
     }
-}
+}
\ No newline at end of file



Mime
View raw message