Author: paperwing
Date: 2012-06-25 16:01:52 -0700 (Mon, 25 Jun 2012)
New Revision: 29686
Modified:
core3/impl/trunk/app-impl/pom.xml
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
Log:
refs #1158 App Manager now accesses the Karaf FeaturesService service to obtain
access for uninstalling bundle apps
Modified: core3/impl/trunk/app-impl/pom.xml
===================================================================
--- core3/impl/trunk/app-impl/pom.xml 2012-06-25 22:27:44 UTC (rev 29685)
+++ core3/impl/trunk/app-impl/pom.xml 2012-06-25 23:01:52 UTC (rev 29686)
@@ -102,6 +102,12 @@
<artifactId>application-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>org.apache.karaf.features.core</artifactId>
+ <version>2.2.7</version>
+ </dependency>
+
<!-- dependency for file copying and moving, as well as
directory watching -->
<dependency>
<groupId>commons-io</groupId>
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-06-25 22:27:44 UTC (rev 29685)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-06-25 23:01:52 UTC (rev 29686)
@@ -1,5 +1,6 @@
package org.cytoscape.app.internal;
+import org.apache.karaf.features.FeaturesService;
import org.cytoscape.app.CyAppAdapter;
import org.cytoscape.app.internal.CyAppAdapterImpl;
import org.cytoscape.app.internal.action.AppManagerAction;
@@ -348,10 +349,13 @@
WebQuerier webQuerier = new WebQuerier(streamUtilServiceRef);
registerService(bc, webQuerier, WebQuerier.class, new
Properties());
+ FeaturesService featuresService = getService(bc,
FeaturesService.class);
+
// Instantiate new manager
final AppManager appManager = new AppManager(
cyAppAdapter,
cyApplicationConfigurationServiceRef, webQuerier);
registerService(bc, appManager, AppManager.class, new
Properties());
+ appManager.setFeaturesService(featuresService);
// AbstractCyAction implementation for updated app manager
AppManagerAction appManagerAction2 = new
AppManagerAction(appManager, cySwingApplicationRef, fileUtilServiceRef,
dialogTaskManagerRef);
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-06-25 22:27:44 UTC (rev 29685)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-06-25 23:01:52 UTC (rev 29686)
@@ -15,6 +15,7 @@
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;
+import org.apache.karaf.features.FeaturesService;
import org.cytoscape.app.AbstractCyApp;
import org.cytoscape.app.CyAppAdapter;
import org.cytoscape.app.internal.event.AppsChangedEvent;
@@ -76,6 +77,11 @@
private WebQuerier webQuerier;
/**
+ * The {@link FeaturesService} used to communicate with Apache Karaf to
manage OSGi bundle based apps
+ */
+ private FeaturesService featuresService;
+
+ /**
* {@link CyApplicationConfiguration} service used to obtain the
directories used to store the apps.
*/
private CyApplicationConfiguration applicationConfiguration;
@@ -96,7 +102,6 @@
public SingleLevelFileFilter(File parentDirectory) {
this.parentDirectory = parentDirectory;
-
}
@Override
@@ -109,7 +114,6 @@
return true;
}
-
}
public AppManager(CySwingAppAdapter swingAppAdapter,
CyApplicationConfiguration applicationConfiguration, final WebQuerier
webQuerier) {
@@ -125,7 +129,7 @@
initializeAppsDirectories();
this.appListeners = new HashSet<AppsChangedListener>();
-
+
// Install previously enabled apps
installAppsInDirectory(new File(getInstalledAppsPath()));
@@ -138,7 +142,14 @@
DebugHelper.print(this, "config dir: " +
applicationConfiguration.getConfigurationDirectoryLocation());
}
+ public FeaturesService getFeaturesService() {
+ return this.featuresService;
+ }
+ public void setFeaturesService(FeaturesService featuresService) {
+ this.featuresService = featuresService;
+ }
+
private void setupAlterationMonitor() {
// Set up the FileAlterationMonitor to install/uninstall apps
when apps are moved in/out of the
// installed/uninstalled app directories
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
2012-06-25 22:27:44 UTC (rev 29685)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
2012-06-25 23:01:52 UTC (rev 29686)
@@ -3,6 +3,8 @@
import java.net.MalformedURLException;
import java.util.List;
+import org.apache.karaf.features.Feature;
+import org.apache.karaf.features.FeaturesService;
import org.cytoscape.app.CyAppAdapter;
import org.cytoscape.app.internal.exception.AppInstallException;
import org.cytoscape.app.internal.exception.AppInstanceException;
@@ -49,6 +51,10 @@
// Use the default installation procedure consisting of copying
over
// the file, creating an instance, and registering with the app
manager.
// defaultInstall(appManager);
+
+ // Copy to Karaf deploy directory
+
+
}
@Override
@@ -57,6 +63,29 @@
// Use the default uninstallation procedure consisting of
moving the app file
// to the uninstalled apps directory
// defaultUninstall(appManager);
+
+ FeaturesService featuresService =
appManager.getFeaturesService();
+
+ try {
+ Feature[] availableFeatures =
featuresService.listFeatures();
+ List<BundleApp.KarafFeature> appFeatures =
this.getFeaturesList();
+
+ Feature availableFeature;
+ for (int i = 0; i < availableFeatures.length; i++) {
+ availableFeature = availableFeatures[i];
+
+ for (BundleApp.KarafFeature appFeature :
appFeatures) {
+ if
(appFeature.featureName.equalsIgnoreCase(availableFeature.getName())
+ &&
appFeature.featureVersion.equalsIgnoreCase(availableFeature.getVersion())) {
+
+ }
+ }
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+
+ }
}
/**
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.