private AbstractPropertyListBuilder(String name, String memberName) { this.list = new PropertyList(name); this.list.memberPropertyName = memberName; }
public PropertyList deepCopy(boolean keepId) { PropertyList copy = new PropertyList(this, keepId); for (Property property : list) { copy.add(property.deepCopy(false)); } return copy; }
private static PropertyList getPropertyList(String listName, String propertyName, List<? extends Object> objects) { PropertyList propertyList = new PropertyList(listName); for(Object o : objects) { propertyList.add(new PropertySimple(propertyName, o)); } return propertyList; }
private PropertyList createPropertyListOfAddresses(String propertyName, List<StorageNode> nodes) { PropertyList list = new PropertyList(propertyName); for (StorageNode storageNode : nodes) { list.add(new PropertySimple("address", storageNode.getAddress())); } return list; }
private void addBundleDestinationSpecification(BundleDestinationSpecification def) { if (this.bundleConfiguration == null) { throw new NullPointerException("bundleConfiguration == null"); } PropertyList propertyList = this.bundleConfiguration.getList(BUNDLE_DEST_LIST_NAME); if (propertyList == null) { propertyList = new PropertyList(BUNDLE_DEST_LIST_NAME); this.bundleConfiguration.put(propertyList); } PropertyMap map = new PropertyMap(BUNDLE_DEST_LIST_ITEM_NAME); def.fillPropertyMap(map); propertyList.add(map); }
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; }
public OperationResult retrievePluginDependencyGraph() { Map<String, List<String>> dependencies = new HashMap<String, List<String>>(); List<String> deploymentOrder; ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); ClassLoaderManager clm = this.pluginContainer.getPluginManager().getClassLoaderManager(); PluginDependencyGraph graph = clm.getPluginDependencyGraph(); deploymentOrder = graph.getDeploymentOrder(); for (String pluginName : deploymentOrder) { List<String> deps = graph.getPluginDependencies(pluginName); if (deps == null || deps.size() == 0) { deps = new ArrayList<String>(Arrays.asList("<none>")); } dependencies.put(pluginName, deps); } } finally { Thread.currentThread().setContextClassLoader(originalCL); } OperationResult info = new OperationResult(); PropertyList list = new PropertyList("plugins"); info.getComplexResults().put(list); for (String plugin : deploymentOrder) { PropertyMap map = new PropertyMap("plugin"); map.put(new PropertySimple("name", plugin)); map.put(new PropertySimple("dependencies", dependencies.get(plugin))); list.add(map); } return info; }
public OperationResult retrieveDiscoveryClassLoaderInformation() { Map<String, ClassLoader> classloaders; ClassLoader originalCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); ClassLoaderManager clm = this.pluginContainer.getPluginManager().getClassLoaderManager(); classloaders = clm.getDiscoveryClassLoaders(); } 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 id = entry.getKey(); ClassLoader classloader = entry.getValue(); PropertyMap map = new PropertyMap("classloader"); map.put(new PropertySimple("id", id)); map.put(new PropertySimple("classloaderInfo", classloader)); list.add(map); } return info; }
private static PropertyList getPropertyList(String propertyName, List<Object> objects) { PropertyList propertyList = new PropertyList(propertyName); Property target; for (Object o : objects) { if (o instanceof List) { // Not sure if we actually support that at all inside RHQ List list = (List) o; target = getPropertyList(propertyName,list); // TODO propertyName? } else if (o instanceof Map) { Map map = (Map) o; target = getPropertyMap(propertyName,map); // TODO propertyName? } else { target = new PropertySimple(propertyName,o); } propertyList.add(target); } return propertyList; }
public Property createPropertyList(PropertyDefinitionList propDefList, AugeasNode node) throws AugeasRhqException { PropertyList propList = new PropertyList(propDefList.getName()); List<AugeasNode> nodes = tree.matchRelative(node, propDefList.getName()); PropertyDefinition listMemberPropDef = propDefList.getMemberDefinition(); for (AugeasNode listMemberNode : nodes) { propList.add(loadProperty(listMemberPropDef, listMemberNode)); } return propList; } }
@SuppressWarnings("unchecked") private void loadAssignedServerGroups(Configuration configuration) { String managementNodeName = getManagementNodeName(); Address theAddress = new Address("/"); Operation op = new ReadChildrenResources(theAddress, "server-group"); op.addAdditionalProperty("recursive-depth", "1"); Result res = getASConnection().execute(op); PropertyList propGroups = new PropertyList("*1"); configuration.put(propGroups); if (res.isSuccess()) { Map<String, Object> groups = (Map<String, Object>) res.getResult(); for (Map.Entry<String, Object> entry : groups.entrySet()) { Map<String, Object> groupDetails = (Map<String, Object>) entry.getValue(); Map<String, Object> deployments = (Map<String, Object>) groupDetails.get("deployment"); if (deployments != null) { Map<String, Object> deployment = (Map<String, Object>) deployments.get(managementNodeName); if (deployment != null) { PropertyMap map = new PropertyMap("*"); map.put(new PropertySimple("server-group", entry.getKey())); map.put(new PropertySimple("runtime-name", deployment.get("runtime-name"))); map.put(new PropertySimple("enabled", deployment.get("enabled"))); propGroups.add(map); } } } } }
@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); } }
private static void adaptPropertyList(PropertyList source, PropertyList target, PropertyDefinitionList definition, Object parent, boolean adaptReadonlyProperties) { if ((adaptReadonlyProperties || !definition.isReadOnly())) { if (target == null) { target = new PropertyList(definition.getName()); add(parent, target); } if (target.getList().isEmpty()) { PropertyDefinition memberDef = definition.getMemberDefinition(); for (Property p : source.getList()) { PropertyType type = conforms(p, memberDef); if (type != null && type != PropertyType.UNKNOWN) { Property targetMember = instantiateDefaultProperty(memberDef); target.add(targetMember); adaptProperty(p, targetMember, memberDef, target, adaptReadonlyProperties); } } } } }
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); } }
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 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); }
protected Property createPropertyList(PropertyDefinitionList propDefList, Augeas augeas, AugeasNode node) { PropertyDefinition listMemberPropDef = propDefList.getMemberDefinition(); if (!(listMemberPropDef instanceof PropertyDefinitionMap)) { throw new IllegalArgumentException( "Invalid Resource ConfigurationDefinition - only lists of maps are supported."); } PropertyDefinitionMap listMemberPropDefMap = (PropertyDefinitionMap) listMemberPropDef; PropertyList propList = new PropertyList(propDefList.getName()); String mapKey = getListMemberMapKey(propDefList); String mapPath = getAugeasPathRelativeToParent(listMemberPropDefMap, node, augeas); String listMemberPathsExpression = node.getPath() + AugeasNode.SEPARATOR_CHAR + mapPath; List<String> listMemberPaths = augeas.match(listMemberPathsExpression); for (String listMemberPath : listMemberPaths) { AugeasNode listMemberNode = new AugeasNode(listMemberPath); PropertyMap listMemberPropMap = new PropertyMap(listMemberPropDefMap.getName()); propList.add(listMemberPropMap); // Add the "key" prop, if defined, to the map. if (mapKey != null) { PropertySimple keyProp = new PropertySimple(mapKey, listMemberNode.getName()); listMemberPropMap.put(keyProp); } // Populate the rest of the map child properties. populatePropertyMap(listMemberPropDefMap, listMemberPropMap, augeas, listMemberNode); } return propList; }
@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); } }