Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7609783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:15:26+00:00 2026-05-31T01:15:26+00:00

Please, consider the following piece of a typical VMWare configuration file (*.vmx): memsize =

  • 0

Please, consider the following piece of a typical VMWare configuration file (*.vmx):

memsize = "2048"
MemTrimRate = "-1"
mks.enable3d = "TRUE"
nvram = "Windows Server 2003 Standard Edition.nvram"
pciBridge0.pciSlotNumber = "17"
pciBridge0.present = "TRUE"
pciBridge4.functions = "8"
pciBridge4.pciSlotNumber = "18"
pciBridge4.present = "TRUE"
pciBridge4.virtualDev = "pcieRootPort"
pciBridge5.functions = "8"
pciBridge5.pciSlotNumber = "19"
pciBridge5.present = "TRUE"
pciBridge5.virtualDev = "pcieRootPort"
pciBridge6.functions = "8"
pciBridge6.pciSlotNumber = "20"
pciBridge6.present = "TRUE"
pciBridge6.virtualDev = "pcieRootPort"
pciBridge7.functions = "8"
pciBridge7.pciSlotNumber = "32"
pciBridge7.present = "TRUE"
pciBridge7.virtualDev = "pcieRootPort"
replay.filename = ""
replay.supported = "FALSE"
roamingVM.exitBehavior = "go"

By observing this configuration, one can imagine a PciBridge java bean type with the following signature:

class PciBridge
{
  public int pciSlotNumber; // or public int getPciSlotNumber(){...} and public void setPciSlotNumber(int v){...}
  public boolean present;   // or get/is/set methods
  public int functions;     // or get/set methods
  public String virtualDev; // or get/set methods
}

Moreover, the configuration manager responsible for reading the vmx files might expose the following method:

public <T> List<T> getObjects(final String prop, Class<T> clazz);

And then given the aforementioned configuration, invoking getObjects("pciBridge", PciBridge.class) would return a list of all the PciBridge objects specified in the configuration – the total of 5 in our case.

How do I implement this functionality? Of course, I have seen the same pattern in several different products, so I figure there should be something ready out there to implement this functionality.

Any ideas?

Thanks.

EDIT

Correction – I do not claim that VMWare utilizes the java properties file format (the double quotes are redundant), but the spirit is the same. Besides, there are proper Java applications utilizing the same pattern.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:15:27+00:00Added an answer on May 31, 2026 at 1:15 am

    I am posting my own solution. The code depends on http://commons.apache.org/beanutils/ to reflect on the beans and on http://commons.apache.org/configuration/ to manage the property based configuration (because it supports property references using the ${} syntax).

    public static <T> Collection<T> getBeans(String prop, Class<T> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
      Pattern pattern = Pattern.compile("^" + prop.replace(".", "\\.") + "(\\d*)\\.(\\w+)$");
      Map<String, T> beans = new TreeMap<String, T>();
      @SuppressWarnings("rawtypes")
      Map description = null;
      T tmpBean = null;
      Iterator<String> itKeys = m_propStore.getKeys();
      while (itKeys.hasNext()) {
        String key = itKeys.next();
        Matcher matcher = pattern.matcher(key);
        boolean matchFound = matcher.find();
    
        if (matchFound) {
          if (description == null) {
            tmpBean = clazz.newInstance();
            description = BeanUtils.describe(tmpBean);
          }
    
          String beanPropName = matcher.group(2);
          if (description.containsKey(beanPropName)) {
            String beanKey = matcher.group(1);
            T bean = beans.get(beanKey);
            if (bean == null) {
              bean = tmpBean == null ? clazz.newInstance() : tmpBean;
              tmpBean = null;
              beans.put(beanKey, bean);
            }
            try {
              BeanUtils.setProperty(bean, beanPropName, m_propStore.getString(key));
            } catch (Exception e) {
              m_logger.error(String.format("[SystemConfiguration]: failed to set the %s.%s bean property to the value of the %s configuration property - %s",
                bean.getClass().getName(), beanPropName, key, e.getMessage()));
            }
          }
        }
      }
      return beans.values();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider the following piece of code, which throws three different exceptions (namely, System.Configuration.ConfigurationErrorsException
Please consider the following function body: var isValidated = true; $(selector1).each(function(){ //do validation with
Please consider the following piece of code: int main() { typedef boost::ptr_vector<int> ptr_vector; ptr_vector
Please consider following code: 1. uint16 a = 0x0001; if(a < 0x0002) { //
Please consider the following: <td style=width: 500px;> <div style=width: 400px;>SomeContent</div> </td> For some reason,
Please consider the following fork() / SIGCHLD pseudo-code. // main program excerpt for (;;)
Please consider the following scenario: map(T,S*) & GetMap(); //Forward decleration map(T, S*) T2pS =
Please consider the following code: public class Person ( public string FirstName {get; set;}
Please consider the following java source: package com.stackoverflow; public class CondSpeed { private static
Please consider the following context from Innate : # Default application for Innate def

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.