Author Message
AntonioRincon
Joined: Apr 9, 2015
Messages: 9
Offline
I want to get use of commons-logging.jar by apache

Which will be the correct place to create the XMLConfiguration object and and initialize from the xml file to be used in different nodes in the application?
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
OD uses commons-logging and log4j. see ddlog4j.properties file in the application data directory.
AntonioRincon
Joined: Apr 9, 2015
Messages: 9
Offline
sorry, what i wanted to say is that I want to get use of commons-configuration.
I want to read a XML file myconfig.xml. I want to create a XML XMLConfiguration object initialize with this xml file, and access to the properties in the xml file in different nodes in the application. If possible I would like to create a single object instead of creating a new XMConfiguration for each session.
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
I see. One question, do the values of the config file change very often? You may want to use "CAVs" configurable application variables. Then on the EP when you configure the application you can set the initial value of the variables there and change the values at any time.
AntonioRincon
Joined: Apr 9, 2015
Messages: 9
Offline
in the xml the is list of values that can increase in pairs name/value, for example

labels
label='result_grammar1' type='type_a'
label='result_grammar2' type='type_b'
label='result_grammar3' type='type_a'

i can not define variables in the project for each posible pair/value as it can added to the configuration file.

Thats the reason I want to get use of the XMLConfiguration, if possible create a single object to be used by all the session, the XMLConfiguration already can be refreseh autimatically in case the xml file changes.
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
I see. I would put the file in the application project "data" folder.
AntonioRincon
Joined: Apr 9, 2015
Messages: 9
Offline
but, where do I have to create the XMLConfiguration, is it possible to be saved in the context of the application to be used when needed?
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
I am not clear on your question. I would suggest placing the file in the application's data folder along wiht the ddrt.properties ddlog4j.properties and other files. That way when you export the application your myconfig.xml will automatically be packaged with the application.
AntonioRincon
Joined: Apr 9, 2015
Messages: 9
Offline
Thanks to clarify where to plase the myconfig.xml. Now my question is how to use the XMLConfiguration in the application, I am trying to save the XMLConfiguration as a session variable, for the moment in this test I am saving XMLConfiguratio as a session variable and retrieving from the session to be used later.

@Override
public void requestBegin(SCESession mySession) {
// TODO Auto-generated method stub
super.requestBegin(mySession);
XMLConfiguration xmlConfiguration1 = null;
XMLConfiguration xmlConfiguration2 = null;
int MaxIntentos;

try {
xmlConfiguration1 = new XMLConfiguration("myconfig.xml");
} catch (Exception e) {
System.out.println("XMLConfiguration: " + e.getMessage());
}

MaxIntentos = xmlConfiguration1.getInt("MaxIntentos");
System.out.println("MaxIntentos1: " + MaxIntentos);

mySession.getVariable("XMLConfiguration").getSimpleVariable().setValue(xmlConfiguration1);
xmlConfiguration2 = (XMLConfiguration) mySession.getVariable("XMLConfiguration").getSimpleVariable().getObjectValue();

MaxIntentos = xmlConfiguration1.getInt("MaxIntentos");
System.out.println("MaxIntentos2: " + MaxIntentos);

}
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
That works storing the object into a simple variable. If you are using modules you will have to pass that simple variables to the modules so they have access. An alternative way it to just store a reference to the config in the session properties.


mySession.setProperty( "xmlconfig", xmlConfiguration1 );

XMLConfiguration x = (XMLConfiguration )mySession.getProperty( "xmlconfig" );
AntonioRincon
Joined: Apr 9, 2015
Messages: 9
Offline
Thanks it's a better aproach, can you reference me to documentation to understand the differences between properties and variables? I Will take a look to MyTroubleDesk sample where Properties are used.
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
Project variables are used in the UI you can set them copy them assign to them, put data into the variables using connectors (database, web service, and etc.).

The session properties are use internally my the framework to store certain state data regarding vxml generation. Also they are used to passed large chunks of data between modules since subdialog vxml construct only allows passing strings a parameters.
Go to:   
Mobile view