本文整理汇总了Java中org.osgi.service.component.ComponentContext.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentContext.getProperties方法的具体用法?Java ComponentContext.getProperties怎么用?Java ComponentContext.getProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.service.component.ComponentContext
的用法示例。
在下文中一共展示了ComponentContext.getProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
@Activate
public void activate(ComponentContext context) {
Dictionary<String, Object> config = context.getProperties();
this.topic = (String)config.get("topic");
if (topic == null) {
throw new IllegalArgumentException("Config property topic must be present.");
}
String eventTopics = (String)config.get(EventConstants.EVENT_TOPIC);
Publisher<Event> fromEventAdmin = eventAdmin.from(eventTopics, Event.class);
toKafka = kafka.to(topic, ProducerRecord.class);
org.slf4j.MDC.put("inLogAppender", "true");
Flux.from(fromEventAdmin)
.doOnEach(event -> org.slf4j.MDC.put("inLogAppender", "true"))
//.log()
.map(event->toRecord(event))
.doOnError(ex -> LOGGER.error(ex.getMessage(), ex))
.subscribe(toKafka);
LOGGER.info("Kafka appender started. Listening on topic " + topic);
}
示例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: modified
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
@Modified
public void modified(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
int newTunnelStatsPollFrequency;
try {
String s = get(properties, "tunnelStatsPollFrequency");
newTunnelStatsPollFrequency = isNullOrEmpty(s) ? tunnelStatsPollFrequency : Integer.parseInt(s.trim());
} catch (NumberFormatException | ClassCastException e) {
newTunnelStatsPollFrequency = tunnelStatsPollFrequency;
}
if (newTunnelStatsPollFrequency != tunnelStatsPollFrequency) {
tunnelStatsPollFrequency = newTunnelStatsPollFrequency;
collectors.values().forEach(tsc -> tsc.adjustPollInterval(tunnelStatsPollFrequency));
log.info("New setting: tunnelStatsPollFrequency={}", tunnelStatsPollFrequency);
}
}
示例4: 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");
}
示例5: 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);
}
}
示例6: modified
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
@Modified
protected void modified(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
String newLinkWeightFunction = get(properties, "linkWeightFunction");
if (newLinkWeightFunction != null &&
!Objects.equals(newLinkWeightFunction, linkWeightFunction)) {
linkWeightFunction = newLinkWeightFunction;
LinkWeight weight = linkWeightFunction.equals(LINK_METRIC) ?
new MetricLinkWeight() :
linkWeightFunction.equals(GEO_DISTANCE) ?
new GeoDistanceLinkWeight(deviceService) : null;
setDefaultLinkWeight(weight);
}
log.info(FORMAT, linkWeightFunction);
}
示例7: 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);
}
}
示例8: 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;
}
}
}
示例9: 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);
}
}
示例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();
Integer newHeartbeatInterval = Tools.getIntegerProperty(properties,
"heartbeatInterval");
if (newHeartbeatInterval == null) {
setHeartbeatInterval(DEFAULT_HEARTBEAT_INTERVAL);
log.info("Heartbeat interval time is not configured, default value is {}",
DEFAULT_HEARTBEAT_INTERVAL);
} else {
setHeartbeatInterval(newHeartbeatInterval);
log.info("Configured. Heartbeat interval time is configured to {}",
heartbeatInterval);
}
Integer newPhiFailureThreshold = Tools.getIntegerProperty(properties,
"phiFailureThreshold");
if (newPhiFailureThreshold == null) {
setPhiFailureThreshold(DEFAULT_PHI_FAILURE_THRESHOLD);
log.info("Phi failure threshold is not configured, default value is {}",
DEFAULT_PHI_FAILURE_THRESHOLD);
} else {
setPhiFailureThreshold(newPhiFailureThreshold);
log.info("Configured. Phi failure threshold is configured to {}",
phiFailureThreshold);
}
}
示例11: modified
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
@Modified
public void modified(ComponentContext context) {
Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties();
try {
String s = get(properties, "garbageCollect");
garbageCollect = isNullOrEmpty(s) ? GARBAGE_COLLECT : Boolean.parseBoolean(s.trim());
s = get(properties, "gcThresh");
gcThresh = isNullOrEmpty(s) ? GC_THRESH : Integer.parseInt(s.trim());
} catch (Exception e) {
gcThresh = GC_THRESH;
garbageCollect = GARBAGE_COLLECT;
}
}
示例12: 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 addressStr = Tools.get(properties, "address");
address = addressStr != null ? addressStr : DEFAULT_ADDRESS;
log.info("Configured. InfluxDB server address is {}", address);
String databaseStr = Tools.get(properties, "database");
database = databaseStr != null ? databaseStr : DEFAULT_DATABASE;
log.info("Configured. InfluxDB server database is {}", database);
String usernameStr = Tools.get(properties, "username");
username = usernameStr != null ? usernameStr : DEFAULT_USERNAME;
log.info("Configured. InfluxDB server username is {}", username);
String passwordStr = Tools.get(properties, "password");
password = passwordStr != null ? passwordStr : DEFAULT_PASSWORD;
log.info("Configured. InfluxDB server password is {}", password);
Integer portConfigured = Tools.getIntegerProperty(properties, "port");
if (portConfigured == null) {
port = DEFAULT_PORT;
log.info("InfluxDB port is not configured, default value is {}", port);
} else {
port = portConfigured;
log.info("Configured. InfluxDB port is configured to {}", port);
}
}
示例13: 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();
Boolean flag;
flag = Tools.isPropertyEnabled(properties, "allowExtraneousRules");
if (flag == null) {
log.info("AllowExtraneousRules is not configured, " +
"using current value of {}", allowExtraneousRules);
} else {
allowExtraneousRules = flag;
log.info("Configured. AllowExtraneousRules is {}",
allowExtraneousRules ? "enabled" : "disabled");
}
flag = Tools.isPropertyEnabled(properties, "purgeOnDisconnection");
if (flag == null) {
log.info("PurgeOnDisconnection is not configured, " +
"using current value of {}", purgeOnDisconnection);
} else {
purgeOnDisconnection = flag;
log.info("Configured. PurgeOnDisconnection is {}",
purgeOnDisconnection ? "enabled" : "disabled");
}
String s = get(properties, "fallbackFlowPollFrequency");
try {
fallbackFlowPollFrequency = isNullOrEmpty(s) ? DEFAULT_POLL_FREQUENCY : Integer.parseInt(s);
} catch (NumberFormatException e) {
fallbackFlowPollFrequency = DEFAULT_POLL_FREQUENCY;
}
}
示例14: modified
import org.osgi.service.component.ComponentContext; //导入方法依赖的package包/类
@Modified
protected void modified(ComponentContext context) {
Dictionary<?, ?> properties = context.getProperties();
if (properties == null) {
return;
}
String strClearRoutes = Tools.get(properties, "clearRoutes");
clearRoutes = Boolean.parseBoolean(strClearRoutes);
log.info("clearRoutes set to {}", clearRoutes);
}
示例15: 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();
try {
String strPort = (String) properties.get("bgpPort");
if (strPort != null) {
bgpPort = Integer.parseInt(strPort);
} else {
bgpPort = DEFAULT_BGP_PORT;
}
} catch (NumberFormatException | ClassCastException e) {
bgpPort = DEFAULT_BGP_PORT;
}
log.debug("BGP port is set to {}", bgpPort);
}