incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r693869 - /incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
Date Wed, 10 Sep 2008 15:41:28 GMT
Author: bdelacretaz
Date: Wed Sep 10 08:41:28 2008
New Revision: 693869

URL: http://svn.apache.org/viewvc?rev=693869&view=rev
Log:
SLING-646 - folder names regexp can be set using 'jcrinstall.folder.name.regexp' property

Modified:
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java

Modified: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java?rev=693869&r1=693868&r2=693869&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
(original)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
Wed Sep 10 08:41:28 2008
@@ -75,6 +75,9 @@
     public static final String DEFAULT_FOLDER_NAME_REGEXP = ".*/install$";
     public static final String DEFAULT_FILENAME_REGEXP = "[a-zA-Z0-9].*\\.[a-zA-Z][a-zA-Z][a-zA-Z]?";
     
+    /** ComponentContext property that overrides the folder name regepx */
+    public static final String FOLDER_NAME_REGEXP_PROPERTY = "sling.jcrinstall.folder.name.regexp";
+    
     /** Scan delay for watched folders */
     protected long scanDelayMsec = 1000L;
     
@@ -85,11 +88,25 @@
      */
     protected void activate(ComponentContext context) throws RepositoryException {
     	
-    	// TODO make this configurable
+    	// TODO make this more configurable?
     	final String [] roots = DEFAULT_ROOTS; 
-    	folderNameFilter = new RegexpFilter(DEFAULT_FOLDER_NAME_REGEXP);
     	filenameFilter = new RegexpFilter(DEFAULT_FILENAME_REGEXP);
     	
+    	String regexp = (String)context.getProperties().get(FOLDER_NAME_REGEXP_PROPERTY);
+    	if(regexp != null) {
+    	    log.info("Using folder name regexp '{}' from ComponentContext {} property", regexp,
FOLDER_NAME_REGEXP_PROPERTY);
+    	    folderNameFilter = new RegexpFilter(regexp);
+    	} else {
+    	    regexp = context.getBundleContext().getProperty(FOLDER_NAME_REGEXP_PROPERTY);
+    	    if(regexp != null) {
+                log.info("Using folder name regexp '{}' from BundleContext {} property",
regexp, FOLDER_NAME_REGEXP_PROPERTY);
+                folderNameFilter = new RegexpFilter(regexp);
+    	    } else {
+                log.info("Using default folder name regexp '{}'", DEFAULT_FOLDER_NAME_REGEXP);
+    	        folderNameFilter = new RegexpFilter(DEFAULT_FOLDER_NAME_REGEXP);
+    	    }
+    	}
+        
         // Listen for any new WatchedFolders created after activation
         session = repository.loginAdministrative(repository.getDefaultWorkspace());
         final int eventTypes = Event.NODE_ADDED;



Mime
View raw message