svn commit: r791775 - /sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java
Author: bdelacretaz Date: Tue Jul 7 09:59:08 2009 New Revision: 791775 URL: http://svn.apache.org/viewvc?rev=791775&view=rev Log: SLING-904 - register OsgiControllerImpl as OsgiControllerServices, testDeferredConfigInstall was failing Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=791775&r1=791774&r2=791775&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Tue Jul 7 09:59:08 2009 @@ -21,6 +21,7 @@ import java.util.Hashtable; import org.apache.sling.osgi.installer.OsgiController; +import org.apache.sling.osgi.installer.OsgiControllerServices; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; @@ -65,7 +66,11 @@ (PackageAdmin)this.packageAdminTracker.getService(), (StartLevel)this.startLevelTracker.getService(), (LogService)this.logServiceTracker.getService()); -serviceReg = context.registerService(new String[] {OsgiController.class.getName()}, service, props); +final String [] serviceInterfaces = { + OsgiController.class.getName(), + OsgiControllerServices.class.getName() +}; +serviceReg = context.registerService(serviceInterfaces, service, props); } /**
svn commit: r791809 - in /sling/trunk/contrib/extensions/jcrinstall/it: ./ src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ src/test/java/org/apa
Author: bdelacretaz Date: Tue Jul 7 12:16:01 2009 New Revision: 791809 URL: http://svn.apache.org/viewvc?rev=791809&view=rev Log: SLING-905 - testBundleDependencies added, checks that bundle installs are retried Added: sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java (with props) sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java (with props) Modified: sling/trunk/contrib/extensions/jcrinstall/it/pom.xml sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java Modified: sling/trunk/contrib/extensions/jcrinstall/it/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/it/pom.xml?rev=791809&r1=791808&r2=791809&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/it/pom.xml (original) +++ sling/trunk/contrib/extensions/jcrinstall/it/pom.xml Tue Jul 7 12:16:01 2009 @@ -194,12 +194,40 @@ testB-1.0 + +**/a/** +META-INF/** + 2 JCRinstall test bundle jcrinstall-testB 1.0 + org.apache.sling.jcr.jcrinstall.it.a;version="1.0" + + + + + +needsB-1.0 +compile + +jar + + +needsB + +**/b/** +META-INF/** + + + +2 +JCRinstall test bundle + jcrinstall-needsB +1.0 + org.apache.sling.jcr.jcrinstall.it.a;version="1.0" Added: sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java?rev=791809&view=auto == --- sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java (added) +++ sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java Tue Jul 7 12:16:01 2009 @@ -0,0 +1,21 @@ +/* + * 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.it.a; + +/** Dummy class used in test bundles */ +public class ClassA { +} Propchange: sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java -- svn:eol-style = native Propchange: sling/trunk/contrib/extensions/jcrinstall/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java -- svn:keywords = Author Date Id Revision Rev URL Added: sling/trunk/contrib/extensions/jc
svn commit: r791814 - in /sling/trunk/contrib/extensions/jcrinstall/osgi/src: main/java/org/apache/sling/osgi/installer/impl/ test/java/org/apache/sling/osgi/installer/impl/
Author: bdelacretaz Date: Tue Jul 7 12:31:02 2009 New Revision: 791814 URL: http://svn.apache.org/viewvc?rev=791814&view=rev Log: SLING-905 - remove support for individual bundle start levels (not used) Removed: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/MockStartLevel.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiResourceProcessorList.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessorIgnoreBundlesTest.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessorTest.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/OsgiResourceProcessorListTest.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=791814&r1=791813&r2=791814&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Tue Jul 7 12:31:02 2009 @@ -64,7 +64,6 @@ props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation"); this.service = new OsgiControllerImpl(context, (PackageAdmin)this.packageAdminTracker.getService(), -(StartLevel)this.startLevelTracker.getService(), (LogService)this.logServiceTracker.getService()); final String [] serviceInterfaces = { OsgiController.class.getName(), Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java?rev=791814&r1=791813&r2=791814&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/BundleResourceProcessor.java Tue Jul 7 12:31:02 2009 @@ -41,7 +41,6 @@ import org.osgi.framework.FrameworkListener; import org.osgi.framework.Version; import org.osgi.service.packageadmin.PackageAdmin; -import org.osgi.service.startlevel.StartLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,7 +60,6 @@ private final BundleContext ctx; private final PackageAdmin packageAdmin; -private final StartLevel startLevel; private int packageRefreshEventsCount; /** @@ -95,10 +93,9 @@ private final Logger log = LoggerFactory.getLogger(this.getClass()); -BundleResourceProcessor(BundleContext ctx, PackageAdmin packageAdmin, StartLevel startLevel) { +BundleResourceProcessor(BundleContext ctx, PackageAdmin packageAdmin) { this.ctx = ctx; this.packageAdmin = packageAdmin; -this.startLevel = startLevel; this.activeBundles = new HashSet(); this.installedBundles = new ArrayList(); @@ -201,12 +198,9 @@ int level = installableData.getBundleStartLevel(); b = ctx.installBundle(uri, data); if(level > 0) { - startLevel.setBundleStartLevel(b, level); - log.debug("No matching Bundle for uri {}, installed with start level {}", uri, level); - } else { - level = startLevel.getBundleStartLevel(b); - log.debug("No matching Bundle for uri {}, installing with current default start level {}", uri, level); + throw new BundleException("Non-zero start level is not supported anymore (" + level + ")"); } +log.debug("No matching Bund
svn commit: r791818 - in /sling/trunk/contrib/extensions/jcrinstall/osgi/src: main/java/org/apache/sling/osgi/installer/ main/java/org/apache/sling/osgi/installer/impl/ test/java/org/apache/sling/osgi
Author: bdelacretaz Date: Tue Jul 7 12:50:20 2009 New Revision: 791818 URL: http://svn.apache.org/viewvc?rev=791818&view=rev Log: SLING-905 - more defensive use of external services Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/ConfigResourceProcessorTest.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java?rev=791818&r1=791817&r2=791818&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java Tue Jul 7 12:50:20 2009 @@ -19,6 +19,7 @@ package org.apache.sling.osgi.installer; import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.log.LogService; /** Proxy for services that might not be always available, allows * classes which are not OSGi services to access such services easily. @@ -27,4 +28,5 @@ */ public interface OsgiControllerServices { ConfigurationAdmin getConfigurationAdmin(); + LogService getLogService(); } Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=791818&r1=791817&r2=791818&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Tue Jul 7 12:50:20 2009 @@ -20,6 +20,7 @@ import java.util.Hashtable; +import org.apache.sling.osgi.installer.JcrInstallException; import org.apache.sling.osgi.installer.OsgiController; import org.apache.sling.osgi.installer.OsgiControllerServices; import org.osgi.framework.BundleActivator; @@ -62,15 +63,26 @@ final Hashtable props = new Hashtable(); props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Install Controller Service"); props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation"); + +// Assume PackageAdmin is available before this bundle is started. +// That's the case when using Felix OSGi, not sure about other frameworks. this.service = new OsgiControllerImpl(context, -(PackageAdmin)this.packageAdminTracker.getService(), -(LogService)this.logServiceTracker.getService()); + (PackageAdmin)checkNotNull(this.packageAdminTracker.getService(), "PackageAdmin"), +logServiceTracker); final String [] serviceInterfaces = { OsgiController.class.getName(), OsgiControllerServices.class.getName() }; serviceReg = context.registerService(serviceInterfaces, service, props); } + +/** Complain if value is null */ +static Object checkNotNull(Object value, String what) throws JcrInstallException { + if(value == null) { + throw new JcrInstallException(what + " is null, cannot activate"); + } + return value; +} /** * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=791818&r1=791817&r2=791818&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java Tue Jul 7 12
svn commit: r792130 - in /sling/trunk/contrib/extensions/jcrinstall/osgi/src: main/java/org/apache/sling/osgi/installer/impl/ main/java/org/apache/sling/osgi/installer/impl/tasks/ test/java/org/apache
Author: bdelacretaz Date: Wed Jul 8 13:18:01 2009 New Revision: 792130 URL: http://svn.apache.org/viewvc?rev=792130&view=rev Log: SLING-1037 - TaskOrderingTest added Added: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java (with props) Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=792130&r1=792129&r2=792130&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java Wed Jul 8 13:18:01 2009 @@ -53,11 +53,14 @@ private final BundleContext bundleContext; private final Storage storage; private ResourceOverrideRules roRules; + +// The data type of the "tasks" member must be consistent with the {...@link TaskOrderingTest} class private final Set tasks = new TreeSet(); private final Set tasksForNextCycle = new TreeSet(); private final Set tasksForThisCycle = new TreeSet(); private final ServiceTracker logServiceTracker; private int threadCounter; +private final PackageAdmin packageAdmin; public static final String BUNDLE_EXTENSION = ".jar"; public static final String STORAGE_FILENAME = "controller.storage"; @@ -65,9 +68,6 @@ /** Storage key: digest of an InstallableData */ public static final String KEY_DIGEST = "data.digest"; -// TODO unused? -private final PackageAdmin packageAdmin; - /** Default value for getLastModified() */ public static final long LAST_MODIFIED_NOT_FOUND = -1; Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java?rev=792130&r1=792129&r2=792130&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java Wed Jul 8 13:18:01 2009 @@ -24,6 +24,6 @@ static final String CONFIG_INSTALL_ORDER = "20-"; static final String BUNDLE_UNINSTALL_ORDER = "30-"; static final String BUNDLE_INSTALL_ORDER = "40-"; - static final String BUNDLE_START_ORDER = "50-"; - static final String REFRESH_PACKAGES_ORDER = "60-"; + static final String REFRESH_PACKAGES_ORDER = "50-"; + static final String BUNDLE_START_ORDER = "60-"; } Added: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=792130&view=auto == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java (added) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Wed Jul 8 13:18:01 2009 @@ -0,0 +1,190 @@ +/* + * 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 Licen
svn commit: r792134 - in /sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks: BundleInstallRemoveTask.java BundleStartTask.java
Author: bdelacretaz Date: Wed Jul 8 13:36:43 2009 New Revision: 792134 URL: http://svn.apache.org/viewvc?rev=792134&view=rev Log: SLING-905 - cleaner retries for starting bundles Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java?rev=792134&r1=792133&r2=792134&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java Wed Jul 8 13:36:43 2009 @@ -85,12 +85,6 @@ @Override protected InstallResultCode doInstallOrUpdate(OsgiControllerTaskContext tctx, Map attributes) throws Exception { -int retryCount = 0; -if ( attributes.get("RETRY_COUNT") != null ) { -retryCount = (Integer)attributes.get("RETRY_COUNT"); -} -retryCount++; -attributes.put("RETRY_COUNT", retryCount); // Check that we have bundle data and manifest InputStream is = data.adaptTo(InputStream.class); @@ -125,7 +119,7 @@ // If the bundle (or one with the same symbolic name) is // already installed, ignore the new one if it's a lower // version - if (b != null && retryCount == 1) { + if (b != null) { final Version installedVersion = new Version((String)(b.getHeaders().get(Constants.BUNDLE_VERSION))); final Version newBundleVersion = new Version(m.getMainAttributes().getValue(Constants.BUNDLE_VERSION)); if(ignoreNewBundle(b.getSymbolicName(), uri, installedVersion, newBundleVersion)) { @@ -135,21 +129,15 @@ if (b != null) { // Existing bundle -> stop, update, restart - if ( retryCount == 1 ) { - if(ocs.getLogService() != null) { - ocs.getLogService().log(LogService.LOG_DEBUG, "Calling Bundle.stop() and updating " + uri); - } - b.stop(); - b.update(is); - b.start(); - } else { - if(ocs.getLogService() != null) { - ocs.getLogService().log(LogService.LOG_DEBUG, "Calling Bundle.start " + uri); - } - b.start(); - } + if(ocs.getLogService() != null) { + ocs.getLogService().log(LogService.LOG_INFO, + "Bundle " + b.getBundleId() + " already present, calling Bundle.stop() and updating " + uri); + } + b.stop(); + b.update(is); updated = true; tctx.addTaskToCurrentCycle(new SynchronousRefreshPackagesTask()); + tctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId())); } else { // New bundle -> install final String fullUri = OsgiControllerImpl.getResourceLocation(uri); @@ -159,8 +147,9 @@ } b = bundleContext.installBundle(fullUri, is); if(ocs.getLogService() != null) { - ocs.getLogService().log(LogService.LOG_DEBUG, "No matching Bundle, installed " + fullUri); + ocs.getLogService().log(LogService.LOG_INFO, "Bundle was not present, installed " + fullUri); } + tctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId())); } } finally { // data is never null here @@ -175,14 +164,6 @@ // and updates where there are no attributes yet attributes.put(Storage.KEY_
svn propchange: r792134 - svn:log
Author: bdelacretaz Revision: 792134 Modified property: svn:log Modified: svn:log at Wed Jul 8 13:37:59 2009 -- --- svn:log (original) +++ svn:log Wed Jul 8 13:37:59 2009 @@ -1 +1 @@ -SLING-905 - cleaner retries for starting bundles +SLING-1037 - cleaner retries for starting bundles
svn commit: r792140 - in /sling/trunk/contrib/extensions/jcrinstall/osgi: ./ src/main/java/org/apache/sling/osgi/installer/impl/ src/main/java/org/apache/sling/osgi/installer/impl/tasks/ src/test/java
Author: bdelacretaz Date: Wed Jul 8 13:52:44 2009 New Revision: 792140 URL: http://svn.apache.org/viewvc?rev=792140&view=rev Log: SLING-904 - remove dependency on org.slf4j logging Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml?rev=792140&r1=792139&r2=792140&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/pom.xml Wed Jul 8 13:52:44 2009 @@ -74,10 +74,6 @@ org.osgi.compendium - org.slf4j - slf4j-api - - org.apache.sling org.apache.sling.commons.testing 2.0.4-incubator Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=792140&r1=792139&r2=792140&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java Wed Jul 8 13:52:44 2009 @@ -78,7 +78,7 @@ this.bundleContext = bc; this.packageAdmin = pa; this.logServiceTracker = logServiceTracker; -storage = new Storage(bc.getDataFile(STORAGE_FILENAME)); +storage = new Storage(bc.getDataFile(STORAGE_FILENAME), this); } public void deactivate() { Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java?rev=792140&r1=792139&r2=792140&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java Wed Jul 8 13:52:44 2009 @@ -30,8 +30,8 @@ import java.util.Map; import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.sling.osgi.installer.OsgiControllerServices; +import org.osgi.service.log.LogService; /** Storage for the OSGi controller, stores Maps for the resources * managed by the controller. @@ -39,8 +39,7 @@ public class Storage { private final File dataFile; private final Map> data; - -private final Logger log = LoggerFactory.getLogger(this.getClass()); +private final OsgiControllerServices ocs; /** {...@link Storage} key for the bundle ID */ public static final String KEY_BUNDLE_ID = "bundle.id"; @@ -48,8 +47,9 @@ /** Create Storage that uses dataFile for persistence, and * read the current status from that file */ @SuppressWarnings("unchecked") -Storage(File dataFile) throws IOException { +Storage(File dataFile, OsgiControllerServices ocs) throws IOException { this.dataFile = dataFile; +this.ocs = ocs; ObjectInputStream ois = null; Map> loadedData = null; Throwable loadException = null; @@ -59,7 +59,9 @@ ois = new ObjectInputStream(new FileInputStream(dataFile)); loadedData = (Map>)ois.readObject(); } else { -log.debug("Data file does not exist, will use empty data"); + if(ocs.getLogService() != null) { + ocs.getLogService().log(LogService.LOG_DEBUG, "Data file does not exist, will use empty data"); +
svn commit: r792164 - /sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java
Author: bdelacretaz Date: Wed Jul 8 14:35:30 2009 New Revision: 792164 URL: http://svn.apache.org/viewvc?rev=792164&view=rev Log: SLING-1037 - test overriding /libs configs with /apps Modified: sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java Modified: sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java?rev=792164&r1=792163&r2=792164&view=diff == --- sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java (original) +++ sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java Wed Jul 8 14:35:30 2009 @@ -27,6 +27,9 @@ */ public class SimpleConfigTest extends JcrinstallTestBase { + static final String CONFIG_URL = HTTP_BASE_URL + "/system/console/config"; + static final int timeoutSeconds = 4; + static class ConfigCondition implements JcrinstallTestBase.StringCondition { private final String expectedValue; private final boolean expectValueInContent; @@ -41,44 +44,77 @@ } }; + protected String createConfig(String configPid, Map properties) throws IOException { + return createConfig("/apps", configPid, properties); + } + + protected String createConfig(String basePath, String configPid, Map properties) throws IOException { + final String configPath = basePath + "/" + getClass().getSimpleName() + "/install"; + testClient.mkdirs(HTTP_BASE_URL, configPath); + properties.put("jcr:primaryType", "sling:OsgiConfig"); + return testClient.createNode(HTTP_BASE_URL + configPath + "/" + configPid, properties); + } + public void testSimpleConfig() throws IOException { - final String uniqueId = getClass().getName() + System.currentTimeMillis(); + final String uniqueId = getClass().getName() + ".A." + System.currentTimeMillis(); final String key = getClass().getName() + ".key"; final String value = getClass().getName() + "." + uniqueId; final String keyValue = key + "=" + value; - final String configUrl = HTTP_BASE_URL + "/system/console/config"; final String contentType = CONTENT_TYPE_HTML; - final int timeoutSeconds = 4; - assertContentWithTimeout("Before test, config must not exist", configUrl, + assertContentWithTimeout("Before test, config must not exist", CONFIG_URL, contentType, new ConfigCondition(keyValue, false), timeoutSeconds); // Create an OSGi config using a sling:OsgiConfig node - final String configPath = "/apps/" + getClass().getSimpleName() + "/install"; - testClient.mkdirs(HTTP_BASE_URL, configPath); - final Map nodeProperties = new HashMap(); - nodeProperties.put("jcr:primaryType", "sling:OsgiConfig"); - nodeProperties.put(key, value); - final String toDelete = testClient.createNode(HTTP_BASE_URL + configPath + "/" + uniqueId, nodeProperties); - assertContentWithTimeout("Config must be present after creating config node", configUrl, + final Map props = new HashMap(); + props.put(key, value); + final String toDelete = createConfig(uniqueId, props); + assertContentWithTimeout("Config must be present after creating config node", CONFIG_URL, contentType, new ConfigCondition(keyValue, true), timeoutSeconds); // Update config node, verify that config is updated final String newValue = getClass().getName() + ".NEW." + System.currentTimeMillis(); final String newKeyValue = key + "=" + newValue; - nodeProperties.put(key, newValue); - testClient.createNode(HTTP_BASE_URL + configPath + "/" + uniqueId, nodeProperties); - assertContentWithTimeout("Config must be modified after node update", configUrl, +
svn commit: r792559 - /sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java
Author: bdelacretaz Date: Thu Jul 9 14:14:08 2009 New Revision: 792559 URL: http://svn.apache.org/viewvc?rev=792559&view=rev Log: SLING-904 - log ID of installed bundle, useful for debugging Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java?rev=792559&r1=792558&r2=792559&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java Thu Jul 9 14:14:08 2009 @@ -145,7 +145,8 @@ } b = bundleContext.installBundle(fullUri, is); if(ocs.getLogService() != null) { - ocs.getLogService().log(LogService.LOG_INFO, "Bundle was not present, installed " + fullUri); + ocs.getLogService().log(LogService.LOG_INFO, + "Bundle was not present, installed " + b.getBundleId() + "/" + fullUri); } tctx.addTaskToCurrentCycle(new BundleStartTask(b.getBundleId())); }
svn commit: r792562 - in /sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl: OsgiControllerImpl.java tasks/SynchronousRefreshPackagesTask.java
Author: bdelacretaz Date: Thu Jul 9 14:37:10 2009 New Revision: 792562 URL: http://svn.apache.org/viewvc?rev=792562&view=rev Log: SLING-1039 - OsgiControllerImpl created too many BundleStartTasks Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=792562&r1=792561&r2=792562&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java Thu Jul 9 14:37:10 2009 @@ -31,9 +31,7 @@ import org.apache.sling.osgi.installer.OsgiControllerServices; import org.apache.sling.osgi.installer.ResourceOverrideRules; import org.apache.sling.osgi.installer.impl.tasks.BundleInstallRemoveTask; -import org.apache.sling.osgi.installer.impl.tasks.BundleStartTask; import org.apache.sling.osgi.installer.impl.tasks.ConfigInstallRemoveTask; -import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.osgi.service.cm.ConfigurationAdmin; @@ -152,20 +150,9 @@ } synchronized (tasks) { - // Add start bundle tasks for all active bundles - // so that they are restarted once we're done - for(Bundle b : bundleContext.getBundles()) { - if(b.getState() == Bundle.ACTIVE) { - final OsgiControllerTask t = new BundleStartTask(b.getBundleId()); - tasks.add(t); - if(getLogService() != null) { -getLogService().log(LogService.LOG_DEBUG, "Added " + t); - } - } - } - if(getLogService() != null) { -getLogService().log(LogService.LOG_INFO, "Executing " + tasks.size() + " queued tasks"); +getLogService().log(LogService.LOG_INFO, "Executing " + tasks.size() + + " queued tasks (more might be created during execution cycle)"); } final long start = System.currentTimeMillis(); Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java?rev=792562&r1=792561&r2=792562&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java Thu Jul 9 14:37:10 2009 @@ -21,6 +21,7 @@ import org.apache.sling.osgi.installer.OsgiControllerServices; import org.apache.sling.osgi.installer.impl.OsgiControllerTask; import org.apache.sling.osgi.installer.impl.OsgiControllerTaskContext; +import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkEvent; import org.osgi.framework.FrameworkListener; import org.osgi.service.log.LogService; @@ -67,6 +68,20 @@ final long timeout = System.currentTimeMillis() + MAX_REFRESH_PACKAGES_WAIT_SECONDS * 1000L; ocs = ctx.getOsgiControllerServices(); +// Refreshing packages might cause some bundles to be stopped, +// make sure all currently active ones are restarted after +// this task executes + for(Bundle b : ctx.getBundleContext().getBundles()) { + if(b.getState() == Bundle.ACTIVE) { + final OsgiControllerTask t = new BundleStartTask(b.getBundleId()); + ctx.addTaskToCurrentCycle(t); + if(ctx.getOsgiControllerServices().getLogService() != null) { + ctx.getOsgiControllerServices().getLogService().log(LogService.LOG_DEBUG, + "Added " + t + " to restart bundle if needed after refreshing packages"); +
svn commit: r792860 - in /sling/trunk/contrib/extensions/jcrinstall/service/src: main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java test/java/org/apache/sling/jcr/jcrinstall/jcr
Author: bdelacretaz Date: Fri Jul 10 09:56:15 2009 New Revision: 792860 URL: http://svn.apache.org/viewvc?rev=792860&view=rev Log: SLING-1044 - jcrinstall should only accept .jar, .cfg and .properties files as installable resources, work in progress Added: sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverterTest.java (with props) Modified: sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java Modified: sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java?rev=792860&r1=792859&r2=792860&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java Fri Jul 10 09:56:15 2009 @@ -1,3 +1,19 @@ +/* + * 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.jcr.impl; import javax.jcr.Node; @@ -24,7 +40,7 @@ public InstallableData convertNode(Node n) throws RepositoryException { InstallableData result = null; if(n.hasProperty(FileInstallableData.JCR_CONTENT_DATA) && n.hasProperty(FileInstallableData.JCR_CONTENT_LAST_MODIFIED)) { - if(filenameFilter.accept(n.getName())) { + if(acceptNodeName(n.getName())) { result = new FileInstallableData(n, bundleStartLevel); } else { log.debug("Node {} ignored due to {}", n.getPath(), filenameFilter); @@ -35,4 +51,8 @@ FileInstallableData.JCR_CONTENT_DATA + " or " + FileInstallableData.JCR_CONTENT_LAST_MODIFIED); return null; } + + boolean acceptNodeName(String name) { + return filenameFilter.accept(name); + } } \ No newline at end of file Added: sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverterTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverterTest.java?rev=792860&view=auto == --- sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverterTest.java (added) +++ sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverterTest.java Fri Jul 10 09:56:15 2009 @@ -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.jcr.impl; + +import junit.framework.TestCase; + +public class FileNodeConverterTest extends TestCase { +private final FileNodeConverter fc = new File
svn commit: r792880 - in /sling/trunk/contrib: extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/insta
Author: bdelacretaz Date: Fri Jul 10 10:54:07 2009 New Revision: 792880 URL: http://svn.apache.org/viewvc?rev=792880&view=rev Log: SLING-1044 - jcrinstall should only accept .jar, .cfg and .properties files as installable resources Added: sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/jcrinstall/ sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/jcrinstall/cfg1.cfg sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/jcrinstall/cfg1.properties (with props) Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPid.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPidTest.java sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverter.java sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FileNodeConverterTest.java sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/SimpleConfigTest.java Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java?rev=792880&r1=792879&r2=792880&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java Fri Jul 10 10:54:07 2009 @@ -37,7 +37,7 @@ static final String ALIAS_KEY = "_alias_factory_pid"; static final String CONFIG_PATH_KEY = "_jcr_config_path"; -static final String CONFIG_EXTENSION = ".cfg"; +static final String [] CONFIG_EXTENSIONS = { ".cfg", ".properties" }; private final DictionaryReader reader = new DictionaryReader(); Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPid.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPid.java?rev=792880&r1=792879&r2=792880&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPid.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPid.java Fri Jul 10 10:54:07 2009 @@ -34,11 +34,14 @@ pid = path.substring(lastSlash + 1); } -// cut off extension if it's .cfg -if(pid.endsWith(ConfigInstallRemoveTask.CONFIG_EXTENSION)) { -final int lastDot = pid.lastIndexOf('.'); -if(lastDot >= 0) { -pid = pid.substring(0, lastDot); +// cut off extension if it's one of our config extensions +for(String ext : ConfigInstallRemoveTask.CONFIG_EXTENSIONS) { +if(pid.endsWith(ext)) { +final int lastDot = pid.lastIndexOf('.'); +if(lastDot >= 0) { +pid = pid.substring(0, lastDot); +} +break; } } Modified: sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPidTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPidTest.java?rev=792880&r1=792879&r2=792880&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPidTest.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/osgi/src/test/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPidTest.java Fri Jul 10 10:54:07 2009 @@ -30,11 +30,17 @@ @org.junit.Test public void testNonFactory() { assertPid("o.a.s.foo.bar.cfg", "o.a.s.foo.bar", null); +assertPid(&qu
svn commit: r793010 - in /sling/trunk/contrib/extensions/jcrinstall: it/src/test/java/org/apache/sling/jcr/jcrinstall/it/ osgi/src/main/java/org/apache/sling/osgi/installer/ osgi/src/main/java/org/apa
Author: bdelacretaz Date: Fri Jul 10 16:21:25 2009 New Revision: 793010 URL: http://svn.apache.org/viewvc?rev=793010&view=rev Log: SLING-1042 - Optimize jcrinstall retry cycles Added: sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/OsgiControllerStatistics.java (with props) sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/EventsCounter.java (with props) sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/EventsCounterImpl.java (with props) Modified: sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java sling/trunk/contrib/extensions/jcrinstall/osgi/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java Modified: sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java?rev=793010&r1=793009&r2=793010&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java Fri Jul 10 16:21:25 2009 @@ -30,12 +30,15 @@ import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption; import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; import java.util.Dictionary; import java.util.Hashtable; import org.apache.sling.osgi.installer.DictionaryInstallableData; import org.apache.sling.osgi.installer.OsgiController; import org.apache.sling.osgi.installer.OsgiControllerServices; +import org.apache.sling.osgi.installer.OsgiControllerStatistics; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Inject; @@ -43,9 +46,12 @@ import org.ops4j.pax.exam.junit.JUnit4TestRunner; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkEvent; +import org.osgi.framework.FrameworkListener; import org.osgi.framework.ServiceReference; import org.osgi.service.cm.Configuration; import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.packageadmin.PackageAdmin; /** Test the OsgiController running in the OSGi framework * @@ -55,9 +61,10 @@ * */ @RunWith(JUnit4TestRunner.class) -public class OsgiControllerTest { +public class OsgiControllerTest implements FrameworkListener { public final static String POM_VERSION = System.getProperty("jcrinstall.pom.version"); public final static String JAR_EXT = ".jar"; + private int packageRefreshEventsCount; @Inject protected BundleContext bundleContext; @@ -71,6 +78,61 @@ return result; } +protected void generateBundleEvent() throws Exception { +// install a bundle manually to generate a bundle event +final File f = getTestBundle("org.apache.sling.jcr.jcrinstall.it-" + POM_VERSION + "-testbundle-1.0.jar"); +final InputStream is = new FileInputStream(f); +Bundle b = null; +try { +b = bundleContext.installBundle(getClass().getName(), is); +b.start(); +final long timeout = System.currentTimeMillis() + 2000L; +while(b.getState() != Bundle.ACTIVE && System.currentTimeMillis() < timeout) { +Thread.sleep(10L); +} +} finally { +if(is != null) { +is.close(); +} +if(b != null) { +b.uninstall(); +} +} +} + +public void frameworkEvent(FrameworkEvent event) { +if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED) { +packageRefreshEventsCount++; +} +} + +protected void refreshPackages() { +bundleContext.addFrameworkListener(this); +final int MAX_REFRESH_PACKAGES_WAIT_SECONDS = 5; +final int targetEventCount = packageRefreshEventsCount + 1; +final long timeout = System.currentTimeMillis() + MAX_REFRESH_PACKAGES_WAIT_SECONDS * 1000L; + +final PackageAdmin pa = getService(PackageAdmi
svn commit: r800689 - /sling/trunk/check_staged_release.sh
Author: bdelacretaz Date: Tue Aug 4 07:31:02 2009 New Revision: 800689 URL: http://svn.apache.org/viewvc?rev=800689&view=rev Log: display digests in output, to include them in votes Modified: sling/trunk/check_staged_release.sh Modified: sling/trunk/check_staged_release.sh URL: http://svn.apache.org/viewvc/sling/trunk/check_staged_release.sh?rev=800689&r1=800688&r2=800689&view=diff == --- sling/trunk/check_staged_release.sh (original) +++ sling/trunk/check_staged_release.sh Tue Aug 4 07:31:02 2009 @@ -45,10 +45,10 @@ if [ "$?" = "0" ]; then CHKSUM="GOOD"; else CHKSUM="BAD"; fi if [ ! -f "$f.asc" ]; then CHKSUM=""; fi echo "gpg: ${CHKSUM}" - if [ "`cat $f.md5 2>/dev/null`" = "`openssl md5 < $f 2>/dev/null`" ]; then CHKSUM="GOOD"; else CHKSUM="BAD"; fi + if [ "`cat $f.md5 2>/dev/null`" = "`openssl md5 < $f 2>/dev/null`" ]; then CHKSUM="GOOD (`cat $f.md5`)"; else CHKSUM="BAD"; fi if [ ! -f "$f.md5" ]; then CHKSUM=""; fi echo "md5: ${CHKSUM}" - if [ "`cat $f.sha1 2>/dev/null`" = "`openssl sha1 < $f 2>/dev/null`" ]; then CHKSUM="GOOD"; else CHKSUM="BAD"; fi + if [ "`cat $f.sha1 2>/dev/null`" = "`openssl sha1 < $f 2>/dev/null`" ]; then CHKSUM="GOOD (`cat $f.sha1`)"; else CHKSUM="BAD"; fi if [ ! -f "$f.sha1" ]; then CHKSUM=""; fi echo "sha1: ${CHKSUM}" done
svn commit: r801199 - /sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java
Author: bdelacretaz Date: Wed Aug 5 12:51:12 2009 New Revision: 801199 URL: http://svn.apache.org/viewvc?rev=801199&view=rev Log: Activator must implement BundleActivator Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java Modified: sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java?rev=801199&r1=801198&r2=801199&view=diff == --- sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java (original) +++ sling/trunk/bundles/commons/classloader/src/main/java/org/apache/sling/commons/classloader/impl/Activator.java Wed Aug 5 12:51:12 2009 @@ -24,6 +24,7 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; import org.osgi.framework.BundleListener; +import org.osgi.framework.BundleActivator; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; import org.osgi.framework.SynchronousBundleListener; @@ -35,7 +36,7 @@ * It listens for bundle events and reregisters the class loader manager * if a bundle event for a used bundle occurs. */ -public class Activator implements SynchronousBundleListener, BundleListener { +public class Activator implements SynchronousBundleListener, BundleListener, BundleActivator { /** Package admin service name */ private static String PACKAGE_ADMIN_NAME = PackageAdmin.class.getName();
svn commit: r801227 - /sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java
Author: bdelacretaz Date: Wed Aug 5 13:34:08 2009 New Revision: 801227 URL: http://svn.apache.org/viewvc?rev=801227&view=rev Log: Add debug logging about servlet selection/caching Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java?rev=801227&r1=801226&r2=801227&view=diff == --- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java (original) +++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java Wed Aug 5 13:34:08 2009 @@ -450,6 +450,7 @@ final SlingHttpServletRequest request) { final Servlet scriptServlet = (this.cache != null ? this.cache.get(locationUtil) : null); if ( scriptServlet != null ) { +log.debug("Using cached servlet {}", scriptServlet.getClass().getName()); return scriptServlet; } @@ -481,6 +482,8 @@ if ( !hasOptingServlet && !isOptingServlet && this.cache != null ) { this.cache.put(locationUtil, candidate); } +log.debug("Using servlet provided by candidate resource {}", +candidateResource.getPath()); return candidate; } if ( isOptingServlet ) {
svn commit: r801242 - /sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java
Author: bdelacretaz Date: Wed Aug 5 14:42:33 2009 New Revision: 801242 URL: http://svn.apache.org/viewvc?rev=801242&view=rev Log: testChangingJsp() added - currently fails, seems like dynamic classloader caches compiled JSP classes forever Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java?rev=801242&r1=801241&r2=801242&view=diff == --- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java (original) +++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java Wed Aug 5 14:42:33 2009 @@ -79,6 +79,25 @@ } } +/* Verify that overwriting a JSP script changes the output immediately */ +public void testChangingJsp() throws Exception { +String toDelete = null; + +try { +final String [] scripts = { "jsp1.jsp", "jsp2.jsp" }; +for(String script : scripts) { +toDelete = uploadTestScript(unstructuredNode.scriptPath, script, "html.jsp"); +final String content = getContent(unstructuredNode.nodeUrl + ".html", CONTENT_TYPE_HTML); +final String expected = "text from " + script + ":" + unstructuredNode.testText; +assertTrue("Content contains '" + expected + "'(" + content + ")", content.contains(expected)); +} +} finally { +if(toDelete != null) { +testClient.delete(toDelete); +} +} +} + private void checkContent(TestNode tn) throws Exception { final String content = getContent(tn.nodeUrl + ".html", CONTENT_TYPE_HTML); assertTrue("JSP script executed as expected (" + content + ")", content.contains("JSP rendering result"));
svn commit: r801244 - in /sling/trunk/launchpad/testing/src/test/resources/integration-test: jsp1.jsp jsp2.jsp
Author: bdelacretaz Date: Wed Aug 5 14:50:31 2009 New Revision: 801244 URL: http://svn.apache.org/viewvc?rev=801244&view=rev Log: forgot jsp files for testChangingJsp() Added: sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp1.jsp (with props) sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp2.jsp (with props) Added: sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp1.jsp URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp1.jsp?rev=801244&view=auto == --- sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp1.jsp (added) +++ sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp1.jsp Wed Aug 5 14:50:31 2009 @@ -0,0 +1,28 @@ + + +<%...@page session="false"%> +<%...@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%> + + +jsp1.jsp + +text from jsp1.jsp:<%= currentNode.getProperty("text").getValue().getString() %> + Propchange: sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp1.jsp -- svn:eol-style = native Added: sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp2.jsp URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp2.jsp?rev=801244&view=auto == --- sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp2.jsp (added) +++ sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp2.jsp Wed Aug 5 14:50:31 2009 @@ -0,0 +1,28 @@ + + +<%...@page session="false"%> +<%...@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%> + + +jsp2.jsp + +text from jsp2.jsp:=<%= currentNode.getProperty("text").getValue().getString() %> + Propchange: sling/trunk/launchpad/testing/src/test/resources/integration-test/jsp2.jsp -- svn:eol-style = native
svn commit: r801300 - /sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Author: bdelacretaz Date: Wed Aug 5 16:54:51 2009 New Revision: 801300 URL: http://svn.apache.org/viewvc?rev=801300&view=rev Log: HttpTestBase.executeScript(...) added Modified: sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java Modified: sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java?rev=801300&r1=801299&r2=801300&view=diff == --- sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java (original) +++ sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java Wed Aug 5 16:54:51 2009 @@ -62,6 +62,9 @@ public static final String SLING_POST_SERVLET_CREATE_SUFFIX = "/"; public static final String DEFAULT_EXT = ".txt"; + + public static final String EXECUTE_RESOURCE_TYPE = "SlingTesting" + HttpTestBase.class.getSimpleName(); + private static int executeCounter; protected SlingIntegrationTestClient testClient; protected HttpClient httpClient; @@ -348,6 +351,44 @@ } return url; } + +/** Upload script, execute with no parameters and return content */ +protected String executeScript(String localFilename) throws Exception { +return executeScript(localFilename, null); +} + +/** Upload script, execute with given parameters (optional) and return content */ +protected String executeScript(String localFilename, List params) throws Exception { + +// Use unique resource type +int counter = 0; +synchronized (getClass()) { +counter = ++executeCounter; +} +final String resourceType = EXECUTE_RESOURCE_TYPE + counter; +final String scriptPath = "/apps/" + resourceType; +testClient.mkdirs(WEBDAV_BASE_URL , scriptPath); + +final int pos = localFilename.lastIndexOf("."); +if(pos < 1) { +throw new IllegalArgumentException("localFilename must have extension (" + localFilename + ")"); +} +final String ext = localFilename.substring(pos + 1); +final List toDelete = new LinkedList(); +try { +toDelete.add(uploadTestScript(scriptPath, localFilename, "txt." + ext)); +final Map props = new HashMap(); +props.put(SLING_RESOURCE_TYPE, resourceType); +final String nodePath = scriptPath + "/node" + counter; +final String nodeUrl = testClient.createNode(HTTP_BASE_URL + nodePath, props); +toDelete.add(nodeUrl); +return getContent(nodeUrl + ".txt", CONTENT_TYPE_DONTCARE, params); +} finally { +for(String url : toDelete) { +testClient.delete(url); +} +} +} protected void assertJavascript(String expectedOutput, String jsonData, String code) throws IOException { assertJavascript(expectedOutput, jsonData, code, null);
svn commit: r801303 - in /sling/trunk/launchpad/testing/src/test: java/org/apache/sling/launchpad/webapp/integrationtest/ resources/integration-test/serverscripts/
Author: bdelacretaz Date: Wed Aug 5 16:58:58 2009 New Revision: 801303 URL: http://svn.apache.org/viewvc?rev=801303&view=rev Log: ExecuteScriptTest added Added: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java (with props) sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/ sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/servertest.esp sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/servertest.jsp (with props) Added: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java?rev=801303&view=auto == --- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java (added) +++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java Wed Aug 5 16:58:58 2009 @@ -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.launchpad.webapp.integrationtest; + +/** Test the executeScript test method */ +public class ExecuteScriptTest extends RenderingTestBase { + +public void testEspScript() throws Exception { +final String content = executeScript("serverscripts/servertest.esp"); +assertContains(content, "ESP path = /apps/SlingTesting"); +} + +public void testJspScript() throws Exception { +final String content = executeScript("serverscripts/servertest.jsp"); +assertContains(content, "JSP path = /apps/SlingTesting"); +} +} Propchange: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java -- svn:eol-style = native Propchange: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java -- svn:keywords = Author Date Id Revision Rev URL Added: sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/servertest.esp URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/servertest.esp?rev=801303&view=auto == --- sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/servertest.esp (added) +++ sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/servertest.esp Wed Aug 5 16:58:58 2009 @@ -0,0 +1,20 @@ +/* + * 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. + */ + +ESP path = <%= currentNode.getPath() %> \ No newline at end of file Added: sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/servertest.jsp URL: http://svn.apache.org/viewvc/sling/trunk/launc
svn commit: r801611 - in /sling/trunk/contrib/extensions/jcrinstall/service/src/main: java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java resources/OSGI-INF/metatype/metatype.propert
Author: bdelacretaz Date: Thu Aug 6 11:44:43 2009 New Revision: 801611 URL: http://svn.apache.org/viewvc?rev=801611&view=rev Log: SLING-1072 - configurable max depth for scanning install folders Modified: sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java sling/trunk/contrib/extensions/jcrinstall/service/src/main/resources/OSGI-INF/metatype/metatype.properties Modified: sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java?rev=801611&r1=801610&r2=801611&view=diff == --- sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java (original) +++ sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java Thu Aug 6 11:44:43 2009 @@ -20,6 +20,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Dictionary; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -96,8 +97,16 @@ /** Default regexp for watched folders */ public static final String DEFAULT_FOLDER_NAME_REGEXP = ".*/install$"; + +/** Configurable max. path depth for watched folders + * @scr.property valueRef="DEFAULT_FOLDER_MAX_DEPTH" type="Integer" + */ +public static final String PROP_INSTALL_FOLDER_MAX_DEPTH = "installFolder.maxDepth"; + +public static final int DEFAULT_FOLDER_MAX_DEPTH = 4; +private int maxWatchedFolderDepth; -/** ComponentContext property that overrides the folder name regepx */ +/** ComponentContext property that overrides the folder name regexp */ public static final String FOLDER_NAME_REGEXP_PROPERTY = "sling.jcrinstall.folder.name.regexp"; public static final String DATA_FILE = "service.properties"; @@ -114,6 +123,14 @@ protected void activate(ComponentContext context) throws Exception { componentContext = context; +final Dictionary properties = context.getProperties(); +final Integer maxDepth = (Integer)properties.get(PROP_INSTALL_FOLDER_MAX_DEPTH); +if(maxDepth == null) { +maxWatchedFolderDepth = DEFAULT_FOLDER_MAX_DEPTH; +} else { +maxWatchedFolderDepth = maxDepth.intValue(); +} + // Call startup() if we already have a repository, else that will be called // by the bind method if(repository != null) { @@ -129,6 +146,7 @@ /** Called at activation time, or when repository becomes available again * after going away. */ protected void startup() throws Exception { +final long start = System.currentTimeMillis(); log.debug("startup()"); // TODO make this more configurable (in sync with ResourceOverrideRulesImpl) @@ -177,6 +195,8 @@ final Thread t = new Thread(this, getClass().getSimpleName() + "_" + System.currentTimeMillis()); t.setDaemon(true); t.start(); + +log.info("startup() took {} msec", System.currentTimeMillis() - start); } protected File getServiceDataFile(ComponentContext context) { @@ -269,12 +289,19 @@ */ void findWatchedFolders(Node n, Set setToUpdate) throws RepositoryException { -if (folderNameFilter.accept(n.getPath())) { -setToUpdate.add(new WatchedFolder(repository, n.getPath(), osgiController, filenameFilter, scanDelayMsec, roRules)); -} -final NodeIterator it = n.getNodes(); -while (it.hasNext()) { -findWatchedFolders(it.nextNode(), setToUpdate); +final String path = n.getPath(); +if (folderNameFilter.accept(path)) { +setToUpdate.add(new WatchedFolder(repository, path, osgiController, filenameFilter, scanDelayMsec, roRules)); +} +final int depth = path.split("/").length; +if(depth > maxWatchedFolderDepth) { +log.debug("Not recursing into {} due to maxWatchedFolderDepth={}", path, maxWatchedFolderDepth); +return; +} else { +final NodeIterator it = n.getNodes(); +while (it.hasNext()) { +findWatchedFolders(it.nextNode(), setToUpdate); +} } } Modified: sling/trunk/contrib/extensions/jcrinstall/service/src/main/resources/OSGI-INF/metatype/metatype.properties URL: http://svn.apache.org/viewvc/sling/trunk/contri
svn commit: r801615 - /sling/trunk/samples/pom.xml
Author: bdelacretaz Date: Thu Aug 6 11:58:23 2009 New Revision: 801615 URL: http://svn.apache.org/viewvc?rev=801615&view=rev Log: Hudson build fails to deploy this as it's not a SNAPSHOT Modified: sling/trunk/samples/pom.xml Modified: sling/trunk/samples/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/samples/pom.xml?rev=801615&r1=801614&r2=801615&view=diff == --- sling/trunk/samples/pom.xml (original) +++ sling/trunk/samples/pom.xml Thu Aug 6 11:58:23 2009 @@ -24,7 +24,7 @@ org.apache.sling sling-samples-builder pom -1-incubator +2-SNAPSHOT Apache Sling Samples (Builder)
svn commit: r801631 - /sling/trunk/contrib/pom.xml
Author: bdelacretaz Date: Thu Aug 6 12:50:21 2009 New Revision: 801631 URL: http://svn.apache.org/viewvc?rev=801631&view=rev Log: Clean the sling folder on mvn clean Modified: sling/trunk/contrib/pom.xml Modified: sling/trunk/contrib/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/pom.xml?rev=801631&r1=801630&r2=801631&view=diff == --- sling/trunk/contrib/pom.xml (original) +++ sling/trunk/contrib/pom.xml Thu Aug 6 12:50:21 2009 @@ -54,6 +54,26 @@ http://svn.apache.org/viewvc/sling/trunk/contrib + + + +maven-clean-plugin +2.2 + + + +${basedir} + +derby.log +cachedir +sling + + + + + + +
svn commit: r801642 - /sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java
Author: bdelacretaz Date: Thu Aug 6 13:37:06 2009 New Revision: 801642 URL: http://svn.apache.org/viewvc?rev=801642&view=rev Log: SLING-1074 - SlingLogWriterTest failed under Windows Modified: sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java Modified: sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java?rev=801642&r1=801641&r2=801642&view=diff == --- sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java (original) +++ sling/trunk/bundles/commons/log/src/test/java/org/apache/sling/commons/log/internal/slf4j/SlingLogWriterTest.java Thu Aug 6 13:37:06 2009 @@ -160,8 +160,8 @@ public void test_daily_rotation() throws IOException { final String base = getBase(); -final SlingLoggerWriter slfw = createLogWriter(base, -1, -"'.'-MM-dd"); +final String limit = "'.'-MM-dd"; +SlingLoggerWriter slfw = createLogWriter(base, -1, limit); setNow(slfw, july21); // only base file should exist with size 0 (for now) @@ -187,7 +187,10 @@ // simulate July 23rd setNow(slfw, july21 + 24*60*60*1000L); forceRotate(slfw); +// setLastModified fails under Windows if file is still open in logger +slfw.close(); test.setLastModified(july21); +slfw = createLogWriter(base, -1, limit); // rotate the file now slfw.checkRotate();
svn commit: r801681 - in /sling/trunk/launchpad/testing/src/test: java/org/apache/sling/launchpad/webapp/integrationtest/ java/org/apache/sling/launchpad/webapp/integrationtest/issues/ resources/integ
Author: bdelacretaz Date: Thu Aug 6 15:42:36 2009 New Revision: 801681 URL: http://svn.apache.org/viewvc?rev=801681&view=rev Log: SLING-1075 use specific JSP script engine config during testing Added: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspTestBase.java (with props) sling/trunk/launchpad/testing/src/test/resources/integration-test/serverscripts/jsp-engine-setup.jsp (with props) Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/issues/SLING457Test.java Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java?rev=801681&r1=801680&r2=801681&view=diff == --- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java (original) +++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ExecuteScriptTest.java Thu Aug 6 15:42:36 2009 @@ -17,7 +17,7 @@ package org.apache.sling.launchpad.webapp.integrationtest; /** Test the executeScript test method */ -public class ExecuteScriptTest extends RenderingTestBase { +public class ExecuteScriptTest extends JspTestBase { public void testEspScript() throws Exception { final String content = executeScript("serverscripts/servertest.esp"); Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java?rev=801681&r1=801680&r2=801681&view=diff == --- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java (original) +++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspForwardTest.java Thu Aug 6 15:42:36 2009 @@ -29,7 +29,7 @@ /** Test the {link ScriptHelper#forward) functionality */ - public class JspForwardTest extends HttpTestBase { + public class JspForwardTest extends JspTestBase { private String nodeUrlA; private String testTextA; Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java?rev=801681&r1=801680&r2=801681&view=diff == --- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java (original) +++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java Thu Aug 6 15:42:36 2009 @@ -29,7 +29,7 @@ /** Test the {link ScriptHelper#include) functionality */ - public class JspIncludeTest extends HttpTestBase { + public class JspIncludeTest extends JspTestBase { private String nodeUrlA; private String testTextA; Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java?rev=801681&r1=801680&r2=801681&view=diff == --- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java (original) +++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java Thu Aug 6 15:42:36 2009 @@ -23,7 +23,7 @@ * TODO this class can be generalized to be used for any scripting language, * that would help in testing all scripting engines. */ -public class JspScriptingTest extends HttpTestBase { +public class JspScriptingTest extends JspTestBase { private St
svn commit: r802833 - in /sling/trunk/contrib: launchpad/testing/pom.xml scripting/xproc/src/main/java/org/apache/sling/scripting/xproc/cocoon/generator/SlingGenerator.java
Author: bdelacretaz Date: Mon Aug 10 15:41:52 2009 New Revision: 802833 URL: http://svn.apache.org/viewvc?rev=802833&view=rev Log: Fix xproc module tests, failed due to use of text/xml mime type Modified: sling/trunk/contrib/launchpad/testing/pom.xml sling/trunk/contrib/scripting/xproc/src/main/java/org/apache/sling/scripting/xproc/cocoon/generator/SlingGenerator.java Modified: sling/trunk/contrib/launchpad/testing/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/pom.xml?rev=802833&r1=802832&r2=802833&view=diff == --- sling/trunk/contrib/launchpad/testing/pom.xml (original) +++ sling/trunk/contrib/launchpad/testing/pom.xml Mon Aug 10 15:41:52 2009 @@ -702,7 +702,7 @@ org.apache.sling org.apache.sling.commons.testing -2.0.4-incubator +2.0.5-SNAPSHOT test Modified: sling/trunk/contrib/scripting/xproc/src/main/java/org/apache/sling/scripting/xproc/cocoon/generator/SlingGenerator.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/xproc/src/main/java/org/apache/sling/scripting/xproc/cocoon/generator/SlingGenerator.java?rev=802833&r1=802832&r2=802833&view=diff == --- sling/trunk/contrib/scripting/xproc/src/main/java/org/apache/sling/scripting/xproc/cocoon/generator/SlingGenerator.java (original) +++ sling/trunk/contrib/scripting/xproc/src/main/java/org/apache/sling/scripting/xproc/cocoon/generator/SlingGenerator.java Mon Aug 10 15:41:52 2009 @@ -31,7 +31,6 @@ import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.scripting.SlingScriptHelper; -import org.apache.sling.commons.mime.MimeTypeService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,16 +50,12 @@ private final Logger log = LoggerFactory.getLogger(getClass()); - private static final String XML_MIME_TYPE = "text/xml"; - private SlingHttpServletRequest request; private SlingHttpServletResponse response; - private MimeTypeService mimeTypeService; public SlingGenerator(SlingScriptHelper sling) { this.request = sling.getRequest(); this.response = sling.getResponse(); - this.mimeTypeService = sling.getService(MimeTypeService.class); } public void execute() { @@ -82,7 +77,7 @@ private InputStream genXmlSource() throws Exception { - String xmlPath = request.getResource().getPath() + "." + mimeTypeService.getExtension(XML_MIME_TYPE); + String xmlPath = request.getResource().getPath() + ".xml"; // The source is a xml file Resource xmlResource = this.request.getResourceResolver().resolve(xmlPath);
svn commit: r802844 - in /sling/trunk/contrib/scripting/scala: engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java interpreter/src/main/scala/org/apache/sling/sc
Author: bdelacretaz Date: Mon Aug 10 16:18:31 2009 New Revision: 802844 URL: http://svn.apache.org/viewvc?rev=802844&view=rev Log: fix failing scala integration tests (/var/classes was not created) Modified: sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala Modified: sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java?rev=802844&r1=802843&r2=802844&view=diff == --- sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java (original) +++ sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java Mon Aug 10 16:18:31 2009 @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Arrays; +import javax.jcr.Item; import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; @@ -114,7 +115,7 @@ createFolder(path)), this); } -catch (final RepositoryException e) { +catch (final Exception e) { return new AbstractSlingScriptEngine(this) { public Object eval(Reader reader, ScriptContext context) throws ScriptException { throw initCause(new ScriptException("Cannot access output directory: " + path), e); @@ -174,10 +175,36 @@ return bundleFs; } -private AbstractFile createFolder(String path) throws RepositoryException { +private AbstractFile createFolder(String path) throws Exception { Session session = repository.loginAdministrative(null); -Node node = (Node) session.getItem(path); -return JcrFS.create(node); +try { +Node node = deepCreateNode(path, session, "sling:Folder"); +if(node == null) { + throw new Exception("Unable to create node " + path); +} +return JcrFS.create(node); +} finally { + if(session != null) { + session.logout(); + } +} +} + +private Node deepCreateNode(String path, Session session, String nodeType) throws RepositoryException { + Node result = null; + if(session.itemExists(path)) { + final Item it = session.getItem(path); + if(it.isNode()) { + result = (Node)it; + } + } else { + final int slashPos = path.lastIndexOf("/"); + final String parentPath = path.substring(0, slashPos); + final String childPath = path.substring(slashPos + 1); + result = deepCreateNode(parentPath, session, nodeType).addNode(childPath, nodeType); + session.save(); + } + return result; } private static URL[] getBootUrls(Bundle bundle) { Modified: sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala?rev=802844&r1=802843&r2=802844&view=diff == --- sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala (original) +++ sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/JcrFS.scala Mon Aug 10 16:18:31 2009 @@ -35,6 +35,7 @@ def create(node: Node): JcrNode = node.getPrimaryNodeType.getName match { case "nt:file" => JcrFile(node) // todo fix: dont hc ns prefixes case "nt:folder" => JcrFolder(node) +case "sling:Folder" => JcrFolder(node) case _ => throw new IOException("Neither file nor folder: " + node.getPath) } @@ -250,4 +251,4 @@ } -} \ No newline at end of file +}
svn commit: r803071 - in /sling/trunk/contrib/launchpad/testing: pom.xml src/main/resources/ src/main/resources/META-INF/ src/main/resources/META-INF/LICENSE src/main/resources/META-INF/NOTICE
Author: bdelacretaz Date: Tue Aug 11 11:44:39 2009 New Revision: 803071 URL: http://svn.apache.org/viewvc?rev=803071&view=rev Log: Use latest launchpad.base and add LICENSE/NOTICE Added: sling/trunk/contrib/launchpad/testing/src/main/resources/ sling/trunk/contrib/launchpad/testing/src/main/resources/META-INF/ sling/trunk/contrib/launchpad/testing/src/main/resources/META-INF/LICENSE sling/trunk/contrib/launchpad/testing/src/main/resources/META-INF/NOTICE Modified: sling/trunk/contrib/launchpad/testing/pom.xml Modified: sling/trunk/contrib/launchpad/testing/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/pom.xml?rev=803071&r1=803070&r2=803071&view=diff == --- sling/trunk/contrib/launchpad/testing/pom.xml (original) +++ sling/trunk/contrib/launchpad/testing/pom.xml Tue Aug 11 11:44:39 2009 @@ -221,7 +221,7 @@ org.apache.sling org.apache.sling.launchpad.base -2.0.4-incubator +2.0.5-SNAPSHOT true @@ -295,12 +295,11 @@ -${basedir} +src/main/resources/META-INF META-INF LICENSE* NOTICE* -DISCLAIMER @@ -648,7 +647,7 @@ org.apache.sling org.apache.sling.launchpad.base -2.0.4-incubator +2.0.5-SNAPSHOT webapp war runtime Added: sling/trunk/contrib/launchpad/testing/src/main/resources/META-INF/LICENSE URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/main/resources/META-INF/LICENSE?rev=803071&view=auto == --- sling/trunk/contrib/launchpad/testing/src/main/resources/META-INF/LICENSE (added) +++ sling/trunk/contrib/launchpad/testing/src/main/resources/META-INF/LICENSE Tue Aug 11 11:44:39 2009 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 +http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Wor
svn commit: r803086 - in /sling/trunk/installer: ./ osgi/
Author: bdelacretaz Date: Tue Aug 11 12:33:51 2009 New Revision: 803086 URL: http://svn.apache.org/viewvc?rev=803086&view=rev Log: SLING-1078 - creating new modules Added: sling/trunk/installer/ sling/trunk/installer/osgi/
svn commit: r803087 - /sling/trunk/installer/osgi/installer/
Author: bdelacretaz Date: Tue Aug 11 12:34:52 2009 New Revision: 803087 URL: http://svn.apache.org/viewvc?rev=803087&view=rev Log: SLING-1078 - creating new modules Added: sling/trunk/installer/osgi/installer/ - copied from r803086, sling/trunk/contrib/extensions/jcrinstall/osgi/
svn commit: r803088 - /sling/trunk/installer/osgi/it/
Author: bdelacretaz Date: Tue Aug 11 12:35:33 2009 New Revision: 803088 URL: http://svn.apache.org/viewvc?rev=803088&view=rev Log: SLING-1078 - creating new modules Added: sling/trunk/installer/osgi/it/ - copied from r803087, sling/trunk/contrib/extensions/jcrinstall/it/
svn commit: r803097 - /sling/trunk/installer/test/
Author: bdelacretaz Date: Tue Aug 11 12:53:22 2009 New Revision: 803097 URL: http://svn.apache.org/viewvc?rev=803097&view=rev Log: SLING-1078 - creating new modules Added: sling/trunk/installer/test/
svn commit: r803098 - /sling/trunk/installer/test/testbundles/
Author: bdelacretaz Date: Tue Aug 11 12:54:21 2009 New Revision: 803098 URL: http://svn.apache.org/viewvc?rev=803098&view=rev Log: SLING-1078 - creating new modules Added: sling/trunk/installer/test/testbundles/ - copied from r803097, sling/trunk/contrib/extensions/jcrinstall/testbundles/
svn commit: r803109 - in /sling/trunk/installer: ./ osgi/installer/ osgi/it/ osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/ test/
Author: bdelacretaz Date: Tue Aug 11 13:20:42 2009 New Revision: 803109 URL: http://svn.apache.org/viewvc?rev=803109&view=rev Log: SLING-1078 - adjust names, all tests pass now Added: sling/trunk/installer/pom.xml (with props) Removed: sling/trunk/installer/test/ Modified: sling/trunk/installer/ (props changed) sling/trunk/installer/osgi/installer/pom.xml sling/trunk/installer/osgi/it/pom.xml sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/SimpleFileInstallableData.java Propchange: sling/trunk/installer/ -- --- svn:ignore (added) +++ svn:ignore Tue Aug 11 13:20:42 2009 @@ -0,0 +1,3 @@ +target +cachedir +sling Modified: sling/trunk/installer/osgi/installer/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/pom.xml?rev=803109&r1=803108&r2=803109&view=diff == --- sling/trunk/installer/osgi/installer/pom.xml (original) +++ sling/trunk/installer/osgi/installer/pom.xml Tue Aug 11 13:20:42 2009 @@ -24,23 +24,23 @@ org.apache.sling sling 6 -../../../../parent/pom.xml +../../../parent/pom.xml org.apache.sling.osgi.installer - 2.0.3-SNAPSHOT + 3.0.0-SNAPSHOT bundle - Apache Sling OSGi installer + Apache Sling OSGi Installer Provides services to install OSGi bundles and configurations by supplying input streams and dictionaries. - scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jcrinstall/osgi - scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jcrinstall/osgi -http://svn.apache.org/viewvc/sling/whiteboard/jcrinstall + scm:svn:http://svn.apache.org/repos/asf/sling/trunk/installer/osgi/installer + scm:svn:https://svn.apache.org/repos/asf/sling/trunk/installer/osgi/installer +http://svn.apache.org/viewvc/sling/installer/osgi/installer Modified: sling/trunk/installer/osgi/it/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/pom.xml?rev=803109&r1=803108&r2=803109&view=diff == --- sling/trunk/installer/osgi/it/pom.xml (original) +++ sling/trunk/installer/osgi/it/pom.xml Tue Aug 11 13:20:42 2009 @@ -23,28 +23,26 @@ org.apache.sling sling 6 -../../../../parent/pom.xml +../../../parent/pom.xml -org.apache.sling.jcr.jcrinstall.it -2.0.3-SNAPSHOT +org.apache.sling.osgi.installer.it +3.0.0-SNAPSHOT jar -Apache Sling Jcrinstall Integration Tests - -Test the jcrinstall bundles in the OSGi framework. - +Apache Sling OSGi Installer Integration Tests +Integration tests of the Sling OSGi installer bundle - - scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jcrinstall/it - scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jcrinstall/it -http://svn.apache.org/viewvc/sling/whiteboard/jcrinstall - + + scm:svn:http://svn.apache.org/repos/asf/sling/trunk/installer/osgi/it + scm:svn:https://svn.apache.org/repos/asf/sling/trunk/installer/osgi/it +http://svn.apache.org/viewvc/sling/installer/osgi/it + @@ -241,7 +239,7 @@ org.apache.sling org.apache.sling.osgi.installer -2.0.3-SNAPSHOT +3.0.0-SNAPSHOT provided Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java?rev=803109&r1=803108&r2=803109&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java Tue Aug 11 13:20:42 2009 @@ -80,7 +80,7 @@ protected void generateBundleEvent() throws Exception { // install a bundle manually to generate a bundle event -final File f = getTestBundle("org.apache.sling.jcr.jcrinstall.it-" + POM_VERSION + "-testbundle-1.0.jar"); +final File f = getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION + "-testbundle-1.0.jar"); final InputStream is = new FileInputStream(f); Bundle b = null; try { @@ -249,19 +249,19 @@ lon
svn commit: r803115 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/ main/java/org/apache/sling/osgi/installer/impl/ main/java/org/apache/sling/osgi/installer
Author: bdelacretaz Date: Tue Aug 11 13:35:31 2009 New Revision: 803115 URL: http://svn.apache.org/viewvc?rev=803115&view=rev Log: SLING-1078 - remove some unused or useless classes Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallResultCode.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/JcrInstallException.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiResourceProcessor.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/MissingServiceException.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/jcr/ Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java?rev=803115&r1=803114&r2=803115&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java Tue Aug 11 13:35:31 2009 @@ -31,7 +31,7 @@ * @param uri Unique identifier for the resource * @param data The data to install */ -void scheduleInstallOrUpdate(String uri, InstallableData data) throws IOException, JcrInstallException; +void scheduleInstallOrUpdate(String uri, InstallableData data) throws IOException; /** Schedule uninstallation of resource that was installed via given uri. * Might be called several times for the same URI - needless calls should @@ -40,7 +40,7 @@ * @param attributes metadata stored by the OsgiController, will be * removed after calling this method */ -void scheduleUninstall(String uri) throws IOException, JcrInstallException; +void scheduleUninstall(String uri) throws IOException; /** Return the list of uri for resources that have been installed * by this controller. Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=803115&r1=803114&r2=803115&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Tue Aug 11 13:35:31 2009 @@ -20,7 +20,6 @@ import java.util.Hashtable; -import org.apache.sling.osgi.installer.JcrInstallException; import org.apache.sling.osgi.installer.OsgiController; import org.apache.sling.osgi.installer.OsgiControllerServices; import org.osgi.framework.BundleActivator; @@ -90,9 +89,9 @@ } /** Complain if value is null */ -static Object checkNotNull(Object value, String what) throws JcrInstallException { +static Object checkNotNull(Object value, String what) { if(value == null) { - throw new JcrInstallException(what + " is null, cannot activate"); + throw new IllegalArgumentException(what + " is null, cannot activate"); } return value; } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java?rev=803115&r1=803114&r2=803115&view=diff =
svn commit: r803124 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/ main/java/org/apache/sling/osgi/installer/impl/ main/java/org/apache/sling/osgi/installer
Author: bdelacretaz Date: Tue Aug 11 13:55:18 2009 New Revision: 803124 URL: http://svn.apache.org/viewvc?rev=803124&view=rev Log: SLING-1078 - more code cleanup Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReader.java - copied, changed from r803108, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/DictionaryReader.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/DictionaryReaderTest.java - copied, changed from r803116, sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryReaderTest.java Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/DictionaryReader.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/EventsCounter.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/EventsCounterImpl.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryReaderTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java?rev=803124&view=auto == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java (added) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiControllerServices.java Tue Aug 11 13:55:18 2009 @@ -0,0 +1,32 @@ +/* + * 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.osgi.installer; + +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.log.LogService; + +/** Proxy for services that might not be always available, allows + * classes which are not OSGi services to access such services easily. + * Should normally be part of the implementation package, but it is + * used in tests to find out when the controller is ready. + */ +public interface OsgiControllerServices { + ConfigurationAdmin getConfigurationAdmin(); + LogService getLogService(); +} Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=803124&r1=803123&r2=803124&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Tue Aug 11 13:55:18 2009 @@ -24,14 +24,18 @@ import org.apache.sling.osgi.installer.OsgiControllerServices; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleEvent; +import org.osgi.framework.BundleListener; import org.osgi.framework.Constants; +
svn commit: r803520 - in /sling/trunk/contrib: launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/scala/ launchpad/testing/src/test/resources/integration-test/scala/ scr
Author: bdelacretaz Date: Wed Aug 12 14:10:00 2009 New Revision: 803520 URL: http://svn.apache.org/viewvc?rev=803520&view=rev Log: SLING-1053 - Scala scripting tests, contributed by Michael Duerig, thanks! Modified: sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/scala/ScalaScriptingTest.java sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/scala/rendering-test.scs sling/trunk/contrib/scripting/scala/engine/README.txt sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngine.java sling/trunk/contrib/scripting/scala/engine/src/main/java/org/apache/sling/scripting/scala/engine/ScalaScriptEngineFactory.java sling/trunk/contrib/scripting/scala/engine/src/test/java/org/apache/sling/scripting/scala/ScalaScriptEngineTest.java sling/trunk/contrib/scripting/scala/engine/src/test/resources/scripts/simple.scs sling/trunk/contrib/scripting/scala/interpreter/ (props changed) sling/trunk/contrib/scripting/scala/interpreter/README.txt sling/trunk/contrib/scripting/scala/interpreter/src/main/scala/org/apache/sling/scripting/scala/interpreter/ScalaInterpreter.scala sling/trunk/contrib/scripting/scala/interpreter/src/test/scala/org/apache/sling/scripting/scala/interpreter/InterpreterTest.scala Modified: sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/scala/ScalaScriptingTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/scala/ScalaScriptingTest.java?rev=803520&r1=803519&r2=803520&view=diff == --- sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/scala/ScalaScriptingTest.java (original) +++ sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/scala/ScalaScriptingTest.java Wed Aug 12 14:10:00 2009 @@ -16,6 +16,9 @@ */ package org.apache.sling.launchpad.webapp.integrationtest.scala; +import java.util.HashMap; +import java.util.Map; + import org.apache.sling.commons.testing.integration.HttpTestBase; import org.apache.sling.servlets.post.SlingPostConstants; @@ -29,6 +32,15 @@ final String testRootPath = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + System.currentTimeMillis(); testRootUrl = testClient.createNode(testRootPath + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); + +Map nodeProperties = new HashMap(); +nodeProperties.put("jcr:primaryType", "nt:folder"); + +// fixme: this is a workaround for the post servlet returning 200 instead of 302 +// if the path is /var/classes +nodeProperties.put(":redirect", "*.json"); + +testClient.createNode(HTTP_BASE_URL + "/var/classes", nodeProperties); testNode = new TestNode(testRootPath + "/test", null); } Modified: sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/scala/rendering-test.scs URL: http://svn.apache.org/viewvc/sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/scala/rendering-test.scs?rev=803520&r1=803519&r2=803520&view=diff == --- sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/scala/rendering-test.scs (original) +++ sling/trunk/contrib/launchpad/testing/src/test/resources/integration-test/scala/rendering-test.scs Wed Aug 12 14:10:00 2009 @@ -16,13 +16,18 @@ * specific language governing permissions and limitations * under the License. */ +package nt.unstructured { + object html { +import html_Bindings._ -val html = Scala rendering result - - text value using resource.adaptTo:{ resource.adaptTo(classOf[javax.jcr.Node]).getProperty("text").getValue().getString() } - - - text value using currentNode:{ currentNode.getProperty("text").getValue().getString() } -; - -println(html) +println { + Scala rendering result + + text value using resource.adaptTo:{ resource.adaptTo(classOf[javax.jcr.Node]).getProperty("text").getValue().getString() } + + + text value using currentNode:{ currentNode.getProperty("text").getValue().getString() } + ; +} + } +} \ No newline at end of file Modified: sling/trunk/contrib/scripting/scala/engine/README.txt URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/scala/engine/README.txt?rev=803520&r1=803519&r2=803520&view=diff == --- sling/trunk
svn propchange: r803520 - svn:log
Author: bdelacretaz Revision: 803520 Modified property: svn:log Modified: svn:log at Wed Aug 12 14:17:44 2009 -- --- svn:log (original) +++ svn:log Wed Aug 12 14:17:44 2009 @@ -1 +1 @@ -SLING-1053 - Scala scripting tests, contributed by Michael Duerig, thanks! +SLING-1053 - Scala scripting improvements, contributed by Michael Duerig, thanks!
svn commit: r803809 - /sling/trunk/contrib/explorers/gwt/pom.xml
Author: bdelacretaz Date: Thu Aug 13 08:47:42 2009 New Revision: 803809 URL: http://svn.apache.org/viewvc?rev=803809&view=rev Log: SLING-990 - use plugin version from parent POM Modified: sling/trunk/contrib/explorers/gwt/pom.xml Modified: sling/trunk/contrib/explorers/gwt/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/pom.xml?rev=803809&r1=803808&r2=803809&view=diff == --- sling/trunk/contrib/explorers/gwt/pom.xml (original) +++ sling/trunk/contrib/explorers/gwt/pom.xml Thu Aug 13 08:47:42 2009 @@ -164,7 +164,6 @@ org.apache.sling maven-sling-plugin -2.0.3-incubator-SNAPSHOT install-bundle @@ -207,4 +206,4 @@ - \ No newline at end of file +
svn commit: r803819 [3/3] - in /sling/trunk/contrib/explorers/jquery: ./ src/ src/main/ src/main/resources/ src/main/resources/META-INF/ src/main/resources/libs/ src/main/resources/libs/sling/ src/mai
Propchange: sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/explorer/js/jquery-1.3.2.js -- svn:executable = *
svn commit: r803819 [1/3] - in /sling/trunk/contrib/explorers/jquery: ./ src/ src/main/ src/main/resources/ src/main/resources/META-INF/ src/main/resources/libs/ src/main/resources/libs/sling/ src/mai
Author: bdelacretaz Date: Thu Aug 13 09:40:03 2009 New Revision: 803819 URL: http://svn.apache.org/viewvc?rev=803819&view=rev Log: SLING-993 - experimental jQuery-based resource explorer Added: sling/trunk/contrib/explorers/jquery/ (with props) sling/trunk/contrib/explorers/jquery/LICENSE sling/trunk/contrib/explorers/jquery/NOTICE sling/trunk/contrib/explorers/jquery/README.txt (with props) sling/trunk/contrib/explorers/jquery/pom.xml (with props) sling/trunk/contrib/explorers/jquery/src/ sling/trunk/contrib/explorers/jquery/src/main/ sling/trunk/contrib/explorers/jquery/src/main/resources/ sling/trunk/contrib/explorers/jquery/src/main/resources/META-INF/ sling/trunk/contrib/explorers/jquery/src/main/resources/META-INF/LICENSE sling/trunk/contrib/explorers/jquery/src/main/resources/META-INF/NOTICE sling/trunk/contrib/explorers/jquery/src/main/resources/libs/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/explorer/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/explorer/css/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/explorer/css/explorer.css (with props) sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/explorer/js/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/explorer/js/explorer.js (with props) sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/explorer/js/jquery-1.3.2.js (with props) Propchange: sling/trunk/contrib/explorers/jquery/ -- --- svn:ignore (added) +++ svn:ignore Thu Aug 13 09:40:03 2009 @@ -0,0 +1,11 @@ +target +bin +derby.log +*.iml +*.ipr +*.iws +.settings +.project +.classpath +.externalToolBuilders +maven-eclipse.xml Added: sling/trunk/contrib/explorers/jquery/LICENSE URL: http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/jquery/LICENSE?rev=803819&view=auto == --- sling/trunk/contrib/explorers/jquery/LICENSE (added) +++ sling/trunk/contrib/explorers/jquery/LICENSE Thu Aug 13 09:40:03 2009 @@ -0,0 +1,232 @@ + + Apache License + Version 2.0, January 2004 +http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works
svn commit: r803820 - in /sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet: ./ default/ default/explorer/ default/explorer/explorer.esp default/explorer/item.esp default/expl
Author: bdelacretaz Date: Thu Aug 13 09:41:02 2009 New Revision: 803820 URL: http://svn.apache.org/viewvc?rev=803820&view=rev Log: SLING-993 - experimental jQuery-based resource explorer Added: sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp (with props) sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/item.esp (with props) sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/properties.esp (with props) Added: sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp URL: http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp?rev=803820&view=auto == --- sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp (added) +++ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp Thu Aug 13 09:41:02 2009 @@ -0,0 +1,60 @@ +<%-- +/* + * 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. + */ +--%> + + +Sling || JCR Explorer + + + + + + + + +http://incubator.apache.org/sling";> +http://incubator.apache.org/sling/site/media.data/logo.png"; alt="Apache Sling"/> + + + + + + + + + + + content + + + + Login + + Note that this explorer is still experimental + - + http://svn.apache.org/repos/asf/sling/trunk/contrib/explorers/jquery"; target="_new">patches are welcome! + + + + Propchange: sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp -- svn:executable = * Added: sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/item.esp URL: http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/item.esp?rev=803820&view=auto == --- sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/item.esp (added) +++ sling/trunk/contrib/explorers/jquery/src/main/resources/libs/sling/servlet/default/explorer/item.esp Thu Aug 13 09:41:02 2009 @@ -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. + */ +--%> + +<% +var nodes = request.resourceResolver.listChildren(resource); + +if (nodes.hasNext()) { + +%> + +<% + +while (nodes.hasNext()) { + var child = nodes.next(); +
svn propchange: r803819 - svn:log
Author: bdelacretaz Revision: 803819 Modified property: svn:log Modified: svn:log at Thu Aug 13 09:43:44 2009 -- --- svn:log (original) +++ svn:log Thu Aug 13 09:43:44 2009 @@ -1 +1 @@ -SLING-993 - experimental jQuery-based resource explorer +SLING-993 - experimental jQuery-based resource explorer - contributed by Renaud Richardet, thanks!
svn propchange: r803820 - svn:log
Author: bdelacretaz Revision: 803820 Modified property: svn:log Modified: svn:log at Thu Aug 13 09:43:52 2009 -- --- svn:log (original) +++ svn:log Thu Aug 13 09:43:52 2009 @@ -1 +1 @@ -SLING-993 - experimental jQuery-based resource explorer +SLING-993 - experimental jQuery-based resource explorer - contributed by Renaud Richardet, thanks!
svn commit: r803824 - in /sling/trunk/contrib/explorers/gwt: README.txt pom.xml
Author: bdelacretaz Date: Thu Aug 13 09:56:37 2009 New Revision: 803824 URL: http://svn.apache.org/viewvc?rev=803824&view=rev Log: SLING-990 - fix package imports/exports as suggested by Juanjo, thanks! Modified: sling/trunk/contrib/explorers/gwt/README.txt sling/trunk/contrib/explorers/gwt/pom.xml Modified: sling/trunk/contrib/explorers/gwt/README.txt URL: http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/README.txt?rev=803824&r1=803823&r2=803824&view=diff == --- sling/trunk/contrib/explorers/gwt/README.txt (original) +++ sling/trunk/contrib/explorers/gwt/README.txt Thu Aug 13 09:56:37 2009 @@ -60,3 +60,8 @@ See the Subversion documentation for other source control features. +Running the Explorer + +After installing the Explorer, http://localhost:8080/apps/explorer/index.html should display +its home page, which says "Sling Explorer" at the top and displays a tree with a Resources +root. Modified: sling/trunk/contrib/explorers/gwt/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/gwt/pom.xml?rev=803824&r1=803823&r2=803824&view=diff == --- sling/trunk/contrib/explorers/gwt/pom.xml (original) +++ sling/trunk/contrib/explorers/gwt/pom.xml Thu Aug 13 09:56:37 2009 @@ -66,9 +66,11 @@ true +!* +!* - SLING-INF/content/apps/explorer;overwrite:=true;uninstall=true;path:=/apps/explorer, - SLING-INF/content/apps/sling/servlet/default/explorer;overwrite:=true;uninstall=true;path:=/apps/sling/servlet/default/explorer + SLING-INF/content/apps/explorer;overwrite:=true;uninstall=true;path:=/apps/explorer, + SLING-INF/content/apps/sling/servlet/default/explorer;overwrite:=true;uninstall=true;path:=/apps/sling/servlet/default/explorer
svn commit: r803827 - in /sling/trunk/contrib/explorers/gwt: ./ src/main/resources/SLING-INF/content/apps/explorer/
Author: bdelacretaz Date: Thu Aug 13 10:09:38 2009 New Revision: 803827 URL: http://svn.apache.org/viewvc?rev=803827&view=rev Log: svn:ignore Modified: sling/trunk/contrib/explorers/gwt/ (props changed) sling/trunk/contrib/explorers/gwt/src/main/resources/SLING-INF/content/apps/explorer/ (props changed) Propchange: sling/trunk/contrib/explorers/gwt/ -- --- svn:ignore (added) +++ svn:ignore Thu Aug 13 10:09:38 2009 @@ -0,0 +1,11 @@ +target +bin +derby.log +*.iml +*.ipr +*.iws +.settings +.project +.classpath +.externalToolBuilders +maven-eclipse.xml Propchange: sling/trunk/contrib/explorers/gwt/src/main/resources/SLING-INF/content/apps/explorer/ -- --- svn:ignore (added) +++ svn:ignore Thu Aug 13 10:09:38 2009 @@ -0,0 +1 @@ +org.apache.sling.explorer.Explorer
svn commit: r803855 - in /sling/trunk/installer/osgi/it: ./ src/main/java/org/apache/sling/jcr/ src/main/java/org/apache/sling/osgi/ src/main/java/org/apache/sling/osgi/installer/ src/main/java/org/ap
Author: bdelacretaz Date: Thu Aug 13 12:09:49 2009 New Revision: 803855 URL: http://svn.apache.org/viewvc?rev=803855&view=rev Log: SLING-1078 - remove remaining references to jcrinstall, this module has no JCR dependencies anymore Added: sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/ sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/installer/ sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/installer/it/ sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/installer/it/Dummy.java - copied, changed from r803805, sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/Dummy.java sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/installer/it/a/ sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/installer/it/a/ClassA.java - copied, changed from r803805, sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/a/ClassA.java sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/installer/it/b/ sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/osgi/installer/it/b/ClassB.java - copied, changed from r803805, sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/jcr/jcrinstall/it/b/ClassB.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiControllerTest.java - copied, changed from r803805, sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/OsgiControllerTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/SimpleFileInstallableData.java - copied, changed from r803805, sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/jcrinstall/it/SimpleFileInstallableData.java Removed: sling/trunk/installer/osgi/it/src/main/java/org/apache/sling/jcr/ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/jcr/ Modified: sling/trunk/installer/osgi/it/pom.xml Modified: sling/trunk/installer/osgi/it/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/pom.xml?rev=803855&r1=803854&r2=803855&view=diff == --- sling/trunk/installer/osgi/it/pom.xml (original) +++ sling/trunk/installer/osgi/it/pom.xml Thu Aug 13 12:09:49 2009 @@ -77,11 +77,11 @@ ${pax.exam.debug.port} -jcrinstall.pom.version +osgi.installer.pom.version ${pom.version} -jcrinstall.base.dir +osgi.installer.base.dir ${project.build.directory} @@ -123,8 +123,8 @@ 2 -JCRinstall test bundle - jcrinstall-testbundle +OSGi controller test bundle + osgi-installer-testbundle 1.0 @@ -141,8 +141,8 @@ 2 -JCRinstall test bundle - jcrinstall-testbundle +OSGi controller test bundle + osgi-installer-testbundle 1.1 @@ -159,8 +159,8 @@ 2 -JCRinstall test bundle - jcrinstall-testbundle +OSGi controller test bundle + osgi-installer-testbundle 1.2 @@ -177,8 +177,8 @@ 2 -JCRinstall test bundle - jcrinstall-testA +OSGi controller test bundle + osgi
svn commit: r803862 - in /sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it: BundleInstallTest.java ConfigInstallTest.java OsgiControllerTest.java OsgiControllerTestBase.j
Author: bdelacretaz Date: Thu Aug 13 12:29:10 2009 New Revision: 803862 URL: http://svn.apache.org/viewvc?rev=803862&view=rev Log: SLING-1078 - separate tests in smaller classes, makes no difference to test execution time as pax web starts framework for each test anyway Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java (with props) sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java (with props) sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiControllerTestBase.java - copied, changed from r803855, sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiControllerTest.java Removed: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiControllerTest.java Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java?rev=803862&view=auto == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java (added) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java Thu Aug 13 12:29:10 2009 @@ -0,0 +1,233 @@ +/* + * 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.osgi.installer.it; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.apache.sling.osgi.installer.OsgiController; +import org.apache.sling.osgi.installer.OsgiControllerStatistics; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.osgi.framework.Bundle; + +...@runwith(JUnit4TestRunner.class) +public class BundleInstallTest extends OsgiControllerTestBase { + +@org.ops4j.pax.exam.junit.Configuration +public static Option[] configuration() { + return defaultConfiguration(); +} + + @Test +public void testInstallUpgradeDowngradeBundle() throws Exception { + final String symbolicName = "osgi-installer-testbundle"; + final String uri = symbolicName + JAR_EXT; + final String BUNDLE_VERSION = "Bundle-Version"; + + assertNull("Test bundle must not be present before test", findBundle(symbolicName)); + + // Install first test bundle and check version + long bundleId = 0; + final OsgiController c = getService(OsgiController.class); + { + c.scheduleInstallOrUpdate(uri, new SimpleFileInstallableData(getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION + "-testbundle-1.1.jar"))); + assertNull("Test bundle must be absent right after scheduleInstallOrUpdate", findBundle(symbolicName)); + c.executeScheduledOperations(); + final Bundle b = findBundle(symbolicName); + assertNotNull("Test bundle 1.1 must be found after executeScheduledOperations", b); + bundleId = b.getBundleId(); + assertEquals("Installed bundle must be started", Bundle.ACTIVE, b.getState()); + assertEquals("Version must be 1.1", "1.1", b.getHeaders().get(BUNDLE_VERSION)); + } + + // Upgrade to later version, verify + { + c.scheduleInstallOrUpdate(uri, new SimpleFileInstallableData(getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION + "-testbundle-1.2.jar"))); + c.executeScheduledOperations(); + final Bundle b = findBundle(symbolicName); + assertNotNull(&
svn commit: r803933 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/impl/ test/java/org/apache/sling/osgi/installer/impl/
Author: bdelacretaz Date: Thu Aug 13 15:39:31 2009 New Revision: 803933 URL: http://svn.apache.org/viewvc?rev=803933&view=rev Log: SLING-1078 - RegisteredResource tests Added: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InputStreamDigestTest.java (with props) sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/LocalFileRegisteredResource.java (with props) sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java (with props) Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=803933&r1=803932&r2=803933&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java Thu Aug 13 15:39:31 2009 @@ -84,7 +84,7 @@ } } - protected File getDataFile(BundleContext ctx) { + protected File getDataFile(BundleContext ctx) throws IOException { String filename = null; synchronized (getClass()) { filename = getClass().getSimpleName() + "." + fileNumber++; @@ -151,7 +151,6 @@ if(os != null) { os.close(); } - data.close(); } return digestToString(d); } Added: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InputStreamDigestTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InputStreamDigestTest.java?rev=803933&view=auto == --- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InputStreamDigestTest.java (added) +++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InputStreamDigestTest.java Thu Aug 13 15:39:31 2009 @@ -0,0 +1,50 @@ +/* + * 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.osgi.installer.impl; + +import java.io.ByteArrayInputStream; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.apache.sling.osgi.installer.InstallableResource; + +public class InputStreamDigestTest { + + private InstallableResource getInstallableResource(String data) { + return new InstallableResource(data, new ByteArrayInputStream(data.getBytes())); + } + + @org.junit.Test public void testStreamDigest() throws Exception { + final String data1 = "This is some data"; + final String data2 = "This is more data, which is different"; + + final RegisteredResource r1 = new LocalFileRegisteredResource(getInstallableResource(data1)); + final RegisteredResource r2 = new LocalFileRegisteredResource(getInstallableResource(data1)); + final RegisteredResource r3 = new LocalFileRegisteredResource(getInstallableResource(data2)); + + assertTrue("r1 has non-empty digest", r1.getDigest().length() > 5); + assertTrue("r2 has non-empty digest", r2.getDigest().length() > 5); + assertTrue("r3 has non-empty digest", r3.getDigest().length() > 5); + + assertEquals("r1 and r2 have same diges
svn commit: r804142 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/ main/java/org/apache/sling/osgi/installer/impl/ main/java/org/apache/sling/osgi/installer
Author: bdelacretaz Date: Fri Aug 14 09:42:59 2009 New Revision: 804142 URL: http://svn.apache.org/viewvc?rev=804142&view=rev Log: SLING-1078 - client must supply digest for InstallableResource that wraps an InputStream Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java - copied, changed from r804107, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java - copied, changed from r804107, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiController.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerImpl.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InputStreamDigestTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/Utilities.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=804142&r1=804141&r2=804142&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Fri Aug 14 09:42:59 2009 @@ -28,6 +28,7 @@ public class InstallableResource { private final String url; private final String extension; + private final String digest; private final InputStream inputStream; private final Dictionary dictionary; @@ -37,22 +38,41 @@ this.extension = getExtension(url); this.inputStream = null; this.dictionary = null; + this.digest = null; } - /** Create a data object that wraps an InputStream */ - public InstallableResource(String url, InputStream is) { + /** Create a data object that wraps an InputStream +* @param url unique URL of the supplied data, must start with the scheme used +* {...@link OsgiInstaller#registerResources} call +* @param is the resource contents +* @param digest must be supplied by client. Does not need to be an actual digest +* of the contents, but must change if the contents change. Having this supplied +* by the client avoids having to compute real digests to find out if a resource +* has changed, which can be expensive. +*/ + public InstallableResource(String url, InputStream is, String digest) { this.url = url; this.extension = getExtension(url); this.inputStream = is; this.dictionary = null; + this.digest = digest; } - /** Create a data object that wraps a Dictionary */ + /** Create a data object that wraps a Dictionary. Digest will be computed +* by the installer in this case, as configuration dictionaries are +* usually small so computing a real digest to find out if they changed +* is ok. +* + * @param url unique URL of the supplied data, must start with the scheme used + * {...@link OsgiInstaller#registerResources} call + * @param is the resource contents +*/ public InstallableResource(String url, Dictionary d) { this.url = url; this.extension = getExtension(url); this.inputStream = null; this.dictionary = d; +this.digest = null; } @Override @@ -66,9 +86,9 @@ return (pos < 0 ? "" : url.substring(pos+1)); } - /** Return this data's URL. It is opaque for the {...@link OsgiController}
svn commit: r804180 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/ installer/src/main/java/org/apache/sling/osgi/installer/impl/ it/src/test/java/org/apache
Author: bdelacretaz Date: Fri Aug 14 12:17:29 2009 New Revision: 804180 URL: http://svn.apache.org/viewvc?rev=804180&view=rev Log: SLING-1078 - integration tests minimally adapted, still fail Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java - copied, changed from r804107, sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiControllerTestBase.java Removed: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiControllerTestBase.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/SimpleFileInstallableData.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=804180&r1=804179&r2=804180&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Fri Aug 14 12:17:29 2009 @@ -90,10 +90,6 @@ * but the scheme must be the one used in the * {...@link OsgiInstaller#registerResources} call. */ - public String getURL() { - return url; - } - public String getUrl() { return url; } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java?rev=804180&r1=804179&r2=804180&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java Fri Aug 14 12:17:29 2009 @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.Collection; -import java.util.Map; /** OSGi Service that installs/updates/removes InstallableData * in the OSGi framework. @@ -33,7 +32,7 @@ * we might support deployment packages as well. */ public interface OsgiInstaller { - + /** Provide the installer with the complete list of installable * resources for a given client. * @@ -57,5 +56,11 @@ void removeResource(InstallableResource d) throws IOException; /** Return counters used for statistics, console display, testing, etc. */ - Map getCounters(); + long [] getCounters(); + + /** Counter index: number of OSGi tasks executed */ + int OSGI_TASKS_COUNTER = 0; + + /** Size of the counters array */ + int COUNTERS_SIZE = 1; } \ No newline at end of file Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=804180&r1=804179&r2=804180&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java Fri Aug 14 12:17:29 2009 @@ -20,8 +20,6 @@ import java.io.IOException; import java.util.Collection; -import java.util.HashMap; -import java.util.Map; import org.apache.sling.osgi.installer.InstallableResource; import org.apache.sling.osgi.installer.OsgiInstaller; @@ -38,7 +36,7 @@ private final BundleContext bundleContext; private final PackageAdmin packageAdmin; private final ServiceTracker logServiceTracker; -private Map counters = new HashMap(); +private long [] counters = new long[COUNTERS_SIZE]; public
svn commit: r804237 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ installer/src/te
Author: bdelacretaz Date: Fri Aug 14 14:28:27 2009 New Revision: 804237 URL: http://svn.apache.org/viewvc?rev=804237&view=rev Log: SLING-1078 - starting to rewrite integration tests, work in progress Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java - copied, changed from r804107, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java - copied, changed from r804107, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerTask.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Copied: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java (from r804107, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java) URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?p2=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java&p1=sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java&r1=804107&r2=804237&rev=804237&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiControllerContext.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java Fri Aug 14 14:28:27 2009 @@ -23,19 +23,20 @@ import org.osgi.service.log.LogService; import org.osgi.service.packageadmin.PackageAdmin; -/** Context for OsgiControllerTask */ -public interface OsgiControllerContext { +/** Installer context, gives access to selected methods of the {...@link OsgiInstallerImpl} */ +public interface OsgiInstallerContext { Storage getStorage(); BundleContext getBundleContext(); PackageAdmin getPackageAdmin(); ConfigurationAdmin getConfigurationAdmin(); LogService getLogService(); + void incrementCounter(int index); /** Schedule a task for execution in the current OsgiController cycle */ - void addTaskToCurrentCycle(OsgiControllerTask t); + void addTaskToCurrentCycle(OsgiInstallerTask t); /** Schedule a task for execution in the next OsgiController cycle, * usually to indicate that a task must be retried */ - void addTaskToNextCycle(OsgiControllerTask t); +
svn commit: r804238 - in /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl: OsgiInstallerThread.java tasks/BundleInstallTask.java
Author: bdelacretaz Date: Fri Aug 14 14:29:09 2009 New Revision: 804238 URL: http://svn.apache.org/viewvc?rev=804238&view=rev Log: SLING-1078 - starting to rewrite integration tests, work in progress Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (with props) sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java (with props) Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=804238&view=auto == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (added) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Fri Aug 14 14:29:09 2009 @@ -0,0 +1,111 @@ +/* + * 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.osgi.installer.impl; + +import java.util.LinkedList; +import java.util.List; +import java.util.TreeSet; + +import org.apache.sling.osgi.installer.impl.tasks.BundleInstallTask; +import org.osgi.service.log.LogService; + +/** Worker thread where all OSGi tasks are executed. + * Runs cycles where the list of RegisteredResources is examined, + * OsgiTasks are created accordingly and executed. + * + * A separate list of RegisteredResources is kept for resources + * that are updated or removed during a cycle, and merged with + * the main list at the end of the cycle. + */ +class OsgiInstallerThread extends Thread { + +private final OsgiInstallerContext ctx; +private final List newResources = new LinkedList(); +private final List registeredResources = new LinkedList(); +private final TreeSet tasks = new TreeSet(); + +OsgiInstallerThread(OsgiInstallerContext ctx) { +setName(getClass().getSimpleName()); +this.ctx = ctx; +} + +@Override +public void run() { +while(true) { +// TODO do nothing if nothing to process! +try { +mergeNewResources(); +computeListOfTasks(); +executeTasks(); +Thread.sleep(250); +} catch(Exception e) { +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_WARNING, e.toString(), e); +} +try { +Thread.sleep(1000); +} catch(InterruptedException ignored) { +} +} +} +} + +private void mergeNewResources() { +synchronized (newResources) { +registeredResources.addAll(newResources); +newResources.clear(); +} +} + +private void computeListOfTasks() { +for(RegisteredResource r : registeredResources) { +if(r.getResourceType() == RegisteredResource.ResourceType.BUNDLE) { +tasks.add(new BundleInstallTask(r)); +} +} +} + +void addTaskToCurrentCycle(OsgiInstallerTask t) { +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "adding task to current cycle:" + t); +} +synchronized (tasks) { +tasks.add(t); +} +} + +private void executeTasks() throws Exception { +while(!tasks.isEmpty()) { +OsgiInstallerTask t = null; +synchronized (tasks) { +t = tasks.first(); +} +t.execute(ctx); +synchronized (tasks) { +tasks.remove(t); +} +} +} + +void addResource(RegisteredResource r) { +synchronized (newResources) { +newResources.add(r); +} +} +} Propchange: sling/trunk/installer/osgi/installer/src/main/jav
svn commit: r804280 - in /sling/trunk/installer/osgi/installer: ./ src/main/java/org/apache/sling/osgi/installer/impl/ src/main/java/org/apache/sling/osgi/installer/impl/tasks/ src/test/java/org/apach
Author: bdelacretaz Date: Fri Aug 14 16:22:45 2009 New Revision: 804280 URL: http://svn.apache.org/viewvc?rev=804280&view=rev Log: SLING-1078 - entity IDs and RegisteredResourceList added Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigurationPid.java - copied, changed from r804107, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPid.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java (with props) sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceList.java (with props) Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPid.java Modified: sling/trunk/installer/osgi/installer/pom.xml sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/ConfigurationPidTest.java Modified: sling/trunk/installer/osgi/installer/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/pom.xml?rev=804280&r1=804279&r2=804280&view=diff == --- sling/trunk/installer/osgi/installer/pom.xml (original) +++ sling/trunk/installer/osgi/installer/pom.xml Fri Aug 14 16:22:45 2009 @@ -42,27 +42,68 @@ scm:svn:https://svn.apache.org/repos/asf/sling/trunk/installer/osgi/installer http://svn.apache.org/viewvc/sling/installer/osgi/installer - - - - -org.apache.felix -maven-bundle-plugin -true - - - -org.apache.sling.osgi.installer.impl.Activator + + + + + org.apache.felix + maven-bundle-plugin + true + + + + org.apache.sling.osgi.installer.impl.Activator - -org.apache.sling.osgi.installer + + org.apache.sling.osgi.installer - org.apache.sling.osgi.installer.impl.* - - - - - + org.apache.sling.osgi.installer.impl.* + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + osgi.installer.base.dir + ${project.build.directory} + + +osgi.installer.pom.version +${pom.version} + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + testbundle-1.0 + compile + + jar + + +
svn commit: r804906 - in /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl: BundleTaskCreator.java OsgiInstallerImpl.java OsgiInstallerThread.java RegisteredReso
Author: bdelacretaz Date: Mon Aug 17 09:27:26 2009 New Revision: 804906 URL: http://svn.apache.org/viewvc?rev=804906&view=rev Log: SLING-1078 - ready to implement task creators Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java (with props) Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceList.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=804906&view=auto == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java (added) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java Mon Aug 17 09:27:26 2009 @@ -0,0 +1,33 @@ +/* + * 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.osgi.installer.impl; + +import java.util.TreeSet; + +import org.apache.sling.osgi.installer.impl.tasks.BundleInstallTask; + +/** TaskCreator that processes a list of bundle RegisteredResources */ +class BundleTaskCreator implements OsgiInstallerThread.TaskCreator { + + public void createTasks(TreeSet resources, TreeSet tasks) { + for(RegisteredResource r : resources) { + tasks.add(new BundleInstallTask(r)); + } + } +} Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java -- svn:eol-style = native Propchange: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java -- svn:keywords = Author Date Id Revision Rev URL Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=804906&r1=804905&r2=804906&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java Mon Aug 17 09:27:26 2009 @@ -102,7 +102,7 @@ public void addResource(InstallableResource r) throws IOException { // TODO do not add if we already have it, based on digest - installerThread.addResource(new RegisteredResource(bundleContext, r)); + installerThread.addNewResource(new RegisteredResource(bundleContext, r)); } public void registerResources(Collection data, Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=804906&r1=804905&r2=804906&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Mon Aug 17 09:27:26 2009 @@ -18,8 +18,10 @@ */ package org.apache.sl
svn commit: r805489 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java it/src/test/java/org/apache/sling/osgi/installer/it/BundleIn
Author: bdelacretaz Date: Tue Aug 18 16:47:22 2009 New Revision: 805489 URL: http://svn.apache.org/viewvc?rev=805489&view=rev Log: SLING-1078 - 'remove bundle' integration test passes Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=805489&r1=805488&r2=805489&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Tue Aug 18 16:47:22 2009 @@ -110,6 +110,12 @@ t = createRegisteredResourcesEntry(); registeredResources.put(r.getEntityId(), t); } + +// If an object with same sort key is already present, replace with the +// new one which might have different attributes +if(t.contains(r)) { +t.remove(r); +} t.add(r); } newResources.clear(); Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java?rev=805489&r1=805488&r2=805489&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java Tue Aug 18 16:47:22 2009 @@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertFalse; import org.apache.sling.osgi.installer.OsgiInstaller; import org.junit.After; @@ -100,26 +101,39 @@ assertEquals("Bundle ID must not change after ignored downgrade", bundleId, b.getBundleId()); } -/** TODO // Uninstall { - c.scheduleUninstall(uri); - c.waitForInstallerAction(); - final Bundle b = findBundle(symbolicName); - assertNull("Test bundle 1.2 must be gone", b); +resetCounters(); +installer.removeResource(getInstallableResource( +getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION + "-testbundle-1.0.jar"))); +installer.removeResource(getInstallableResource( +getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION + "-testbundle-1.1.jar"))); +installer.removeResource(getInstallableResource( +getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION + "-testbundle-1.2.jar"))); + +// wait for one task: uninstall +waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1); +final Bundle b = findBundle(symbolicName); +assertNull("Bundle must be gone", b); } - // Install lower version, must work - { - c.scheduleInstallOrUpdate(uri, new FileInstallableResource(getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION + "-testbundle-1.0.jar"))); - c.waitForInstallerAction(); - final Bundle b = findBundle(symbolicName); - assertNotNull("Test bundle 1.0 must be found after waitForInstallerAction", b); - assertEquals("Installed bundle must be started", Bundle.ACTIVE, b.getState()); - assertEquals("Version must be 1.0 after uninstall and downgrade", "1.0", b.getHeaders().get(BUNDLE_VERSION)); - assertFalse("Bundle ID must have changed after uninstall and reinstall", bundleId == b.getBundleId()); - } - */ + /** TODO + // Reinstall lower version, must work +{ +resetCounters(); +installer.addResource(getInstallableResource( +getTestBundle("org.apache.sling.osgi.installer.it-" + POM_VERSION +
svn commit: r805730 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ it/ it/src/test/
Author: bdelacretaz Date: Wed Aug 19 10:17:55 2009 New Revision: 805730 URL: http://svn.apache.org/viewvc?rev=805730&view=rev Log: SLING-1078 - 'Reinstall lower version' integration test passes Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java sling/trunk/installer/osgi/it/pom.xml sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java?rev=805730&r1=805729&r2=805730&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerTask.java Wed Aug 19 10:17:55 2009 @@ -18,10 +18,16 @@ */ package org.apache.sling.osgi.installer.impl; +import org.osgi.service.log.LogService; + /** Base class for tasks that can be executed by the {...@link OsgiInstallerImpl} */ public abstract class OsgiInstallerTask implements Comparable { /** Execute this task */ - public abstract void execute(OsgiInstallerContext ctx) throws Exception; + public void execute(OsgiInstallerContext ctx) throws Exception { + if(ctx.getLogService() != null) { + ctx.getLogService().log(LogService.LOG_DEBUG, "Executing task " + this); + } + } /** Tasks are sorted according to this key */ public abstract String getSortKey(); Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java?rev=805730&r1=805729&r2=805730&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java Wed Aug 19 10:17:55 2009 @@ -32,6 +32,11 @@ this.resource = r; } +@Override +public String toString() { + return getClass().getSimpleName() + ": " + resource; +} + @Override public void execute(OsgiInstallerContext ctx) throws Exception { final Bundle b = ctx.getBundleContext().installBundle(resource.getUrl(), resource.getInputStream()); Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java?rev=805730&r1=805729&r2=805730&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java Wed Aug 19 10:17:55 2009 @@ -36,6 +36,11 @@ this.resource = r; } +@Override +public String toString() { + return getClass().getSimpleName() + ": " + resource; +} + @Override public void execute(OsgiInstallerContext ctx) throws Exception { final String symbolicName = (String)resource.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME); Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java?rev=805730&r1=805729&r2=805730&view=diff == --- sling/trunk/installer/osgi/instal
svn commit: r805838 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ it/src/test/java/org/apache/sling/osgi/installer/it/
Author: bdelacretaz Date: Wed Aug 19 15:30:04 2009 New Revision: 805838 URL: http://svn.apache.org/viewvc?rev=805838&view=rev Log: SLING-1078 - all integration tests from take three re-activated and all pass Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java (with props) sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java - copied, changed from r805815, sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java (with props) sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java (with props) Removed: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=805838&r1=805837&r2=805838&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java Wed Aug 19 15:30:04 2009 @@ -89,8 +89,7 @@ if(getLogService() != null) { getLogService().log(LogService.LOG_DEBUG, "adding task to next cycle:" + t); } - // TODO - //tasksForNextCycle.add(t); + installerThread.addTaskToNextCycle(t); } public BundleContext getBundleContext() { Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=805838&r1=805837&r2=805838&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Wed Aug 19 15:30:04 2009 @@ -18,11 +18,11 @@ */ package org.apache.sling.osgi.installer.impl; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -42,6 +42,7 @@ private final OsgiInstallerContext ctx; private final List newResources = new LinkedList(); private final SortedSet tasks = new TreeSet(); +private final SortedSet tasksForNextCycle = new TreeSet(); /** Group our RegisteredResource by OSGi entity */ private Map>registeredResources = @@ -121,6 +122,12 @@ newResources.clear(); } } + +void addTaskToNextCycle(OsgiInstallerTask t) { +synchronized (tasksForNextCycle) { +tasksForNextCycle.add(t); +} +} /** Factored out to use the exact same structure in tests */ static SortedSet createRegisteredResourcesEntry() { @@ -128,8 +135,22 @@ } -/** Compute OSGi tasks based on our resources, and add to supplied list of tasks */ -void computeTasks() { +/** Compute OSGi tasks based on our resources, and add to supplied list of tasks */ +void computeTasks() throws Exception { +// Add tasks that were scheduled for next cycle and are executable now +final List toKeep = new ArrayList(); +synchronized (tasksForNextCycle) { +for(OsgiInstallerTask t : tasksForNextCycle) { +if(t.isExecutable(ctx)) { +tasks.add(t); +} else { +toKeep.add(t); +} +} +tasksForNextCycle.clear(); +tasksForNextCycle.addAll(toKeep); +} + // Walk the list of entities, and create appropriate OSGi tasks for each group for(SortedSet group : registe
svn commit: r805850 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/impl/tasks/ test/java/org/apache/sling/osgi/installer/impl/ test/java/org/apache/sling/osg
Author: bdelacretaz Date: Wed Aug 19 15:47:20 2009 New Revision: 805850 URL: http://svn.apache.org/viewvc?rev=805850&view=rev Log: SLING-1078 - obsolete classes removed Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/InstallRemoveTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallRemoveIgnoreTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java?rev=805850&r1=805849&r2=805850&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java Wed Aug 19 15:47:20 2009 @@ -24,6 +24,8 @@ import org.apache.sling.osgi.installer.impl.RegisteredResource; import org.osgi.framework.Bundle; +/** Install a bundle supplied as a RegisteredResource. + * Creates a BundleStartTask to start the bundle */ public class BundleInstallTask extends OsgiInstallerTask { private final RegisteredResource resource; @@ -46,7 +48,7 @@ @Override public String getSortKey() { -return TaskOrder.BUNDLE_INSTALL_ORDER; +return TaskOrder.BUNDLE_INSTALL_ORDER + resource.getUrl(); } } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java?rev=805850&r1=805849&r2=805850&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java Wed Aug 19 15:47:20 2009 @@ -25,8 +25,9 @@ import org.osgi.framework.Bundle; import org.osgi.framework.Constants; -/** Remove a bundle from a RegisteredResource. Creates - * a refresh packages task when executed. +/** Remove a bundle from a RegisteredResource. + * Creates a SynchronousRefreshPackagesTask when + * executed. */ public class BundleRemoveTask extends OsgiInstallerTask { @@ -56,7 +57,7 @@ @Override public String getSortKey() { -return TaskOrder.BUNDLE_REMOVE_ORDER; +return TaskOrder.BUNDLE_REMOVE_ORDER + resource.getUrl(); } } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java?rev=805850&r1=805849&r2=805850&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java Wed Aug 19 15:47:20 2009 @@ -28,7 +28,11 @@ import org.osgi.framework.BundleException; import org.osgi.service.log.LogService; -/** Task that starts a bundle */ +/** Start a bundle given its bundle ID + * Restarts if the bundle does not start on the first try, + * but only after receiving a bundle or framework event, + * indicating that it's worth retrying + */ public cl
svn commit: r805872 - in /sling/trunk/installer/osgi: installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java it/pom.xml it/src/test/java/org/apache/sling/osgi/installe
Author: bdelacretaz Date: Wed Aug 19 16:38:00 2009 New Revision: 805872 URL: http://svn.apache.org/viewvc?rev=805872&view=rev Log: SLING-1078 - BundleSnapshotUpdateTest added Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java (with props) Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java sling/trunk/installer/osgi/it/pom.xml Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java?rev=805872&r1=805871&r2=805872&view=diff == --- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java (original) +++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java Wed Aug 19 16:38:00 2009 @@ -125,7 +125,9 @@ @Test public void testBundleUpgradeSnapshot() { -final String v = "2.0.7.-SNAPSHOT"; +// Need to use OSGi-compliant version number, in bundles +// bnd and other tools generate correct numbers. +final String v = "2.0.7.SNAPSHOT"; final RegisteredResource [] r = { new MockBundleResource(SN, v) }; Modified: sling/trunk/installer/osgi/it/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/pom.xml?rev=805872&r1=805871&r2=805872&view=diff == --- sling/trunk/installer/osgi/it/pom.xml (original) +++ sling/trunk/installer/osgi/it/pom.xml Wed Aug 19 16:38:00 2009 @@ -235,6 +235,32 @@ + +snapshot-1.0 +compile + +jar + + +snap + +**/b/** +META-INF/** + + + +2 +OSGi controller test bundle + osgi-installer-snapshot-test + + 1.0.0.SNAPSHOT + + + + Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java?rev=805872&view=auto == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java (added) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java Wed Aug 19 16:38:00 2009 @@ -0,0 +1,96 @@ +/* + * 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.osgi.installer.it; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.apache.sling.osgi.installer.OsgiInstaller; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.osgi.framework.Bundle; + +/** Verify that snapshot bundles are updated even if + * their version
svn commit: r806097 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ installer/src/te
Author: bdelacretaz Date: Thu Aug 20 09:31:54 2009 New Revision: 806097 URL: http://svn.apache.org/viewvc?rev=806097&view=rev Log: SLING-1078 - keep track of bundle digests to avoid unnecessary updates, and test snapshot updates Added: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java - copied, changed from r805815, sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java Removed: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiControllerContext.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleInstallTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleStartTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/SynchronousRefreshPackagesTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/BundleTaskCreatorTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleTaskCreator.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=806097&r1=806096&r2=806097&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java Thu Aug 20 09:31:54 2009 @@ -18,6 +18,8 @@ */ package org.apache.sling.osgi.installer.impl; +import java.util.HashMap; +import java.util.Map; import java.util.SortedSet; import org.apache.sling.osgi.installer.impl.tasks.BundleInstallTask; @@ -25,15 +27,21 @@ import org.apache.sling.osgi.installer.impl.tasks.BundleUpdateTask; import org.apache.sling.osgi.installer.impl.tasks.TaskUtilities; import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.Version; +import org.osgi.service.log.LogService; /** TaskCreator that processes a list of bundle RegisteredResources */ class BundleTaskCreator implements OsgiInstallerThread.TaskCreator { public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT"; +/** Store the digests of the bundles for which we create update tasks, + * keyed by symbolic name, to avoid generating repated updates + * for snapshot bundles + */ +private final Map digests = new HashMap(); + /** Holds the bundle info that we need, makes it easier to test * without an OSGi framework */ static class BundleInfo { @@ -56,7 +64,7 @@ * has desired state == active, and generates the appropriate OSGi tasks to * reach this state. */ - public void createTasks(BundleContext ctx, SortedSet resources, SortedSet tasks) { + public void createTasks(OsgiInstallerContext ctx, SortedSet resources, SortedSet tasks) { // Find the bundle that must be active: the resources collection is ordered according // to priorities, so we just need to find the first one that is installable @@ -68,10 +76,15 @@ } } + RegisteredResource toUpdate = null; + String digestToSave = null; + final RegisteredResource firstResource = resources.first(); +
svn commit: r806168 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ installer/src/te
Author: bdelacretaz Date: Thu Aug 20 13:42:10 2009 New Revision: 806168 URL: http://svn.apache.org/viewvc?rev=806168&view=rev Log: SLING-1078 - OsgiInstaller.registerResources() implemented and tested Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java (with props) Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleDependenciesTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleSnapshotUpdateTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=806168&r1=806167&r2=806168&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java Thu Aug 20 13:42:10 2009 @@ -19,7 +19,9 @@ package org.apache.sling.osgi.installer.impl; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.apache.sling.osgi.installer.InstallableResource; import org.apache.sling.osgi.installer.OsgiInstaller; @@ -105,19 +107,21 @@ } public void addResource(InstallableResource r) throws IOException { - // TODO do not add if we already have it, based on digest - installerThread.addNewResource(new RegisteredResourceImpl(bundleContext, r)); + synchronized (installerThread) { + installerThread.addNewResource(new RegisteredResourceImpl(bundleContext, r)); +} } - public void registerResources(Collection data, - String urlScheme) throws IOException { - // TODO + public void registerResources(Collection data, String urlScheme) throws IOException { +installerThread.addNewResources(data, urlScheme, bundleContext); } public void removeResource(InstallableResource r) throws IOException { final RegisteredResource rr = new RegisteredResourceImpl(bundleContext, r); rr.setInstallable(false); - installerThread.addNewResource(rr); +synchronized (installerThread) { +installerThread.addNewResource(rr); +} } public Storage getStorage() { Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=806168&r1=806167&r2=806168&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Thu Aug 20 13:42:10 2009 @@ -18,14 +18,20 @@ */ package org.apache.sling.os
svn commit: r806231 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/ installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org
Author: bdelacretaz Date: Thu Aug 20 15:58:09 2009 New Revision: 806231 URL: http://svn.apache.org/viewvc?rev=806231&view=rev Log: SLING-1078 - bundle priorities added Added: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java (with props) sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundlePrioritiesTest.java (with props) Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockBundleResource.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=806231&r1=806230&r2=806231&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Thu Aug 20 15:58:09 2009 @@ -31,6 +31,10 @@ private final String digest; private final InputStream inputStream; private final Dictionary dictionary; + private int priority; + + /** Default resource priority */ + public static final int DEFAULT_PRIORITY = 100; /** Create an empty data object, used when removing resources */ public InstallableResource(String url) { @@ -39,6 +43,7 @@ this.inputStream = null; this.dictionary = null; this.digest = null; + this.priority = DEFAULT_PRIORITY; } /** Create a data object that wraps an InputStream @@ -56,6 +61,7 @@ this.inputStream = is; this.dictionary = null; this.digest = digest; +this.priority = DEFAULT_PRIORITY; } /** Create a data object that wraps a Dictionary. Digest will be computed @@ -73,6 +79,7 @@ this.inputStream = null; this.dictionary = d; this.digest = null; +this.priority = DEFAULT_PRIORITY; } @Override @@ -94,19 +101,40 @@ return url; } + /** Return this resource's extension, based on its URL */ public String getExtension() { return extension; } + /** Return an input stream with the data of this resource. Null if resource +* contains a dictionary instead. Caller is responsible for closing the stream. +*/ public InputStream getInputStream() { return inputStream; } + /** Return this resource's dictionary. Null if resource contains an InputStream instead */ public Dictionary getDictionary() { return dictionary; } - + + /** Return this resource's digest. Not necessarily an actual md5 or other digest of the +* data, can be any string that changes if the data changes. +*/ public String getDigest() { return digest; } + + /** Return the priority of this resource. Priorities are used to decide which +* resource to install when several are registered for the same OSGi entity +* (bundle, config, etc.) +*/ +public int getPriority() { +return priority; +} + +/** Set the priority of this resource */ +public void setPriority(int priority) { +this.priority = priority; +} } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java?rev=806231&r1=806230&r2=806231&view=diff ===
svn commit: r806248 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/ installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/test/java/org
Author: bdelacretaz Date: Thu Aug 20 16:47:14 2009 New Revision: 806248 URL: http://svn.apache.org/viewvc?rev=806248&view=rev Log: SLING-1078 - purge uninstallable resources and groups Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java?rev=806248&r1=806247&r2=806248&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java Thu Aug 20 16:47:14 2009 @@ -64,6 +64,13 @@ /** Counter index: number of installer cycles */ int INSTALLER_CYCLES_COUNTER = 1; +/** Counter index: number of currently registered resources */ +int REGISTERED_RESOURCES_COUNTER = 2; + +/** Counter index: number of currently registered resource groups + * of resources having the same OSGi entity ID */ +int REGISTERED_GROUPS_COUNTER = 3; + /** Size of the counters array */ - int COUNTERS_SIZE = 2; + int COUNTERS_SIZE = 4; } \ No newline at end of file Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?rev=806248&r1=806247&r2=806248&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java Thu Aug 20 16:47:14 2009 @@ -31,6 +31,7 @@ ConfigurationAdmin getConfigurationAdmin(); LogService getLogService(); void incrementCounter(int index); +void setCounter(int index, long value); /** Schedule a task for execution in the current OsgiController cycle */ void addTaskToCurrentCycle(OsgiInstallerTask t); Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=806248&r1=806247&r2=806248&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java Thu Aug 20 16:47:14 2009 @@ -49,12 +49,7 @@ this.packageAdmin = pa; this.logServiceTracker = logServiceTracker; -installerThread = new OsgiInstallerThread(this) { -@Override -protected void cycleDone() { -incrementCounter(INSTALLER_CYCLES_COUNTER); -} -}; +installerThread = new OsgiInstallerThread(this); installerThread.setDaemon(true); installerThread.start(); } @@ -132,4 +127,8 @@ public void incrementCounter(int index) { counters[index]++; } + +public void setCounter(int index, long value) { +counters[index] = value; +} } \ No newline at end of file Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?
svn commit: r806448 - /sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java
Author: bdelacretaz Date: Fri Aug 21 08:22:09 2009 New Revision: 806448 URL: http://svn.apache.org/viewvc?rev=806448&view=rev Log: SLING-1078 - RegisterResourcesTest verifies that URL scheme is taken into account in registerResources() Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java?rev=806448&r1=806447&r2=806448&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Fri Aug 21 08:22:09 2009 @@ -16,6 +16,7 @@ */ package org.apache.sling.osgi.installer.it; +import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -98,6 +99,17 @@ } { +// Add a bundle with different URL scheme - must not be removed by registerResources +resetCounters(); +installer.addResource(new InstallableResource( +"anotherscheme:testA.jar", +new FileInputStream(getTestBundle(BUNDLE_BASE_NAME + "-testA-1.0.jar")), +"digest1")); +waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 2); +assertBundle("testA bundle added", "osgi-installer-testA", "1.0", Bundle.ACTIVE); +} + +{ // Simulate later registration where some bundles have disappeared // the installer must mark them "not installable" and act accordingly final List r = new ArrayList(); @@ -117,6 +129,7 @@ assertFalse("Bundle needsB must be stopped as testB is gone (" + state + ")", Bundle.ACTIVE == state); assertBundle("Testbundle must be back to 1.0 as 1.1 and 1.2 is gone", "osgi-installer-testbundle", "1.0", Bundle.ACTIVE); +assertBundle("testA bundle should still be present", "osgi-installer-testA", "1.0", Bundle.ACTIVE); } { @@ -135,6 +148,7 @@ b.start(); assertBundle("After reinstalling testB, needsB must be startable, ", "osgi-installer-needsB", "1.0", Bundle.ACTIVE); +assertBundle("testA bundle should still be present", "osgi-installer-testA", "1.0", Bundle.ACTIVE); } } }
svn commit: r806483 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/ installer/src/main/java/org/apache/sling/osgi/installer/impl/ it/src/test/java/org/apache
Author: bdelacretaz Date: Fri Aug 21 10:15:34 2009 New Revision: 806483 URL: http://svn.apache.org/viewvc?rev=806483&view=rev Log: SLING-1078 - Worker thread waits when it has nothing to do Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/WorkerThreadIdleTest.java (with props) Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java?rev=806483&r1=806482&r2=806483&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java Fri Aug 21 10:15:34 2009 @@ -71,6 +71,12 @@ * of resources having the same OSGi entity ID */ int REGISTERED_GROUPS_COUNTER = 3; +/** Counter index: is worker thread idle? (not really a counter: 1 means true) */ +int WORKER_THREAD_IS_IDLE_COUNTER = 4; + +/** Counter index: how many times did worker thread become idle */ +int WORKER_THREAD_BECOMES_IDLE_COUNTER = 5; + /** Size of the counters array */ - int COUNTERS_SIZE = 4; + int COUNTERS_SIZE = 6; } \ No newline at end of file Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java?rev=806483&r1=806482&r2=806483&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java Fri Aug 21 10:15:34 2009 @@ -19,9 +19,7 @@ package org.apache.sling.osgi.installer.impl; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import org.apache.sling.osgi.installer.InstallableResource; import org.apache.sling.osgi.installer.OsgiInstaller; @@ -55,6 +53,7 @@ } public void deactivate() { +installerThread.deactivate(); if(getLogService() != null) { getLogService().log(LogService.LOG_WARNING, OsgiInstaller.class.getName() Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=806483&r1=806482&r2=806483&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Fri Aug 21 10:15:34 2009 @@ -31,6 +31,10 @@ import org.apache.sling.osgi.installer.InstallableResource; import org.apache.sling.osgi.installer.OsgiInstaller; import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleEvent; +import org.osgi.framework.BundleListener; +import org.osgi.framework.FrameworkEvent; +import org.osgi.framework.FrameworkListener; import org.osgi.service.log.LogService; /** Worker thread where all OSGi tasks are executed. @@ -41,13 +45,14 @@ * that are updated or removed during a cycle, and merged with * the main list at the end of the cycle. */ -class OsgiInstallerThread extends Thread { +class OsgiInstallerThread extends Thread implements FrameworkListener, B
svn commit: r806524 - /sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java
Author: bdelacretaz Date: Fri Aug 21 12:12:06 2009 New Revision: 806524 URL: http://svn.apache.org/viewvc?rev=806524&view=rev Log: SLING-1078 - Avoid timing dependencies in test Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java?rev=806524&r1=806523&r2=806524&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java Fri Aug 21 12:12:06 2009 @@ -80,11 +80,18 @@ assertCounter(OsgiInstaller.REGISTERED_RESOURCES_COUNTER, 5); assertCounter(OsgiInstaller.REGISTERED_GROUPS_COUNTER, 3); +resetCounters(); installer.removeResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.0.jar"))); + waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1); + +resetCounters(); installer.removeResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.1.jar"))); + waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1); + resetCounters(); installer.removeResource(getInstallableResource(getTestBundle(BUNDLE_BASE_NAME + "-testbundle-1.2.jar"))); -waitForInstallerAction(OsgiInstaller.OSGI_TASKS_COUNTER, 1); + waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1); + assertNull("testbundle must be gone at end of test", findBundle("osgi-installer-testbundle")); // Now check that bundles A and B have kept their states
svn commit: r806566 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ installer/src/te
Author: bdelacretaz Date: Fri Aug 21 14:16:56 2009 New Revision: 806566 URL: http://svn.apache.org/viewvc?rev=806566&view=rev Log: SLING-1078 - Configuration handling and tests Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java (with props) sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/AbstractConfigTask.java (with props) sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java - copied, changed from r806445, sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java (with props) sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java - copied, changed from r806445, sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java (with props) Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallRemoveTask.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigurationPid.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskOrder.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=806566&r1=806565&r2=806566&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java Fri Aug 21 14:16:56 2009 @@ -32,7 +32,7 @@ import org.osgi.service.log.LogService; /** TaskCreator that processes a list of bundle RegisteredResources */ -class BundleTaskCreator implements OsgiInstallerThread.TaskCreator { +class BundleTaskCreator { public static final String MAVEN_SNAPSHOT_MARKER = "SNAPSHOT"; Added: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java?rev=806566&view=auto == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java (added) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java Fri Aug 21 14:16:56 2009 @@ -0,0 +1,75 @@ +/* + * 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.osgi.installer.impl; + +import
svn commit: r806568 - /sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java
Author: bdelacretaz Date: Fri Aug 21 14:27:08 2009 New Revision: 806568 URL: http://svn.apache.org/viewvc?rev=806568&view=rev Log: SLING-1078 - Config tasks ordering test Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java?rev=806568&r1=806567&r2=806568&view=diff == --- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java (original) +++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/TaskOrderingTest.java Fri Aug 21 14:27:08 2009 @@ -31,12 +31,13 @@ import org.apache.sling.osgi.installer.impl.tasks.BundleRemoveTask; import org.apache.sling.osgi.installer.impl.tasks.BundleStartTask; import org.apache.sling.osgi.installer.impl.tasks.BundleUpdateTask; +import org.apache.sling.osgi.installer.impl.tasks.ConfigInstallTask; +import org.apache.sling.osgi.installer.impl.tasks.ConfigRemoveTask; import org.apache.sling.osgi.installer.impl.tasks.SynchronousRefreshPackagesTask; /** Test the ordering and duplicates elimination of * OsgiControllerTasks */ -// TODO add config-related tasks public class TaskOrderingTest { private Set taskSet; @@ -65,6 +66,8 @@ public void testBasicOrdering() throws Exception { int testIndex = 1; final OsgiInstallerTask [] tasksInOrder = { + new ConfigRemoveTask(getRegisteredResource("test:a")), +new ConfigInstallTask(getRegisteredResource("test:a")), new BundleRemoveTask(getRegisteredResource("test:url")), new BundleUpdateTask(getRegisteredResource("test:url")), new BundleInstallTask(getRegisteredResource("test:url")), @@ -73,38 +76,46 @@ }; taskSet.clear(); -taskSet.add(tasksInOrder[4]); +taskSet.add(tasksInOrder[6]); + taskSet.add(tasksInOrder[5]); + taskSet.add(tasksInOrder[4]); taskSet.add(tasksInOrder[3]); taskSet.add(tasksInOrder[2]); - taskSet.add(tasksInOrder[1]); - taskSet.add(tasksInOrder[0]); +taskSet.add(tasksInOrder[1]); +taskSet.add(tasksInOrder[0]); assertOrder(testIndex++, taskSet, tasksInOrder); taskSet.clear(); - taskSet.add(tasksInOrder[0]); - taskSet.add(tasksInOrder[1]); +taskSet.add(tasksInOrder[0]); +taskSet.add(tasksInOrder[1]); taskSet.add(tasksInOrder[2]); taskSet.add(tasksInOrder[3]); taskSet.add(tasksInOrder[4]); + taskSet.add(tasksInOrder[5]); + taskSet.add(tasksInOrder[6]); assertOrder(testIndex++, taskSet, tasksInOrder); taskSet.clear(); - taskSet.add(tasksInOrder[1]); - taskSet.add(tasksInOrder[0]); taskSet.add(tasksInOrder[3]); taskSet.add(tasksInOrder[2]); +taskSet.add(tasksInOrder[0]); + taskSet.add(tasksInOrder[5]); taskSet.add(tasksInOrder[4]); +taskSet.add(tasksInOrder[1]); + taskSet.add(tasksInOrder[6]); assertOrder(testIndex++, taskSet, tasksInOrder); taskSet.clear(); + taskSet.add(tasksInOrder[4]); + taskSet.add(tasksInOrder[5]); + taskSet.add(tasksInOrder[6]); +taskSet.add(tasksInOrder[0]); taskSet.add(tasksInOrder[2]); taskSet.add(tasksInOrder[3]); - taskSet.add(tasksInOrder[4]); - taskSet.add(tasksInOrder[0]); - taskSet.add(tasksInOrder[1]); +taskSet.add(tasksInOrder[1]); assertOrder(testIndex++, taskSet, tasksInOrder); }
svn commit: r806575 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ installer/src/te
Author: bdelacretaz Date: Fri Aug 21 14:45:24 2009 New Revision: 806575 URL: http://svn.apache.org/viewvc?rev=806575&view=rev Log: SLING-1078 - code cleanup Removed: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Storage.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/TaskUtilities.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/StorageTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/AbstractConfigTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleRemoveTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/BundleUpdateTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigInstallTask.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/tasks/ConfigRemoveTask.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/MockOsgiInstallerContext.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/Utilities.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStartRetriesTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java?rev=806575&r1=806574&r2=806575&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/Activator.java Fri Aug 21 14:45:24 2009 @@ -125,17 +125,16 @@ } } +/** Used for tasks that wait for a framework or bundle event before retrying their operations */ public static long getTotalEventsCount() { return eventsCount; } public void frameworkEvent(FrameworkEvent arg0) { -// we'll retry as soon as any FrameworkEvent or BundleEvent happens eventsCount++; } public void bundleChanged(BundleEvent arg0) { -// we'll retry as soon as any FrameworkEvent or BundleEvent happens eventsCount++; } } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java?rev=806575&r1=806574&r2=806575&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/BundleTaskCreator.java Fri Aug 21 14:45:24 2009 @@ -25,7 +25,6 @@ import org.apache.sling.osgi.installer.impl.tasks.BundleInstallTask; import org.apache.sling.osgi.installer.impl.tasks.BundleRemoveTask; import org.apache.sling.osgi.installer.impl.tasks.BundleUpdateTask; -import org.apache.sling.osgi.installer.impl.tasks.TaskUtilities; import org.osgi.framework.Bundle; import org.osgi.framework.Constants; import org.osgi.framework.Version; @@ -140,7 +139,7 @@ protected BundleInfo getBundleInfo(OsgiInstallerContext ctx, RegisteredResource bundle) { final String symbolicName = (String)bundle.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME); - final Bundle b = TaskUtilities.getMatchingBundle(ctx.getBundleContext(), symbolicName); + final Bundle b = ctx.getMatchingBundle(symbolicName); if(b == null) { return null; } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?re
svn commit: r806584 - in /sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it: ConfigInstallTest.java ConfigPrioritiesTest.java
Author: bdelacretaz Date: Fri Aug 21 15:03:33 2009 New Revision: 806584 URL: http://svn.apache.org/viewvc?rev=806584&view=rev Log: SLING-1078 - use longer timeouts in tests to be on the safe side Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java?rev=806584&r1=806583&r2=806584&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java Fri Aug 21 15:03:33 2009 @@ -38,7 +38,7 @@ public class ConfigInstallTest extends OsgiInstallerTestBase { -private final static long TIMEOUT = 2500L; +private final static long TIMEOUT = 5000L; @org.ops4j.pax.exam.junit.Configuration public static Option[] configuration() { Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java?rev=806584&r1=806583&r2=806584&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java Fri Aug 21 15:03:33 2009 @@ -31,7 +31,7 @@ @RunWith(JUnit4TestRunner.class) public class ConfigPrioritiesTest extends OsgiInstallerTestBase { -private final static long TIMEOUT = 2500L; +private final static long TIMEOUT = 5000L; @org.ops4j.pax.exam.junit.Configuration public static Option[] configuration() {
svn commit: r807125 - /sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java
Author: bdelacretaz Date: Mon Aug 24 08:43:44 2009 New Revision: 807125 URL: http://svn.apache.org/viewvc?rev=807125&view=rev Log: SLING-1078 - add missing resetCounters() call Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java?rev=807125&r1=807124&r2=807125&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java Mon Aug 24 08:43:44 2009 @@ -119,6 +119,7 @@ installer.removeResource(r); waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1); sleep(1000L); +resetCounters(); configAdmin.start(); waitForConfigAdmin(true); waitForInstallerAction(OsgiInstaller.WORKER_THREAD_BECOMES_IDLE_COUNTER, 1);
svn commit: r807130 - /sling/trunk/installer/jcr/
Author: bdelacretaz Date: Mon Aug 24 08:53:13 2009 New Revision: 807130 URL: http://svn.apache.org/viewvc?rev=807130&view=rev Log: SLING-1078 - moving jcrinstall code to new installer module Added: sling/trunk/installer/jcr/
svn commit: r807131 - /sling/trunk/installer/jcr/service/
Author: bdelacretaz Date: Mon Aug 24 08:54:03 2009 New Revision: 807131 URL: http://svn.apache.org/viewvc?rev=807131&view=rev Log: SLING-1078 - moving jcrinstall code to new installer module Added: sling/trunk/installer/jcr/service/ - copied from r807130, sling/trunk/contrib/extensions/jcrinstall/service/
svn commit: r807132 - in /sling/trunk/installer/jcr: jcrinstall/ service/
Author: bdelacretaz Date: Mon Aug 24 08:54:45 2009 New Revision: 807132 URL: http://svn.apache.org/viewvc?rev=807132&view=rev Log: SLING-1078 - moving jcrinstall code to new installer module Added: sling/trunk/installer/jcr/jcrinstall/ - copied from r807131, sling/trunk/installer/jcr/service/ Removed: sling/trunk/installer/jcr/service/
svn commit: r807247 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java it/src/test/java/org/apache/sling/osgi/installer/it/Register
Author: bdelacretaz Date: Mon Aug 24 14:40:07 2009 New Revision: 807247 URL: http://svn.apache.org/viewvc?rev=807247&view=rev Log: SLING-1078 - fix handling of registerResources with empty collection of resources Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=807247&r1=807246&r2=807247&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Mon Aug 24 14:40:07 2009 @@ -22,9 +22,11 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -52,6 +54,7 @@ private final SortedSet tasks = new TreeSet(); private final SortedSet tasksForNextCycle = new TreeSet(); private final List> newResourcesSets = new ArrayList>(); +private final Set newResourcesSchemes = new HashSet(); private boolean active = true; /** Group our RegisteredResource by OSGi entity */ @@ -158,11 +161,14 @@ toAdd.add(rr); } -if(!toAdd.isEmpty()) { -synchronized (newResources) { -newResourcesSets.add(toAdd); -newResources.notify(); +synchronized (newResources) { +if(!toAdd.isEmpty()) { + newResourcesSets.add(toAdd); } +// Need to manage schemes separately: in case toAdd is empty we +// want to mark all such resources as non-installable +newResourcesSchemes.add(urlScheme); +newResources.notify(); } } @@ -172,8 +178,7 @@ // of available resources for a given scheme. So, before adding them mark // all resources with the same scheme in newResources, and existing // registeredResources, as not installable -for(SortedSet s : newResourcesSets) { -final String scheme = s.first().getUrlScheme(); + for(String scheme : newResourcesSchemes) { debug("Processing set of new resources with scheme " + scheme); for(RegisteredResource r : newResources) { if(r.getUrlScheme().equals(scheme)) { @@ -189,10 +194,13 @@ } } } + } +for(SortedSet s : newResourcesSets) { newResources.addAll(s); -debug("Added set of " + s.size() + " new resources with scheme " + scheme); +debug("Added set of " + s.size() + " new resources with scheme " + s.first().getUrlScheme()); } newResourcesSets.clear(); +newResourcesSchemes.clear(); for(RegisteredResource r : newResources) { SortedSet t = registeredResources.get(r.getEntityId()); Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java?rev=807247&r1=807246&r2=807247&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/RegisterResourcesTest.java Mon Aug 24 14:40:07 2009 @@ -16,9 +16,13 @@ */ package org.apache.sling.osgi.installer.it; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.apache.sling.osgi.installer.InstallableResource; @@ -32,9 +36,6 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertFalse; - @RunWith(JUnit4TestRunner.class) /** Test the {...@
svn commit: r807261 - /sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockRunMode.java
Author: bdelacretaz Date: Mon Aug 24 15:00:00 2009 New Revision: 807261 URL: http://svn.apache.org/viewvc?rev=807261&view=rev Log: SLING-1078 - jcrinstall partially adapted to new osgicontroller, work in progress Removed: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockRunMode.java
svn commit: r807272 - in /sling/trunk/installer: jcr/jcrinstall/pom.xml jcr/jcrinstall/src/main/resources/OSGI-INF/metatype/metatype.properties pom.xml
Author: bdelacretaz Date: Mon Aug 24 15:07:12 2009 New Revision: 807272 URL: http://svn.apache.org/viewvc?rev=807272&view=rev Log: SLING-1078 - add jcrinstall module, and use consistent names Modified: sling/trunk/installer/jcr/jcrinstall/pom.xml sling/trunk/installer/jcr/jcrinstall/src/main/resources/OSGI-INF/metatype/metatype.properties sling/trunk/installer/pom.xml Modified: sling/trunk/installer/jcr/jcrinstall/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/pom.xml?rev=807272&r1=807271&r2=807272&view=diff == --- sling/trunk/installer/jcr/jcrinstall/pom.xml (original) +++ sling/trunk/installer/jcr/jcrinstall/pom.xml Mon Aug 24 15:07:12 2009 @@ -31,10 +31,10 @@ 3.0.0-SNAPSHOT bundle - Apache Sling Jcrinstall Service + Apache Sling JCR Installer -Loads OSGi bundles, deployment packages and configs from -configurable locations in the JCR repository. +Installs OSGi bundles and configurations +found in the JCR repository. 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=807272&r1=807271&r2=807272&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 24 15:07:12 2009 @@ -23,7 +23,7 @@ # descriptions as used in the metatype.xml descriptor generated by the # the SCR plugin -jcrinstall.name = Apache Sling JCR Install +jcrinstall.name = Apache Sling JCR Installer jcrinstall.description = Installs OSGi bundles and configurations found \ in the JCR Repository. Modified: sling/trunk/installer/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/installer/pom.xml?rev=807272&r1=807271&r2=807272&view=diff == --- sling/trunk/installer/pom.xml (original) +++ sling/trunk/installer/pom.xml Mon Aug 24 15:07:12 2009 @@ -33,5 +33,6 @@ osgi/installer osgi/it + jcr/jcrinstall
svn commit: r807639 - in /sling/trunk/installer/jcr/jcrinstall/src: main/java/org/apache/sling/jcr/jcrinstall/impl/ test/java/org/apache/sling/jcr/jcrinstall/impl/ test/java/org/apache/sling/jcr/jcrin
Author: bdelacretaz Date: Tue Aug 25 14:06:37 2009 New Revision: 807639 URL: http://svn.apache.org/viewvc?rev=807639&view=rev Log: SLING-1078 - FindPathsToWatchTest and support classes added Added: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ContentHelper.java - copied, changed from r807539, sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ContentHelper.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/EventHelper.java - copied, changed from r807539, sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/EventHelper.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FindPathsToWatchTest.java - copied, changed from r807539, sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FindWatchedFoldersTest.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java (with props) sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockInstallableResource.java - copied, changed from r807539, sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockInstallableData.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java (with props) Removed: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ContentHelper.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/EventHelper.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/FindWatchedFoldersTest.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockInstallableData.java Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolderCreationListener.java 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=807639&r1=807638&r2=807639&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 Tue Aug 25 14:06:37 2009 @@ -18,20 +18,20 @@ */ package org.apache.sling.jcr.jcrinstall.impl; -import org.apache.sling.api.resource.ResourceResolver; -import org.apache.sling.jcr.resource.JcrResourceResolverFactory; -import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; import java.util.List; +import java.util.Set; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.RepositoryException; import javax.jcr.Session; +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.InstallableResource; import org.apache.sling.osgi.installer.OsgiInstaller; import org.apache.sling.runmode.RunMode; @@ -56,7 +56,7 @@ * name="service.vendor" * value="The Apache Software Foundation" */ -public class JcrInstaller implements Serializable { +public class JcrInstaller implements Runnable { private static final long serialVersionUID = 1L; public static final String URL_SCHEME = "jcrinstall"; @@ -110,6 +110,12 @@ /** Session shared by all WatchedFolder */ private Session session; +/** Count cycles of our run() method, used in testing */ +private int cyclesCount; + +/** Used to stop background thread when deactivated */ +private int deactivationCounter = 1; + /** Convert Nodes to InstallableResources */ static interface NodeConverter { InstallableResource convertNode(String urlScheme, Node n) throws Exception; @@ -118,6 +124,9 @@ /** Our NodeConverters*/ private final Collection converters = new ArrayList(); +/** Detect newly created folders that we must watch */ +private final List listeners = new LinkedList(); + protected void activate(ComponentContext contex
svn commit: r807663 - /sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletMoveTest.java
Author: bdelacretaz Date: Tue Aug 25 15:11:36 2009 New Revision: 807663 URL: http://svn.apache.org/viewvc?rev=807663&view=rev Log: SLING-1084 - testMoveAtRoot() added, passes with the changes of revision 807657 Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletMoveTest.java Modified: sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletMoveTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletMoveTest.java?rev=807663&r1=807662&r2=807663&view=diff == --- sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletMoveTest.java (original) +++ sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletMoveTest.java Tue Aug 25 15:11:36 2009 @@ -473,4 +473,31 @@ testClient.delete(testRoot); } +public void testMoveAtRoot() throws IOException { +final String pathA = "/" + getClass().getSimpleName() + "_A"; +final String pathB = "/" + getClass().getSimpleName() + "_B"; + +final String testText = "Hello." + Math.random(); +Map props = new HashMap(); +props.put("text", testText); + +// Create pathA +testClient.delete(HTTP_BASE_URL + pathA); +assertHttpStatus(HTTP_BASE_URL + pathA, HttpServletResponse.SC_NOT_FOUND); +testClient.createNode(HTTP_BASE_URL + pathA, props); + +// Move to pathB +testClient.delete(HTTP_BASE_URL + pathB); +assertHttpStatus(HTTP_BASE_URL + pathB, HttpServletResponse.SC_NOT_FOUND); +props.clear(); +props.put(SlingPostConstants.RP_OPERATION, +SlingPostConstants.OPERATION_MOVE); +props.put(SlingPostConstants.RP_DEST, pathB); +props.put(SlingPostConstants.RP_REPLACE, "true"); +testClient.createNode(HTTP_BASE_URL + pathA, props); +String content = getContent(HTTP_BASE_URL + pathB + ".json", CONTENT_TYPE_JSON); +assertJavascript(testText, content, "out.println(data.text)"); +assertHttpStatus(HTTP_BASE_URL + pathA, HttpServletResponse.SC_NOT_FOUND); +} + } \ No newline at end of file
svn commit: r807716 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/ main/java/org/apache/sling/osgi/installer/impl/ test/java/org/apache/sling/osgi/installer
Author: bdelacretaz Date: Tue Aug 25 17:01:21 2009 New Revision: 807716 URL: http://svn.apache.org/viewvc?rev=807716&view=rev Log: SLING-1078 - digests moved to InstallableResource, clients might need them to keep track of things Added: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/InstallableResourceTest.java (with props) Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=807716&r1=807715&r2=807716&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Tue Aug 25 17:01:21 2009 @@ -18,7 +18,13 @@ */ package org.apache.sling.osgi.installer; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.io.ObjectOutputStream; +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.Dictionary; /** A piece of data that can be installed by the OSGi controller. @@ -32,6 +38,7 @@ private final InputStream inputStream; private final Dictionary dictionary; private int priority; +public static final String DIGEST_TYPE = "MD5"; /** Default resource priority */ public static final int DEFAULT_PRIORITY = 100; @@ -78,7 +85,11 @@ this.extension = getExtension(url); this.inputStream = null; this.dictionary = d; -this.digest = null; + try { + this.digest = computeDigest(d); + } catch(Exception e) { + throw new IllegalStateException("Unexpected Exception while computing digest", e); + } this.priority = DEFAULT_PRIORITY; } @@ -137,4 +148,22 @@ public void setPriority(int priority) { this.priority = priority; } -} + +/** convert digest to readable string (http://www.javalobby.org/java/forums/t84420.html) */ +public static String digestToString(MessageDigest d) { +final BigInteger bigInt = new BigInteger(1, d.digest()); +return new String(bigInt.toString(16)); +} + +/** Digest is needed to detect changes in data + * @throws */ +public static String computeDigest(Dictionary data) throws IOException, NoSuchAlgorithmException { +final MessageDigest d = MessageDigest.getInstance(DIGEST_TYPE); +final ByteArrayOutputStream bos = new ByteArrayOutputStream(); +final ObjectOutputStream oos = new ObjectOutputStream(bos); +oos.writeObject(data); +bos.flush(); +d.update(bos.toByteArray()); +return digestToString(d); +} +} \ No newline at end of file Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java?rev=807716&r1=807715&r2=807716&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java Tue Aug 25 17:01:21 2009 @@ -76,7 +76,6 @@ private final RegisteredResource.ResourceType resourceType; - public static final String DIGEST_TYPE = "MD5"; public static final String ENTITY_JAR_PREFIX = "jar:"; public static final String ENTITY_BUNDLE_PREFIX = "bundle:"; public static final String ENTITY_CONFIG_PREFIX = "config:"; @@ -94,6 +93,10 @@ priority = input.getPriority(); serialNumber = getNextSerialNumber(); +if(input.getDigest() == null || input.getDigest().length(
svn commit: r807717 - in /sling/trunk/installer/jcr/jcrinstall/src: main/java/org/apache/sling/jcr/jcrinstall/impl/ test/java/org/apache/sling/jcr/jcrinstall/impl/ test/java/org/apache/sling/jcr/jcrin
Author: bdelacretaz Date: Tue Aug 25 17:02:11 2009 New Revision: 807717 URL: http://svn.apache.org/viewvc?rev=807717&view=rev Log: SLING-1078 - RegisteredResourceTest re-implemented (and much simpler ;-) Added: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ResourceDetectionTest.java - copied, changed from r807661, sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/ResourceDetectionTest.java Removed: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/ Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ContentHelper.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java 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=807717&r1=807716&r2=807717&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 Tue Aug 25 17:02:11 2009 @@ -180,9 +180,9 @@ // Scan watchedFolders and register resources with installer final List resources = new LinkedList(); for(WatchedFolder f : watchedFolders) { - final Collection c = f.scan(); - log.debug("Startup: {} provides resources {}", f, c); - resources.addAll(c); + final WatchedFolder.ScanResult r = f.scan(); + log.debug("Startup: {} provides resources {}", f, r.toAdd); + resources.addAll(r.toAdd); } log.info("Registering {} resources with OSGi installer", resources.size()); @@ -315,6 +315,21 @@ try { // TODO rendezvous with installer if any folder has been deleted addAndDeleteFolders(); + +// Rescan WatchedFolders if needed +if(System.currentTimeMillis() > WatchedFolder.getNextScanTime()) { +for(WatchedFolder wf : watchedFolders) { +final WatchedFolder.ScanResult sr = wf.scan(); +for(InstallableResource r : sr.toRemove) { +log.info("Removing resource from OSGi installer: {}",r); +installer.removeResource(r); +} +for(InstallableResource r : sr.toAdd) { +log.info("Adding resource to OSGi installer: {}",r); +installer.addResource(r); +} +} +} cyclesCount++; // TODO wait for events from our listeners, and/or WatchedFolder scan time Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java?rev=807717&r1=807716&r2=807717&view=diff == --- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java (original) +++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java Tue Aug 25 17:02:11 2009 @@ -18,9 +18,12 @@ */ package org.apache.sling.jcr.jcrinstall.impl; +import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.jcr.Item; import javax.jcr.Node; @@ -48,6 +51,14 @@ private final Collection converters; protected final Logger log = LoggerFactory.getLogger(getClass()); +static class ScanResult { +List toAdd = new ArrayList(); +List toRemove = new ArrayList(); +}; + +/** Store the digests of the last returned resources, keyed by path, to detect changes */ +private final Map digests = new HashMap(); + // WatchedFolders that need a rescan will be scanned // once no JCR events have been received for this amount of time. public static
svn commit: r807976 - in /sling/trunk/installer/jcr/jcrinstall/src: main/java/org/apache/sling/jcr/jcrinstall/impl/ test/java/org/apache/sling/jcr/jcrinstall/impl/
Author: bdelacretaz Date: Wed Aug 26 12:15:34 2009 New Revision: 807976 URL: http://svn.apache.org/viewvc?rev=807976&view=rev Log: SLING-1078 - ResourceDetectionTest: test deletion of resources Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ResourceDetectionTest.java 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=807976&r1=807975&r2=807976&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 Wed Aug 26 12:15:34 2009 @@ -57,7 +57,7 @@ * value="The Apache Software Foundation" */ public class JcrInstaller implements Runnable { - private static final long serialVersionUID = 1L; + public static final long RUN_LOOP_DELAY_MSEC = 500L; public static final String URL_SCHEME = "jcrinstall"; private final Logger log = LoggerFactory.getLogger(getClass()); @@ -129,6 +129,8 @@ protected void activate(ComponentContext context) throws Exception { + log.info("activate()"); + session = repository.loginAdministrative(repository.getDefaultWorkspace()); // Setup converters @@ -194,9 +196,10 @@ } protected void deactivate(ComponentContext context) { + log.info("deactivate()"); + try { deactivationCounter++; -listeners.clear(); folderNameFilter = null; watchedFolders = null; converters.clear(); @@ -207,6 +210,7 @@ session.logout(); session = null; } +listeners.clear(); } catch(Exception e) { log.warn("Exception in deactivate()", e); } @@ -276,13 +280,15 @@ } /** Add new folders to watch if any have been detected - * @return true if any WatchedFolders have been removed + * @return a list of InstallableResource that must be unregistered, + * for folders that have been removed */ -private boolean addAndDeleteFolders() throws RepositoryException { +private List addAndDeleteFolders() throws Exception { + final List result = new LinkedList(); for(WatchedFolderCreationListener wfc : listeners) { final Set newPaths = wfc.getAndClearPaths(); if(newPaths != null && newPaths.size() > 0) { -log.info("Detected {} new folder(s to watch", newPaths.size()); +log.info("Detected {} new folder(s) to watch", newPaths.size()); for(String path : newPaths) { watchedFolders.add( new WatchedFolder(session, path, folderNameFilter.getPriority(path), URL_SCHEME, converters)); @@ -290,12 +296,11 @@ } } -boolean deleted = false; final List toRemove = new ArrayList(); for(WatchedFolder wf : watchedFolders) { if(!session.itemExists(wf.getPath())) { -deleted = true; log.info("Deleting {}, path does not exist anymore", wf); +result.addAll(wf.scan().toRemove); wf.cleanup(); toRemove.add(wf); } @@ -304,7 +309,7 @@ watchedFolders.remove(wf); } -return deleted; +return result; } /** Run periodic scans of our watched folders, and watch for folders creations/deletions */ @@ -313,8 +318,11 @@ final int savedCounter = deactivationCounter; while(savedCounter == deactivationCounter) { try { -// TODO rendezvous with installer if any folder has been deleted -addAndDeleteFolders(); +final List toRemove = addAndDeleteFolders(); +for(InstallableResource r : toRemove) { +log.info("Removing resource from OSGi installer (folder deleted): {}",r); +inst
svn commit: r807989 - in /sling/trunk/installer: jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ osgi/installer/sr
Author: bdelacretaz Date: Wed Aug 26 13:04:25 2009 New Revision: 807989 URL: http://svn.apache.org/viewvc?rev=807989&view=rev Log: SLING-1078 - use empty InstallableResource for resource removal (as data is not available anymore ;-) Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleStatePreservedTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigPrioritiesTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/OsgiInstallerTestBase.java Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java?rev=807989&r1=807988&r2=807989&view=diff == --- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java (original) +++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java Wed Aug 26 13:04:25 2009 @@ -18,7 +18,6 @@ */ package org.apache.sling.jcr.jcrinstall.impl; -import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -153,9 +152,8 @@ // Resources left in the digests map have been deleted since last scan, // need to be removed from OsgiInstaller -final ByteArrayInputStream emptyStream = new ByteArrayInputStream("".getBytes()); for(Map.Entry e : digests.entrySet()) { -InstallableResource r = new InstallableResource(e.getKey(), emptyStream, e.getValue()); +InstallableResource r = new InstallableResource(e.getKey()); result.toRemove.add(r); } Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java?rev=807989&r1=807988&r2=807989&view=diff == --- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java (original) +++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java Wed Aug 26 13:04:25 2009 @@ -68,6 +68,9 @@ } public void removeResource(InstallableResource d) throws IOException { + if(!d.isEmpty()) { + throw new IllegalArgumentException("InstallableResource must be empty for removeResource call"); + } urls.remove(d.getUrl()); recordCall("remove", d); } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=807989&r1=807988&r2=807989&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Wed Aug 26 13:04:25 2009 @@ -38,6 +38,7 @@ private final InputStream inputStream; private final Dictionary dictionary; private int priority; + private final boolean empty; public static final String DIGEST_TYPE = "MD5"; /** Default resource priority */ @@ -51,6 +52,7 @@ this.dictionary = null; this.digest = null;
svn commit: r808013 - in /sling/trunk/installer/jcr/jcrinstall/src: main/java/org/apache/sling/jcr/jcrinstall/impl/ test/java/org/apache/sling/jcr/jcrinstall/impl/
Author: bdelacretaz Date: Wed Aug 26 14:01:36 2009 New Revision: 808013 URL: http://svn.apache.org/viewvc?rev=808013&view=rev Log: SLING-1078 - test*update added Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ContentHelper.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ResourceDetectionTest.java 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=808013&r1=808012&r2=808013&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 Wed Aug 26 14:01:36 2009 @@ -187,7 +187,7 @@ resources.addAll(r.toAdd); } - log.info("Registering {} resources with OSGi installer", resources.size()); + log.info("Registering {} resources with OSGi installer: {}", resources.size(), resources); installer.registerResources(resources, URL_SCHEME); final Thread t = new Thread(this, getClass().getSimpleName() + "." + deactivationCounter); @@ -333,7 +333,7 @@ installer.removeResource(r); } for(InstallableResource r : sr.toAdd) { -log.info("Adding resource to OSGi installer: {}",r); +log.info("Registering resource with OSGi installer: {}",r); installer.addResource(r); } } Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java?rev=808013&r1=808012&r2=808013&view=diff == --- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java (original) +++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java Wed Aug 26 14:01:36 2009 @@ -21,8 +21,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import javax.jcr.Item; import javax.jcr.Node; @@ -48,6 +50,7 @@ private boolean needsScan; private final String urlScheme; private final Collection converters; +private final Set existingResourceUrls = new HashSet(); protected final Logger log = LoggerFactory.getLogger(getClass()); static class ScanResult { @@ -129,6 +132,7 @@ // Return an InstallableResource for all child nodes for which we have a NodeConverter final ScanResult result = new ScanResult(); +final Set resourcesSeen = new HashSet(); if(folder != null) { final NodeIterator it = folder.getNodes(); while(it.hasNext()) { @@ -136,11 +140,9 @@ for(JcrInstaller.NodeConverter nc : converters) { final InstallableResource r = nc.convertNode(urlScheme, n); if(r != null) { + resourcesSeen.add(r.getUrl()); final String oldDigest = digests.get(r.getUrl()); - if(r.getDigest().equals(oldDigest)) { - // Already returned that resource, ignore - digests.remove(r.getUrl()); - } else { + if(!r.getDigest().equals(oldDigest)) { r.setPriority(priority); result.toAdd.add(r); } @@ -150,16 +152,22 @@ } } -// Resources left in the digests map have been deleted since last scan, -// need to be removed from OsgiInstaller -for(Map.Entry e : digests.entrySet()) { -InstallableResource r = new InstallableResource(e.getKey()); -result.toRemove.add(r); +// Resources that existed but are not in resourcesSeen n
svn commit: r808061 - /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java
Author: bdelacretaz Date: Wed Aug 26 15:44:33 2009 New Revision: 808061 URL: http://svn.apache.org/viewvc?rev=808061&view=rev Log: SLING-1078 - log configuration PID Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java?rev=808061&r1=808060&r2=808061&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java Wed Aug 26 15:44:33 2009 @@ -60,7 +60,7 @@ final String previousDigest = digests.get(pid); if(toActivate.getDigest().equals(previousDigest)) { if(ctx.getLogService() != null) { - ctx.getLogService().log(LogService.LOG_DEBUG, "Configuration already installed, ignored: " + toActivate); + ctx.getLogService().log(LogService.LOG_DEBUG, "Configuration (" + pid + ") already installed, ignored: " + toActivate); } } else { tasks.add(new ConfigInstallTask(toActivate));
svn commit: r808340 - /sling/trunk/bundles/commons/classloader/
Author: bdelacretaz Date: Thu Aug 27 09:39:59 2009 New Revision: 808340 URL: http://svn.apache.org/viewvc?rev=808340&view=rev Log: svn:ignore Modified: sling/trunk/bundles/commons/classloader/ (props changed) Propchange: sling/trunk/bundles/commons/classloader/ -- --- svn:ignore (original) +++ svn:ignore Thu Aug 27 09:39:59 2009 @@ -1 +1,15 @@ target +sling +bin +logs +jackrabbit-repository +derby.log +*.iml +*.ipr +*.iws +.settings +.project +.classpath +.externalToolBuilders +maven-eclipse.xml +
svn commit: r808453 - in /sling/trunk/installer/jcr/jcrinstall/src: main/java/org/apache/sling/jcr/jcrinstall/impl/ test/java/org/apache/sling/jcr/jcrinstall/impl/
Author: bdelacretaz Date: Thu Aug 27 15:19:08 2009 New Revision: 808453 URL: http://svn.apache.org/viewvc?rev=808453&view=rev Log: SLING-1078 - avoid unnecessary scans in JcrInstaller.run() loop Added: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/RescanTimer.java (with props) sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/RootFolderListener.java - copied, changed from r808152, sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolderCreationListener.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ScanningLoopTest.java (with props) Removed: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolderCreationListener.java Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ContentHelper.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/FindPathsToWatchTest.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MiscUtil.java sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ResourceDetectionTest.java 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=808453&r1=808452&r2=808453&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 Thu Aug 27 15:19:08 2009 @@ -61,6 +61,13 @@ public static final String URL_SCHEME = "jcrinstall"; private final Logger log = LoggerFactory.getLogger(getClass()); + + /** Counters, used for statistics and testing */ + private final long [] counters = new long[COUNTERS_COUNT]; + public static final int SCAN_FOLDERS_COUNTER = 0; +public static final int UPDATE_FOLDERS_LIST_COUNTER = 1; +public static final int RUN_LOOP_COUNTER = 2; +public static final int COUNTERS_COUNT = 3; /**This class watches the repository for installable resources * @scr.reference @@ -110,9 +117,6 @@ /** Session shared by all WatchedFolder */ private Session session; -/** Count cycles of our run() method, used in testing */ -private int cyclesCount; - /** Used to stop background thread when deactivated */ private int deactivationCounter = 1; @@ -125,8 +129,11 @@ private final Collection converters = new ArrayList(); /** Detect newly created folders that we must watch */ -private final List listeners = new LinkedList(); +private final List listeners = new LinkedList(); +/** Timer used to call updateFoldersList() */ +private final RescanTimer updateFoldersListTimer = new RescanTimer(); + protected void activate(ComponentContext context) throws Exception { log.info("activate()"); @@ -170,7 +177,7 @@ // Setup folder filtering and watching folderNameFilter = new FolderNameFilter(roots, folderNameRegexp, runMode); for (String path : roots) { -listeners.add(new WatchedFolderCreationListener(session, folderNameFilter, path)); +listeners.add(new RootFolderListener(session, folderNameFilter, path, updateFoldersListTimer)); } // Find paths to watch and create WatchedFolders to manage them @@ -204,7 +211,7 @@ watchedFolders = null; converters.clear(); if(session != null) { -for(WatchedFolderCreationListener wfc : listeners) { +for(RootFolderListener wfc : listeners) { wfc.cleanup(session); } session.logout(); @@ -259,7 +266,7 @@ } final int depth = path.split("/").length; if(depth > maxWatchedFolderDepth) { -log.debug("Not recursing into {} due to maxWatchedFolderDepth={}", path, maxWatchedFolderDepth); +log.info("Not recursing into {} due to maxWatchedFolderDepth={}", path, maxWatchedFolderDepth); return; } else { final NodeIterator it = n.getNodes(); @@ -283,1
svn commit: r808547 - in /sling/trunk/installer: jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/ osgi/installer/src/main/java/org/apache/sling/osgi/installer/ osgi/installer/src/mai
Author: bdelacretaz Date: Thu Aug 27 17:30:34 2009 New Revision: 808547 URL: http://svn.apache.org/viewvc?rev=808547&view=rev Log: SLING-1078 - OsgiInstaller ignores invalid and non-bundle jars Added: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.java (with props) sling/trunk/installer/osgi/it/src/test/resources/ sling/trunk/installer/osgi/it/src/test/resources/invalid-jar.jar Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerImpl.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceImpl.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java sling/trunk/installer/osgi/it/pom.xml Modified: sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java?rev=808547&r1=808546&r2=808547&view=diff == --- sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java (original) +++ sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/MockOsgiInstaller.java Thu Aug 27 17:30:34 2009 @@ -47,7 +47,7 @@ /** Keep track of registered URLS */ private final Set urls = new HashSet(); -public void addResource(InstallableResource d) throws IOException { +public void addResource(InstallableResource d) { urls.add(d.getUrl()); recordCall("add", d); } @@ -56,7 +56,7 @@ return counters; } -public void registerResources(Collection data, String urlScheme) throws IOException { +public void registerResources(Collection data, String urlScheme) { // Sort the data to allow comparing the recorded calls reliably final List sorted = new LinkedList(); sorted.addAll(data); @@ -67,7 +67,7 @@ } } -public void removeResource(InstallableResource d) throws IOException { +public void removeResource(InstallableResource d) { if(!d.isEmpty()) { throw new IllegalArgumentException("InstallableResource must be empty for removeResource call"); } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java?rev=808547&r1=808546&r2=808547&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/OsgiInstaller.java Thu Aug 27 17:30:34 2009 @@ -41,20 +41,23 @@ * previously registered/added resources, compares with the new * list and removes resources that have disappeared. * + * Invalid resources are ignored. +* * @param data the list of available resources * @param urlScheme identifies the client. All URLs of the supplied data * must use this scheme */ - void registerResources(Collection data, String urlScheme) throws IOException; + void registerResources(Collection data, String urlScheme); /** Inform the installer that a resource is available for installation. * also called if the resource has been modified since it was registered. +* Invalid resources are ignored. */ - void addResource(InstallableResource r) throws IOException; + void addResource(InstallableResource r); /** Inform the installer that a resource is no longer available * @param r an empty InstallableResource, isEmpty() must return true */ - void removeResource(InstallableResource r) throws IOException; + void removeResource(InstallableResource r); /** Return counters used for statistics, console display, testing, etc. */ long [] getCo
svn commit: r808789 - /sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.java
Author: bdelacretaz Date: Fri Aug 28 07:28:17 2009 New Revision: 808789 URL: http://svn.apache.org/viewvc?rev=808789&view=rev Log: SLING-1078 - test was disabled by mistake Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.java Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.java?rev=808789&r1=808788&r2=808789&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/InvalidBundlesTest.java Fri Aug 28 07:28:17 2009 @@ -72,7 +72,6 @@ assertNoOsgiTasks("At the end of test"); } -/** @Test public void testIndividualInvalidBundles() throws Exception { final String symbolicName = "osgi-installer-testbundle"; @@ -122,5 +121,4 @@ assertNoOsgiTasks("After test " + testIndex++); } - */ } \ No newline at end of file
svn commit: r808807 - in /sling/trunk/installer/osgi: installer/src/main/java/org/apache/sling/osgi/installer/impl/ it/src/test/java/org/apache/sling/osgi/installer/it/
Author: bdelacretaz Date: Fri Aug 28 08:14:36 2009 New Revision: 808807 URL: http://svn.apache.org/viewvc?rev=808807&view=rev Log: SLING-1078 - config with same digest as previously uninstalled one was not reinstalled Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/ConfigInstallTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java?rev=808807&r1=808806&r2=808807&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/ConfigTaskCreator.java Fri Aug 28 08:14:36 2009 @@ -49,22 +49,19 @@ if(toActivate == null) { // None of our resources are installable, remove corresponding config // (task simply does nothing if config does not exist) - tasks.add(new ConfigRemoveTask(resources.first())); + final RegisteredResource first = resources.first(); + tasks.add(new ConfigRemoveTask(first)); + digests.remove(getDigestKey(first)); } else { - final ConfigurationPid cp = (ConfigurationPid)toActivate.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE); - if(cp == null) { - throw new IllegalArgumentException("Resource does not provide a CONFIG_PID_ATTRIBUTE: " + toActivate); - } - final String pid = cp.getCompositePid(); - - final String previousDigest = digests.get(pid); + final String key = getDigestKey(toActivate); + final String previousDigest = digests.get(key); if(toActivate.getDigest().equals(previousDigest)) { if(ctx.getLogService() != null) { - ctx.getLogService().log(LogService.LOG_DEBUG, "Configuration (" + pid + ") already installed, ignored: " + toActivate); + ctx.getLogService().log(LogService.LOG_DEBUG, "Configuration (" + key+ ") already installed, ignored: " + toActivate); } } else { tasks.add(new ConfigInstallTask(toActivate)); - digests.put(pid, toActivate.getDigest()); + digests.put(key, toActivate.getDigest()); if(ctx.getLogService() != null) { ctx.getLogService().log(LogService.LOG_DEBUG, "Scheduling update/install of config " + toActivate + ", digest has changed or was absent"); @@ -72,4 +69,12 @@ } } } + + private String getDigestKey(RegisteredResource r) { +final ConfigurationPid cp = (ConfigurationPid)r.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE); +if(cp == null) { +throw new IllegalArgumentException("Resource does not provide a CONFIG_PID_ATTRIBUTE: " + r); +} +return cp.getCompositePid(); + } } Modified: sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java?rev=808807&r1=808806&r2=808807&view=diff == --- sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java (original) +++ sling/trunk/installer/osgi/it/src/test/java/org/apache/sling/osgi/installer/it/BundleInstallUpgradeDowngradeTest.java Fri Aug 28 08:14:36 2009 @@ -135,4 +135,41 @@ assertNoOsgiTasks("After test " + testIndex++); } + + @Test + public void testRemoveAndReadd() throws Exception { + final String symbolicName = "osgi-installer-testbundle"; + int testIndex = 0; + + { + assertNull("Test bundle must be absent before installin
svn commit: r808818 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/InstallableResource.java test/java/org/apache/sling/osgi/installer/impl/RegisteredResource
Author: bdelacretaz Date: Fri Aug 28 08:53:59 2009 New Revision: 808818 URL: http://svn.apache.org/viewvc?rev=808818&view=rev Log: SLING-1078 - config digest takes URL into account Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=808818&r1=808817&r2=808818&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Fri Aug 28 08:53:59 2009 @@ -89,7 +89,7 @@ this.inputStream = null; this.dictionary = d; try { - this.digest = computeDigest(d); + this.digest = url + ":" + computeDigest(d); } catch(Exception e) { throw new IllegalStateException("Unexpected Exception while computing digest", e); } Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java?rev=808818&r1=808817&r2=808818&view=diff == --- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java (original) +++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceTest.java Fri Aug 28 08:53:59 2009 @@ -18,6 +18,7 @@ */ package org.apache.sling.osgi.installer.impl; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -153,6 +154,15 @@ assertEquals("RegisteredResource entity ID must match", "config:someconfig", r.getEntityId()); } +@org.junit.Test public void testConfigDigestIncludesUrl() throws Exception { +final Dictionary data = new Hashtable(); +final InstallableResource rA = new InstallableResource("test:urlA", data); +final InstallableResource rB = new InstallableResource("test:urlB", data); +assertFalse( +"Expecting configs with same data but different URLs to have different digests", +rA.getDigest().equals(rB.getDigest())); +} + @org.junit.Test public void testUrlScheme() throws Exception { final ByteArrayInputStream s = new ByteArrayInputStream("foo".getBytes());
svn commit: r808842 - /sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java
Author: bdelacretaz Date: Fri Aug 28 10:27:39 2009 New Revision: 808842 URL: http://svn.apache.org/viewvc?rev=808842&view=rev Log: SLING-1000 - improve navigation by displaying requests methods and partial path Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java?rev=808842&r1=808841&r2=808842&view=diff == --- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java (original) +++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/request/RequestHistoryConsolePlugin.java Fri Aug 28 10:27:39 2009 @@ -20,9 +20,11 @@ import java.io.IOException; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.Dictionary; import java.util.Hashtable; import java.util.Iterator; +import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -51,6 +53,10 @@ public static final int STORED_REQUESTS_COUNT = 20; private final SlingHttpServletRequest[] requests = new SlingHttpServletRequest[STORED_REQUESTS_COUNT]; + + /** Need to store methods separately, apparently requests clear this data when done processing */ + private final String [] methods = new String[STORED_REQUESTS_COUNT]; + private int lastRequestIndex = -1; private RequestHistoryConsolePlugin() { @@ -69,6 +75,7 @@ index = 0; } requests[index] = r; +methods[index] = r.getMethod(); lastRequestIndex = index; } @@ -130,6 +137,55 @@ return "Recent requests"; } + private int getArrayIndex(int displayIndex) { + int result = lastRequestIndex - displayIndex; + if (result < 0) { +result += requests.length; + } + return result; + } + + private String getLinksTable(int currentRequestIndex) { +final List links = new ArrayList(); +for (int i = 0; i < requests.length; i++) { +final StringBuilder sb = new StringBuilder(); +if (requests[i] != null) { +sb.append(""); +if (i == currentRequestIndex) { +sb.append(""); +} +sb.append(getRequestLabel(getArrayIndex(i))); +if (i == currentRequestIndex) { +sb.append(""); +} +sb.append(" "); +links.add(sb.toString()); +} +} + +final int nCols = 5; +while((links.size() % nCols) != 0) { +links.add(" "); +} + +final StringBuilder tbl = new StringBuilder(); + +tbl.append("\n\n"); +int i=0; +for(String str : links) { +if( (i++ % nCols) == 0) { +tbl.append("\n\n"); +} +tbl.append(""); +tbl.append(str); +tbl.append("\n"); +} +tbl.append("\n"); + +tbl.append("\n"); +return tbl.toString(); + } + @Override protected void renderContent(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { @@ -153,10 +209,7 @@ } // index is relative to lastRequestIndex -int arrayIndex = lastRequestIndex - index; -if (arrayIndex < 0) { - arrayIndex += requests.length; -} +final int arrayIndex = getArrayIndex(index); SlingHttpServletRequest r = null; try { @@ -178,27 +231,14 @@ pw.println(""); pw.println(""); pw.println(""); -for (int i = 0; i < requests.length; i++) { - if (requests[i] != null) { -final String info = (i == 0 ? " (latest)" : ""); -pw.print(""); -if (i == index) { - pw.print(""); -} -pw.print("Request " + i + info); -if (i == index) { - pw.print(""); -} -pw.println(" "); - } -} +pw.println(getLinksTable(index)); pw.println(""); if (r != null) { // Request Progress Tracker Info pw.println(""); pw.println(""); - pw.print("Request " + index + " - RequestProgressTracker Info"); + pw.print("Request " + index + " (" + getRequestLabel(index) + ") - RequestProgressTracker Info"); pw.println(&quo
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/jcrinsta
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 @@ org.apache.sling.jcr.jcrinstall.impl.* SLING-INF/nodetypes/osgiconfig.cnd sling=http://sling.apache.org/jcr/sling/1.0 + *;artifactId=org.apache.sling.commons.osgi @@ -75,12 +76,12 @@ org.apache.sling - org.apache.sling.jcr.resource + org.apache.sling.jcr.api 2.0.2-incubator org.apache.sling - org.apache.sling.jcr.api + org.apache.sling.commons.osgi 2.0.2-incubator 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++) { +
svn commit: r809511 - /sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java
Author: bdelacretaz Date: Mon Aug 31 09:13:18 2009 New Revision: 809511 URL: http://svn.apache.org/viewvc?rev=809511&view=rev Log: SLING-1078 - get properties from BundleContext first, we want system properties to override configs Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/JcrInstaller.java 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=809511&r1=809510&r2=809511&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 09:13:18 2009 @@ -234,9 +234,9 @@ /** Get a property value from the component context or bundle context */ protected Object getPropertyValue(ComponentContext ctx, String name) { -Object result = ctx.getProperties().get(name); +Object result = ctx.getBundleContext().getProperty(name); if(result == null) { -result = ctx.getBundleContext().getProperty(name); +result = ctx.getProperties().get(name); } return result; }
svn commit: r809513 - /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
Author: bdelacretaz Date: Mon Aug 31 09:22:17 2009 New Revision: 809513 URL: http://svn.apache.org/viewvc?rev=809513&view=rev Log: SLING-1078 - additional logging Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=809513&r1=809512&r2=809513&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Mon Aug 31 09:22:17 2009 @@ -145,7 +145,9 @@ } // Will mark all resources which have r's URL as uninstallable - debug("Adding URL " + r.getUrl() + " to urlsToRemove"); +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "Adding URL " + r.getUrl() + " to urlsToRemove"); +} urlsToRemove.add(r.getUrl()); synchronized (newResources) { @@ -156,6 +158,9 @@ /** Register a single new resource, will be processed on the next cycle */ void addNewResource(RegisteredResource r) { synchronized (newResources) { +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "Adding new resource " + r); +} newResources.add(r); newResources.notify(); } @@ -185,6 +190,9 @@ "URL of all supplied InstallableResource must start with supplied scheme" + ", scheme is not '" + urlScheme + "' for URL " + r.getUrl()); } +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "Adding new resource " + r); +} toAdd.add(rr); } @@ -194,6 +202,9 @@ } // Need to manage schemes separately: in case toAdd is empty we // want to mark all such resources as non-installable +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "Adding to newResourcesSchemes: " + urlScheme); +} newResourcesSchemes.add(urlScheme); newResources.notify(); } @@ -206,25 +217,35 @@ // all resources with the same scheme in newResources, and existing // registeredResources, as not installable for(String scheme : newResourcesSchemes) { -debug("Processing set of new resources with scheme " + scheme); +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "Processing set of new resources with scheme " + scheme); +} for(RegisteredResource r : newResources) { if(r.getUrlScheme().equals(scheme)) { r.setInstallable(false); -debug("New resource set to non-installable: " + r); +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "New resource set to non-installable: " + r); +} } } for(SortedSet ss : registeredResources.values()) { for(RegisteredResource r : ss) { if(r.getUrlScheme().equals(scheme)) { r.setInstallable(false); -debug("Existing resource set to non-installable: " + r); +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, "Existing resource set to non-installable: " + r); +} } } } } for(SortedSet s : newResourcesSets) { newResources.addAll(s); -debug("Added set of " + s.size() + " new resources with scheme " + s.first().getUrlScheme()); +if(ctx.getLogService() != null) { +ctx.getLogService().log(LogService.LOG_DEBUG, +"Added set of " + s.size() + " new r
svn commit: r809510 - in /sling/trunk/installer/osgi/installer/src: main/java/org/apache/sling/osgi/installer/impl/ test/java/org/apache/sling/osgi/installer/impl/
Author: bdelacretaz Date: Mon Aug 31 09:09:01 2009 New Revision: 809510 URL: http://svn.apache.org/viewvc?rev=809510&view=rev Log: SLING-1078 - RegisteredResourceComparator now correctly compares configs Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java?rev=809510&r1=809509&r2=809510&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java Mon Aug 31 09:09:01 2009 @@ -42,7 +42,7 @@ // Order first by symbolic name final String nameA = (String)a.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME); final String nameB = (String)b.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME); -if(nameA != null) { +if(nameA != null && nameB != null) { result = nameA.compareTo(nameB); } @@ -85,6 +85,31 @@ } int compareConfig(RegisteredResource a, RegisteredResource b) { -return 0; +int result = 0; + +// First compare by pid +final ConfigurationPid pA = (ConfigurationPid)a.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE); +final ConfigurationPid pB = (ConfigurationPid)b.getAttributes().get(RegisteredResource.CONFIG_PID_ATTRIBUTE); +if(pA != null && pA.getCompositePid() != null && pB != null && pB.getCompositePid() != null) { +result = pA.getCompositePid().compareTo(pB.getCompositePid()); +} + +// Then by priority, higher values first +if(result == 0) { +if(a.getPriority() < b.getPriority()) { +result = 1; +} else if(a.getPriority() > b.getPriority()) { +result = -1; +} +} + +// Then by digest +if(result == 0) { +if(a.getDigest() != null) { +result = a.getDigest().compareTo(b.getDigest()); +} +} + +return result; } -} \ No newline at end of file +} Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java?rev=809510&r1=809509&r2=809510&view=diff == --- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java (original) +++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java Mon Aug 31 09:09:01 2009 @@ -70,7 +70,9 @@ digest = testDigestChanged(d, digest, step, true); d.put("key", "value"); digest = testDigestChanged(d, digest, step, false); - + d.put("key", "valueB"); + digest = testDigestChanged(d, digest, step, true); + d.put("int", new Integer(12)); digest = testDigestChanged(d, digest, step, true); d.put("int", new Integer(12)); Modified: sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java?rev=809510&r1=809509&r2=809510&view=diff == --- sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java (original) +++ sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java Mon Aug 31 09:09:01 2009 @@ -18,20 +18,23 @@ */ package org.apache.sling.osgi.installer.impl; -impo
svn commit: r809559 - in /sling/trunk/installer: jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/ osgi/installer/src/main/java/org/apache/sling/osgi/installer/ osgi/installer/src/mai
Author: bdelacretaz Date: Mon Aug 31 12:40:57 2009 New Revision: 809559 URL: http://svn.apache.org/viewvc?rev=809559&view=rev Log: SLING-1078 - resource digest ignored in RegisteredResource comparisons Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/DictionaryDigestTest.java sling/trunk/installer/osgi/installer/src/test/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparatorTest.java Modified: sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java?rev=809559&r1=809558&r2=809559&view=diff == --- sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java (original) +++ sling/trunk/installer/jcr/jcrinstall/src/main/java/org/apache/sling/jcr/jcrinstall/impl/WatchedFolder.java Mon Aug 31 12:40:57 2009 @@ -143,7 +143,9 @@ if(r != null) { resourcesSeen.add(r.getUrl()); final String oldDigest = digests.get(r.getUrl()); - if(!r.getDigest().equals(oldDigest)) { + if(r.getDigest().equals(oldDigest)) { + log.debug("Digest didn't change, ignoring " + r); + } else { r.setPriority(priority); result.toAdd.add(r); } Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java?rev=809559&r1=809558&r2=809559&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/InstallableResource.java Mon Aug 31 12:40:57 2009 @@ -26,6 +26,9 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Dictionary; +import java.util.Enumeration; +import java.util.SortedSet; +import java.util.TreeSet; /** A piece of data that can be installed by the OSGi controller. * Wraps either a Dictionary or an InputStream. @@ -159,13 +162,21 @@ return new String(bigInt.toString(16)); } -/** Digest is needed to detect changes in data - * @throws */ +/** Digest is needed to detect changes in data, and must not depend on dictionary ordering */ public static String computeDigest(Dictionary data) throws IOException, NoSuchAlgorithmException { final MessageDigest d = MessageDigest.getInstance(DIGEST_TYPE); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ObjectOutputStream oos = new ObjectOutputStream(bos); -oos.writeObject(data); + +final SortedSet sortedKeys = new TreeSet(); +for(Enumeration e = data.keys(); e.hasMoreElements(); ) { + sortedKeys.add(e.nextElement()); +} +for(String key : sortedKeys) { + oos.writeObject(key); + oos.writeObject(data.get(key)); +} + bos.flush(); d.update(bos.toByteArray()); return digestToString(d); Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java?rev=809559&r1=809558&r2=809559&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/RegisteredResourceComparator.java Mon Aug 31 12:40:57 2009 @@ -66,18 +66,13 @@ } } -if(result == 0) { -if(isSnapshot) { -// For snapshot
svn commit: r809579 - /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java
Author: bdelacretaz Date: Mon Aug 31 13:28:51 2009 New Revision: 809579 URL: http://svn.apache.org/viewvc?rev=809579&view=rev Log: SLING-1078 - schedule task retries only on meaningful bundle events Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java?rev=809579&r1=809578&r2=809579&view=diff == --- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java (original) +++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerThread.java Mon Aug 31 13:28:51 2009 @@ -35,8 +35,6 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; import org.osgi.framework.BundleListener; -import org.osgi.framework.FrameworkEvent; -import org.osgi.framework.FrameworkListener; import org.osgi.service.log.LogService; /** Worker thread where all OSGi tasks are executed. @@ -47,7 +45,7 @@ * that are updated or removed during a cycle, and merged with * the main list at the end of the cycle. */ -class OsgiInstallerThread extends Thread implements FrameworkListener, BundleListener { +class OsgiInstallerThread extends Thread implements BundleListener { private final OsgiInstallerContext ctx; private final List newResources = new LinkedList(); @@ -72,7 +70,6 @@ void deactivate() { ctx.getBundleContext().removeBundleListener(this); -ctx.getBundleContext().removeFrameworkListener(this); active = false; synchronized (newResources) { newResources.notify(); @@ -81,7 +78,6 @@ @Override public void run() { -ctx.getBundleContext().addFrameworkListener(this); ctx.getBundleContext().addBundleListener(this); while(active) { @@ -381,17 +377,27 @@ ctx.incrementCounter(OsgiInstaller.INSTALLER_CYCLES_COUNTER); } -/** Need to wake up on framework and bundle events, as we might have tasks waiting to retry */ -public void frameworkEvent(FrameworkEvent arg0) { -synchronized (newResources) { -newResources.notify(); -} -} - -/** Need to wake up on framework and bundle events, as we might have tasks waiting to retry */ -public void bundleChanged(BundleEvent arg0) { -synchronized (newResources) { -newResources.notify(); -} +/** If we have any tasks waiting to be retried, schedule their execution */ +private void scheduleRetries() { + final int toRetry = tasksForNextCycle.size(); + if(toRetry > 0) { + if(ctx.getLogService() != null) { + ctx.getLogService().log(LogService.LOG_DEBUG, toRetry + " tasks scheduled for retrying"); + } +synchronized (newResources) { +newResources.notify(); +} + } +} + +public void bundleChanged(BundleEvent e) { + final int t = e.getType(); + if(t == BundleEvent.INSTALLED || t == BundleEvent.RESOLVED || t == BundleEvent.STARTED || t == BundleEvent.UPDATED) { + if(ctx.getLogService() != null) { + ctx.getLogService().log(LogService.LOG_DEBUG, + "Received BundleEvent that might allow installed bundles to start, scheduling retries if any"); + } + scheduleRetries(); + } } } \ No newline at end of file