I have the following XML and want to convert it into Java object.
<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<datasource jndi-name="java:jboss/datasources/FDMS_DemoDS" pool-name="FDMS_DemoDS">
<connection-url>jdbc:mysql://localhost:3306/demo?zeroDateTimeBehavior=convertToNull</connection-url>
<driver>com.mysql</driver>
<pool>
<max-pool-size>60</max-pool-size>
</pool>
<security>
<user-name>fduser</user-name>
<password>fdms!</password>
</security>
</datasource>
</datasources>
I am not sure what will be my corresponding java class when I use JAXB to convert it.
This is what I have tried so far based on my understanding:
@XmlRootElement
public class Datasources {
String connectionUrl;
String maxPoolSize;
String driver;
public String getConnectionUrl() {
return connectionUrl;
}
@XmlElement
public void setConnectionUrl(String connectionUrl) {
this.connectionUrl = connectionUrl;
}
public String getMaxPoolSize() {
return maxPoolSize;
}
@XmlElement
public void setMaxPoolSize(String maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
public String getDriver() {
return driver;
}
@XmlElement
public void setDriver(String driver) {
this.driver = driver;
}
}