Donnerstag, 31. März 2011

XMLBeans Developers are searching for new features, small fixes or new ideas

On 22.03.2011 an Apache XmlBeans Developer sends this email to all XmlBeans Developer mailing list

I'm sending this email to reach out to people interested in XMLBeans, we the active committers, were wondering if there is anybody actively using XMLBeans that might be interested in adding new features, small fixes or just have new ideas.

We made a rough list with things we think they will be useful to have:
- add full support for generics, default to JDK 1.5
- finish support for XMLSchema 1.1, many details around 1.1 built-in schema types are already in
- better .xsdconfig, add support for different value serialization to support bug XMLBEANS-451.

Please don't be shy any response is appreciated, Active XMLBeans Committers

So if anyone uses XMLBeans actively or have some feature requests let them know.

Montag, 28. März 2011

Debugging Tests runned by maven

For debugging tests which are executed by maven you can use the following option:
mvn -Dmaven.surefire.debug test

Then maven will starts and is waiting for a remote debug connection on port 5005.

This works at least with Maven2 and Maven3. I have not test it with maven1.

Freitag, 25. März 2011

Set custom connection property to Apache Commons DBCP BasicDataSource via Spring config

When you want to set a custom connection Property to the BasicDataSource from Apache commons dbcp you need to use the method: public void addConnectionProperty(String name, String value)

You can't use the normal spring config to add a property because the variable connectionProperties has no getter and setter method.

Here's the example:
Spring context.xml

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver">
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="connectionProperties">
<props>
<prop key="includeSynonyms">true</prop>
</props>
</property>
</bean>

In your code you try to autowire the datasource like this:

@Autowired
protected javax.sql.DataSource dataSource;


If you try this, you will get the following exception:
org.springframework.beans.NotWritablePropertyException: Invalid property 'connectionProperties' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'connectionProperties' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

How can you solve this problem?
Using the addConnectionProperty Method from BasicDataSource? Yes. But you can't access it at the moment directly in the spring config.
There is a ImprovementRequest for Spring and the planed to solve it in Spring Core Release 3.2RC1.


The other way would be:
Create your own Interface which extends javax.sql.DataSource
and extends the org.apache.commons.dbcp.BasicDataSource class with your own implementation

ExtendDataSource interface

package com.apache.dbutils;

import javax.sql.DataSource;

public interface ExtendDataSource extends DataSource {

public String getIncludeSynonyms();

public void setIncludeSynonyms(String includeSynonyms);
}


ExtendBasicDataSource Class

package com.apache.dbutils;

import java.sql.SQLException;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.dbutils.ExtendDataSource;

public class ExtendBasicDataSource extends BasicDataSource
implements ExtendDataSource {

public ExtendBasicDataSource () {
super();
}

/**
* @see java.sql.Wrapper#unwrap(java.lang.Class)
*/
@Override
public T unwrap(Class iface) {
throw new UnsupportedOperationException("Is not implemented by org.apache.commons.dbcp.BasicDataSource so we will not implement it either");
}

/**
* @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
*/
@Override
public boolean isWrapperFor(Class iface) throws SQLException {
throw new UnsupportedOperationException("Is not implemented by org.apache.commons.dbcp.BasicDataSource so we will not implement it either");
}

/**
* @see com.wirecard.settlement.dbutils.SettlementDataSource#getIncludeSynonyms()
*/
@Override
public String getIncludeSynonyms() {
return super.connectionProperties.getProperty("includeSynonyms");
}

/**
* @see com.wirecard.settlement.dbutils.SettlementDataSource#setIncludeSynonyms(java.lang.String)
*/
@Override
public void setIncludeSynonyms(String includeSynonyms) {
super.addConnectionProperty("includeSynonyms", String.valueOf(includeSynonyms));
}
}


And now you need to change your Spring Config

<bean id="dataSource" class="com.apache.dbutils.ExtendBasicDataSource" method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver">
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="includeSynonyms" value="true" />
</bean>


You don't need to change your code where you autowire the datasource.