当前位置: 首页>>代码示例>>Java>>正文


Java FeaturesService类代码示例

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


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


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