Loading configuration data
To permit your application to communicate with the data collection server, you must provide it with configuration data. The configuration data contains information, such as your developer dcsid, which tells the data collection server that the data it receives should be associated with your Analytics Service web portal account. You can use WebtrendsConfigurator.LoadConfigFile() to do this.
You must pass one of three things into LoadConfigFile(): a config.xml file that is located in the same package as your application, the WebtrendsConfig abstract class, or an implementation of the IWebtrendsConfig interface.
Firstly, you can use WebtrendsConfigurator.LoadConfigFile(String packageName, String filename) to load the XML configuration file provided with the Analytics Service SDK. Your config.xml file must be located in the same package as the class in which you call this method.
To successfully import the configuration file using the code sample below, the file must be located in the com.sample package, along with AnalyticsDemo.java.
WebtrendsConfigurator.LoadConfigFile("com.sample.AnalyticsDemo", "config.xml");
If you don't want to rely on an external .xml file, you can provide WebtrendsConfigurator.LoadConfigFile() with an instance of the WebtrendsConfig abstract class. The methods provided by WebtrendsConfig return the same default values as the .xml file. You can overwrite these methods as needed to provide your own configuration settings.
WebtrendsConfigurator.LoadConfigFile(
new WebtrendsConfig()
{
public String wt_dc_app_name() {
return "TheBestHelloWorldAppEver";
}
public String wt_dc_app_version() {
return "1.0.22";
}
public String wt_dc_dcsid() {
return "dcs123456789012owzt929yog_1234";
}
public String wt_dc_debug() {
return "false";
}
public String wt_dc_timezone() {
return "-8";
}
public String wt_dc_url() {
return "http://dc.webtrends.com/v1";
}
public String wt_dc_app_category(){
return "Games";
}
public String wt_dc_app_publisher(){
return "WTEng-Test-App";
}
}
);
You can also pass in an implementation of the IWebtrendsConfig interface. The IWebtrendsConfig interface defines methods for all the tags in the provided .xml file, but provides no defaults. It is reccomended that you use the WebtrendsConfig class, which provides defaults, for this reason.
WebtrendsConfigurator.LoadConfigFile(
new IWebtrendsConfig()
{
// provide implementation
}
);