org.apache.karaf.features.internal
Class FeaturesServiceImpl
java.lang.Object
org.apache.karaf.features.internal.FeaturesServiceImpl
- All Implemented Interfaces:
- java.util.EventListener, FeaturesService, org.osgi.framework.FrameworkListener
public class FeaturesServiceImpl
- extends java.lang.Object
- implements FeaturesService, org.osgi.framework.FrameworkListener
The Features service implementation.
Adding a repository url will load the features contained in this repository and
create dummy sub shells. When invoked, these commands will prompt the user for
installing the needed bundles.
Method Summary |
void |
addRepository(java.net.URI uri)
|
protected void |
callListeners(FeatureEvent event)
|
protected void |
callListeners(RepositoryEvent event)
|
static java.lang.String |
cleanupVersion(java.lang.String version)
Clean up version parameters. |
protected org.osgi.service.cm.Configuration |
createConfiguration(org.osgi.service.cm.ConfigurationAdmin configurationAdmin,
java.lang.String pid,
java.lang.String factoryPid)
|
protected java.lang.String |
createValue(java.util.Set<java.lang.Long> set)
|
protected void |
doInstallFeature(FeaturesServiceImpl.InstallationState state,
Feature feature,
boolean verbose)
|
protected java.util.Set<org.osgi.framework.Bundle> |
findBundlesToRefresh(FeaturesServiceImpl.InstallationState state)
|
protected java.util.Set<org.osgi.framework.Bundle> |
findBundlesWithFramentsToRefresh(FeaturesServiceImpl.InstallationState state)
|
protected java.util.Set<org.osgi.framework.Bundle> |
findBundlesWithOptionalPackagesToRefresh(FeaturesServiceImpl.InstallationState state)
|
protected org.osgi.service.cm.Configuration |
findExistingConfiguration(org.osgi.service.cm.ConfigurationAdmin configurationAdmin,
java.lang.String pid,
java.lang.String factoryPid)
|
void |
frameworkEvent(org.osgi.framework.FrameworkEvent event)
|
org.osgi.framework.BundleContext |
getBundleContext()
|
org.osgi.service.cm.ConfigurationAdmin |
getConfigAdmin()
|
Feature |
getFeature(java.lang.String name)
|
Feature |
getFeature(java.lang.String name,
java.lang.String version)
|
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,Feature>> |
getFeatures()
|
java.util.Set<Feature> |
getFeaturesContainingBundle(org.osgi.framework.Bundle bundle)
|
protected java.util.List<org.apache.felix.utils.manifest.Clause> |
getOptionalImports(java.lang.String importsStr)
|
org.osgi.service.packageadmin.PackageAdmin |
getPackageAdmin()
|
long |
getRefreshTimeout()
|
long |
getResolverTimeout()
|
org.osgi.service.startlevel.StartLevel |
getStartLevel()
|
void |
installAllFeatures(java.net.URI uri)
|
protected org.osgi.framework.Bundle |
installBundleIfNeeded(FeaturesServiceImpl.InstallationState state,
BundleInfo bundleInfo,
boolean verbose)
|
void |
installConfigurationFile(java.lang.String fileLocation,
java.lang.String finalname,
boolean verbose)
|
void |
installFeature(Feature f,
java.util.EnumSet<FeaturesService.Option> options)
|
void |
installFeature(java.lang.String name)
|
void |
installFeature(java.lang.String name,
java.lang.String version)
|
void |
installFeature(java.lang.String name,
java.lang.String version,
java.util.EnumSet<FeaturesService.Option> options)
|
void |
installFeatures(java.util.Set<Feature> features,
java.util.EnumSet<FeaturesService.Option> options)
|
protected RepositoryImpl |
internalAddRepository(java.net.URI uri)
|
void |
internalRemoveRepository(java.net.URI uri)
|
boolean |
isInstalled(Feature f)
|
Feature[] |
listFeatures()
|
Feature[] |
listInstalledFeatures()
|
Repository[] |
listRepositories()
|
protected java.util.Map<Feature,java.util.Set<java.lang.Long>> |
loadMap(java.util.Properties props,
java.lang.String prefix)
|
protected java.util.Set<java.net.URI> |
loadSet(java.util.Properties props,
java.lang.String prefix)
|
protected boolean |
loadState()
|
protected java.lang.String[] |
parsePid(java.lang.String pid)
|
protected java.util.Set<java.lang.Long> |
readValue(java.lang.String val)
|
protected void |
refreshPackages(org.osgi.framework.Bundle[] bundles)
|
void |
registerListener(FeaturesListener listener)
|
void |
removeRepository(java.net.URI uri)
|
protected java.util.List<BundleInfo> |
resolve(Feature feature)
|
void |
restoreRepository(java.net.URI uri)
|
protected void |
saveMap(java.util.Properties props,
java.lang.String prefix,
java.util.Map<Feature,java.util.Set<java.lang.Long>> map)
|
protected void |
saveSet(java.util.Properties props,
java.lang.String prefix,
java.util.Set<java.net.URI> set)
|
protected void |
saveState()
|
void |
setBoot(java.lang.String boot)
|
void |
setBundleContext(org.osgi.framework.BundleContext bundleContext)
|
void |
setConfigAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)
|
void |
setPackageAdmin(org.osgi.service.packageadmin.PackageAdmin packageAdmin)
|
void |
setRefreshTimeout(long refreshTimeout)
|
void |
setResolverTimeout(long resolverTimeout)
|
void |
setStartLevel(org.osgi.service.startlevel.StartLevel startLevel)
|
void |
setUrls(java.lang.String uris)
|
void |
start()
|
void |
stop()
|
void |
uninstallAllFeatures(java.net.URI uri)
|
void |
uninstallFeature(java.lang.String name)
|
void |
uninstallFeature(java.lang.String name,
java.lang.String version)
|
void |
unregisterListener(FeaturesListener listener)
|
void |
validateRepository(java.net.URI uri)
Validate repository. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CONFIG_KEY
public static final java.lang.String CONFIG_KEY
- See Also:
- Constant Field Values
FeaturesServiceImpl
public FeaturesServiceImpl()
getBundleContext
public org.osgi.framework.BundleContext getBundleContext()
setBundleContext
public void setBundleContext(org.osgi.framework.BundleContext bundleContext)
getConfigAdmin
public org.osgi.service.cm.ConfigurationAdmin getConfigAdmin()
setConfigAdmin
public void setConfigAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)
getPackageAdmin
public org.osgi.service.packageadmin.PackageAdmin getPackageAdmin()
setPackageAdmin
public void setPackageAdmin(org.osgi.service.packageadmin.PackageAdmin packageAdmin)
getStartLevel
public org.osgi.service.startlevel.StartLevel getStartLevel()
setStartLevel
public void setStartLevel(org.osgi.service.startlevel.StartLevel startLevel)
getResolverTimeout
public long getResolverTimeout()
setResolverTimeout
public void setResolverTimeout(long resolverTimeout)
getRefreshTimeout
public long getRefreshTimeout()
setRefreshTimeout
public void setRefreshTimeout(long refreshTimeout)
registerListener
public void registerListener(FeaturesListener listener)
unregisterListener
public void unregisterListener(FeaturesListener listener)
setUrls
public void setUrls(java.lang.String uris)
throws java.net.URISyntaxException
- Throws:
java.net.URISyntaxException
setBoot
public void setBoot(java.lang.String boot)
validateRepository
public void validateRepository(java.net.URI uri)
throws Exception
- Validate repository.
- Specified by:
validateRepository
in interface FeaturesService
- Parameters:
uri
- Repository uri.
- Throws:
Exception
- When validation fails.
addRepository
public void addRepository(java.net.URI uri)
throws Exception
- Specified by:
addRepository
in interface FeaturesService
- Throws:
Exception
internalAddRepository
protected RepositoryImpl internalAddRepository(java.net.URI uri)
throws Exception
- Throws:
Exception
removeRepository
public void removeRepository(java.net.URI uri)
- Specified by:
removeRepository
in interface FeaturesService
internalRemoveRepository
public void internalRemoveRepository(java.net.URI uri)
restoreRepository
public void restoreRepository(java.net.URI uri)
throws Exception
- Specified by:
restoreRepository
in interface FeaturesService
- Throws:
Exception
listRepositories
public Repository[] listRepositories()
- Specified by:
listRepositories
in interface FeaturesService
installAllFeatures
public void installAllFeatures(java.net.URI uri)
throws Exception
- Throws:
Exception
uninstallAllFeatures
public void uninstallAllFeatures(java.net.URI uri)
throws Exception
- Throws:
Exception
installFeature
public void installFeature(java.lang.String name)
throws Exception
- Specified by:
installFeature
in interface FeaturesService
- Throws:
Exception
installFeature
public void installFeature(java.lang.String name,
java.lang.String version)
throws Exception
- Specified by:
installFeature
in interface FeaturesService
- Throws:
Exception
installFeature
public void installFeature(java.lang.String name,
java.lang.String version,
java.util.EnumSet<FeaturesService.Option> options)
throws Exception
- Specified by:
installFeature
in interface FeaturesService
- Throws:
Exception
installFeature
public void installFeature(Feature f,
java.util.EnumSet<FeaturesService.Option> options)
throws Exception
- Specified by:
installFeature
in interface FeaturesService
- Throws:
Exception
installFeatures
public void installFeatures(java.util.Set<Feature> features,
java.util.EnumSet<FeaturesService.Option> options)
throws Exception
- Specified by:
installFeatures
in interface FeaturesService
- Throws:
Exception
doInstallFeature
protected void doInstallFeature(FeaturesServiceImpl.InstallationState state,
Feature feature,
boolean verbose)
throws Exception
- Throws:
Exception
resolve
protected java.util.List<BundleInfo> resolve(Feature feature)
throws Exception
- Throws:
Exception
findBundlesToRefresh
protected java.util.Set<org.osgi.framework.Bundle> findBundlesToRefresh(FeaturesServiceImpl.InstallationState state)
findBundlesWithFramentsToRefresh
protected java.util.Set<org.osgi.framework.Bundle> findBundlesWithFramentsToRefresh(FeaturesServiceImpl.InstallationState state)
findBundlesWithOptionalPackagesToRefresh
protected java.util.Set<org.osgi.framework.Bundle> findBundlesWithOptionalPackagesToRefresh(FeaturesServiceImpl.InstallationState state)
getOptionalImports
protected java.util.List<org.apache.felix.utils.manifest.Clause> getOptionalImports(java.lang.String importsStr)
installBundleIfNeeded
protected org.osgi.framework.Bundle installBundleIfNeeded(FeaturesServiceImpl.InstallationState state,
BundleInfo bundleInfo,
boolean verbose)
throws java.io.IOException,
org.osgi.framework.BundleException
- Throws:
java.io.IOException
org.osgi.framework.BundleException
installConfigurationFile
public void installConfigurationFile(java.lang.String fileLocation,
java.lang.String finalname,
boolean verbose)
throws java.io.IOException
- Throws:
java.io.IOException
uninstallFeature
public void uninstallFeature(java.lang.String name)
throws Exception
- Specified by:
uninstallFeature
in interface FeaturesService
- Throws:
Exception
uninstallFeature
public void uninstallFeature(java.lang.String name,
java.lang.String version)
throws Exception
- Specified by:
uninstallFeature
in interface FeaturesService
- Throws:
Exception
listFeatures
public Feature[] listFeatures()
throws Exception
- Specified by:
listFeatures
in interface FeaturesService
- Throws:
Exception
listInstalledFeatures
public Feature[] listInstalledFeatures()
- Specified by:
listInstalledFeatures
in interface FeaturesService
isInstalled
public boolean isInstalled(Feature f)
- Specified by:
isInstalled
in interface FeaturesService
getFeature
public Feature getFeature(java.lang.String name)
throws Exception
- Specified by:
getFeature
in interface FeaturesService
- Throws:
Exception
getFeature
public Feature getFeature(java.lang.String name,
java.lang.String version)
throws Exception
- Specified by:
getFeature
in interface FeaturesService
- Throws:
Exception
getFeatures
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,Feature>> getFeatures()
throws Exception
- Throws:
Exception
start
public void start()
throws Exception
- Throws:
Exception
stop
public void stop()
throws Exception
- Throws:
Exception
frameworkEvent
public void frameworkEvent(org.osgi.framework.FrameworkEvent event)
- Specified by:
frameworkEvent
in interface org.osgi.framework.FrameworkListener
refreshPackages
protected void refreshPackages(org.osgi.framework.Bundle[] bundles)
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
parsePid
protected java.lang.String[] parsePid(java.lang.String pid)
createConfiguration
protected org.osgi.service.cm.Configuration createConfiguration(org.osgi.service.cm.ConfigurationAdmin configurationAdmin,
java.lang.String pid,
java.lang.String factoryPid)
throws java.io.IOException,
org.osgi.framework.InvalidSyntaxException
- Throws:
java.io.IOException
org.osgi.framework.InvalidSyntaxException
findExistingConfiguration
protected org.osgi.service.cm.Configuration findExistingConfiguration(org.osgi.service.cm.ConfigurationAdmin configurationAdmin,
java.lang.String pid,
java.lang.String factoryPid)
throws java.io.IOException,
org.osgi.framework.InvalidSyntaxException
- Throws:
java.io.IOException
org.osgi.framework.InvalidSyntaxException
saveState
protected void saveState()
loadState
protected boolean loadState()
saveSet
protected void saveSet(java.util.Properties props,
java.lang.String prefix,
java.util.Set<java.net.URI> set)
loadSet
protected java.util.Set<java.net.URI> loadSet(java.util.Properties props,
java.lang.String prefix)
saveMap
protected void saveMap(java.util.Properties props,
java.lang.String prefix,
java.util.Map<Feature,java.util.Set<java.lang.Long>> map)
loadMap
protected java.util.Map<Feature,java.util.Set<java.lang.Long>> loadMap(java.util.Properties props,
java.lang.String prefix)
createValue
protected java.lang.String createValue(java.util.Set<java.lang.Long> set)
readValue
protected java.util.Set<java.lang.Long> readValue(java.lang.String val)
callListeners
protected void callListeners(FeatureEvent event)
callListeners
protected void callListeners(RepositoryEvent event)
cleanupVersion
public static java.lang.String cleanupVersion(java.lang.String version)
- Clean up version parameters. Other builders use more fuzzy definitions of
the version syntax. This method cleans up such a version to match an OSGi
version.
- Parameters:
version
-
- Returns:
getFeaturesContainingBundle
public java.util.Set<Feature> getFeaturesContainingBundle(org.osgi.framework.Bundle bundle)
throws Exception
- Throws:
Exception
Copyright © 2007-2011 Apache Software Foundation. All Rights Reserved.