本文整理汇总了Java中org.apache.karaf.features.FeaturesService.getFeature方法的典型用法代码示例。如果您正苦于以下问题:Java FeaturesService.getFeature方法的具体用法?Java FeaturesService.getFeature怎么用?Java FeaturesService.getFeature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.karaf.features.FeaturesService
的用法示例。
在下文中一共展示了FeaturesService.getFeature方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installNexusEdition
import org.apache.karaf.features.FeaturesService; //导入方法依赖的package包/类
private static void installNexusEdition(final BundleContext ctx, @Nullable final String editionName)
throws Exception
{
if (editionName != null && editionName.length() > 0) {
final ServiceTracker<?, FeaturesService> tracker = new ServiceTracker<>(ctx, FeaturesService.class, null);
tracker.open();
try {
FeaturesService featuresService = tracker.waitForService(1000);
Feature editionFeature = featuresService.getFeature(editionName);
log.info("Installing: {}", editionFeature);
// edition might already be installed in the cache; if so then skip installation
if (!featuresService.isInstalled(editionFeature)) {
// avoid auto-refreshing bundles as that could trigger unwanted restart/lifecycle events
EnumSet<Option> options = EnumSet.of(NoAutoRefreshBundles, NoAutoRefreshManagedBundles);
featuresService.installFeature(editionFeature.getId(), options);
}
log.info("Installed: {}", editionFeature);
}
finally {
tracker.close();
}
}
}
示例2: getFeaturesReport
import org.apache.karaf.features.FeaturesService; //导入方法依赖的package包/类
private String getFeaturesReport( FeaturesService featuresService, List<String> uninstalledFeatures )
throws Exception {
ServiceReference<BundleService> serviceReferenceBundleService =
bundleContext.getServiceReference( BundleService.class );
BundleService bundleService = bundleContext.getService( serviceReferenceBundleService );
List<BundleStateService> bundleStateServices = getBundleStateServices();
String featuresReport = System.lineSeparator() + "--------- Karaf Feature Watcher Report Begin ---------";
for ( String uninstalledFeature : uninstalledFeatures ) {
Feature feature = featuresService.getFeature( uninstalledFeature );
featuresReport +=
System.lineSeparator() + getFeatureReport( featuresService, bundleService, bundleStateServices, feature );
}
return featuresReport + System.lineSeparator() + "--------- Karaf Feature Watcher Report End ---------";
}
示例3: waitForFeatures
import org.apache.karaf.features.FeaturesService; //导入方法依赖的package包/类
private void waitForFeatures( List<String> requiredFeatures, FeaturesService featuresService ) throws Exception {
long entryTime = System.currentTimeMillis();
// Loop through to see if features are all installed
while ( true ) {
List<String> uninstalledFeatures = new ArrayList<String>();
for ( String requiredFeature : requiredFeatures ) {
requiredFeature = requiredFeature.trim();
Feature feature = featuresService.getFeature( requiredFeature );
if ( feature != null && featuresService.isInstalled( feature ) == false ) {
uninstalledFeatures.add( requiredFeature );
}
}
if ( uninstalledFeatures.size() > 0 ) {
if ( System.currentTimeMillis() - timeout > entryTime ) {
IServiceBarrier serviceBarrier =
IServiceBarrierManager.LOCATOR.getManager().getServiceBarrier( "KarafFeatureWatcherBarrier" );
if ( serviceBarrier == null || serviceBarrier.isAvailable() ) {
logger.debug( getFeaturesReport( featuresService, uninstalledFeatures ) );
throw new FeatureWatcherException( "Timed out waiting for Karaf features to install: " + StringUtils
.join( uninstalledFeatures, "," ) );
} else {
entryTime = System.currentTimeMillis();
}
}
logger.debug( "KarafFeatureWatcher is waiting for the following features to install: " + StringUtils.join(
uninstalledFeatures, "," ) );
Thread.sleep( 100 );
continue;
}
break;
}
}
示例4: ChildAwareFeatureWrapper
import org.apache.karaf.features.FeaturesService; //导入方法依赖的package包/类
ChildAwareFeatureWrapper(final Feature feature, final FeaturesService featuresService) throws Exception {
super(featuresService.getFeature(feature.getName(), feature.getVersion()));
Preconditions.checkNotNull(featuresService, "FeatureWrapper requires non-null FeatureService in constructor");
this.featuresService = featuresService;
}