本文整理汇总了Java中org.osgi.util.tracker.BundleTrackerCustomizer类的典型用法代码示例。如果您正苦于以下问题:Java BundleTrackerCustomizer类的具体用法?Java BundleTrackerCustomizer怎么用?Java BundleTrackerCustomizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BundleTrackerCustomizer类属于org.osgi.util.tracker包,在下文中一共展示了BundleTrackerCustomizer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
@Activate
void activate(BundleContext ctx) {
this.base = new File("").toURI();
// Find the resolved vaadin bundle
this.vaadinResourceBundles = new BundleTracker<Bundle>(ctx, Bundle.RESOLVED |
Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING,
new BundleTrackerCustomizer<Bundle>() {
@Override
public Bundle addingBundle(Bundle bundle, BundleEvent event) {
return VAADIN_SERVER_BUNDLE.equals(bundle.getSymbolicName()) ?
bundle : null;
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, Bundle object) {
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) {
}
});
this.vaadinResourceBundles.open();
}
示例2: ExtensibleBundleTracker
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
public ExtensibleBundleTracker(final BundleContext context, final int bundleState,
final BundleTrackerCustomizer<T> primaryBundleTrackerCustomizer,
final BundleTrackerCustomizer<?>... additionalBundleTrackerCustomizers) {
super(context, bundleState, null);
this.primaryTracker = primaryBundleTrackerCustomizer;
this.additionalTrackers = additionalBundleTrackerCustomizers;
eventExecutor = Executors.newSingleThreadExecutor(THREAD_FACTORY);
LOG.trace("Registered as extender with context {} and bundle state {}", context, bundleState);
}
示例3: OsgiMessageInterpolator
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
public OsgiMessageInterpolator ( final BundleContext context )
{
this.tracker = new BundleTracker<> ( context, Bundle.ACTIVE | Bundle.RESOLVED, new BundleTrackerCustomizer<Resolver> () {
@Override
public Resolver addingBundle ( final Bundle bundle, final BundleEvent event )
{
if ( bundle.getResource ( "META-INF/ValidationMessages.properties" ) != null )
{
return new Resolver ( bundle );
}
return null;
}
@Override
public void modifiedBundle ( final Bundle bundle, final BundleEvent event, final Resolver resolver )
{
}
@Override
public void removedBundle ( final Bundle bundle, final BundleEvent event, final Resolver resolver )
{
resolver.dispose ();
}
} );
this.tracker.open ();
}
示例4: start
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
@Override
public void start(BundleContext context) {
Collection<BundleTrackerCustomizer<Object>> handlers =
Arrays.asList(new CdiBundleChangeListener(context.getBundle()),
new ResourceHandlingBundleListener());
trackers = handlers.stream().map((c) ->
new BundleTracker<>(context, Bundle.ACTIVE, c)).collect(Collectors.toList());
new Thread(() -> trackers.forEach((t) -> t.open())).start();
}
示例5: forEachAdditionalBundle
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
private void forEachAdditionalBundle(final BundleStrategy lambda) {
for (BundleTrackerCustomizer<?> trac : additionalTrackers) {
lambda.execute(trac);
}
}
示例6: MyBundleTracker
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
public MyBundleTracker(BundleContext context, int stateMask,
BundleTrackerCustomizer customizer) {
super(context, stateMask, customizer);
}
示例7: activate
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
@Activate
public void activate(final BundleContext context) {
bt = new BundleTracker<ServiceRegistration<PersistenceProvider>>(context, Bundle.ACTIVE + Bundle.STARTING,
new BundleTrackerCustomizer<ServiceRegistration<PersistenceProvider>>() {
@Override
public ServiceRegistration<PersistenceProvider> addingBundle(Bundle bundle, BundleEvent event) {
String name = bundle.getSymbolicName();
if (name == null || !name.equals("org.datanucleus.api.jpa"))
return null;
Version version = bundle.getVersion();
if (version == null || baseVersion.compareTo(version) > 0)
return null;
URL url = bundle.getResource("META-INF/services/" + PersistenceProvider.class.getName());
if (url == null)
return null;
ServiceLoader<PersistenceProvider> sl = ServiceLoader.load(PersistenceProvider.class, bundle
.adapt(BundleWiring.class).getClassLoader());
for (PersistenceProvider pp : sl) {
return bundle.getBundleContext().registerService(PersistenceProvider.class,
new DatanucleusWrapper(pp), null);
}
return null;
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event,
ServiceRegistration<PersistenceProvider> object) {
// TODO Auto-generated method stub
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event,
ServiceRegistration<PersistenceProvider> reg) {
reg.unregister();
}
});
bt.open();
}
示例8: execute
import org.osgi.util.tracker.BundleTrackerCustomizer; //导入依赖的package包/类
void execute(BundleTrackerCustomizer<?> tracker);