• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FeaturesService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.karaf.features.FeaturesService的典型用法代码示例。如果您正苦于以下问题:Java FeaturesService类的具体用法?Java FeaturesService怎么用?Java FeaturesService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FeaturesService类属于org.apache.karaf.features包,在下文中一共展示了FeaturesService类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addingService

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
@Override
@SuppressWarnings("IllegalCatch")
public FeaturesService addingService(final ServiceReference<FeaturesService> reference) {
    BundleContext bc = reference.getBundle().getBundleContext();
    final FeaturesService featureService = bc.getService(reference);
    final Optional<XmlFileStorageAdapter> currentPersister = XmlFileStorageAdapter.getInstance();

    if (XmlFileStorageAdapter.getInstance().isPresent()) {
        final Set<String> installedFeatureIds = Sets.newHashSet();
        try {
            for (final Feature installedFeature : featureService.listInstalledFeatures()) {
                installedFeatureIds.add(installedFeature.getId());
            }
        } catch (final Exception e) {
            LOG.error("Error listing installed features", e);
        }

        currentPersister.get().setFeaturesService(() -> installedFeatureIds);
    }
    ConfigFeaturesListener configFeaturesListener = new ConfigFeaturesListener(configPusher, featureService);
    registration = bc.registerService(FeaturesListener.class.getCanonicalName(), configFeaturesListener, null);
    return featureService;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:24,代码来源:FeatureServiceCustomizer.java


示例2: uninstallNewFeatures

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
/**
 * The feature service does not uninstall feature dependencies when uninstalling a single feature.
 * So we need to make sure we uninstall all features that were newly installed.
 *
 * @param featuresBefore
 * @throws Exception
 */
protected void uninstallNewFeatures(Set<Feature> featuresBefore)
        throws Exception {
    Feature[] features = featureService.listInstalledFeatures();
    for (Feature curFeature : features) {
        if (!featuresBefore.contains(curFeature)) {
            try {
                System.out.println("Uninstalling " + curFeature.getName());
                featureService.uninstallFeature(curFeature.getName(), curFeature.getVersion(),
                        EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:Jahia,项目名称:jahia-loganalyzer,代码行数:23,代码来源:BaseTest.java


示例3: 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();
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:27,代码来源:BootstrapListener.java


示例4: 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 ---------";
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:17,代码来源:KarafFeatureWatcherImpl.java


示例5: createMockFeature

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
private Dependency createMockFeature( String name, String version, boolean installed, List<Dependency> dependencies,
    List<BundleInfo> bundles, FeaturesService featuresService ) throws Exception {
  Feature feature = mock( Feature.class );
  when( feature.getName() ).thenReturn( name );

  when( featuresService.getFeature( name ) ).thenReturn( feature );
  if ( version != null ) {
    when( feature.hasVersion() ).thenReturn( true );
    when( feature.getVersion() ).thenReturn( version );
    when( featuresService.getFeature( name, version ) ).thenReturn( feature );

  } else {
    when( feature.hasVersion() ).thenReturn( false );
  }

  when( feature.getDependencies() ).thenReturn( dependencies );
  when( feature.getBundles() ).thenReturn( bundles );

  when( featuresService.isInstalled( feature ) ).thenReturn( installed );

  Dependency dependency = mock( Dependency.class );
  when( dependency.getName() ).thenReturn( name );
  when( dependency.getVersion() ).thenReturn( version );
  return dependency;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:26,代码来源:KarafFeatureWatcherImplTest.java


示例6: addingService

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
@Override
public ConfigPusher addingService(final ServiceReference<ConfigPusher> configPusherServiceReference) {
    LOG.trace("Got ConfigPusherCustomizer.addingService {}", configPusherServiceReference);
    BundleContext bc = configPusherServiceReference.getBundle().getBundleContext();
    ConfigPusher cpService = bc.getService(configPusherServiceReference);
    featureServiceCustomizer = new FeatureServiceCustomizer(cpService);
    fsst = new ServiceTracker<>(bc, FeaturesService.class.getName(), featureServiceCustomizer);
    fsst.open();
    return cpService;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:11,代码来源:ConfigPusherCustomizer.java


示例7: installCamelFeature

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
protected void installCamelFeature(String mainFeature) throws Exception {
    if (!mainFeature.startsWith("camel-")) {
        mainFeature = "camel-" + mainFeature;
    }
    LOG.info("Install main feature: {}", mainFeature);
    // do not refresh bundles causing out bundle context to be invalid
    // TODO: see if we can find a way maybe to install camel.xml as bundle/feature instead of part of unit test (see src/test/resources/OSGI-INF/blueprint)
    featuresService.installFeature(mainFeature, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:AbstractFeatureTest.java


示例8: 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;
    }
  }
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:36,代码来源:KarafFeatureWatcherImpl.java


示例9: ConfigFeaturesListener

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
public ConfigFeaturesListener(final ConfigPusher configPusher, final FeaturesService featuresService) {
    pushingThread = new Thread(new ConfigPushingRunnable(configPusher, featuresService, queue),
            "ConfigFeatureListener - ConfigPusher");
    pushingThread.start();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:ConfigFeaturesListener.java


示例10: 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;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:ChildAwareFeatureWrapper.java


示例11: getFeaturesService

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
protected FeaturesService getFeaturesService() {
    return featuresService;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:4,代码来源:ChildAwareFeatureWrapper.java


示例12: modifiedService

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
@Override
public void modifiedService(final ServiceReference<FeaturesService> reference, final FeaturesService service) {
    // we don't care if the properties change
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:FeatureServiceCustomizer.java


示例13: removedService

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
@Override
public void removedService(final ServiceReference<FeaturesService> reference, final FeaturesService service) {
    close();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:FeatureServiceCustomizer.java


示例14: ConfigPushingRunnable

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
public ConfigPushingRunnable(final ConfigPusher configPusher, final FeaturesService featuresService,
                             final BlockingQueue<FeatureEvent> featureEvents) {
    queue = featureEvents;
    this.configPusher = new FeatureConfigPusher(configPusher, featuresService);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:ConfigPushingRunnable.java


示例15: FeatureConfigPusher

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
public FeatureConfigPusher(final ConfigPusher configPusher, final FeaturesService featuresService) {
    pusher = configPusher;
    this.featuresService = featuresService;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:FeatureConfigPusher.java


示例16: installAndAssertFeature

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
protected void installAndAssertFeature(String feature) throws Exception {
    featureService.installFeature(feature, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles));
    assertFeatureInstalled(feature);
}
 
开发者ID:Jahia,项目名称:jahia-loganalyzer,代码行数:5,代码来源:BaseTest.java


示例17: Features

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
public Features(FeaturesService featuresService, boolean uninstall, String ... names) throws Exception {
    this.featuresService = featuresService;
    this.uninstall = uninstall;
    featureSet = new HashSet<>(Arrays.asList(names));
    featuresService.installFeatures(featureSet, EnumSet.noneOf(FeaturesService.Option.class));
}
 
开发者ID:apache,项目名称:servicemix,代码行数:7,代码来源:Features.java


示例18: close

import org.apache.karaf.features.FeaturesService; //导入依赖的package包/类
@Override
public void close() throws Exception {
    if (this.uninstall) {
        featuresService.uninstallFeatures(featureSet, EnumSet.noneOf(FeaturesService.Option.class));
    }
}
 
开发者ID:apache,项目名称:servicemix,代码行数:7,代码来源:Features.java



注:本文中的org.apache.karaf.features.FeaturesService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JcePEMDecryptorProviderBuilder类代码示例发布时间:2022-05-21
下一篇:
Java RegistryException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap