Why not using bundle:watch ? Regards JB
On 08/26/2015 05:29 PM, sreeraaman wrote:
Dear All, We have a requirement, wherein, all updates should happen automatically. Our application is packaged as a custom karaf distro and run as a service in the end-user environment. All the application specific bundles / features are hosted in our nexus repo and the same is added to the org.ops4j.pax.url.mvn.cfg file under the property org.ops4j.pax.url.mvn.repositories. Hence, all bundle / feature resolution will pickup our nexus repository. Now, to enable an auto update for our application, we were thinking of the following possibility. Have a quartz scheduler that will run everyday at a pre-determined time and trigger our AutoUpdater Service which is a SCR Component. The component looks like this. @Component(name="AppUpdater",provide=IAutoUpdater.class,immediate=true) public class AutoUpdater implements IAutoUpdater{ //we inject the FeaturesService & MavenResolver (pax url aether) FeaturesService featureService; MavenResolver mavenResolver; @Reference(service=MavenResolver.class,optional=false) public void setMavenResolver(..){ .. } @Reference(service=FeaturesService.class,optional=false) public void setFeatureService(...){ .. } The IAutoUpdater interface has a method with the following signature. public void update(String[] featuresToUpdate); In the implementation of the update method, we do the following: public void update(String[] featuresToUpdate){ for (String feature:featuresToUpdate){ //Try to retrieve the feature by name Feature f = featureService.getFeature(feature); if (f != null) { // feature is already installed //we build the feature url. for eg. mvn:mygroupid/feature/LATEST/features/xml //feature name & //artifact ids are the same. String featureUrl = buildFeatureUrl(feature); //This resolves and downloads the feature xml file File file = mavenResolver.resolve(featureUrl); //parse the xml to obtain the latest feature version. String latestVersion = parseFeatureFile(file); //compare the latestversion with the installed feature version. if (!f.getVersion().equals(latestVersion)){ //feature requires an update. //remove the current feature featureService.uninstallFeature(feature); //remove the repository as well featureService.removeRepository(featureService.getRepositoryUriFor(feature, f.getVersion()), true); featureService.addRepository(file.toURI()); featureService.installFeature(feature); else{ //you are already running the latest version of the feature. leave it as it is. } } } } } Just wanted to understand if this is the right way of doing it or is there any other approach that can be adopted. Note: MavenResolver is available only as of pax-url-aether 2.4.1. This solution would work only on karaf 3.0.4 +. best regards Sriraman. -- View this message in context: http://karaf.922171.n3.nabble.com/Karaf-Feature-autoupdate-tp4042069.html Sent from the Karaf - User mailing list archive at Nabble.com.
-- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com