本文整理汇总了Java中org.apache.sling.commons.osgi.PropertiesUtil.toLong方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesUtil.toLong方法的具体用法?Java PropertiesUtil.toLong怎么用?Java PropertiesUtil.toLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.sling.commons.osgi.PropertiesUtil
的用法示例。
在下文中一共展示了PropertiesUtil.toLong方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
@Modified
protected final void activate(final Map<String, Object> config) {
Map<String, Object> properties = Collections.emptyMap();
if (config != null) {
properties = config;
}
booleanProp = PropertiesUtil.toBoolean(properties.get(BOOLEAN_PROPERTY_NAME), BOOLEAN_PROPERTY_DEFAULT_VALUE);
stringProp = PropertiesUtil.toString(properties.get(STRING_PROPERTY_NAME), STRING_PROPERTY_DEFAULT_VALUE);
dropdownProp = PropertiesUtil.toString(properties.get(DROPDOWN_PROPERTY_NAME), DROPDOWN_PROPERTY_DEFAULT_VALUE);
stringArrayProp = PropertiesUtil.toStringArray(properties.get(STRING_ARRAY_PROPERTY_NAME));
passwordProp = PropertiesUtil.toString(properties.get(PASSWORD_PROPERTY_NAME), "").toCharArray();
longProp = PropertiesUtil.toLong(properties.get(LONG_PROPERTY_NAME), LONG_PROPERTY_DEFAULT_VALUE);
}
示例2: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
public void activate(Map<String, Object> properties) {
messageReceiveTimeout = PropertiesUtil.toLong(
properties.get(MESSAGE_RECEIVE_TIMEOUT_PROPERTY_NAME), DEFAULT_MESSAGE_RECEIVE_TIMEOUT);
suiteRunnerCache = CacheBuilder.newBuilder()
.expireAfterAccess(CACHE_EXPIRATION_TIMEOUT, TimeUnit.MILLISECONDS)
.removalListener(new RunnerCacheRemovalListener())
.build();
suiteStatusCache = CacheBuilder.newBuilder()
.expireAfterAccess(CACHE_EXPIRATION_TIMEOUT, TimeUnit.MILLISECONDS)
.build();
cacheUpdater = new CacheUpdater(suiteRunnerCache, suiteStatusCache, lockService);
suiteStatusHandler = new SuiteStatusHandler(suiteStatusCache);
}
示例3: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(Map<String, Object> properties) {
LOGGER.info("Activating ExternalSnippetHttpClient - {}", this);
Long connectionTtl = PropertiesUtil
.toLong(properties.get(CONNECTION_TTL_PARAMETER), DEFAULT_CONNECTION_TTL);
Integer maxConcurrentConnections = PropertiesUtil
.toInteger(properties.get(MAX_CONCURRENT_CONNECTIONS_PARAMETER),
DEFAULT_MAX_CONCURRENT_CONNECTIONS);
final PoolingHttpClientConnectionManager poolingConnManager =
new PoolingHttpClientConnectionManager(connectionTtl, TimeUnit.SECONDS);
poolingConnManager.setMaxTotal(maxConcurrentConnections);
httpClient = HttpClients.custom().setConnectionManager(poolingConnManager).build();
}
示例4: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
public void activate(Map properties) {
ft = PropertiesUtil.toLong(properties.get(PARAM_FAILURE_TIMEOUT),
DEFAULT_TASK_RUN_FAILURE_TIMEOUT_SECONDS);
mttl = PropertiesUtil
.toLong(properties.get(PARAM_MESSAGE_TTL), DEFAULT_MESSAGE_TIME_TO_LIVE_SECONDS) * 1000;
urlPackageSize = PropertiesUtil.toInteger(properties.get(PARAM_URL_PACKAGE_SIZE),
DEFAULT_URL_PACKAGE_SIZE);
maxMessagesInCollectorQueue = PropertiesUtil.toInteger(
properties.get(PARAM_MAX_MESSAGES_IN_COLLECTOR_QUEUE),
DEFAULT_MAX_MESSAGES_IN_COLLECTOR_QUEUE);
runnerMode = RunnerMode.valueOf(PropertiesUtil.toString(properties.get(RUNNER_MODE), "online")
.toUpperCase());
LOG.info(
"Running with parameters: [ft: {} sec ; mttl: {} ; urlPackageSize: {} ; maxMessagesInCollectorQueue: {}; runnerMode: {}.]",
ft, mttl, urlPackageSize, maxMessagesInCollectorQueue, runnerMode);
Injector injector = Guice
.createInjector(
new SimpleRunnerModule(ft, mttl, urlPackageSize, maxMessagesInCollectorQueue,
jmsConnection, messagesManager, runnerMode, metadataDAO));
messageListener = injector.getInstance(RunnerMessageListener.class);
}
示例5: getLongProperty
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
/**
* Get the value of an OSGi configuration long property for a given PID.
*
* @param pid The PID of the OSGi component to retrieve
* @param property The property of the config to retrieve
* @param value The value to assign the provided property
* @return The property value
*/
public Long getLongProperty(final String pid, final String property, final Long defaultValue) {
long placeholder = -1L;
long defaultTemp = defaultValue != null ? defaultValue : placeholder;
try {
Configuration conf = configAdmin.getConfiguration(pid);
@SuppressWarnings("unchecked")
Dictionary<String, Object> props = conf.getProperties();
if (props != null) {
long result = PropertiesUtil.toLong(props.get(property), defaultTemp);
return result == placeholder ? null : result;
}
} catch (IOException e) {
LOGGER.error("Could not get property", e);
}
return defaultValue;
}
示例6: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(final Map<String, Object> props) throws ServiceException {
logger.debug("activate(): props = {}", props);
this.filterRoots = PropertiesUtil.toStringArray(props.get(PROP_FILTER_ROOTS), null);
if (this.filterRoots == null) {
throw new ServiceException(PROP_FILTER_ROOTS + " is mandatory!");
}
final String localDirValue = StringUtils.trim(PropertiesUtil.toString(props.get(PROP_LOCAL_PATH), null));
if (localDirValue == null) {
throw new ServiceException(PROP_LOCAL_PATH + " is mandatory!");
}
this.localDir = new File(localDirValue);
this.overwriteConfigFiles = PropertiesUtil.toBoolean(props.get(PROP_OVERWRITE_CONFIG_FILES),
DEFAULT_OVERWRITE_CONFIG_FILES);
this.syncOnceType = PropertiesUtil.toString(props.get(PROP_SYNC_ONCE_TYPE), SYNC_ONCE_DISABLED);
generateFiles();
Long expectedSyncOnceTime = null;
if (this.willSyncOnce) {
expectedSyncOnceTime = PropertiesUtil.toLong(props.get(PROP_SYNC_ONCE_EXPECTED_TIME),
DEFAULT_SYNC_ONCE_EXPECTED_TIME);
}
this.serviceSettings.addSyncRoot(this.localDir, expectedSyncOnceTime);
}
示例7: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(Map<String, Object> configs) {
// Read config and populate values.
ttl = PropertiesUtil.toLong(configs.get(PROP_TTL), DEFAULT_TTL);
maxSizeInMb = PropertiesUtil.toLong(configs.get(PROP_MAX_SIZE_IN_MB), DEFAULT_MAX_SIZE_IN_MB);
// Initializing the cache.
// If cache is present, invalidate all and reinitailize the cache.
// Recording cache usage stats enabled.
if (null != cache) {
cache.invalidateAll();
log.info("Mem cache already present. Invalidating the cache and re-initializing it.");
}
if (ttl != DEFAULT_TTL) {
// If ttl is present, attach it to guava cache configuration.
cache = CacheBuilder.newBuilder()
.maximumWeight(maxSizeInMb * MEGABYTE)
.weigher(new MemCacheEntryWeigher())
.expireAfterWrite(ttl, TimeUnit.SECONDS)
.removalListener(new MemCacheEntryRemovalListener())
.recordStats()
.build();
} else {
// If ttl is absent, go only with the maximum weight condition.
cache = CacheBuilder.newBuilder()
.maximumWeight(maxSizeInMb * MEGABYTE)
.weigher(new MemCacheEntryWeigher())
.removalListener(new MemCacheEntryRemovalListener())
.recordStats()
.build();
}
log.info("MemHttpCacheStoreImpl activated / modified.");
}
示例8: doActivate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Override
protected void doActivate(ComponentContext context) throws Exception {
Dictionary<?, ?> properties = context.getProperties();
maxage = PropertiesUtil.toLong(properties.get(PROP_MAX_AGE), -1);
if (maxage < 0) {
throw new ConfigurationException(PROP_MAX_AGE, "Max Age must be specified and greater than 0.");
}
}
示例9: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected final void activate(final Map<String, String> config) {
statuses = arrayToList(PropertiesUtil.toStringArray(config.get(PROP_WORKFLOW_STATUSES), DEFAULT_WORKFLOW_STATUSES));
models = arrayToList(PropertiesUtil.toStringArray(config.get(PROP_WORKFLOW_MODELS), DEFAULT_WORKFLOW_MODELS));
final String[] payloadsArray =
PropertiesUtil.toStringArray(config.get(PROP_WORKFLOW_PAYLOADS), DEFAULT_WORKFLOW_PAYLOADS);
for (final String payload : payloadsArray) {
if (StringUtils.isNotBlank(payload)) {
final Pattern p = Pattern.compile(payload);
if (p != null) {
payloads.add(p);
}
}
}
final Long olderThanTs = PropertiesUtil.toLong(config.get(PROP_WORKFLOWS_OLDER_THAN), 0);
if (olderThanTs > 0) {
olderThan = Calendar.getInstance();
olderThan.setTimeInMillis(olderThanTs);
}
batchSize = PropertiesUtil.toInteger(config.get(PROP_BATCH_SIZE), DEFAULT_BATCH_SIZE);
if (batchSize < 1) {
batchSize = DEFAULT_BATCH_SIZE;
}
maxDuration = PropertiesUtil.toInteger(config.get(PROP_MAX_DURATION), DEFAULT_MAX_DURATION);
final InfoWriter iw = new InfoWriter();
iw.title("Workflow Instance Removal Configuration");
iw.message("Workflow status: {}", statuses);
iw.message("Workflow models: {}", models);
iw.message("Payloads: {}", Arrays.asList(payloadsArray));
iw.message("Older than: {}", olderThan);
iw.message("Batch size: {}", batchSize);
iw.message("Max Duration (minutes): {}", maxDuration);
iw.end();
log.info(iw.toString());
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:46,代码来源:WorkflowInstanceRemoverScheduler.java