/** * * @param key * @param requiredType * @throws IllegalStateException If the configuration property type does not match the required type */ static void checkRequiredType(ConfigurationKey key, Class<?> requiredType) { if (!key.isValidValueType(requiredType)) { throw ConfigurationLogger.LOG.configurationPropertyTypeMismatch(key.getDefaultValue().getClass(), requiredType, key.get()); } }
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Only local URLs involved") private Map<ConfigurationKey, Object> readObsoleteFileProperties(Set<URL> files, Map<String, ConfigurationKey> nameToKeyMap) { if (files.isEmpty()) { return Collections.emptyMap(); } Map<ConfigurationKey, Object> found = new EnumMap<ConfigurationKey, Object>(ConfigurationKey.class); for (URL file : files) { ConfigurationLogger.LOG.readingPropertiesFile(file); Properties fileProperties = loadProperties(file); for (String name : fileProperties.stringPropertyNames()) { ConfigurationKey key = nameToKeyMap.get(name); if (key != null) { processKeyValue(found, key, fileProperties.getProperty(name)); } else { ConfigurationLogger.LOG.unsupportedConfigurationKeyFound(name + " in " + fileProperties); } } } return found; }
private void processKeyValue(Map<ConfigurationKey, Object> properties, String stringKey, Object value, boolean integratorSource) { ConfigurationKey key = ConfigurationKey.fromString(stringKey); if (key != null) { if (key.isIntegratorOnly() && !integratorSource) { ConfigurationLogger.LOG.cannotSetIntegratorOnlyConfigurationProperty(stringKey, value); } else { processKeyValue(properties, key, value); } } else { ConfigurationLogger.LOG.unsupportedConfigurationKeyFound(stringKey); } }
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Only local URLs involved") private Set<URL> findPropertiesFiles(Deployment deployment, String fileName) { Set<ResourceLoader> resourceLoaders = new HashSet<ResourceLoader>(); Set<URL> files = new HashSet<URL>(); ResourceLoader deploymentResourceLoader = deployment.getServices().get(ResourceLoader.class); if (deploymentResourceLoader != null) { resourceLoaders.add(deploymentResourceLoader); } for (BeanDeploymentArchive archive : deployment.getBeanDeploymentArchives()) { ResourceLoader resourceLoader = archive.getServices().get(ResourceLoader.class); if (resourceLoader == null) { ConfigurationLogger.LOG.resourceLoaderNotSpecifiedForArchive(archive); continue; } resourceLoaders.add(resourceLoader); } for (ResourceLoader resourceLoader : resourceLoaders) { URL file = resourceLoader.getResource(fileName); if (file != null) { files.add(file); } } return files; }
/** * * @param services * @param deployment */ public WeldConfiguration(ServiceRegistry services, Deployment deployment) { Preconditions.checkArgumentNotNull(deployment, "deployment"); this.properties = init(services, deployment); this.proxyDumpFilePath = initProxyDumpFilePath(); this.proxyIgnoreFinalMethodsPattern = initProxyIgnoreFinalMethodsPattern(); StringJoiner logOutputBuilder = new StringJoiner(", ", "{", "}"); for (Entry<ConfigurationKey, Object> entry : properties.entrySet()) { logOutputBuilder.add(entry.getKey().get() + "=" + entry.getValue()); } ConfigurationLogger.LOG.configurationInitialized(logOutputBuilder.toString()); }
/** * Process the given key and value. First validate the value and check if there's no different value for the same key in the same source - invalid and * different values are treated as a deployment problem. * * @param properties * @param key * @param value */ private void processKeyValue(Map<ConfigurationKey, Object> properties, ConfigurationKey key, Object value) { if (value instanceof String) { value = key.convertValue((String) value); } if (key.isValidValue(value)) { Object previous = properties.put(key, value); if (previous != null && !previous.equals(value)) { throw ConfigurationLogger.LOG.configurationKeyHasDifferentValues(key.get(), previous, value); } } else { throw ConfigurationLogger.LOG.invalidConfigurationPropertyValue(value, key.get()); } }
/** * Merge two maps of configuration properties. If the original contains a mapping for the same key, the new mapping is ignored. * * @param original * @param toMerge */ static void merge(Map<ConfigurationKey, Object> original, Map<ConfigurationKey, Object> toMerge, String mergedSourceDescription) { for (Entry<ConfigurationKey, Object> entry : toMerge.entrySet()) { Object existing = original.get(entry.getKey()); if (existing != null) { ConfigurationLogger.LOG.configurationKeyAlreadySet(entry.getKey().get(), existing, entry.getValue(), mergedSourceDescription); } else { original.put(entry.getKey(), entry.getValue()); } } }
/** * Process the given string key and value. First try to convert the <code>stringKey</code> - unsupported keys are ignored. Then delegate to * {@link #processKeyValue(Map, ConfigurationKey, Object)}. * * @param properties * @param stringKey * @param value */ private void processKeyValue(Map<ConfigurationKey, Object> properties, String stringKey, Object value) { ConfigurationKey key = ConfigurationKey.fromString(stringKey); if (key != null) { processKeyValue(properties, key, value); } else { ConfigurationLogger.LOG.unsupportedConfigurationKeyFound(stringKey); } }
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Only local URLs involved") private Set<URL> findPropertiesFiles(Deployment deployment, String fileName) { Set<ResourceLoader> resourceLoaders = new HashSet<ResourceLoader>(); Set<URL> files = new HashSet<URL>(); ResourceLoader deploymentResourceLoader = deployment.getServices().get(ResourceLoader.class); if (deploymentResourceLoader != null) { resourceLoaders.add(deploymentResourceLoader); } for (BeanDeploymentArchive archive : deployment.getBeanDeploymentArchives()) { ResourceLoader resourceLoader = archive.getServices().get(ResourceLoader.class); if (resourceLoader == null) { ConfigurationLogger.LOG.resourceLoaderNotSpecifiedForArchive(archive); continue; } resourceLoaders.add(resourceLoader); } for (ResourceLoader resourceLoader : resourceLoaders) { URL file = resourceLoader.getResource(fileName); if (file != null) { files.add(file); } } return files; }
/** * * @param services * @param deployment */ public WeldConfiguration(ServiceRegistry services, Deployment deployment) { Preconditions.checkArgumentNotNull(deployment, "deployment"); this.properties = init(services, deployment); this.proxyDumpFilePath = initProxyDumpFilePath(); this.proxyIgnoreFinalMethodsPattern = initProxyIgnoreFinalMethodsPattern(); StringJoiner logOutputBuilder = new StringJoiner(", ", "{", "}"); for (Entry<ConfigurationKey, Object> entry : properties.entrySet()) { logOutputBuilder.add(entry.getKey().get() + "=" + entry.getValue()); } ConfigurationLogger.LOG.configurationInitialized(logOutputBuilder.toString()); }
/** * Process the given key and value. First validate the value and check if there's no different value for the same key in the same source - invalid and * different values are treated as a deployment problem. * * @param properties * @param key * @param value */ private void processKeyValue(Map<ConfigurationKey, Object> properties, ConfigurationKey key, Object value) { if (value instanceof String) { value = key.convertValue((String) value); } if (key.isValidValue(value)) { Object previous = properties.put(key, value); if (previous != null && !previous.equals(value)) { throw ConfigurationLogger.LOG.configurationKeyHasDifferentValues(key.get(), previous, value); } } else { throw ConfigurationLogger.LOG.invalidConfigurationPropertyValue(value, key.get()); } }
/** * Merge two maps of configuration properties. If the original contains a mapping for the same key, the new mapping is ignored. * * @param original * @param toMerge */ static void merge(Map<ConfigurationKey, Object> original, Map<ConfigurationKey, Object> toMerge, String mergedSourceDescription) { for (Entry<ConfigurationKey, Object> entry : toMerge.entrySet()) { Object existing = original.get(entry.getKey()); if (existing != null) { ConfigurationLogger.LOG.configurationKeyAlreadySet(entry.getKey().get(), existing, entry.getValue(), mergedSourceDescription); } else { original.put(entry.getKey(), entry.getValue()); } } }
/** * Read the set of property files. Keys and Values are automatically validated and converted. * * @param resourceLoader * @return all the properties from the weld.properties file */ @SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Only local URLs involved") private Map<ConfigurationKey, Object> readFileProperties(Set<URL> files) { Map<ConfigurationKey, Object> found = new EnumMap<ConfigurationKey, Object>(ConfigurationKey.class); for (URL file : files) { ConfigurationLogger.LOG.readingPropertiesFile(file); Properties fileProperties = loadProperties(file); for (String name : fileProperties.stringPropertyNames()) { processKeyValue(found, name, fileProperties.getProperty(name)); } } return found; }
@SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Only local URLs involved") private Set<URL> findPropertiesFiles(Deployment deployment, String fileName) { Set<ResourceLoader> resourceLoaders = new HashSet<ResourceLoader>(); Set<URL> files = new HashSet<URL>(); ResourceLoader deploymentResourceLoader = deployment.getServices().get(ResourceLoader.class); if (deploymentResourceLoader != null) { resourceLoaders.add(deploymentResourceLoader); } for (BeanDeploymentArchive archive : deployment.getBeanDeploymentArchives()) { ResourceLoader resourceLoader = archive.getServices().get(ResourceLoader.class); if (resourceLoader == null) { ConfigurationLogger.LOG.resourceLoaderNotSpecifiedForArchive(archive); continue; } resourceLoaders.add(resourceLoader); } for (ResourceLoader resourceLoader : resourceLoaders) { URL file = resourceLoader.getResource(fileName); if (file != null) { files.add(file); } } return files; }
/** * * @param services * @param deployment */ public WeldConfiguration(ServiceRegistry services, Deployment deployment) { Preconditions.checkArgumentNotNull(deployment, "deployment"); this.properties = init(services, deployment); this.proxyDumpFilePath = initProxyDumpFilePath(); this.proxyIgnoreFinalMethodsPattern = initProxyIgnoreFinalMethodsPattern(); StringJoiner logOutputBuilder = new StringJoiner(", ", "{", "}"); for (Entry<ConfigurationKey, Object> entry : properties.entrySet()) { logOutputBuilder.add(entry.getKey().get() + "=" + entry.getValue()); } ConfigurationLogger.LOG.configurationInitialized(logOutputBuilder.toString()); }
/** * Process the given key and value. First validate the value and check if there's no different value for the same key in the same source - invalid and * different values are treated as a deployment problem. * * @param properties * @param key * @param value */ private void processKeyValue(Map<ConfigurationKey, Object> properties, ConfigurationKey key, Object value) { if (value instanceof String) { value = key.convertValue((String) value); } if (key.isValidValue(value)) { Object previous = properties.put(key, value); if (previous != null && !previous.equals(value)) { throw ConfigurationLogger.LOG.configurationKeyHasDifferentValues(key.get(), previous, value); } } else { throw ConfigurationLogger.LOG.invalidConfigurationPropertyValue(value, key.get()); } }
/** * * @param key * @param requiredType * @throws IllegalStateException If the configuration property type does not match the required type */ static void checkRequiredType(ConfigurationKey key, Class<?> requiredType) { if (!key.isValidValueType(requiredType)) { throw ConfigurationLogger.LOG.configurationPropertyTypeMismatch(key.getDefaultValue().getClass(), requiredType, key.get()); } }
private void processKeyValue(Map<ConfigurationKey, Object> properties, String stringKey, Object value, boolean integratorSource) { ConfigurationKey key = ConfigurationKey.fromString(stringKey); if (key != null) { if (key.isIntegratorOnly() && !integratorSource) { ConfigurationLogger.LOG.cannotSetIntegratorOnlyConfigurationProperty(stringKey, value); } else { processKeyValue(properties, key, value); } } else { ConfigurationLogger.LOG.unsupportedConfigurationKeyFound(stringKey); } }
/** * Merge two maps of configuration properties. If the original contains a mapping for the same key, the new mapping is ignored. * * @param original * @param toMerge */ static void merge(Map<ConfigurationKey, Object> original, Map<ConfigurationKey, Object> toMerge, String mergedSourceDescription) { for (Entry<ConfigurationKey, Object> entry : toMerge.entrySet()) { Object existing = original.get(entry.getKey()); if (existing != null) { ConfigurationLogger.LOG.configurationKeyAlreadySet(entry.getKey().get(), existing, entry.getValue(), mergedSourceDescription); } else { original.put(entry.getKey(), entry.getValue()); } } }
/** * Read the set of property files. Keys and Values are automatically validated and converted. * * @param resourceLoader * @return all the properties from the weld.properties file */ @SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Only local URLs involved") private Map<ConfigurationKey, Object> readFileProperties(Set<URL> files) { Map<ConfigurationKey, Object> found = new EnumMap<ConfigurationKey, Object>(ConfigurationKey.class); for (URL file : files) { ConfigurationLogger.LOG.readingPropertiesFile(file); Properties fileProperties = loadProperties(file); for (String name : fileProperties.stringPropertyNames()) { processKeyValue(found, name, fileProperties.getProperty(name)); } } return found; }