Atomikos Forum |
|
I am using Atomikos in Tomcat to create a DB2 XA datasource.
To configure the "com.ibm.db2.jcc.DB2XADataSource" I have to set the xaProperties.securityMechanism to "4". The problem is that this property is a short. com.ibm.db2.jcc.DB2BaseDataSource: public static final short propertyDefault_securityMechanism = 3; I had to extend the method "convert" in "com.atomikos.beans.PropertyUtils" so that it can convert from String to short. This class is used by the "com.atomikos.tomcat.BeanFactory" to initialize the "DB2XADataSource" with the parameters configured in the Tomcat "context.xml". Can you integrate this extension into the next release of Atomikos? Best regards Andreas @SuppressWarnings({"rawtypes"}) private static Object convert(Object value, Class destinationClass) throws PropertyException { if (value.getClass() == destinationClass) { return value; } if (value.getClass() == int.class || value.getClass() == Integer.class || value.getClass() == boolean.class || value.getClass() == Boolean.class) { return value; } if ((destinationClass == int.class || destinationClass == Integer.class) && value.getClass() == String.class) { return new Integer((String) value); } // START EXTENSION if ((destinationClass == short.class || destinationClass == Short.class) && value.getClass() == String.class) { return new Short((String) value); } // STOP EXTENSION if ((destinationClass == boolean.class || destinationClass == Boolean.class) && value.getClass() == String.class) { return Boolean.valueOf((String) value); } throw new PropertyException("cannot convert values of type '" + value.getClass().getName() + "' into type '" + destinationClass + "'"); } Extract from my context.xml: <Resource name="jdbc/beispiel" uniqueResourceName="jdbc/beispiel" auth="Container" type="com.atomikos.jdbc.AtomikosDataSourceBean" factory="com.provinzial.tomcat.AtomikosBeanFactory" minPoolSize="2" maxPoolSize="4" xaDataSourceClassName="com.ibm.db2.jcc.DB2XADataSource" xaProperties.user="${user.name}" xaProperties.serverName="..." xaProperties.portNumber="5069" xaProperties.databaseName="..." xaProperties.securityMechanism="4" xaProperties.clientProgramName="Beispiel" xaProperties.clientApplicationInformation="TOMCAT" xaProperties.clientWorkstation="LOCAL" xaProperties.driverType="4" testQuery="SELECT 1 FROM sysibm.sysdummy1" /> |