Repository: karaf-cellar Updated Branches: refs/heads/master cce70103b -> 4034deb14
[KARAF-4669] Add bundle start-level in the cluster groups Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/4034deb1 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/4034deb1 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/4034deb1 Branch: refs/heads/master Commit: 4034deb14ab416bd6028320642f3a16a76aad316 Parents: cce7010 Author: Jean-Baptiste Onofré <[email protected]> Authored: Wed May 10 16:14:55 2017 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Wed May 10 16:14:55 2017 +0200 ---------------------------------------------------------------------- .../karaf/cellar/bundle/BundleEventHandler.java | 6 +++--- .../apache/karaf/cellar/bundle/BundleState.java | 9 +++++++++ .../karaf/cellar/bundle/BundleSupport.java | 9 +++++++-- .../karaf/cellar/bundle/BundleSynchronizer.java | 13 ++++++++----- .../karaf/cellar/bundle/ClusterBundleEvent.java | 12 +++++++++++- .../karaf/cellar/bundle/LocalBundleListener.java | 5 ++++- .../bundle/management/CellarBundleMBean.java | 13 ++++++++++++- .../internal/CellarBundleMBeanImpl.java | 19 ++++++++++++------- .../bundle/shell/InstallBundleCommand.java | 8 ++++++-- .../cellar/bundle/shell/ListBundleCommand.java | 7 ++++--- .../cellar/bundle/shell/StartBundleCommand.java | 6 +++++- .../cellar/bundle/shell/StopBundleCommand.java | 2 +- .../bundle/shell/UninstallBundleCommand.java | 2 +- .../cellar/bundle/shell/UpdateBundleCommand.java | 2 +- 14 files changed, 84 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java index 109cad3..8916b4f 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java @@ -85,14 +85,14 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl } } if (event.getType() == Bundle.INSTALLED) { - installBundleFromLocation(event.getLocation()); + installBundleFromLocation(event.getLocation(), event.getStartLevel()); LOGGER.debug("CELLAR BUNDLE: installing {}/{}", event.getSymbolicName(), event.getVersion()); } else if (event.getType() == Bundle.UNINSTALLED) { uninstallBundle(event.getSymbolicName(), event.getVersion()); LOGGER.debug("CELLAR BUNDLE: uninstalling {}/{}", event.getSymbolicName(), event.getVersion()); } else if (event.getType() == Bundle.ACTIVE) { if (!isInstalled(event.getLocation())) { - installBundleFromLocation(event.getLocation()); + installBundleFromLocation(event.getLocation(), event.getStartLevel()); } try { startBundle(event.getSymbolicName(), event.getVersion()); @@ -108,7 +108,7 @@ public class BundleEventHandler extends BundleSupport implements EventHandler<Cl } } else if (event.getType() == Bundle.RESOLVED) { if (!isInstalled(event.getLocation())) { - installBundleFromLocation(event.getLocation()); + installBundleFromLocation(event.getLocation(), event.getStartLevel()); LOGGER.debug("CELLAR BUNDLE: installing {}/{}", event.getSymbolicName(), event.getVersion()); } Bundle b = findBundle(event.getLocation()); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java index a9c1519..ab8e913 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleState.java @@ -29,6 +29,7 @@ public class BundleState implements Serializable { private String symbolicName; private String version; private String location; + private Integer startLevel; private int status; private byte[] data; @@ -72,6 +73,14 @@ public class BundleState implements Serializable { this.location = location; } + public Integer getStartLevel() { + return startLevel; + } + + public void setStartLevel(Integer startLevel) { + this.startLevel = startLevel; + } + public int getStatus() { return status; } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java index 242dc04..738960d 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java @@ -19,6 +19,7 @@ import org.apache.karaf.features.Feature; import org.apache.karaf.features.FeaturesService; import org.apache.karaf.util.bundles.BundleUtils; import org.osgi.framework.*; +import org.osgi.framework.startlevel.BundleStartLevel; import java.io.File; import java.io.FileInputStream; @@ -40,10 +41,14 @@ public class BundleSupport extends CellarSupport { * Locally install a bundle. * * @param location the bundle location. + * @param level optional bundle start level. * @throws BundleException in case of installation failure. */ - public void installBundleFromLocation(String location) throws BundleException { - getBundleContext().installBundle(location); + public void installBundleFromLocation(String location, Integer level) throws BundleException { + Bundle bundle = getBundleContext().installBundle(location); + if (level != null) { + bundle.adapt(BundleStartLevel.class).setStartLevel(level); + } } public boolean isInstalled(String location) { http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java index afde1c4..f1b064e 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSynchronizer.java @@ -24,6 +24,7 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import org.osgi.framework.BundleReference; +import org.osgi.framework.startlevel.BundleStartLevel; import org.osgi.framework.wiring.FrameworkWiring; import org.osgi.service.cm.Configuration; import org.osgi.util.tracker.ServiceTracker; @@ -143,14 +144,14 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer { if (state.getStatus() == Bundle.INSTALLED) { if (!isInstalled(state.getLocation())) { LOGGER.debug("CELLAR BUNDLE: installing bundle located {} on node", state.getLocation()); - installBundleFromLocation(state.getLocation()); + installBundleFromLocation(state.getLocation(), state.getStartLevel()); } else { LOGGER.debug("CELLAR BUNDLE: bundle located {} already installed on node", state.getLocation()); } } else if (state.getStatus() == Bundle.ACTIVE) { if (!isInstalled(state.getLocation())) { LOGGER.debug("CELLAR BUNDLE: installing bundle located {} on node", state.getLocation()); - installBundleFromLocation(state.getLocation()); + installBundleFromLocation(state.getLocation(), state.getStartLevel()); } if (!isStarted(state.getLocation())) { LOGGER.debug("CELLAR BUNDLE: starting bundle {}/{} on node", symbolicName, version); @@ -161,7 +162,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer { } else if (state.getStatus() == Bundle.RESOLVED) { if (!isInstalled(state.getLocation())) { LOGGER.debug("CELLAR BUNDLE: installing bundle located {} on node", state.getLocation()); - installBundleFromLocation(state.getLocation()); + installBundleFromLocation(state.getLocation(), state.getStartLevel()); } Bundle b = findBundle(state.getLocation()); if (b != null) { @@ -235,6 +236,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer { String version = bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); String bundleLocation = bundle.getLocation(); int status = bundle.getState(); + int level = bundle.adapt(BundleStartLevel.class).getStartLevel(); String id = getId(bundle); @@ -251,6 +253,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer { name = (name == null) ? bundle.getLocation() : name; bundleState.setId(bundleId); bundleState.setName(name); + bundleState.setStartLevel(level); bundleState.setSymbolicName(symbolicName); bundleState.setVersion(version); bundleState.setLocation(bundleLocation); @@ -258,7 +261,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer { // update cluster state clusterBundles.put(id, bundleState); // send cluster event - ClusterBundleEvent clusterEvent = new ClusterBundleEvent(symbolicName, version, bundleLocation, status); + ClusterBundleEvent clusterEvent = new ClusterBundleEvent(symbolicName, version, bundleLocation, level, status); clusterEvent.setSourceGroup(group); clusterEvent.setSourceNode(clusterManager.getNode()); clusterEvent.setLocal(clusterManager.getNode()); @@ -271,7 +274,7 @@ public class BundleSynchronizer extends BundleSupport implements Synchronizer { bundleState.setStatus(status); clusterBundles.put(id, bundleState); // send cluster event - ClusterBundleEvent clusterEvent = new ClusterBundleEvent(symbolicName, version, bundleLocation, status); + ClusterBundleEvent clusterEvent = new ClusterBundleEvent(symbolicName, version, bundleLocation, null, status); clusterEvent.setSourceGroup(group); clusterEvent.setSourceNode(clusterManager.getNode()); clusterEvent.setLocal(clusterManager.getNode()); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java index 938c4ef..d87c996 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/ClusterBundleEvent.java @@ -24,14 +24,16 @@ public class ClusterBundleEvent extends Event { private String symbolicName; private String version; private String location; + private Integer startLevel; private int type; private Node local; - public ClusterBundleEvent(String symbolicName, String version, String location, int type) { + public ClusterBundleEvent(String symbolicName, String version, String location, Integer startLevel, int type) { super(symbolicName + "/" + version); this.symbolicName = symbolicName; this.version = version; this.location = location; + this.startLevel = startLevel; this.type = type; } @@ -59,6 +61,14 @@ public class ClusterBundleEvent extends Event { this.location = location; } + public Integer getStartLevel() { + return startLevel; + } + + public void setStartLevel(Integer startLevel) { + this.startLevel = startLevel; + } + public int getType() { return type; } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java index 72d8caf..bfb7de0 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java @@ -21,6 +21,7 @@ import org.apache.karaf.cellar.core.event.EventType; import org.apache.karaf.features.Feature; import org.osgi.framework.BundleEvent; import org.osgi.framework.SynchronousBundleListener; +import org.osgi.framework.startlevel.BundleStartLevel; import org.osgi.service.cm.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -90,6 +91,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun String version = event.getBundle().getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); String bundleLocation = event.getBundle().getLocation(); int status = event.getBundle().getState(); + int startLevel = event.getBundle().adapt(BundleStartLevel.class).getStartLevel(); if (isAllowed(group, Constants.CATEGORY, bundleLocation, EventType.OUTBOUND)) { @@ -111,6 +113,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun state.setVersion(version); state.setSymbolicName(symbolicName); state.setStatus(status); + state.setStartLevel(startLevel); state.setLocation(bundleLocation); clusterBundles.put(symbolicName + "/" + version, state); } @@ -125,7 +128,7 @@ public class LocalBundleListener extends BundleSupport implements SynchronousBun } // broadcast the cluster event - ClusterBundleEvent clusterBundleEvent = new ClusterBundleEvent(symbolicName, version, bundleLocation, status); + ClusterBundleEvent clusterBundleEvent = new ClusterBundleEvent(symbolicName, version, bundleLocation, startLevel, status); clusterBundleEvent.setSourceGroup(group); clusterBundleEvent.setSourceNode(clusterManager.getNode()); clusterBundleEvent.setLocal(clusterManager.getNode()); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/CellarBundleMBean.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/CellarBundleMBean.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/CellarBundleMBean.java index 5704902..1fb2bf5 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/CellarBundleMBean.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/CellarBundleMBean.java @@ -30,14 +30,25 @@ public interface CellarBundleMBean { void install(String group, String location) throws Exception; /** + * Install a bundle in a cluster group. + * + * @param group the cluster group name. + * @param location the bundle location. + * @param start true to start the bundle, false else. + * @throws Exception in case of install failure. + */ + void install(String group, String location, boolean start) throws Exception; + + /** * Install and eventually start a bundle in a cluster group. * * @param group the cluster group name. * @param location the bundle location. + * @param level the bundle start level. * @param start true to start the bundle, false else. * @throws Exception */ - void install(String group, String location, boolean start) throws Exception; + void install(String group, String location, Integer level, boolean start) throws Exception; /** * Uninstall a bundle from a cluster group. http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java index 908bc08..abd76f4 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java @@ -92,11 +92,16 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle @Override public void install(String groupName, String location) throws Exception { - this.install(groupName, location, false); + this.install(groupName, location, null,false); } @Override public void install(String groupName, String location, boolean start) throws Exception { + this.install(groupName, location, null, start); + } + + @Override + public void install(String groupName, String location, Integer level, boolean start) throws Exception { // check if cluster group exists Group group = groupManager.findGroupByName(groupName); if (group == null) { @@ -156,11 +161,11 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle } // broadcast the event - ClusterBundleEvent event = new ClusterBundleEvent(symbolicName, version, location, Bundle.INSTALLED); + ClusterBundleEvent event = new ClusterBundleEvent(symbolicName, version, location, level, Bundle.INSTALLED); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); if (start) { - event = new ClusterBundleEvent(symbolicName, version, location, Bundle.ACTIVE); + event = new ClusterBundleEvent(symbolicName, version, location, level, Bundle.ACTIVE); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); } @@ -211,7 +216,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, Bundle.UNINSTALLED); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, null, Bundle.UNINSTALLED); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); @@ -268,7 +273,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, Bundle.ACTIVE); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, null, Bundle.ACTIVE); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); @@ -322,7 +327,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, Bundle.RESOLVED); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, null, Bundle.RESOLVED); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); @@ -379,7 +384,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleState.UPDATE); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, null, BundleState.UPDATE); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java index fe79aa8..c743679 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java @@ -52,6 +52,9 @@ public class InstallBundleCommand extends CellarCommandSupport { @Option(name = "-s", aliases = {"--start"}, description = "Start the bundle after installation", required = false, multiValued = false) boolean start; + @Option(name = "-l", aliases = {"--start-level"}, description = "Set the start level of the bundle", required = false, multiValued = false) + Integer level; + @Reference private EventProducer eventProducer; @@ -107,6 +110,7 @@ public class InstallBundleCommand extends CellarCommandSupport { state.setName(name); state.setSymbolicName(symbolicName); state.setVersion(version); + state.setStartLevel(level); state.setId(clusterBundles.size()); state.setLocation(url); if (start) { @@ -122,11 +126,11 @@ public class InstallBundleCommand extends CellarCommandSupport { // broadcast the cluster event ClusterBundleEvent event; if (start) { - event = new ClusterBundleEvent(symbolicName, version, url, Bundle.ACTIVE); + event = new ClusterBundleEvent(symbolicName, version, url, level, Bundle.ACTIVE); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); } else { - event = new ClusterBundleEvent(symbolicName, version, url, Bundle.INSTALLED); + event = new ClusterBundleEvent(symbolicName, version, url, level, Bundle.INSTALLED); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java index 1b032d8..6c9c2d8 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java @@ -70,6 +70,7 @@ public class ListBundleCommand extends BundleCommandSupport { ShellTable table = new ShellTable(); table.column("ID").alignRight(); table.column("State"); + table.column("Lvl"); table.column("Located"); table.column("Blocked"); table.column("Version"); @@ -151,12 +152,12 @@ public class ListBundleCommand extends BundleCommandSupport { blocked = "out"; if (showLocation) { - table.addRow().addContent(bundle.getId(), status, located, blocked, bundle.getVersion(), bundle.getLocation()); + table.addRow().addContent(bundle.getId(), status, bundle.getStartLevel(), located, blocked, bundle.getVersion(), bundle.getLocation()); } else { if (showSymbolicName) { - table.addRow().addContent(bundle.getId(), status, located, blocked, bundle.getVersion(), bundle.getSymbolicName()); + table.addRow().addContent(bundle.getId(), status, bundle.getStartLevel(), located, blocked, bundle.getVersion(), bundle.getSymbolicName()); } else { - table.addRow().addContent(bundle.getId(), status, located, blocked, bundle.getVersion(), bundle.getName()); + table.addRow().addContent(bundle.getId(), status, bundle.getStartLevel(), located, blocked, bundle.getVersion(), bundle.getName()); } } } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java index d53dc06..9286e46 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java @@ -23,6 +23,7 @@ import org.apache.karaf.cellar.core.control.SwitchStatus; import org.apache.karaf.cellar.core.event.EventProducer; import org.apache.karaf.cellar.core.event.EventType; import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Option; import org.apache.karaf.shell.api.action.lifecycle.Reference; import org.apache.karaf.shell.api.action.lifecycle.Service; import org.osgi.framework.Bundle; @@ -34,6 +35,9 @@ import java.util.Map; @Service public class StartBundleCommand extends BundleCommandSupport { + @Option(name = "-l", aliases = {"--start-level"}, description = "Set the start level of a bundle", required = false, multiValued = false) + Integer level; + @Reference private EventProducer eventProducer; @@ -83,7 +87,7 @@ public class StartBundleCommand extends BundleCommandSupport { // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, Bundle.ACTIVE); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, level, Bundle.ACTIVE); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java index 4faf095..3f5e2b0 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java @@ -83,7 +83,7 @@ public class StopBundleCommand extends BundleCommandSupport { // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, Bundle.RESOLVED); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, null, Bundle.RESOLVED); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java index c45eab6..d032598 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java @@ -82,7 +82,7 @@ public class UninstallBundleCommand extends BundleCommandSupport { // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, Bundle.UNINSTALLED); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, null, Bundle.UNINSTALLED); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event); http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/4034deb1/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java index a86183d..535d1f3 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java @@ -96,7 +96,7 @@ public class UpdateBundleCommand extends BundleCommandSupport { // broadcast the cluster event String[] split = bundle.split("/"); - ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, BundleState.UPDATE); + ClusterBundleEvent event = new ClusterBundleEvent(split[0], split[1], location, null, BundleState.UPDATE); event.setSourceGroup(group); event.setSourceNode(clusterManager.getNode()); eventProducer.produce(event);
