Author: gnodet
Date: Tue May 6 03:22:27 2008
New Revision: 653736
URL: http://svn.apache.org/viewvc?rev=653736&view=rev
Log:
SMX4KNL-32: Lazy load feature repositories to avoid delay when the url can not
be accessed or things like that
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java?rev=653736&r1=653735&r2=653736&view=diff
==============================================================================
---
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
(original)
+++
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/FeaturesService.java
Tue May 6 03:22:27 2008
@@ -33,7 +33,7 @@
void uninstallFeature(String name) throws Exception;
- String[] listFeatures();
+ String[] listFeatures() throws Exception;
String[] listInstalledFeatures();
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java?rev=653736&r1=653735&r2=653736&view=diff
==============================================================================
---
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
(original)
+++
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/Repository.java
Tue May 6 03:22:27 2008
@@ -26,6 +26,6 @@
URL getURL();
- Feature[] getFeatures();
+ Feature[] getFeatures() throws Exception;
}
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java?rev=653736&r1=653735&r2=653736&view=diff
==============================================================================
---
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
(original)
+++
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/FeaturesServiceImpl.java
Tue May 6 03:22:27 2008
@@ -113,11 +113,6 @@
RepositoryImpl repo = new RepositoryImpl(url);
repositories.put(url, repo);
features = null;
- try {
- repo.load();
- } catch (IOException e) {
- LOGGER.warn("Error loading features repository from url '" + url,
e);
- }
}
public void removeRepository(URL url) {
@@ -126,7 +121,7 @@
}
public void internalRemoveRepository(URL url) {
- Repository repo = repositories.remove(url);
+ repositories.remove(url);
features = null;
}
@@ -216,7 +211,7 @@
saveState();
}
- public String[] listFeatures() {
+ public String[] listFeatures() throws Exception {
Collection<String> features = new ArrayList<String>();
for (Repository repo : repositories.values()) {
for (Feature f : repo.getFeatures()) {
@@ -230,11 +225,11 @@
return installed.keySet().toArray(new String[installed.size()]);
}
- protected Feature getFeature(String name) {
+ protected Feature getFeature(String name) throws Exception {
return getFeatures().get(name);
}
- protected Map<String, Feature> getFeatures() {
+ protected Map<String, Feature> getFeatures() throws Exception {
if (features == null) {
Map<String, Feature> map = new HashMap<String, Feature>();
for (Repository repo : repositories.values()) {
Modified:
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java?rev=653736&r1=653735&r2=653736&view=diff
==============================================================================
---
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
(original)
+++
servicemix/smx4/kernel/trunk/gshell/gshell-features/src/main/java/org/apache/servicemix/gshell/features/internal/RepositoryImpl.java
Tue May 6 03:22:27 2008
@@ -43,7 +43,7 @@
public class RepositoryImpl implements Repository {
private URL url;
- private List<Feature> features = new ArrayList<Feature>();
+ private List<Feature> features;
public RepositoryImpl(URL url) {
this.url = url;
@@ -53,7 +53,10 @@
return url;
}
- public Feature[] getFeatures() {
+ public Feature[] getFeatures() throws Exception {
+ if (features == null) {
+ load();
+ }
return features.toArray(new Feature[features.size()]);
}