Activator.java 文件源码

java
阅读 42 收藏 0 点赞 0 评论 0

项目:Ptoceti 作者:
/**
    * Called by the framework for initialisation when the Activator class is
    * loaded. The method first get a service reference on the osgi logging
    * service, used for logging whithin the bundle.
    * 
    * If the method cannot get a reference to the logging service, a
    * NullPointerException is thrown.
    * 
    * @param context
    * @throws BundleException
    */
   public void start(BundleContext context) throws BundleException {

Activator.bc = context;

// we construct a listener to detect if the log service appear or
// disapear.
String logFilter = "(objectclass=" + logServiceName + ")";
ServiceListener logServiceListener = new LogServiceListener();
try {
    bc.addServiceListener(logServiceListener, logFilter);
    // in case the service is already registered, we send a REGISTERED
    // event to its listener.
    ServiceReference srLog = bc.getServiceReference(logServiceName);
    if (srLog != null) {
    logServiceListener.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, srLog));
    }
} catch (InvalidSyntaxException e) {
    throw new BundleException("Error in filter string while registering LogServiceListener." + e.toString());
}

log(LogService.LOG_INFO, "Starting version " + bc.getBundle().getHeaders().get("Bundle-Version"));

influxDbFactory.start();
   }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号