incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r693111 - in /incubator/sling/trunk/extensions/jcrinstall: ./ src/main/java/org/apache/sling/jcr/jcrinstall/osgi/ src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/ src/test/java/org/apache/sling/jcr/jcrinstall/ src/test/java/org/apac...
Date Mon, 08 Sep 2008 14:32:58 GMT
Author: bdelacretaz
Date: Mon Sep  8 07:32:51 2008
New Revision: 693111

URL: http://svn.apache.org/viewvc?rev=693111&view=rev
Log:
SLING-646 - work in progress, OSGi controller partially implemented

Added:
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/InstallResultCode.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/JcrInstallException.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiController.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Storage.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessorTest.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/StorageTest.java   (with props)
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Utilities.java   (with props)
Removed:
    incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/DummyTest.java
Modified:
    incubator/sling/trunk/extensions/jcrinstall/pom.xml

Modified: incubator/sling/trunk/extensions/jcrinstall/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/pom.xml?rev=693111&r1=693110&r2=693111&view=diff
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/pom.xml (original)
+++ incubator/sling/trunk/extensions/jcrinstall/pom.xml Mon Sep  8 07:32:51 2008
@@ -98,6 +98,11 @@
       <version>2.0.2-incubator</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock-junit4</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   
 </project>

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/InstallResultCode.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/InstallResultCode.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/InstallResultCode.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/InstallResultCode.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,31 @@
+/*
+ * 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.jcrinstall.osgi;
+
+/** Result codes for resource installation operations */
+public class InstallResultCode {
+    /** Result code for installOrUpdate: resource was ignored */
+    public static final int IGNORED = 0;
+
+    /** Result code for installOrUpdate: resource was installed */
+    public static final int INSTALLED = 1;
+    
+    /** Result code for installOrUpdate: resource was updated */
+    public static final int UPDATED = 2;
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/InstallResultCode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/InstallResultCode.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/JcrInstallException.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/JcrInstallException.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/JcrInstallException.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/JcrInstallException.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,30 @@
+/*
+ * 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.jcrinstall.osgi;
+
+@SuppressWarnings("serial")
+public class JcrInstallException extends Exception {
+    public JcrInstallException(String reason) {
+        super(reason);
+    }
+    
+    public JcrInstallException(String reason, Throwable cause) {
+        super(reason, cause);
+    }
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/JcrInstallException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/JcrInstallException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiController.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiController.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiController.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiController.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,57 @@
+/*
+ * 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.jcrinstall.osgi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Set;
+
+/** jcrinstall component that installs/updates/removes 
+ *  OSGi resources (bundles, deployment packages, configs)
+ *  in the OSGi framework.
+ */
+public interface OsgiController {
+    
+    /** Install or update supplied resource 
+     *  @param uri Unique identifier for the resource
+     *  @param lastModified if the resource is installed, this is stored
+     *      and can be retrieved using getLastModified().
+     *  @param data resource contents
+     *  @return one of the {@link InstallResultCode} result codes. 
+     */
+    int installOrUpdate(String uri, long lastModified, InputStream data) throws IOException, JcrInstallException;
+    
+    /** Uninstall the resource that was installed via given uri
+     *  @param uri Unique identifier for the resource
+     *  @param attributes metadata stored by the OsgiController, will be
+     *      removed after calling this method
+     */
+    void uninstall(String uri) throws JcrInstallException;
+    
+    /** Return the list of uri for resources that have been installed 
+     *  by this controller.
+     */
+    Set<String> getInstalledUris();
+    
+    /** Get the lastModified value for given uri, assuming the resource pointed
+     *  to by that uri was installed.
+     *  @return -1 if we don't have info for given uri
+     */
+    long getLastModified(String uri);
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiController.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.jcrinstall.osgi;
+
+import java.io.InputStream;
+import java.util.Map;
+
+
+/** Interface for components that can process OSGi "resources",
+ *  that is bundles, deployment packages, configs, etc.
+ */
+public interface OsgiResourceProcessor {
+    
+    /** True if this processor can process the given uri */
+    boolean canProcess(String uri);
+    
+    /** Install or update supplied resource 
+     *  @param uri Unique identifier for the resource
+     *  @param attributes metadata stored by the OsgiController, can be used to
+     *      store additional information
+     *  @param data resource contents
+     *  @return one of the {@link InstallResultCode} result codes. 
+     */
+    int installOrUpdate(String uri, Map<String, Object> attributes, InputStream data) throws Exception;
+    
+    /** Uninstall the resource that was installed via given uri
+     *  @param uri Unique identifier for the resource
+     *  @param attributes metadata stored by the OsgiController, will be
+     *      removed after calling this method
+     */
+    void uninstall(String uri, Map<String, Object> attributes) throws Exception;
+    
+    /** Process our installer queue, if needed, for example by trying
+     *  to start outstanding bundles.
+     */
+    void processResourceQueue() throws Exception;
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/OsgiResourceProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,136 @@
+/*
+ * 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.jcrinstall.osgi.impl;
+
+import static org.apache.sling.jcr.jcrinstall.osgi.InstallResultCode.INSTALLED;
+import static org.apache.sling.jcr.jcrinstall.osgi.InstallResultCode.UPDATED;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.sling.jcr.jcrinstall.osgi.OsgiResourceProcessor;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** OsgiResourceProcessor for Bundles */
+public class BundleResourceProcessor implements OsgiResourceProcessor {
+
+    public static final String BUNDLE_EXTENSION = ".jar";
+    
+    /** {@link Storage} key for the bundle ID */
+    public static final String KEY_BUNDLE_ID = "bundle.id";
+    
+    private final BundleContext ctx;
+    private final Map<Long, Bundle> pendingBundles;
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    BundleResourceProcessor(BundleContext ctx) {
+        this.ctx = ctx;
+        pendingBundles = new HashMap<Long, Bundle>();
+    }
+
+    public int installOrUpdate(String uri, Map<String, Object> attributes, InputStream data) throws Exception {
+        // Update if we already have a bundle id, else install
+        Bundle b = null;
+        boolean updated = false;
+        final Long longId = (Long)attributes.get(KEY_BUNDLE_ID);
+        
+        if(longId != null) {
+            b = ctx.getBundle(longId.longValue());
+            if(b == null) {
+                log.debug("Bundle having id {} not found, uri {} will be installed instead of updating", longId, uri);
+            } else {
+                b.update(data);
+                updated = true;
+            }
+        }
+        
+        if(!updated) {
+            b = ctx.installBundle(OsgiControllerImpl.getResourceLocation(uri), data);
+            attributes.put(KEY_BUNDLE_ID, new Long(b.getBundleId()));
+        }
+        
+        pendingBundles.put(new Long(b.getBundleId()), b);
+        
+        return updated ? UPDATED : INSTALLED; 
+    }
+
+    public void uninstall(String uri, Map<String, Object> attributes) throws BundleException {
+        final Long longId = (Long)attributes.get(KEY_BUNDLE_ID);
+        if(longId == null) {
+            log.debug("No {} in metadata, bundle cannot be uninstalled");
+        } else {
+            final Bundle b = ctx.getBundle(longId.longValue());
+            if(b == null) {
+                log.debug("Bundle having id {} not found, cannot uninstall");
+            } else {
+                pendingBundles.remove(new Long(b.getBundleId()));
+                b.uninstall();
+            }
+        }
+    }
+
+    public boolean canProcess(String uri) {
+        return uri.endsWith(BUNDLE_EXTENSION);
+    }
+
+    public void processResourceQueue() throws BundleException {
+        
+        if(pendingBundles.isEmpty()) {
+            return;
+        }
+        
+        final Iterator<Long> iter = pendingBundles.keySet().iterator(); 
+        while(iter.hasNext()) {
+            final Long id = iter.next();
+            final Bundle bundle = ctx.getBundle(id.longValue());
+            
+            if(bundle == null) {
+                log.debug("Bundle id {} not found in processResourceQueue(), removed from pending bundles queue");
+                iter.remove();
+                
+            } else if ((bundle.getState() & Bundle.ACTIVE) > 0) {
+                log.info("Bundle {} is already active, removed from pending bundles queue", bundle.getLocation());
+                iter.remove();
+            
+            } else if ((bundle.getState() & Bundle.STARTING) > 0) {
+                log.info("Bundle {} is starting.", bundle.getLocation());
+                
+            } else if ((bundle.getState() & Bundle.STOPPING) > 0) {
+                log.info("Bundle {} is stopping.", bundle.getLocation());
+                
+            } else if ((bundle.getState() & Bundle.UNINSTALLED) > 0) {
+                log.info("Bundle {} is uninstalled, removed from pending bundles queue", bundle.getLocation());
+                iter.remove();
+                
+            } else if ((bundle.getState() & Bundle.RESOLVED) > 0) {
+                log.info("Bundle {} is resolved, trying to start it.", bundle.getLocation());
+                bundle.start();
+                
+            } else if ((bundle.getState() & Bundle.INSTALLED) > 0) {
+                log.info("Bundle {} is installed but not resolved.", bundle.getLocation());
+            }
+        }
+    }
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,125 @@
+/*
+ * 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.jcrinstall.osgi.impl;
+
+import static org.apache.sling.jcr.jcrinstall.osgi.InstallResultCode.IGNORED;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.jcr.jcrinstall.osgi.JcrInstallException;
+import org.apache.sling.jcr.jcrinstall.osgi.OsgiController;
+import org.apache.sling.jcr.jcrinstall.osgi.OsgiResourceProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class OsgiControllerImpl implements OsgiController {
+
+    private Storage storage;
+    private List<OsgiResourceProcessor> processors;
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    /** Storage key: last modified as a Long */
+    public static final String KEY_LAST_MODIFIED = "last.modified";
+    
+    /** Default value for getLastModified() */
+    public static final long LAST_MODIFIED_NOT_FOUND = -1;
+    
+    public int installOrUpdate(String uri, long lastModified, InputStream data) throws IOException, JcrInstallException {
+        int result = IGNORED;
+        final OsgiResourceProcessor p = getProcessor(uri);
+        if(p != null) {
+            try {
+                final Map<String, Object> map = storage.getMap(uri);
+                result = p.installOrUpdate(uri, map, data);
+                if(result != IGNORED) {
+                    map.put(KEY_LAST_MODIFIED, new Long(lastModified));
+                }
+                storage.saveToFile();
+            } catch(IOException ioe) {
+                throw ioe;
+            } catch(Exception e) {
+                throw new JcrInstallException("Exception in installOrUpdate", e);
+            }
+        }
+        return result;
+    }
+    
+    public void uninstall(String uri) throws JcrInstallException {
+        final OsgiResourceProcessor p = getProcessor(uri);
+        if(p != null) {
+            try {
+                p.uninstall(uri, storage.getMap(uri));
+                storage.remove(uri);
+                storage.saveToFile();
+            } catch(Exception e) {
+                throw new JcrInstallException("Exception in uninstall", e);
+            }
+        }
+    }
+    
+    public Set<String> getInstalledUris() {
+        return storage.getKeys();
+    }
+
+    /** {@inheritDoc}
+     *  @return LAST_MODIFIED_NOT_FOUND if uri not found
+     */
+    public long getLastModified(String uri) {
+        long result = LAST_MODIFIED_NOT_FOUND;
+        
+        if(storage.contains(uri)) {
+            final Map<String, Object> uriData = storage.getMap(uri);
+            final Long lastMod = (Long)uriData.get(KEY_LAST_MODIFIED); 
+            if(lastMod != null) {
+                result = lastMod.longValue();
+            }
+        }
+        return result;
+    }
+    
+    static String getResourceLocation(String uri) {
+        return "jcrinstall://" + uri;
+    }
+    
+    /** Return the first processor that accepts given uri, null if not found */
+    OsgiResourceProcessor getProcessor(String uri) {
+        OsgiResourceProcessor result = null;
+        
+        if(processors == null) {
+            throw new IllegalStateException("Processors are not set");
+        }
+        
+        for(OsgiResourceProcessor p : processors) {
+            if(p.canProcess(uri)) {
+                result = p;
+                break;
+            }
+        }
+        
+        if(result == null) {
+            log.debug("No processor found for resource {}", uri);
+        }
+        
+        return result;
+    }
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Storage.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Storage.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Storage.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Storage.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,121 @@
+/*
+ * 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.jcrinstall.osgi.impl;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Storage for the OSGi controller, stores Maps for the resources
+ *  managed by the controller.
+ */
+class Storage {
+    private final File dataFile;
+    private final Map<String, Map<String, Object>> data;
+    
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+    
+    /** Create Storage that uses dataFile for persistence, and
+     *  read the current status from that file */
+    @SuppressWarnings("unchecked")
+    Storage(File dataFile) throws IOException {
+        this.dataFile = dataFile;
+        ObjectInputStream ois = null;
+        Map<String, Map<String, Object>> loadedData = null;
+        Throwable loadException = null;
+        
+        try {
+            ois = new ObjectInputStream(new FileInputStream(dataFile));
+            loadedData = (Map<String, Map<String, Object>>)ois.readObject();
+        } catch(EOFException eof) {
+            loadException = eof;
+        } catch(ClassNotFoundException cnfe) {
+            loadException = cnfe;
+        } finally {
+            if(ois != null) {
+                ois.close();
+            }
+        }
+        
+        if(loadException != null) {
+            log.debug("Unable to retrieve data from data file, will use empty data", loadException);
+            loadedData = new HashMap<String, Map<String, Object>>();
+        }
+        
+        data = loadedData;
+    }
+    
+    /** Persist our data to our data file */
+    protected void saveToFile() throws IOException {
+        ObjectOutputStream oos = null;
+        try {
+            synchronized(data) {
+                oos = new ObjectOutputStream(new FileOutputStream(dataFile));
+                oos.writeObject(data);
+            }
+        } finally {
+            if(oos != null) {
+                oos.flush();
+                oos.close();
+            }
+        }
+    }
+    
+    /** True if our data contains give key */
+    boolean contains(String key) {
+        return data.containsKey(key);
+    }
+    
+    /** Get the data map for given key.
+     *  If we don't have it yet, and empty map is
+     *  created, but saveData is not called.  
+     */
+    Map<String, Object>getMap(String key) {
+        Map<String, Object> result = data.get(key);
+        synchronized(data) {
+            if(result == null) {
+                result = new HashMap<String, Object>();
+                data.put(key, result);
+            }
+        }
+        return result;
+    }
+    
+    /** Remove given key from our storage */
+    void remove(String key) {
+        synchronized(data) {
+            data.remove(key);
+        }
+    }
+    
+    /** Get the Set of of keys in our data map */
+    Set<String> getKeys() {
+        return data.keySet();
+    }
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Storage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Storage.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessorTest.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessorTest.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessorTest.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,125 @@
+/*
+ * 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.jcrinstall.osgi.impl;
+
+import static org.apache.sling.jcr.jcrinstall.osgi.InstallResultCode.IGNORED;
+import static org.apache.sling.jcr.jcrinstall.osgi.InstallResultCode.INSTALLED;
+import static org.apache.sling.jcr.jcrinstall.osgi.InstallResultCode.UPDATED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.Sequence;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/** Test the BundleResourceProcessor */
+public class BundleResourceProcessorTest {
+    
+    private Mockery mockery;
+    private Sequence sequence;
+    
+    static class TestStorage extends Storage {
+        int saveCounter;
+        
+        TestStorage(File f) throws IOException {
+            super(f);
+        }
+
+        @Override
+        protected void saveToFile() throws IOException {
+            super.saveToFile();
+            saveCounter++;
+        }
+    }
+    
+    @org.junit.Before public void setup() {
+        mockery = new Mockery();
+        sequence = mockery.sequence(getClass().getSimpleName());
+    }
+    
+    @org.junit.Test public void testInstall() throws Exception {
+        
+        final OsgiControllerImpl c = new OsgiControllerImpl();
+        final BundleContext bc = mockery.mock(BundleContext.class);
+        final BundleResourceProcessor p = new BundleResourceProcessor(bc);
+        Utilities.setProcessors(c, p);
+        final TestStorage s = new TestStorage(Utilities.getTestFile());
+        Utilities.setStorage(c, s);
+        final Bundle b = mockery.mock(Bundle.class);
+        final long bundleId = 1234;
+        final String uri = "/test/bundle.jar";
+        final InputStream data = new ByteArrayInputStream(uri.getBytes());
+        long lastModified = System.currentTimeMillis();
+
+        // We'll try installing a bundle, re-installing to cause
+        // it to be updated, and removing
+        mockery.checking(new Expectations() {{
+            allowing(b).getBundleId() ; 
+            will(returnValue(bundleId));
+            
+            one(bc).installBundle(OsgiControllerImpl.getResourceLocation(uri), data);
+            inSequence(sequence);
+            will(returnValue(b));
+            
+            allowing(bc).getBundle(bundleId);
+            inSequence(sequence);
+            will(returnValue(b));
+            
+            one(b).update(data);
+            inSequence(sequence);
+            
+            one(b).uninstall();
+            inSequence(sequence);
+        }});
+        
+        // Do the calls and check some stuff on the way
+        assertFalse("Before install, uri must not be in list", c.getInstalledUris().contains(uri));
+        
+        assertEquals("First install returns INSTALLED", INSTALLED, c.installOrUpdate(uri, lastModified, data));
+        assertTrue("After install, uri must be in list", c.getInstalledUris().contains(uri));
+        assertEquals("LastModified must have been stored", lastModified, c.getLastModified(uri));
+        assertEquals("Storage data has been saved during install", 1, s.saveCounter);
+        
+        lastModified = System.currentTimeMillis();
+        assertEquals("Second install returns UPDATED", UPDATED, c.installOrUpdate(uri, lastModified, data));
+        assertTrue("After update, uri must be in list", c.getInstalledUris().contains(uri));
+        assertEquals("LastModified must have been updated", lastModified, c.getLastModified(uri));
+        assertEquals("Storage data has been saved during update", 2, s.saveCounter);
+        
+        c.uninstall(uri);
+        assertFalse("After uninstall, uri must not be in list", c.getInstalledUris().contains(uri));
+        assertEquals("LastModified must be gone", -1, c.getLastModified(uri));
+        assertFalse("After getLastModified, uri must not be in list", c.getInstalledUris().contains(uri));
+        assertEquals("Storage data has been saved during uninstall", 3, s.saveCounter);
+        
+        final String nonJarUri = "no_jar_extension";
+        assertEquals(nonJarUri + " must be ignored", c.installOrUpdate("", lastModified, data), IGNORED);
+
+        // And verify expectations
+        mockery.assertIsSatisfied();
+    }
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/BundleResourceProcessorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.jcrinstall.osgi.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.apache.sling.jcr.jcrinstall.osgi.OsgiResourceProcessor;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
+import org.junit.runner.RunWith;
+
+@RunWith(JMock.class)
+public class OsgiControllerGetProcessorTest {
+  
+    private final Mockery mockery = new Mockery();
+
+    @org.junit.Test public void testNoProcessors() throws Exception {
+        final OsgiControllerImpl c = new OsgiControllerImpl();
+        Utilities.setProcessors(c);
+        assertNull("Controller must return null processor for null uri", c.getProcessor(null));
+        assertNull("Controller must return null processor for TEST uri", c.getProcessor("TEST"));
+    }
+    
+    @org.junit.Test public void testTwoProcessors() throws Exception {
+        final OsgiControllerImpl c = new OsgiControllerImpl();
+        final OsgiResourceProcessor p1 = mockery.mock(OsgiResourceProcessor.class);
+        final OsgiResourceProcessor p2 = mockery.mock(OsgiResourceProcessor.class);
+        Utilities.setProcessors(c, p1, p2);
+        
+        mockery.checking(new Expectations() {{
+            allowing(p1).canProcess("foo") ; will(returnValue(true));
+            allowing(p1).canProcess("bar") ; will(returnValue(false));
+            allowing(p2).canProcess("foo") ; will(returnValue(false));
+            allowing(p2).canProcess("bar") ; will(returnValue(true));
+        }});
+        
+        assertEquals("foo extension must return processor p1", p1, c.getProcessor("foo"));
+        assertEquals("bar extension must return processor p2", p2, c.getProcessor("bar"));
+    }
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/OsgiControllerGetProcessorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/StorageTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/StorageTest.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/StorageTest.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/StorageTest.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,90 @@
+/*
+ * 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.jcrinstall.osgi.impl;
+
+import java.io.File;
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+/** Test the Storage class */
+public class StorageTest {
+
+    @org.junit.Test public void testEmptyDataFile() throws Exception {
+        final Storage s = new Storage(Utilities.getTestFile());
+        assertEquals("Storage is initially empty", 0, s.getKeys().size());
+    }
+    
+    @org.junit.Test public void testStoreAndRetrieve() throws Exception {
+
+        final File f = Utilities.getTestFile();
+        final String [] keys = { "one", "two" };
+        
+        {
+            final Storage s = new Storage(f);
+            
+            for(String key : keys) {
+                final Map<String, Object> m = s.getMap(key);
+                m.put(key + ".len", Integer.valueOf(key.length()));
+            }
+            assertEquals("Before saving, number of keys in storage matches", keys.length, s.getKeys().size());
+            s.saveToFile();
+        }
+        
+        {
+            final Storage s = new Storage(f);
+            assertEquals("After retrieving, number of keys in storage matches", keys.length, s.getKeys().size());
+            for(String key : keys) {
+                final Map<String, Object> m = s.getMap(key);
+                assertEquals("Map for " + key + " has one entry", 1, m.size());
+                final Integer len = (Integer)m.get(key + ".len");
+                assertNotNull("Integer len found for key " + key, len);
+                assertEquals("Integer len matches for key " + key, key.length(), len.intValue());
+            }
+        }
+        
+    }
+    
+    @org.junit.Test public void testContains() throws Exception {
+        final Storage s = new Storage(Utilities.getTestFile());
+        final String uri = "TEST_URI";
+        assertFalse("Storage must initially be empty", s.contains(uri));
+        s.contains(uri);
+        assertFalse("Storage must be empty after contains call", s.contains(uri));
+        s.getMap(uri);
+        assertTrue("Storage contains key after getMap call", s.contains(uri));
+    }
+    
+    @org.junit.Test public void testRemove() throws Exception {
+        final File f = Utilities.getTestFile();
+        {
+            final Storage s = new Storage(f);
+            s.getMap("one");
+            assertEquals("After adding one entry, size is 1", 1, s.getKeys().size());
+            s.remove("one");
+            assertEquals("After removing entry, size is 0", 0, s.getKeys().size());
+            s.saveToFile();
+        }
+        
+        {
+            final Storage s = new Storage(f);
+            assertEquals("After save/restore, size is 0", 0, s.getKeys().size());
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/StorageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/StorageTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Utilities.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Utilities.java?rev=693111&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Utilities.java (added)
+++ incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Utilities.java Mon Sep  8 07:32:51 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.jcrinstall.osgi.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.sling.jcr.jcrinstall.osgi.OsgiResourceProcessor;
+
+class Utilities {
+    
+    static File getTestFile() throws IOException {
+        final File result = File.createTempFile(Utilities.class.getName(), null);
+        result.deleteOnExit();
+        return result;
+    }
+    
+    static void setProcessors(OsgiControllerImpl c, OsgiResourceProcessor ... processors) throws Exception {
+        final List<OsgiResourceProcessor> list = new LinkedList<OsgiResourceProcessor>();
+        for(OsgiResourceProcessor p : processors) {
+            list.add(p);
+        }
+        
+        final Field f = c.getClass().getDeclaredField("processors");
+        f.setAccessible(true);
+        f.set(c, list);
+    }
+    
+    static void setStorage(OsgiControllerImpl c, Storage s) throws Exception {
+        final Field f = c.getClass().getDeclaredField("storage");
+        f.setAccessible(true);
+        f.set(c, s);
+    }
+
+}

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Utilities.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/osgi/impl/Utilities.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message