本文整理汇总了Java中org.osgi.util.tracker.BundleTracker类的典型用法代码示例。如果您正苦于以下问题:Java BundleTracker类的具体用法?Java BundleTracker怎么用?Java BundleTracker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BundleTracker类属于org.osgi.util.tracker包,在下文中一共展示了BundleTracker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.osgi.util.tracker.BundleTracker; //导入依赖的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: open
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public void open(final BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> bundleTracker) {
LOG.debug("ModuleInfoBundleTracker open starting with bundleTracker {}", bundleTracker);
if (bundleTracker != null) {
this.bundleTracker = bundleTracker;
starting = true;
bundleTracker.open();
starting = false;
moduleInfoRegistry.updateService();
} else {
starting = false;
}
LOG.debug("ModuleInfoBundleTracker open complete");
}
示例3: testWrap
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
@Test
public void testWrap() throws Exception {
final ServiceRegistration<?> serviceReg = mockServiceRegistration();
OsgiRegistrationUtil.wrap(serviceReg).close();
verify(serviceReg).unregister();
final BundleTracker<?> tracker = mock(BundleTracker.class);
doNothing().when(tracker).close();
OsgiRegistrationUtil.wrap(tracker).close();
verify(tracker).close();
final ServiceTracker<?, ?> sTracker = mock(ServiceTracker.class);
doNothing().when(sTracker).close();
OsgiRegistrationUtil.wrap(sTracker).close();
verify(sTracker).close();
}
示例4: start
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public void start () throws ServletException, NamespaceException
{
final BundleContext bundleContext = FrameworkUtil.getBundle ( DispatcherServletInitializer.class ).getBundleContext ();
this.context = Dispatcher.createContext ( bundleContext );
this.errorHandler = new ErrorHandlerTracker ();
Dictionary<String, String> initparams = new Hashtable<> ();
final MultipartConfigElement multipart = Servlets.createMultiPartConfiguration ( PROP_PREFIX_MP );
final DispatcherServlet servlet = new DispatcherServlet ();
servlet.setErrorHandler ( this.errorHandler );
this.webContainer.registerServlet ( servlet, "dispatcher", new String[] { "/" }, initparams, 1, false, multipart, this.context );
this.proxyFilter = new FilterTracker ( bundleContext );
this.webContainer.registerFilter ( this.proxyFilter, new String[] { "/*" }, null, null, this.context );
initparams = new Hashtable<> ();
initparams.put ( "filter-mapping-dispatcher", "request" );
this.webContainer.registerFilter ( new BundleFilter (), new String[] { "/bundle/*" }, null, initparams, this.context );
this.jspTracker = new BundleTracker<> ( bundleContext, Bundle.INSTALLED | Bundle.ACTIVE, new JspBundleCustomizer ( this.webContainer, this.context ) );
this.jspTracker.open ();
}
示例5: registerBundleLoaderExecutor
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
private void registerBundleLoaderExecutor() {
/* bundle loader extensions will be registered so that custom loaders like JSPBundle
loader can watch for other bundles and run extension service*/
new BundleTracker(osgiFramework.getBundleContext(), Bundle.STARTING, null) {
@Override
public Object addingBundle(Bundle bundle, BundleEvent event) {
// custom bundle loaders
if (bundleLoaders != null) {
for (BundleLoader loader : bundleLoaders) {
try {
loader.loadBundle(bundle);
} catch (BundleLoadingException e) {
LOGGER.error("Error while running custom bundle loader " + loader.getClass().getName() + " Error: " + e.getMessage());
}
}
}
return super.addingBundle(bundle, event);
}
}.open();
}
示例6: init
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
/**
* Initializes the instance by opening the bundle tracker. All already active bundles will get processed.
*/
@PostConstruct
public void init() {
bundleTracker = new BundleTracker(bundleContext, Bundle.STARTING, this);
bundleTracker.open();
// the default language
languages.put(DEFAULT_LOCALE.toString(), DEFAULT_LOCALE.getDisplayLanguage(DEFAULT_LOCALE));
// go through already running bundles
for (Bundle bundle : bundleContext.getBundles()) {
if (bundle.getState() == Bundle.STARTING || bundle.getState() == Bundle.ACTIVE) {
processBundle(bundle);
}
}
}
示例7: init
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public void init() {
bundleTracker = new BundleTracker<Bundle>(context, Bundle.ACTIVE, null) {
@Override
public Bundle addingBundle(Bundle bundle, BundleEvent event) {
onBundleAdded(bundle);
return bundle;
}
@Override
public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) {
onBundleRemoved(bundle);
}
};
bundleTracker.open();
}
示例8: start
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public void start () throws ServletException, NamespaceException
{
final BundleContext bundleContext = FrameworkUtil.getBundle ( DispatcherServletInitializer.class ).getBundleContext ();
this.context = Dispatcher.createContext ( bundleContext );
Dictionary<String, String> initparams = new Hashtable<> ();
final MultipartConfigElement multipart = JspServletInitializer.createMultiPartConfiguration ( PROP_PREFIX_MP );
this.webContainer.registerServlet ( new DispatcherServlet (), "dispatcher", new String[] { "/" }, initparams, 1, false, multipart, this.context );
this.proxyFilter = new FilterTracker ( bundleContext );
this.webContainer.registerFilter ( this.proxyFilter, new String[] { "/*" }, null, null, this.context );
initparams = new Hashtable<> ();
initparams.put ( "filter-mapping-dispatcher", "request" );
this.webContainer.registerFilter ( new BundleFilter (), new String[] { "/bundle/*" }, null, initparams, this.context );
this.jspTracker = new BundleTracker<> ( bundleContext, Bundle.INSTALLED | Bundle.ACTIVE, new JspBundleCustomizer ( this.webContainer, this.context ) );
this.jspTracker.open ();
}
示例9: ServiceJockeyListener
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public ServiceJockeyListener(BundleContext context, ServiceHandlerCatalog catalog) {
shc = catalog;
bt = new BundleTracker(context, Bundle.STARTING | Bundle.ACTIVE, null) {
@Override
@SuppressWarnings("unchecked")
public Object addingBundle(Bundle bundle, BundleEvent event) {
System.out.println("*** Bundle: " + bundle.getSymbolicName());
Dictionary props = bundle.getHeaders();
Object header = props.get("Service-Jockey");
if (header != null) {
try {
shc.addDefinition(bundle.getEntry("/" + header));
} catch (Exception e) {
e.printStackTrace();
}
}
return super.addingBundle(bundle, event);
}
};
bt.open();
}
示例10: testServiceJockeyListener
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public void testServiceJockeyListener() throws Exception {
ServiceHandlerCatalog shc = mock(ServiceHandlerCatalog.class);
BundleContext bc = mock(BundleContext.class);
ServiceJockeyListener sjl = new ServiceJockeyListener(bc, shc);
assertSame(shc, sjl.shc);
assertNotNull(sjl.bt);
Method m = BundleTracker.class.getDeclaredMethod("tracked");
m.setAccessible(true);
assertNotNull(m.invoke(sjl.bt));
verify(shc, never()).addDefinition((URL) Mockito.anyObject());
Bundle b = mock(Bundle.class);
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put("Service-Jockey", "entry");
when(b.getHeaders()).thenReturn(props);
when(b.getEntry("/entry")).thenReturn(new URL("http://localhost/entry"));
sjl.bt.addingBundle(b, null);
verify(shc).addDefinition(new URL("http://localhost/entry"));
sjl.close();
assertNull("Bundle trakcer should have been closed", m.invoke(sjl.bt));
}
示例11: start
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
@Override
public void start(final BundleContext context) throws Exception {
ctx = context;
persistenceDescriptorParser = new PersistenceDescriptorParserImpl();
persistenceProviderRequisiteTracker = new PersistenceProviderRequisiteTracker(context, null);
dataSourceFactoryRequisiteTracker = new DataSourceFactoryRequisitTracker(context, this);
jtaRequisiteTracker = new JTARequisiteTracker(context, this);
jtaDataSourceRequisiteTracker = new DataSourceRequisiteTracker(context, true);
nonJtaDataSourceRequisiteTracker = new DataSourceRequisiteTracker(context, false);
persistenceBundleTracker = new BundleTracker(ctx, Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING
| Bundle.ACTIVE | Bundle.STOPPING, this);
persistenceProviderRequisiteTracker.open();
dataSourceFactoryRequisiteTracker.open();
jtaRequisiteTracker.open();
jtaDataSourceRequisiteTracker.open();
nonJtaDataSourceRequisiteTracker.open();
persistenceBundleTracker.open();
}
示例12: start
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
registerWeavingHook(context, TransformerRegistrySingleton.get());
PersistenceBundleTracker customizer = new PersistenceBundleTracker(context.getBundle().adapt(BundleWiring.class));
persistenceBundleManager = new BundleTracker<Bundle>(context, Bundle.STARTING | Bundle.ACTIVE, customizer);
persistenceBundleManager.open();
}
示例13: start
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
logger.info("Starting Vertx-Extender");
bundleContext = context;
bundleContext.addBundleListener(this);
this.tracker = new BundleTracker<>(bundleContext, Bundle.ACTIVE | Bundle.STARTING, this);
if (!this.synchronous) {
this.executors = Executors.newScheduledThreadPool(3);
}
verticleObserver = new VerticleObserver();
this.tracker.open();
}
示例14: AnnotatedClassRegistry
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public AnnotatedClassRegistry(BundleContext bundleContext, String bundleHeader,
Class<? extends Annotation> annotationClass) {
this.bundleContext = bundleContext;
this.bundleHeader = bundleHeader;
this.annotationClass = annotationClass;
tracker = new BundleTracker(bundleContext, Bundle.RESOLVED | Bundle.ACTIVE, this);
}
示例15: TagLibTracker
import org.osgi.util.tracker.BundleTracker; //导入依赖的package包/类
public TagLibTracker ( final BundleContext context, String mappedPrefix )
{
this.systemTlds.add ( "org.apache.taglibs.standard-impl" );
if ( mappedPrefix == null )
{
mappedPrefix = "/WEB-INF/";
}
this.mappedPrefix = mappedPrefix;
this.bundleTracker = new BundleTracker<> ( context, Bundle.RESOLVED | Bundle.ACTIVE, this.customizer );
this.bundleTracker.open ();
}