You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/04/26 09:29:34 UTC
svn commit: r1330686 -
/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
Author: jbonofre
Date: Thu Apr 26 07:29:34 2012
New Revision: 1330686
URL: http://svn.apache.org/viewvc?rev=1330686&view=rev
Log:
[KARAF-1345] Check the feature handler switch status
Modified:
karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
Modified: karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java?rev=1330686&r1=1330685&r2=1330686&view=diff
==============================================================================
--- karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java (original)
+++ karaf/cellar/trunk/features/src/main/java/org/apache/karaf/cellar/features/FeaturesEventHandler.java Thu Apr 26 07:29:34 2012
@@ -15,6 +15,7 @@ package org.apache.karaf.cellar.features
import org.apache.karaf.cellar.core.control.BasicSwitch;
import org.apache.karaf.cellar.core.control.Switch;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventHandler;
import org.apache.karaf.cellar.core.event.EventType;
import org.apache.karaf.features.FeatureEvent;
@@ -50,31 +51,33 @@ public class FeaturesEventHandler extend
public void handle(RemoteFeaturesEvent event) {
String name = event.getName();
String version = event.getVersion();
- if (isAllowed(event.getSourceGroup(), Constants.FEATURES_CATEGORY, name, EventType.INBOUND) || event.getForce()) {
- FeatureEvent.EventType type = event.getType();
- Boolean isInstalled = isInstalled(name, version);
- try {
- if (FeatureEvent.EventType.FeatureInstalled.equals(type) && !isInstalled) {
- if (version != null) {
- LOGGER.debug("CELLAR FEATURES: installing feature {}/{}", name, version);
- featuresService.installFeature(name, version);
- } else {
- LOGGER.debug("CELLAR FEATURES: installing feature {}", name);
- featuresService.installFeature(name);
- }
- } else if (FeatureEvent.EventType.FeatureUninstalled.equals(type) && isInstalled) {
- if (version != null) {
- LOGGER.debug("CELLAR FEATURES: un-installing feature {}/{}", name, version);
- featuresService.uninstallFeature(name, version);
- } else {
- LOGGER.debug("CELLAR FEATURES: un-installing feature {}", name);
- featuresService.uninstallFeature(name);
+ if (eventSwitch.getStatus().equals(SwitchStatus.ON)) {
+ if (isAllowed(event.getSourceGroup(), Constants.FEATURES_CATEGORY, name, EventType.INBOUND) || event.getForce()) {
+ FeatureEvent.EventType type = event.getType();
+ Boolean isInstalled = isInstalled(name, version);
+ try {
+ if (FeatureEvent.EventType.FeatureInstalled.equals(type) && !isInstalled) {
+ if (version != null) {
+ LOGGER.debug("CELLAR FEATURES: installing feature {}/{}", name, version);
+ featuresService.installFeature(name, version);
+ } else {
+ LOGGER.debug("CELLAR FEATURES: installing feature {}", name);
+ featuresService.installFeature(name);
+ }
+ } else if (FeatureEvent.EventType.FeatureUninstalled.equals(type) && isInstalled) {
+ if (version != null) {
+ LOGGER.debug("CELLAR FEATURES: un-installing feature {}/{}", name, version);
+ featuresService.uninstallFeature(name, version);
+ } else {
+ LOGGER.debug("CELLAR FEATURES: un-installing feature {}", name);
+ featuresService.uninstallFeature(name);
+ }
}
+ } catch (Exception e) {
+ LOGGER.error("CELLAR FEATURES: failed to handle feature event", e);
}
- } catch (Exception e) {
- LOGGER.error("CELLAR FEATURES: failed to handle feature event", e);
- }
- } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED INBOUND", name);
+ } else LOGGER.warn("CELLAR FEATURES: feature {} is marked as BLOCKED INBOUND", name);
+ }
}
public Class<RemoteFeaturesEvent> getType() {