@Override public String getContextValue(final String contextKey) { return _configuredObject.getContextValue(String.class, contextKey); }
private static Long getExplicitJECacheSize(ConfiguredObject<?> configuredObject) { try { Long jeMaxMemory = configuredObject.getContextValue(Long.class, EnvironmentConfig.MAX_MEMORY); if (jeMaxMemory != null && jeMaxMemory > 0) { return jeMaxMemory; } } catch (IllegalArgumentException e) { // pass } try { Integer jeMaxMemoryPercent = configuredObject.getContextValue(Integer.class, EnvironmentConfig.MAX_MEMORY_PERCENT); if (jeMaxMemoryPercent != null && jeMaxMemoryPercent > 0) { return (Runtime.getRuntime().maxMemory() * (long) jeMaxMemoryPercent) / 100; } } catch (IllegalArgumentException e) { // pass } return null; } }
private static Map<String, String> getContextSettingsWithNameMatchingRegExpPattern(ConfiguredObject<?> object, Pattern pattern) { Map<String, String> targetMap = new HashMap<>(); for (String name : object.getContextKeys(false)) { if (pattern.matcher(name).matches()) { String contextValue = object.getContextValue(String.class, name); targetMap.put(name, contextValue); } } return targetMap; }
public static CacheMode getCacheMode(final ConfiguredObject<?> object) { if (object.getContextKeys(false).contains(EnvironmentFacade.CACHE_MODE_PROPERTY_NAME)) { try { return object.getContextValue(CacheMode.class, EnvironmentFacade.CACHE_MODE_PROPERTY_NAME); } catch (IllegalArgumentException iae) { LOGGER.warn("Failed to parse {} as {}", object.getContextValue(String.class, EnvironmentFacade.CACHE_MODE_PROPERTY_NAME), CacheMode.class, iae); } } return EnvironmentFacade.CACHE_MODE_DEFAULT; }
public static <T> T getContextValue(final ConfiguredObject<?> parent, final Class<T> paremeterClass, final String parameterName, final T defaultValue) { if (parent.getContextKeys(false).contains(parameterName)) { return parent.getContextValue(paremeterClass, parameterName); } else { return defaultValue; } }
public static <T> T getContextValue(final ConfiguredObject<?> parent, final Class<T> paremeterClass, final Type type, final String parameterName, final T defaultValue) { if (parent.getContextKeys(false).contains(parameterName)) { return parent.getContextValue(paremeterClass, type, parameterName); } else { return defaultValue; } } }
@Override public PreferenceStore createInstance(final ConfiguredObject<?> parent, final Map<String, Object> preferenceStoreAttributes) { final Object path = preferenceStoreAttributes.get(PATH); if (path == null || !(path instanceof String)) { throw new IllegalConfigurationException("JsonFilePreferenceStore requires path"); } final String posixFilePermissions = parent.getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS); return new JsonFilePreferenceStore((String) path, posixFilePermissions); }
private void reportStatisticsForObject(final ConfiguredObject<?> object) { final String statisticsReportPatternContextKey = String.format("qpid.%s.statisticsReportPattern", object.getCategoryClass().getSimpleName().toLowerCase()); if (object.getContextKeys(false).contains(statisticsReportPatternContextKey)) { String reportPattern = object.getContextValue(String.class, statisticsReportPatternContextKey); String formattedStatistics = Strings.expand(reportPattern, false, new FormattingStatisticsResolver(object)); String loggerName = String.format("qpid.statistics.%s", object.getCategoryClass().getSimpleName()); Logger logger = LoggerFactory.getLogger(loggerName); logger.info("Statistics: {}", formattedStatistics); } } }
for (String contextKey : actualContext.keySet()) effectiveContext.put(contextKey, configuredObject.getContextValue(String.class, contextKey));
if(object.getContextKeys(false).contains(ENCRYPTER_KEY_FILE)) fileLocation = object.getContextValue(String.class, ENCRYPTER_KEY_FILE); fileLocation = object.getContextValue(String.class, SystemConfig.QPID_WORK_DIR) + File.separator + DEFAULT_KEYS_SUBDIR_NAME + File.separator + object.getCategoryClass().getSimpleName() + "_"
String contextValue = contextValueSet ? object.getContextValue(String.class, paramName) : null; contextValueSet = (contextValue != null);
@Override public void init(ConfiguredObject<?> parent) { assertState(State.CLOSED); _parent = parent; _classNameMapping = generateClassNameMap(_parent.getModel(), _rootClass); FileBasedSettings fileBasedSettings = (FileBasedSettings) _parent; setup(parent.getName(), fileBasedSettings.getStorePath(), parent.getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS), Collections.emptyMap()); changeState(State.CLOSED, State.CONFIGURED); }
for (String attr : providerAttributeNames) providerAttributes.put(attr, parent.getContextValue(String.class, attr));