Author: bdelacretaz
Date: Wed Jun 10 10:41:41 2009
New Revision: 783282
URL: http://svn.apache.org/viewvc?rev=783282&view=rev
Log:
SLING-904 - remove start level changes in RepositoryObserver, should not be
needed with modified osgi controller
Removed:
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockStartLevel.java
Modified:
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/resources/OSGI-INF/metatype/metatype.properties
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockRepositoryObserver.java
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndChangeBundlesTest.java
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndRestartTest.java
Modified:
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java?rev=783282&r1=783281&r2=783282&view=diff
==============================================================================
---
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
(original)
+++
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/java/org/apache/sling/jcr/jcrinstall/jcr/impl/RepositoryObserver.java
Wed Jun 10 10:41:41 2009
@@ -41,11 +41,8 @@
import org.apache.sling.osgi.installer.OsgiController;
import org.apache.sling.osgi.installer.ResourceOverrideRules;
import org.apache.sling.runmode.RunMode;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentContext;
-import org.osgi.service.startlevel.StartLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,7 +64,7 @@
* name="service.vendor"
* value="The Apache Software Foundation"
*/
-public class RepositoryObserver implements Runnable, FrameworkListener,
JcrInstallService {
+public class RepositoryObserver implements Runnable, JcrInstallService {
private final SortedSet<WatchedFolder> folders = new
TreeSet<WatchedFolder>();
private RunModeRegexpFilter folderNameFilter;
@@ -87,12 +84,8 @@
/** @scr.reference cardinality="0..1" policy="dynamic" */
protected SlingRepository repository;
- /** @scr.reference */
- protected StartLevel startLevel;
-
private Session session;
private File serviceDataFile;
- private int startLevelToSetAtStartup;
private final List<NodeConverter> converters = new
ArrayList<NodeConverter>();
@@ -121,26 +114,6 @@
protected void activate(ComponentContext context) throws Exception {
componentContext = context;
- // Context can be null in automated tests, to make them simpler
- if(context != null) {
- context.getBundleContext().addFrameworkListener(this);
- }
-
- // Check start levels
- if(context != null) {
- final int myLevel =
startLevel.getBundleStartLevel(context.getBundleContext().getBundle());
- final int initialBundleStartLevel =
startLevel.getInitialBundleStartLevel();
- if(initialBundleStartLevel < myLevel) {
- // Running at a lower start level than the bundles that we
install
- // allows us to stop them if the repository goes away
(SLING-747)
- log.warn(
- "The configured start level for installed bundles
({})"
- + " should be higher than the jcrinstall start level
({})",
- initialBundleStartLevel, myLevel
- );
- }
- }
-
// Call startup() if we already have a repository, else that will be
called
// by the bind method
if(repository != null) {
@@ -202,17 +175,9 @@
// Handle initial uninstalls and installs
observationCycleActive = true;
- final int myStartLevel = startLevel.getStartLevel();
handleInitialUninstalls();
runOneCycle();
- // Restore start level if we brought it down due to the repository
going away
- if(startLevelToSetAtStartup > 0 && startLevelToSetAtStartup !=
myStartLevel) {
- log.info("startup(): resetting start level to {}",
startLevelToSetAtStartup);
- startLevel.setStartLevel(startLevelToSetAtStartup);
- startLevelToSetAtStartup = 0;
- }
-
// start queue processing
final Thread t = new Thread(this, getClass().getSimpleName() + "_" +
System.currentTimeMillis());
t.setDaemon(true);
@@ -234,17 +199,13 @@
protected void deactivate(ComponentContext context) {
log.debug("deactivate()");
- shutdown(false);
- if(context != null) {
- context.getBundleContext().removeFrameworkListener(this);
- }
+ shutdown();
activated = false;
componentContext = null;
- startLevelToSetAtStartup = 0;
}
/** Called at deactivation time, or when repository stops being available
*/
- protected void shutdown(boolean allowStartLevelChange) {
+ protected void shutdown() {
log.debug("shutdown()");
observationCycleActive = false;
@@ -267,16 +228,8 @@
}
listeners.clear();
- folders.clear();
+ folders.clear();
- if(componentContext != null && allowStartLevelChange) {
- final int currentStartLevel = startLevel.getStartLevel();
- final int myStartLevel =
startLevel.getBundleStartLevel(componentContext.getBundleContext().getBundle());
- if(currentStartLevel > myStartLevel) {
- log.info("shutdown(): changing start level from {} to the
jcrinstall start level of {}", currentStartLevel, myStartLevel);
- startLevel.setStartLevel(myStartLevel);
- }
- }
}
/** Add WatchedFolders that have been discovered by our
WatchedFolderCreationListeners, if any */
@@ -463,18 +416,10 @@
protected void unbindSlingRepository(SlingRepository r) {
// Store current start level: shutdown() will bring it down and we want
// to go back to it if repository comes back
- startLevelToSetAtStartup = startLevel.getStartLevel();
- log.debug("unbindSlingRepository() called at start level {}",
startLevelToSetAtStartup);
- shutdown(true);
+ shutdown();
repository = null;
}
- public void frameworkEvent(FrameworkEvent e) {
- if(e.getType() == FrameworkEvent.STARTLEVEL_CHANGED) {
- log.info("FrameworkEvent.STARTLEVEL_CHANGED, start level={}",
startLevel.getStartLevel());
- }
- }
-
protected Set<WatchedFolder> getWatchedFolders() {
return folders;
}
@@ -510,4 +455,4 @@
public boolean isEnabled() {
return repository != null;
}
- }
\ No newline at end of file
+}
\ No newline at end of file
Modified:
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/resources/OSGI-INF/metatype/metatype.properties
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=783282&r1=783281&r2=783282&view=diff
==============================================================================
---
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/main/resources/OSGI-INF/metatype/metatype.properties
Wed Jun 10 10:41:41 2009
@@ -25,11 +25,4 @@
jcrinstall.name = Apache Sling JCR Install
jcrinstall.description = Installs OSGi bundles and configurations found \
- in the JCR Repository.
-
-bundles.startlevel.name = Start level of installed bundles
-bundles.startlevel.description = Bundles installed by jcrinstall are set \
- to this OSGi start level, which should be higher than the start level \
- of the jcrinstall bundle. The default start level of the framework should \
- be equal or higher to the configured value, so that installed bundles are \
- started right after being installed by jcrinstall.
+ in the JCR Repository.
\ No newline at end of file
Modified:
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockRepositoryObserver.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockRepositoryObserver.java?rev=783282&r1=783281&r2=783282&view=diff
==============================================================================
---
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockRepositoryObserver.java
(original)
+++
incubator/sling/trunk/contrib/extensions/jcrinstall/service/src/test/java/org/apache/sling/jcr/jcrinstall/jcr/impl/MockRepositoryObserver.java
Wed Jun 10 10:41:41 2009
@@ -42,7 +42,6 @@
osgiController = c;
scanDelayMsec = 0;
this.serviceDataFile = serviceDataFile;
- startLevel = new MockStartLevel();
}
public void run() {
Modified:
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndChangeBundlesTest.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndChangeBundlesTest.java?rev=783282&r1=783281&r2=783282&view=diff
==============================================================================
---
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndChangeBundlesTest.java
(original)
+++
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndChangeBundlesTest.java
Wed Jun 10 10:41:41 2009
@@ -22,7 +22,7 @@
/** Test replacing bundles while jcrinstall is disabled
*/
public class StopAndChangeBundlesTest extends JcrinstallTestBase {
-
+
public void testStopAndRestart() throws Exception {
final int activeBeforeTest = getActiveBundlesCount();
final List<String> installed = new LinkedList<String>();
@@ -30,6 +30,7 @@
final int nBundlesA = 7 * scaleFactor;
final int nBundlesB = 13 * scaleFactor;
+ enableJcrinstallService(true);
assertActiveBundleCount("before adding bundles",
activeBeforeTest, defaultBundlesTimeout);
@@ -55,10 +56,11 @@
installed.add(installClonedBundle(null, null));
}
- // Before reactivating, bundles count must be the initial count,
- // as jcrinstall brings the start level down
+ // Before reactivating, bundles count must be the same as
+ // before deactivating, as jcrinstall does not manipulate
+ // start levels anymore
assertActiveBundleCount("after replacing bundles",
- activeBeforeTest, defaultBundlesTimeout);
+ activeBeforeTest + nBundlesA,
defaultBundlesTimeout);
// Re-enable and verify that only original bundles + set B are
active
enableJcrinstallService(true);
Modified:
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndRestartTest.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndRestartTest.java?rev=783282&r1=783281&r2=783282&view=diff
==============================================================================
---
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndRestartTest.java
(original)
+++
incubator/sling/trunk/contrib/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/jcrinstall/StopAndRestartTest.java
Wed Jun 10 10:41:41 2009
@@ -33,15 +33,20 @@
installed.add(installClonedBundle(null, null));
}
+ enableJcrinstallService(true);
assertActiveBundleCount("after adding bundles",
activeBeforeTest + nBundles,
defaultBundlesTimeout);
-
+
+ // Bundles stay active if disabling jcrinstall,
+ // startlevel manipulations have been removed
enableJcrinstallService(false);
+ sleep(1000L);
assertActiveBundleCount("after disabling jcrinstall",
- activeBeforeTest, defaultBundlesTimeout);
+ activeBeforeTest + nBundles,
defaultBundlesTimeout);
enableJcrinstallService(true);
+ sleep(1000L);
assertActiveBundleCount("after re-enabling jcrinstall",
activeBeforeTest + nBundles,
defaultBundlesTimeout);