本文整理汇总了Java中org.osgi.service.component.ComponentContext.getBundleContext方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentContext.getBundleContext方法的具体用法?Java ComponentContext.getBundleContext怎么用?Java ComponentContext.getBundleContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.service.component.ComponentContext
的用法示例。
在下文中一共展示了ComponentContext.getBundleContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
public void start(ComponentContext context) {
BundleContext bcontext = context.getBundleContext();
ServiceReference<IExpressionService> ref = bcontext.getServiceReference(IExpressionService.class);
if (ref == null) {
System.out.println("Starting "+ServerExpressionService.class.getSimpleName());
bcontext.registerService(IExpressionService.class, new ServerExpressionService(), null);
}
}
示例2: activate
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
@Activate
protected void activate(ComponentContext ctx) throws ConfigurationException {
bc = ctx.getBundleContext();
Object value = ctx.getProperties().get(UPDATE_INTERVAL);
if(value instanceof Number){
updateInterval = ((Number)value).intValue();
} else if(value != null && !value.toString().isEmpty()){
try {
updateInterval = new BigDecimal(value.toString()).intValue();
} catch (NumberFormatException e) {
throw new ConfigurationException(UPDATE_INTERVAL,
"Unable to parse integer value from the configured value '"
+ value +"' (type: "+value.getClass()+")");
}
} else {
updateInterval = DEFAULT_UPDATE_INTERVAL;
}
if(updateInterval < 0){
log.warn("Negative update interval '{}' configured. Will use default '{}'!",
updateInterval,DEFAULT_UPDATE_INTERVAL);
updateInterval = DEFAULT_UPDATE_INTERVAL;
} else if(updateInterval == 0){
updateInterval = DEFAULT_UPDATE_INTERVAL;
}
//we need to copy over the service ranking
providerProperties = new Hashtable<String,Object>();
Object ranking = ctx.getProperties().get(Constants.SERVICE_RANKING);
if(ranking != null){
providerProperties.put(Constants.SERVICE_RANKING, ranking);
}
updateProviderState();
}
示例3: activate
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
@Activate
protected void activate(ComponentContext context) {
bundleContext = context.getBundleContext();
poller = SharedScheduledExecutors.getSingleThreadExecutor()
.scheduleAtFixedRate(this::checkStartedState, PERIOD,
PERIOD, TimeUnit.MILLISECONDS);
log.info("Started");
}
示例4: start
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
public void start(ComponentContext context) {
this.bcontext = context.getBundleContext();
}