本文整理汇总了Java中org.apache.sling.commons.osgi.PropertiesUtil.toBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesUtil.toBoolean方法的具体用法?Java PropertiesUtil.toBoolean怎么用?Java PropertiesUtil.toBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.sling.commons.osgi.PropertiesUtil
的用法示例。
在下文中一共展示了PropertiesUtil.toBoolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: disableIfNeeded
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的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));
}
}
示例3: activateComponent
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activateComponent(ComponentContext componentContext) {
artifactMappings.clear();
bundlesToBeIgnored.clear();
final Dictionary<?, ?> properties = componentContext.getProperties();
final String[] dependencyMappingList = (String[]) properties.get(PROP_DEPENDENCY_MAPPING);
for (String dependencyMapping : dependencyMappingList) {
ArtifactMapping artifactMapping = ArtifactMapping.parseMappingFromOsgiConfig(dependencyMapping);
artifactMappings.put(artifactMapping.getBundleSymbolicName(), artifactMapping);
}
final String[] listIgnoreBundle = (String[]) properties.get(PROP_IGNORE_BUNDLE);
for (String ignoreBundle : listIgnoreBundle) {
try {
bundlesToBeIgnored.add(Pattern.compile(ignoreBundle));
} catch (Exception ex) {
LOGGER.error("Cannot parse bundle to ignore because RegEx is not valid.", ex);
}
}
dependencyOutputPrefix = (String) properties.get(PROP_DEPENDENCY_OUTPUT_PREFIX);
defaultGroupId = (String) properties.get(PROP_DEFAULT_GROUP_ID);
defaultArtifactId = (String) properties.get(PROP_DEFAULT_ARTIFACT_ID);
defaultVersion = (String) properties.get(PROP_DEFAULT_VERSION);
scopeProvided = PropertiesUtil.toBoolean(properties.get(PROP_DEPENDENCY_SCOPE_PROVIDED), PROP_DEPENDENCY_SCOPE_PROVIDED_DEFAULT_VALUE);
}
示例4: getBooleanProperty
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
/**
* Get the value of an OSGi configuration boolean 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 boolean getBooleanProperty(final String pid, final String property, final boolean defaultValue) {
try {
Configuration conf = configAdmin.getConfiguration(pid);
@SuppressWarnings("unchecked")
Dictionary<String, Object> props = conf.getProperties();
if (props != null) {
return PropertiesUtil.toBoolean(props.get(property), defaultValue);
}
} catch (IOException e) {
LOGGER.error("Could not get property", e);
}
return defaultValue;
}
示例5: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
@SuppressWarnings("squid:S1149")
protected void activate(ComponentContext componentContext) {
final BundleContext bundleContext = componentContext.getBundleContext();
final Dictionary<?, ?> props = componentContext.getProperties();
final int size = PropertiesUtil.toInteger(props.get(PROP_MD5_CACHE_SIZE), DEFAULT_MD5_CACHE_SIZE);
this.md5Cache = CacheBuilder.newBuilder().recordStats().maximumSize(size).build();
this.disableVersioning = PropertiesUtil.toBoolean(props.get(PROP_DISABLE_VERSIONING), DEFAULT_DISABLE_VERSIONING);
this.enforceMd5 = PropertiesUtil.toBoolean(props.get(PROP_ENFORCE_MD5), DEFAULT_ENFORCE_MD5);
if (enforceMd5) {
Dictionary<String, Object> filterProps = new Hashtable<String, Object>();
filterProps.put("sling.filter.scope", "REQUEST");
filterProps.put("service.ranking", Integer.valueOf(0));
filterReg = bundleContext.registerService(Filter.class.getName(),
new BadMd5VersionedClientLibsFilter(), filterProps);
}
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:19,代码来源:VersionedClientlibsTransformerFactory.java
示例6: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(Map<String, Object> properties) {
this.externalizerDomain = PropertiesUtil.toString(properties.get(PROP_EXTERNALIZER_DOMAIN),
DEFAULT_EXTERNALIZER_DOMAIN);
this.includeLastModified = PropertiesUtil.toBoolean(properties.get(PROP_INCLUDE_LAST_MODIFIED),
DEFAULT_INCLUDE_LAST_MODIFIED);
this.includeInheritValue = PropertiesUtil.toBoolean(properties.get(PROP_INCLUDE_INHERITANCE_VALUE),
DEFAULT_INCLUDE_INHERITANCE_VALUE);
this.changefreqProperties = PropertiesUtil.toStringArray(properties.get(PROP_CHANGE_FREQUENCY_PROPERTIES),
new String[0]);
this.priorityProperties = PropertiesUtil.toStringArray(properties.get(PROP_PRIORITY_PROPERTIES), new String[0]);
this.damAssetProperty = PropertiesUtil.toString(properties.get(PROP_DAM_ASSETS_PROPERTY), "");
this.damAssetTypes = Arrays
.asList(PropertiesUtil.toStringArray(properties.get(PROP_DAM_ASSETS_TYPES), new String[0]));
this.excludeFromSiteMapProperty = PropertiesUtil.toString(properties.get(PROP_EXCLUDE_FROM_SITEMAP_PROPERTY),
NameConstants.PN_HIDE_IN_NAV);
this.characterEncoding = PropertiesUtil.toString(properties.get(PROP_CHARACTER_ENCODING_PROPERTY), null);
this.extensionlessUrls = PropertiesUtil.toBoolean(properties.get(PROP_EXTENSIONLESS_URLS),
DEFAULT_EXTENSIONLESS_URLS);
this.removeTrailingSlash = PropertiesUtil.toBoolean(properties.get(PROP_REMOVE_TRAILING_SLASH),
DEFAULT_REMOVE_TRAILING_SLASH);
}
示例7: configure
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
private void configure(Map<String, String> config) {
// touch vs classic
this.isTouch = PropertiesUtil.toBoolean(config.get(TOUCH_UI), DEFAULT_TOUCH_UI);
// wcm editor configurations
this.wcmEditorTouchUrl = PropertiesUtil
.toString(config.get(WCM_EDITOR_URL_TOUCH), WCM_EDITOR_URL_TOUCH_DEFAULT);
this.wcmEditorClassicUrl = PropertiesUtil.toString(config.get(WCM_EDITOR_URL_CLASSIC),
WCM_EDITOR_URL_CLASSIC_DEFAULT);
// dam editor configurations
this.damEditorTouchUrl = PropertiesUtil
.toString(config.get(DAM_EDITOR_URL_TOUCH), DAM_EDITOR_URL_TOUCH_DEFAULT);
this.damEditorClassicUrl = PropertiesUtil.toString(config.get(DAM_EDITOR_URL_CLASSIC),
DAM_EDITOR_URL_CLASSIC_DEFAULT);
}
示例8: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(final Map<String, Object> config) {
supportMultiLevel = PropertiesUtil.toBoolean(config.get(PROP_SUPPORT_MULTI_LEVEL), DEFAULT_SUPPORT_MULTI_LEVEL);
// Property Names
namespaceablePropertyNames = PropertiesUtil.toStringArray(config.get(PROP_NAMESPACEABLE_PROPERTY_NAMES),
DEFAULT_NAMESPACEABLE_PROPERTY_NAMES);
// Property Value Patterns
namespaceablePropertyValuePatterns = new ArrayList<Pattern>();
String[] regexes = PropertiesUtil.toStringArray(config.get(PROP_NAMESPACEABLE_PROPERTY_VALUE_PATTERNS),
DEFAULT_NAMESPACEABLE_PROPERTY_VALUE_PATTERNS);
for (final String regex : regexes) {
namespaceablePropertyValuePatterns.add(Pattern.compile(regex));
}
final InfoWriter iw = new InfoWriter();
iw.title("ACS AEM Commons - CQInclude Property Namespace Servlet");
iw.message("Namespace-able Property Names: {}", Arrays.asList(namespaceablePropertyNames));
iw.message("Namespace-able Property Value Patterns: {}", namespaceablePropertyValuePatterns);
iw.end();
log.info(iw.toString());
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:25,代码来源:CQIncludePropertyNamespaceServlet.java
示例9: 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);
}
示例10: 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;
}
enabled = PropertiesUtil.toBoolean(properties.get(ENABLE_SERVICE), ENABLE_SERVICE_DEFAULT);
}
示例11: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(Configuration configuration) {
dataNameWhitelist = PropertiesUtil.toStringArray(configuration.name_whitelist());
allowExpressions = PropertiesUtil.toBoolean(configuration.allow_expressions(), PROP_ALLOW_EXPRESSION_DEFAULT);
formsHandlingServletHelper = new FormsHandlingServletHelper(dataNameWhitelist, validator, FormConstants.RT_ALL_CORE_FORM_CONTAINER,
allowExpressions, formStructureHelperFactory);
}
示例12: modified
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Modified
public void modified(final Map<String, Object> properties){
name = String.valueOf(properties.get("name.property"));
gender = String.valueOf(properties.get(GENDER_PROPERTY));
this.phoneNumbers = Arrays.asList(PropertiesUtil.toStringArray(properties.get(PHONE_NUMBER_PROPERTY)));
this.isAlive = PropertiesUtil.toBoolean(properties.get(IS_ALIVE_PROPERTY), false);
log.info("Map is : {}", properties);
log.info("Phone Number is : {}" , this.phoneNumbers);
}
示例13: modified
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Modified
public void modified(final Map<String, Object> properties) {
this.name = String.valueOf(properties.get(NAME_PROPERTY));
this.gender = String.valueOf(properties.get(GENDER_PROPERTY));
this.phoneNumbers = Arrays.asList(PropertiesUtil.toStringArray(properties.get(PHONE_NUMBERS_PROPERTY)));
this.isAlive = PropertiesUtil.toBoolean(properties.get(IS_ALIVE_PROPERTY), false);
this.children = PropertiesUtil.toInteger(properties.get(HOW_MANY_CHILDREN), 0);
LOG.info("Map is : {}", this.toString());
}
示例14: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(Map<String, Object> properties) {
this.httpProxyHost = PropertiesUtil.toString(properties.get(PROP_HTTP_PROXY_HOST), null);
this.httpProxyPort = PropertiesUtil.toInteger(properties.get(PROP_HTTP_PROXY_PORT), 0);
this.useSsl = PropertiesUtil.toBoolean(properties.get(PROP_USE_SSL), DEFAULT_USE_SSL);
this.factory = new TwitterFactory(buildConfiguration());
}
示例15: activate
import org.apache.sling.commons.osgi.PropertiesUtil; //导入方法依赖的package包/类
@Activate
protected void activate(Map<String, Object> configs) {
resourceTypePatterns = ParameterUtil.toPatterns(PropertiesUtil.toStringArray(configs.get(PROP_RESOURCE_TYPES), new String[]{}));
pathPatterns = ParameterUtil.toPatterns(PropertiesUtil.toStringArray(configs.get(PROP_PATHS), new String[]{}));
checkContentResourceType = PropertiesUtil.toBoolean(configs.get(PROP_CHECK_CONTENT_RESOURCE_TYPE),false);
log.info("ResourceHttpCacheConfigExtension activated/modified.");
}
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:9,代码来源:ResourceTypeHttpCacheConfigExtension.java