/** * Creates a new {@link PropertyMap} object that is associated with the given name and has the given properties as * its initial set of child properties. All properties found in <code>startingProperties</code> will have their * {@link Property#setParentMap(PropertyMap) parent map} set to this newly constructed map. * * @param name the name of the map itself * @param startingProperties a set of properties to be immediately added to this map */ public PropertyMap(@NotNull String name, Property... startingProperties) { this(name); for (Property property : startingProperties) { put(property); } }
private void addAttributeToPropertyMap(String attributeName, PropertyMap propertyMap, Map<String, String> queryCacheAttributes) { propertyMap.put(new PropertySimple(attributeName, queryCacheAttributes.get(attributeName))); } }
public PropertyMap deepCopy(boolean keepId) { PropertyMap copy = new PropertyMap(this, keepId); for (Property property : map.values()) { copy.put(property.deepCopy(keepId)); } return copy; }
private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) { PropertyList logEventSources = pluginConfiguration .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP); if (logEventSources == null) return; File serverLogFile = new File(fileName); if (serverLogFile.exists() && !serverLogFile.isDirectory()) { PropertyMap serverLogEventSource = new PropertyMap("logEventSource"); serverLogEventSource.put(new PropertySimple( LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile)); serverLogEventSource.put(new PropertySimple( LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE)); logEventSources.add(serverLogEventSource); } }
private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) { PropertyList logEventSources = pluginConfiguration .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP); if (logEventSources == null) return; File serverLogFile = new File(fileName); if (!serverLogFile.isDirectory()) { PropertyMap serverLogEventSource = new PropertyMap("logEventSource"); serverLogEventSource.put(new PropertySimple( LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile)); serverLogEventSource.put(new PropertySimple( LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE)); logEventSources.add(serverLogEventSource); } }
@Override protected void fillPropertyMap(PropertyMap map) { super.fillPropertyMap(map); map.put(new PropertySimple(BUNDLE_DEST_DEFINITION_CONNECTION_NAME, connectionString)); PropertyList list = new PropertyList(BUNDLE_DEST_DEFINITION_REF_LIST_NAME); map.put(list); for (ConfigRef ref : referencedConfiguration) { PropertyMap refMap = new PropertyMap(BUNDLE_DEST_DEFINITION_REF_LIST_MEMBER_NAME); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_TYPE_NAME, ref.getType().name())); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_CONTEXT_NAME, ref.getContext().name())); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_NAME_NAME, ref.getName())); refMap.put(new PropertySimple(BUNDLE_DEST_DEF_REF_TARGET_NAME_NAME, ref.getTargetName())); list.add(refMap); } }
protected void fillPropertyMap(PropertyMap map) { map.put(new PropertySimple(BUNDLE_DEST_NAME_NAME, getName())); if (getDescription() != null) { PropertySimple descriptionProp = new PropertySimple(BUNDLE_DEST_DESCRIPTION_NAME, getDescription()); map.put(descriptionProp); } PropertyList accepts = new PropertyList(BUNDLE_DEST_ACCEPTS_LIST_NAME); map.put(accepts); for (String acc : acceptedBundleTypes) { PropertySimple p = new PropertySimple(BUNDLE_DEST_ACCEPTS_LIST_MEMBER_NAME, acc); accepts.add(p); } }
public void updateResourceConfiguration(AugeasNode node, ConfigurationDefinition resourceConfigDef, Configuration resourceConfig) throws AugeasRhqException { Collection<PropertyDefinition> propDefs = resourceConfigDef.getPropertyDefinitions().values(); PropertyMap startProp = new PropertyMap(); for (Property property : resourceConfig.getProperties()) startProp.put(property); for (PropertyDefinition propDef : propDefs) { updateProperty(propDef, startProp, node, 0); } }
@Override protected void fillPropertyMap(PropertyMap map) { super.fillPropertyMap(map); PropertySimple valueContextProp = new PropertySimple(BUNDLE_DEST_BASE_DIR_VALUE_CONTEXT_NAME, getValueContext().name()); PropertySimple valueNameProp = new PropertySimple(BUNDLE_DEST_BASE_DIR_VALUE_NAME_NAME, getValueName()); map.put(valueContextProp); map.put(valueNameProp); }
private static PropertyMap getPropertyMap(String propertyName, Map<String, Object> map) { PropertyMap propertyMap = new PropertyMap(propertyName); Set<String> keys = map.keySet(); for (String key : keys) { Object value = map.get(key); Property target; if (value instanceof Map) { target = getPropertyMap(key, (Map)value); } else if (value instanceof List) { target = getPropertyList(key, (List)value); } else { target = new PropertySimple(key,value); } propertyMap.put(target); } return propertyMap; }
public OperationResult retrievePluginClassLoaderInformation() { Map<String, ClassLoader> classloaders; ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); ClassLoaderManager clm = this.pluginContainer.getPluginManager().getClassLoaderManager(); classloaders = clm.getPluginClassLoaders(); } finally { Thread.currentThread().setContextClassLoader(originalCL); } OperationResult info = new OperationResult(); PropertySimple numClassLoaders = new PropertySimple("numberOfClassLoaders", String.valueOf(classloaders.size())); PropertyList list = new PropertyList("classloaders"); info.getComplexResults().put(numClassLoaders); info.getComplexResults().put(list); for (Map.Entry<String, ClassLoader> entry : classloaders.entrySet()) { String pluginName = entry.getKey(); ClassLoader classloader = entry.getValue(); PropertyMap map = new PropertyMap("classloader"); map.put(new PropertySimple("pluginName", pluginName)); map.put(new PropertySimple("classloaderInfo", classloader)); list.add(map); } return info; }
private void initBasedir(DriftDescriptor descriptor, DriftDefinitionTemplate template) { Basedir basedir = descriptor.getBasedir(); String valueContext = basedir.getValueContext(); String valueName = basedir.getValueName(); PropertyMap basedirMap = new PropertyMap(DriftConfigurationDefinition.PROP_BASEDIR); basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT, valueContext)); basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME, valueName)); template.getConfiguration().put(basedirMap); }
@Override public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, Exception { if ("threadDump".equals(name)) { ThreadMXBean threadBean = getEmsBean().getProxy(ThreadMXBean.class); long[] threadIds = threadBean.getAllThreadIds(); ThreadInfo[] threadInfos = threadBean.getThreadInfo(threadIds, Integer.MAX_VALUE); OperationResult result = new OperationResult(); Configuration resultConfig = result.getComplexResults(); resultConfig.put(new PropertySimple("totalCount", threadBean.getThreadCount())); PropertyList threadList = new PropertyList("threadList"); resultConfig.put(threadList); for (ThreadInfo threadInfo : threadInfos) { PropertyMap map = new PropertyMap("thread"); map.put(new PropertySimple("name", threadInfo.getThreadName())); map.put(new PropertySimple("id", threadInfo.getThreadId())); map.put(new PropertySimple("state", threadInfo.getThreadState().name())); map.put(new PropertySimple("stack", getStringStackTrace(threadInfo.getStackTrace()))); threadList.add(map); } return result; } else { return super.invokeOperation(name, parameters); } }
public void setBasedir(BaseDirectory basedir) { if (basedir == null) { throw new NullPointerException("basedir is null"); } if (basedir.getValueContext() == null) { throw new NullPointerException("valueContext is null"); } if (basedir.getValueName() == null) { throw new NullPointerException("valueName is null"); } String valueContext = basedir.getValueContext().name(); String valueName = basedir.getValueName(); PropertyMap basedirMap = new PropertyMap(DriftConfigurationDefinition.PROP_BASEDIR); basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT, valueContext)); basedirMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME, StringUtils .useForwardSlash(valueName))); configuration.put(basedirMap); }
public PropertyMap createPropertyMap(PropertyDefinitionMap propDefMap, AugeasNode node) throws AugeasRhqException { PropertyMap propMap = new PropertyMap(propDefMap.getName()); for (PropertyDefinition mapEntryPropDef : propDefMap.getOrderedPropertyDefinitions()) { propMap.put(loadProperty(mapEntryPropDef, node)); } return propMap; }
public void addInclude(Filter filter) { PropertyList filtersList = configuration.getList(DriftConfigurationDefinition.PROP_INCLUDES); if (filtersList == null) { // this is going to be our first include filter - make sure we create an initial list and put it in the config filtersList = new PropertyList(DriftConfigurationDefinition.PROP_INCLUDES); configuration.put(filtersList); } PropertyMap filterMap = new PropertyMap(DriftConfigurationDefinition.PROP_INCLUDES_INCLUDE); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, StringUtils.useForwardSlash(filter .getPath()))); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, filter.getPattern())); filtersList.add(filterMap); }
public void addExclude(Filter filter) { PropertyList filtersList = configuration.getList(DriftConfigurationDefinition.PROP_EXCLUDES); if (filtersList == null) { // this is going to be our first include filter - make sure we create an initial list and put it in the config filtersList = new PropertyList(DriftConfigurationDefinition.PROP_EXCLUDES); configuration.put(filtersList); } PropertyMap filterMap = new PropertyMap(DriftConfigurationDefinition.PROP_EXCLUDES_EXCLUDE); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, StringUtils.useForwardSlash(filter .getPath()))); filterMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, filter.getPattern())); filtersList.add(filterMap); }
private void initExcludes(DriftDescriptor descriptor, DriftDefinitionTemplate template) { if (descriptor.getExcludes() != null && descriptor.getExcludes().getExclude().size() > 0) { Configuration config = template.getConfiguration(); PropertyList excludes = new PropertyList(DriftConfigurationDefinition.PROP_EXCLUDES); for (DriftFilterDescriptor exclude : descriptor.getExcludes().getExclude()) { PropertyMap excludeMap = new PropertyMap(DriftConfigurationDefinition.PROP_EXCLUDES_EXCLUDE); excludeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, exclude.getPath())); excludeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, exclude.getPattern())); excludes.add(excludeMap); } config.put(excludes); } }
private void initIncludes(DriftDescriptor descriptor, DriftDefinitionTemplate template) { if (descriptor.getIncludes() != null && descriptor.getIncludes().getInclude().size() > 0) { Configuration config = template.getConfiguration(); PropertyList includes = new PropertyList(DriftConfigurationDefinition.PROP_INCLUDES); for (DriftFilterDescriptor include : descriptor.getIncludes().getInclude()) { PropertyMap includeMap = new PropertyMap(DriftConfigurationDefinition.PROP_INCLUDES_INCLUDE); includeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATH, include.getPath())); includeMap.put(new PropertySimple(DriftConfigurationDefinition.PROP_PATTERN, include.getPattern())); includes.add(includeMap); } config.put(includes); } }
private int addNewMap(AbstractConfigurationComponent config) { String listName = config.getListName(); PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) config.getConfigurationDefinition() .getPropertyDefinitionList(listName).getMemberDefinition(); String mapName = mapDefinition.getName(); PropertyMap newMap = new PropertyMap(mapName); for (PropertyDefinition mapMemberDefinition : mapDefinition.getOrderedPropertyDefinitions()) { PropertyDefinitionSimple simpleDefinition = (PropertyDefinitionSimple) mapMemberDefinition; newMap.put(new PropertySimple(simpleDefinition.getName(), (simpleDefinition.isRequired()) ? "" : null)); } PropertyList list = config.getConfiguration().getList(listName); list.add(newMap); return list.getList().size() - 1; }