Repository: karaf-cellar
Updated Branches:
refs/heads/cellar-2.3.x eaedf443a -> 213e521e4
[KARAF-3646] moved away from java.lang.isAssignableFrom in favor of
org.apache.commons.lang3.ClassUtils.isAssignable;
Conflicts:
dosgi/pom.xml
pom.xml
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/e9d6ee5b
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/e9d6ee5b
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/e9d6ee5b
Branch: refs/heads/cellar-2.3.x
Commit: e9d6ee5bd89e840029ee671d88ce2b0fe88fb479
Parents: eaedf44
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Sun Sep 20 21:26:14 2015 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Sun Sep 20 21:26:14 2015 +0200
----------------------------------------------------------------------
.../features/shell/InstallFeatureCommand.java | 74 +++++++++++---------
1 file changed, 41 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/e9d6ee5b/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
----------------------------------------------------------------------
diff --git
a/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
b/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
index 2e0fa1f..f7a93d7 100644
---
a/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
+++
b/features/src/main/java/org/apache/karaf/cellar/features/shell/InstallFeatureCommand.java
@@ -63,46 +63,54 @@ public class InstallFeatureCommand extends
FeatureCommandSupport {
return null;
}
- Map<String, FeatureState> clusterFeatures =
clusterManager.getMap(Constants.FEATURES_MAP + Configurations.SEPARATOR +
groupName);
+ ClassLoader originalClassLoader =
Thread.currentThread().getContextClassLoader();
+
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
- // try to resolve the feature version if not provided
- if (version == null) {
- for (FeatureState state : clusterFeatures.values()) {
- if (state.getName().equals(feature)) {
- version = state.getVersion();
+ try {
+
+ Map<String, FeatureState> clusterFeatures =
clusterManager.getMap(Constants.FEATURES_MAP + Configurations.SEPARATOR +
groupName);
+
+ // try to resolve the feature version if not provided
+ if (version == null) {
+ for (FeatureState state : clusterFeatures.values()) {
+ if (state.getName().equals(feature)) {
+ version = state.getVersion();
+ }
}
}
- }
- // check if the feature exists in the map
- if (!clusterFeatures.containsKey(feature + "/" + version)) {
- if (version != null)
- System.err.println("Feature " + feature + "/" + version + "
doesn't exist in the cluster group " + groupName);
- else System.err.println("Feature " + feature + " doesn't exist in
the cluster group " + groupName);
- return null;
- }
+ // check if the feature exists in the map
+ if (!clusterFeatures.containsKey(feature + "/" + version)) {
+ if (version != null)
+ System.err.println("Feature " + feature + "/" + version +
" doesn't exist in the cluster group " + groupName);
+ else System.err.println("Feature " + feature + " doesn't exist
in the cluster group " + groupName);
+ return null;
+ }
- // check if the outbound event is allowed
- if (!isAllowed(group, Constants.CATEGORY, feature,
EventType.OUTBOUND)) {
- System.err.println("Feature " + feature + " is blocked outbound
for cluster group " + groupName);
- return null;
- }
+ // check if the outbound event is allowed
+ if (!isAllowed(group, Constants.CATEGORY, feature,
EventType.OUTBOUND)) {
+ System.err.println("Feature " + feature + " is blocked
outbound for cluster group " + groupName);
+ return null;
+ }
- // update the features in the cluster group
- FeatureState clusterFeatureState = clusterFeatures.get(feature + "/" +
version);
- if (clusterFeatureState == null) {
- clusterFeatureState = new FeatureState();
- clusterFeatureState.setName(feature);
- clusterFeatureState.setVersion(version);
+ // update the features in the cluster group
+ FeatureState clusterFeatureState = clusterFeatures.get(feature +
"/" + version);
+ if (clusterFeatureState == null) {
+ clusterFeatureState = new FeatureState();
+ clusterFeatureState.setName(feature);
+ clusterFeatureState.setVersion(version);
+ }
+ clusterFeatureState.setInstalled(Boolean.TRUE);
+ clusterFeatures.put(feature + "/" + version, clusterFeatureState);
+ // TODO does it make sense to also update the cluster bundles, I
don't think so ...
+
+ // broadcast the cluster event
+ ClusterFeaturesEvent event = new ClusterFeaturesEvent(feature,
version, noClean, noRefresh, FeatureEvent.EventType.FeatureInstalled);
+ event.setSourceGroup(group);
+ eventProducer.produce(event);
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalClassLoader);
}
- clusterFeatureState.setInstalled(Boolean.TRUE);
- clusterFeatures.put(feature + "/" + version, clusterFeatureState);
- // TODO does it make sense to also update the cluster bundles, I don't
think so ...
-
- // broadcast the cluster event
- ClusterFeaturesEvent event = new ClusterFeaturesEvent(feature,
version, noClean, noRefresh, FeatureEvent.EventType.FeatureInstalled);
- event.setSourceGroup(group);
- eventProducer.produce(event);
return null;
}