// javadoc inherited
public void marshal(Object arg0, IMarshallingContext context)
throws JiBXException {
MarshallingContext ctx = (MarshallingContext) context;
DatasourceConfiguration dataSource = (DatasourceConfiguration) arg0;
DataSourceType type = dataSource.getType();
if (type == DataSourceType.JDBC_DATASOURCE) {
JDBCDatasource jdbcDatasource = (JDBCDatasource) dataSource;
ctx.startTag(index, JDBC_DATASOURCE_TAG_NAME);
writeTagsTextContent(ctx, DRIVER_CLASS_TAG_NAME,
jdbcDatasource.getDriverClass());
writeTagsTextContent(ctx, CONNECTION_STRING_TAG_NAME,
jdbcDatasource.getConnectionString());
marshalName(index, ctx, jdbcDatasource.getName());
ctx.endTag(index, JDBC_DATASOURCE_TAG_NAME);
} else if (type == DataSourceType.INTERNAL_POOL_DATASOURCE) {
InternalPoolDatasource internalPoolDatasource =
(InternalPoolDatasource) dataSource;
ctx.startTag(index, INTERNAL_POOL_DATASOURCE_TAG_NAME);
writeTagsTextContent(ctx, DRIVER_CLASS_TAG_NAME,
internalPoolDatasource.getDriverClass());
writeTagsTextContent(ctx, URL_TAG_NAME,
internalPoolDatasource.getUrl());
writeTagsTextContent(ctx, USERNAME_TAG_NAME,
internalPoolDatasource.getUsername());
writeTagsTextContent(ctx, PASSWORD_TAG_NAME,
internalPoolDatasource.getPassword());
writeTagsTextContent(ctx, MAX_ACTIVE_TAG_NAME,
internalPoolDatasource.getMaxActive());
writeTagsTextContent(ctx, MAX_IDLE_TAG_NAME,
internalPoolDatasource.getMaxIdle());
writeTagsTextContent(ctx, MAX_WAIT_TAG_NAME,
internalPoolDatasource.getMaxWait());
marshalName(index, ctx, internalPoolDatasource.getName());
ctx.endTag(index, INTERNAL_POOL_DATASOURCE_TAG_NAME);
} else if (type == DataSourceType.JNDI_DATASOURCE) {
JNDIDatasource jndiDatasource = (JNDIDatasource) dataSource;
ctx.startTag(index, JNDI_DATASOURCE_TAG_NAME);
writeTagsTextContent(ctx, JNDI_NAME_TAG_NAME,
jndiDatasource.getJndiName());
marshalName(index, ctx, jndiDatasource.getName());
ctx.endTag(index, JNDI_DATASOURCE_TAG_NAME);
} else {
throw new JiBXException(EXCEPTION_LOCALIZER
.format("invalid-datasource-type"));
}
}