当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesUtil类代码示例

本文整理汇总了Java中org.apache.sling.commons.osgi.PropertiesUtil的典型用法代码示例。如果您正苦于以下问题:Java PropertiesUtil类的具体用法?Java PropertiesUtil怎么用?Java PropertiesUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PropertiesUtil类属于org.apache.sling.commons.osgi包,在下文中一共展示了PropertiesUtil类的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);
}
 
开发者ID:nateyolles,项目名称:aem-osgi-annotation-demo,代码行数:17,代码来源:SampleFelixServiceImpl.java

示例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));
    }
}
 
开发者ID:DantaFramework,项目名称:Core,代码行数:24,代码来源:OSGiUtils.java

示例3: bindExtensionService

import org.apache.sling.commons.osgi.PropertiesUtil; //导入依赖的package包/类
@Reference(
        policy = ReferencePolicy.DYNAMIC,
        service = RuntimeExtension.class,
        cardinality = ReferenceCardinality.MULTIPLE
)
@SuppressWarnings("unused")
protected synchronized void bindExtensionService(RuntimeExtension extension, Map<String, Object> properties) {
    Integer newPriority = PropertiesUtil.toInteger(properties.get(Constants.SERVICE_RANKING), 0);
    String extensionName = PropertiesUtil.toString(properties.get(RuntimeExtension.NAME), "");
    Integer priority = PropertiesUtil.toInteger(mappingPriorities.get(extensionName), 0);
    if (newPriority > priority) {
        mapping = Collections.unmodifiableMap(add(mapping, extension, extensionName));
        mappingPriorities.put(extensionName, newPriority);
    } else {
        if (!mapping.containsKey(extensionName)) {
            mapping = Collections.unmodifiableMap(add(mapping, extension, extensionName));
            mappingPriorities.put(extensionName, newPriority);
        }
    }

}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:22,代码来源:ExtensionRegistryService.java

示例4: 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);
}
 
开发者ID:sbrinkmann,项目名称:aem-maven-repository,代码行数:26,代码来源:POMGeneratorImpl.java

示例5: 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);
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:18,代码来源:SuiteExecutor.java

示例6: 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();
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:17,代码来源:ExternalSnippetHttpClient.java

示例7: 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);
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:26,代码来源:Runner.java

示例8: initialize

import org.apache.sling.commons.osgi.PropertiesUtil; //导入依赖的package包/类
@Activate
public void initialize(final ComponentContext context) {
  this.subServiceName = PropertiesUtil.toString(context.getProperties().get(PROPERTY_SUBSERVICENAME), "");
  scriptResources = PropertiesUtil.toStringArray(context.getProperties().get(PROPERTY_SCRIPTS_PATHS), new String[0]);
  int poolTotalSize = PropertiesUtil.toInteger(context.getProperties().get(PROPERTY_POOL_TOTAL_SIZE), 20);
  JavacriptEnginePoolFactory javacriptEnginePoolFactory = new JavacriptEnginePoolFactory(createLoader(scriptResources), null);
  ObjectPool<JavascriptEngine> pool = createPool(poolTotalSize, javacriptEnginePoolFactory);
  this.engine = new ReactScriptEngine(this, pool, isReloadScripts(context), finder, dynamicClassLoaderManager);
  this.listener = new JcrResourceChangeListener(repositoryConnectionFactory, new JcrResourceChangeListener.Listener() {
    @Override
    public void changed(String script) {
      createScripts();
    }
  }, subServiceName);
  this.listener.activate(scriptResources);
  this.createScripts();
}
 
开发者ID:sinnerschrader,项目名称:aem-react,代码行数:18,代码来源:ReactScriptEngineFactory.java

示例9: getStringProperty

import org.apache.sling.commons.osgi.PropertiesUtil; //导入依赖的package包/类
/**
 * Get the value of an OSGi configuration string 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 String getStringProperty(final String pid, final String property, final String defaultValue) {
    try {
        Configuration conf = configAdmin.getConfiguration(pid);

        @SuppressWarnings("unchecked")
        Dictionary<String, Object> props = conf.getProperties();

        if (props != null) {
            return PropertiesUtil.toString(props.get(property), defaultValue);
        }
    } catch (IOException e) {
        LOGGER.error("Could not get property", e);
    }

    return defaultValue;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:25,代码来源:OsgiConfigurationServiceImpl.java

示例10: 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;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:25,代码来源:OsgiConfigurationServiceImpl.java

示例11: 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;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:30,代码来源:OsgiConfigurationServiceImpl.java

示例12: activate

import org.apache.sling.commons.osgi.PropertiesUtil; //导入依赖的package包/类
@SuppressWarnings("unused")
@Activate
private void activate(final ComponentContext componentContext) {
    
	BundleContext bundleContext = componentContext.getBundleContext();
	
	final Dictionary<?,?> properties = componentContext.getProperties();
	
	// default.group
	this.defaultGroup = PropertiesUtil.toString(properties.get(DEFAULT_GROUP), this.ADMIN_GROUP);
	
	// payload.mappings
	String[] mappings = PropertiesUtil.toStringArray(properties.get(PAYLOAD_MAPPINGS));
	for (String mapping : mappings) {
		this.getPayloadMappings().add(mapping.trim().split(":"));
	}

}
 
开发者ID:VillanovaUniversity,项目名称:villanova-cqtools-workflow,代码行数:19,代码来源:PathBasedParticipantChooser.java

示例13: activate

import org.apache.sling.commons.osgi.PropertiesUtil; //导入依赖的package包/类
@Activate
protected void activate (ComponentContext ctx)  {
	packageRoot = PropertiesUtil.toString(ctx.getProperties().get(PROPERTY_PACKAGE_ROOT), DEFAULT_PACKAGE_ROOT);

	final File directory = new File (packageRoot);

	if (directory.exists() && directory.isDirectory()) {
		LOG.info("Looking for packages in {}",directory.getAbsolutePath());
		try {
			//installPackages (directory);
		} catch (Exception e) {
			LOG.error("Got exception during service activation",e);
		}
	} else {
		LOG.warn ("Package root directory {} does not exist or is not a directory", directory.getAbsolutePath());
	}


}
 
开发者ID:joerghoh,项目名称:cqdeploy,代码行数:20,代码来源:PackageInstallerImpl.java

示例14: activate

import org.apache.sling.commons.osgi.PropertiesUtil; //导入依赖的package包/类
@Activate
@Modified
protected void activate(Map<String, Object> configs) {

    // User groups after removing empty strings.
    userGroups = new ArrayList(Arrays.asList(PropertiesUtil.toStringArray(configs.get(PROP_USER_GROUPS), new
            String[]{})));
    ListIterator<String> listIterator = userGroups.listIterator();
    while (listIterator.hasNext()) {
        String value = listIterator.next();
        if (StringUtils.isBlank(value)) {
            listIterator.remove();
        }
    }

    log.info("GroupHttpCacheConfigExtension activated/modified.");
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:18,代码来源:GroupHttpCacheConfigExtension.java

示例15: activate

import org.apache.sling.commons.osgi.PropertiesUtil; //导入依赖的package包/类
@Activate
protected void activate(final Map<String, String> config) throws LoginException {
    log.trace("Activating the ACS AEM Commons - JCR Package Replication Status Updater (Event Handler)");

    this.replicatedByOverride = PropertiesUtil.toString(config.get(PROP_REPLICATED_BY_OVERRIDE),
                                    PropertiesUtil.toString(config.get(LEGACY_PROP_REPLICATED_BY_OVERRIDE),
                                            DEFAULT_REPLICATED_BY_OVERRIDE));

    String tmp = PropertiesUtil.toString(config.get(PROP_REPLICATED_AT), "");
    try {
        this.replicatedAt = ReplicatedAt.valueOf(tmp);
    } catch (IllegalArgumentException ex) {
        this.replicatedAt = ReplicatedAt.PACKAGE_LAST_MODIFIED;
    }

    this.replicationStatusNodeTypes = PropertiesUtil.toStringArray(config.get(PROP_REPLICATION_STATUS_NODE_TYPES),
            DEFAULT_REPLICATION_STATUS_NODE_TYPES);

    log.info("Package Replication Status - Replicated By Override User: [ {} ]", this.replicatedByOverride);
    log.info("Package Replication Status - Replicated At: [ {} ]", this.replicatedAt.toString());
    log.info("Package Replication Status - Node Types: [ {} ]",
            StringUtils.join(this.replicationStatusNodeTypes, ", "));
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:24,代码来源:JcrPackageReplicationStatusEventHandler.java


注:本文中的org.apache.sling.commons.osgi.PropertiesUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。