Solved! and here is how it was done.
On the maven-surefire-plugin I added the required values as "systemPropertyVariables"
<systemPropertyVariables>
<component.name>${artifactId}</component.name>
<component.version>${version}</component.version>
</systemPropertyVariables>
So the plugin would look like this;
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<systemPropertyVariables>
<component.name>${artifactId}</component.name>
<component.version>${version}</component.version>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
In the testng.xml we need to mention these as parameters inorder to access them through the listener.
<suite name="SampleTest_TestSuite1" verbose="1">
<parameter name="component" value="${component.name}"/>
<parameter name="version" value="${component.version}"/>
<test name="SampleTest" preserve-order="true" parallel="false">
<classes>
...
</classes>
</test>
</suite>
Then we access these parameters through testng listener.
public class DataBaseReporterListener implements IReporter {
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String s) {
String componentName = suites.get(0).getParameter("component");
String componentVersion = suites.get(0).getParameter("version");