Skip to main content
1 of 3

I looked at the code and this is how the cartridges are loaded:

public static Engine newEngine()
    throws AmbientDataException
{
    try
    {
        AmbientDataConfig ambientDataConfig = AmbientDataContext.getAmbientDataConfig();
        Set cartridgeDefinitions = new HashSet();
        Configuration config;
        for(Iterator i$ = ambientDataConfig.getCartridgeConfigurations().iterator(); i$.hasNext(); cartridgeDefinitions.add(cartridgeDefinitionFromConfig(config)))
            config = (Configuration)i$.next();

        return new Engine(cartridgeDefinitions);
    }
    catch(ConfigurationException ex)
    {
        LOG.error("Unable to configure the AmbientData Framework", ex);
        throw new AmbientDataException("Error while configuring ambient data framework", ex);
    }
}

So it "seems" it loads the cartridges from the xml confg file (cd_ambient_conf.xml) in the getCartridgeConfigurations by executing the following loop:

for(Iterator i$ = ConfigurationHelper.getConfigurations(configuration, "/Configuration/Cartridges/Cartridge").iterator(); i$.hasNext(); result.add((new XMLConfigurationReader()).readConfiguration(fileName, "schemas/cd_ambient_cartridge_conf.xsd")))
    {
       ....
    }

Which means they should be loaded in the same order they show in the configuration file. Further investigation, the cartridges configuration are saved on a java.util.HashSet object which by definition it doesn't care about the order of its elements. Copied from the javadoc:

public class HashSet<E>
extends AbstractSet<E>
implements Set<E>, Cloneable, Serializable
This class implements the Set interface, backed by a hash table (actually a HashMap instance). It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This class permits the null element.

So I think that answers your question. I don't think there's a way to control the order of the execution. But yet again, let's see if someone from R&D confirms my research.