本文整理汇总了Java中org.osgi.service.component.ComponentContext类的典型用法代码示例。如果您正苦于以下问题:Java ComponentContext类的具体用法?Java ComponentContext怎么用?Java ComponentContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ComponentContext类属于org.osgi.service.component包,在下文中一共展示了ComponentContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
/**
* Component activator
*
* @param componentContext The component context
* @throws Exception
*/
@Activate
protected void activate(ComponentContext componentContext)
throws Exception {
session = repository.loginService(CONFIG_SERVICE, null);
observationManager = session.getWorkspace().getObservationManager();
// set up observation listener
observationManager.addEventListener(
this,
Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_CHANGED | Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED,
APPS_ROOT,
true /* isDeep */,
null /* uuid */,
null /* nodeTypeName */,
true /* noLocal */
);
OSGiUtils.activate(this, componentContext);
}
示例2: modified
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Modified
public void modified(ComponentContext context) {
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
int newMessageHandlerThreadPoolSize;
try {
String s = get(properties, "messageHandlerThreadPoolSize");
newMessageHandlerThreadPoolSize =
isNullOrEmpty(s) ? messageHandlerThreadPoolSize : Integer.parseInt(s.trim());
} catch (NumberFormatException e) {
log.warn(e.getMessage());
newMessageHandlerThreadPoolSize = messageHandlerThreadPoolSize;
}
// Any change in the following parameters implies thread pool restart
if (newMessageHandlerThreadPoolSize != messageHandlerThreadPoolSize) {
setMessageHandlerThreadPoolSize(newMessageHandlerThreadPoolSize);
restartMessageHandlerThreadPool();
}
log.info(FORMAT, messageHandlerThreadPoolSize);
}
示例3: disableIfNeeded
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
/**
* Disable component if property "enabled" is set to false
*
* @param ctx component context
*/
private static void disableIfNeeded(Object obj, ComponentContext ctx) {
OptionalComponent oc = obj.getClass().getAnnotation(OptionalComponent.class);
if (oc == null) {
return;
}
boolean enabled = PropertiesUtil.toBoolean(ctx.getProperties().get(oc.propertyName()), true);
if (!enabled) {
String pid = (String) ctx.getProperties().get(Constants.SERVICE_PID);
LOG.info("disabling component {}", pid);
// at this point this is the only way to reliably disable a component
// it's going to show up as "unsatisfied" in Felix console.
throw new ComponentException(format("Component %s is intentionally disabled", pid));
}
}
示例4: modified
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Modified
public void modified(ComponentContext context) {
if (context == null) {
netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS;
log.info("No component configuration");
return;
}
Dictionary<?, ?> properties = context.getProperties();
int newNetconfReplyTimeout;
try {
String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT);
newNetconfReplyTimeout = isNullOrEmpty(s) ?
netconfReplyTimeout : Integer.parseInt(s.trim());
} catch (NumberFormatException e) {
log.warn("Component configuration had invalid value", e);
return;
}
netconfReplyTimeout = newNetconfReplyTimeout;
log.info("Settings: {} = {}", PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout);
}
示例5: readComponentConfiguration
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
/**
* Extracts properties from the component configuration context.
*
* @param context the component context
*/
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
Integer newPendingFutureTimeoutMinutes =
Tools.getIntegerProperty(properties, "pendingFutureTimeoutMinutes");
if (newPendingFutureTimeoutMinutes == null) {
pendingFutureTimeoutMinutes = DEFAULT_PENDING_FUTURE_TIMEOUT_MINUTES;
log.info("Pending future timeout is not configured, " +
"using current value of {}", pendingFutureTimeoutMinutes);
} else {
pendingFutureTimeoutMinutes = newPendingFutureTimeoutMinutes;
log.info("Configured. Pending future timeout is configured to {}",
pendingFutureTimeoutMinutes);
}
}
示例6: activate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Activate
protected void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
providerService = providerRegistry.register(this);
controller.addListener(listener);
controller.addEventListener(listener);
modified(context);
pendingBatches = createBatchCache();
createCollectors();
log.info("Started with flowPollFrequency = {}, adaptiveFlowSampling = {}",
flowPollFrequency, adaptiveFlowSampling);
}
示例7: deactivate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Deactivate
public void deactivate(ComponentContext context) {
try {
controller.getDevices().stream().forEach(device -> {
deviceBuilderExecutor.execute(new DeviceFactory(device, false));
});
deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
log.error("Device builder did not terminate");
}
deviceBuilderExecutor.shutdownNow();
netCfgService.unregisterConfigFactory(factory);
netCfgService.removeListener(cfgLister);
providerRegistry.unregister(this);
providerService = null;
log.info("Stopped");
}
示例8: activate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Activate
protected void activate(ComponentContext context) throws IOException {
modified(context);
log.debug("Server starting on {}", listenPort);
try {
server = NettyServerBuilder.forPort(listenPort)
.addService(DeviceProviderRegistryRpcGrpc.bindService(new DeviceProviderRegistryServerProxy()))
.addService(LinkProviderServiceRpcGrpc.bindService(new LinkProviderServiceServerProxy(this)))
.build().start();
} catch (IOException e) {
log.error("Failed to start gRPC server", e);
throw e;
}
log.info("Started on {}", listenPort);
}
示例9: activate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Activate
public void activate(ComponentContext context) {
alarmsExecutor = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
eventHandlingExecutor =
Executors.newFixedThreadPool(CORE_POOL_SIZE,
groupedThreads("onos/pollingalarmprovider",
"device-installer-%d", log));
providerService = providerRegistry.register(this);
deviceService.addListener(deviceListener);
mastershipService.addListener(mastershipListener);
if (context == null) {
alarmPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
log.info("No component configuration");
} else {
Dictionary<?, ?> properties = context.getProperties();
alarmPollFrequencySeconds = getNewPollFrequency(properties, alarmPollFrequencySeconds);
}
scheduledTask = schedulePolling();
log.info("Started");
}
示例10: readComponentConfiguration
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
/**
* Extracts properties from the component configuration context.
*
* @param context the component context
*/
private void readComponentConfiguration(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
String newXosServerAddress =
Tools.get(properties, XOS_SERVER_ADDRESS_PROPERTY_NAME);
if (!isNullOrEmpty(newXosServerAddress)) {
xosServerAddress = newXosServerAddress;
}
String newXosServerPortString =
Tools.get(properties, XOS_SERVER_PORT_PROPERTY_NAME);
if (!isNullOrEmpty(newXosServerPortString)) {
xosServerPort = Integer.parseInt(newXosServerPortString);
}
String newXosProviderServiceString =
Tools.get(properties, XOS_PROVIDER_SERVICE_PROPERTY_NAME);
if (!isNullOrEmpty(newXosProviderServiceString)) {
xosProviderService = Integer.parseInt(newXosProviderServiceString);
}
}
示例11: modified
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Modified
protected void modified(ComponentContext context) {
log.info("Received configuration change...");
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
String newIp = get(properties, "aliasIp");
String newMask = get(properties, "aliasMask");
String newAdapter = get(properties, "aliasAdapter");
// Process any changes in the parameters...
if (!Objects.equals(newIp, aliasIp) ||
!Objects.equals(newMask, aliasMask) ||
!Objects.equals(newAdapter, aliasAdapter)) {
synchronized (this) {
log.info("Reconfiguring with aliasIp={}, aliasMask={}, aliasAdapter={}, wasLeader={}",
newIp, newMask, newAdapter, wasLeader);
if (wasLeader) {
removeIpAlias(aliasIp, aliasMask, aliasAdapter);
addIpAlias(newIp, newMask, newAdapter);
}
aliasIp = newIp;
aliasMask = newMask;
aliasAdapter = newAdapter;
}
}
}
示例12: activate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Activate
protected void activate(ComponentContext context) {
componentConfigService.registerProperties(getClass());
modified(context);
coreAppId = coreService.registerApplication(CoreService.CORE_APP_NAME);
routerAppId = coreService.registerApplication(RoutingService.ROUTER_APP_ID);
networkConfigRegistry.registerConfigFactory(mcastConfigFactory);
networkConfigService.addListener(configListener);
deviceService.addListener(deviceListener);
interfaceService.addListener(internalInterfaceList);
updateConfig();
log.info("Started");
}
示例13: modified
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Modified
public void modified(ComponentContext context) {
int newRate = DEFAULT_RATE;
if (context != null) {
Dictionary properties = context.getProperties();
try {
String s = get(properties, "rate");
newRate = isNullOrEmpty(s)
? rate : Integer.parseInt(s.trim());
} catch (Exception e) {
return;
}
}
if (newRate != rate) {
log.info("Per node rate changed to {}", newRate);
rate = newRate;
stopTest();
runner.execute(this::startTest);
}
}
示例14: activate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Activate
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
appId = coreService.registerApplication("org.onosproject.athena.fwd");
packetService.addProcessor(processor, PacketProcessor.director(3));
topologyService.addListener(topologyListener);
readComponentConfiguration(context);
requestIntercepts();
log.info("Started", appId.id());
// // for evaluation 1 -- Jinwoo Kim
// packetIn = 0;
// ThreadTest t = new ThreadTest();
// t.start();
}
示例15: activate
import org.osgi.service.component.ComponentContext; //导入依赖的package包/类
@Activate
protected void activate(final ComponentContext context) {
String maxDimensionsValue = getProperty(MAX_DIMENSIONS_PN, context);
String[] maxDimensionsArray = maxDimensionsValue.split("x");
if (maxDimensionsArray.length == 2) {
maxHeight = NumberUtils.toInt(maxDimensionsArray[0], maxHeight);
maxWidth = NumberUtils.toInt(maxDimensionsArray[1], maxWidth);
}
}