Thursday, 22 December 2011

Apache CXF connector to Alfresco

After generating Apache CXF connector to Alfresco using WSDL document, we also have to add security interceptors. Here is a code fragment I have used:

org.apache.cxf.endpoint.Client client = ClientProxy.getClient(service);
Map inProps = new HashMap();
inProps.put(WSHandlerConstants.ACTION, "UsernameToken Timestamp");
inProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
inProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, "com.roche.xp2.content.lowlevel.alfresco.util.AlfrescoRepositoryProviderCallback");
inProps.put(WSHandlerConstants.USER, "ticket");
WSS4JOutInterceptor wssIn = new WSS4JOutInterceptor(inProps);
client.getEndpoint().getOutInterceptors().add( new org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor());

Thursday, 15 December 2011

Spring 3.1 Released

This release provides a significant upgrade to the Spring framework with environment profiles, caching abstraction, JDBC 4.1 and Java 7 fork/join and Hibernate 4.0 support. More info about changes:
Download available here:

Sunday, 4 December 2011

How to log Garbage collection in java?

You have to add the following parameters when running a java program
  • -XX:+PringGC - switching on summary of every run of Garbage collection
  • -XX:+PringGCDetails - switching on detail summary of every run of Garbage collection
  • -Xloggc:filename - filename to which logs will be put

Logging application behavior, whose are deployed on tomcat

You can log many events of application without changing its code. You can switch on Valves in tomcat configuration. Valve (org.apache.catalina.valves.Valve) is acting like filter on HttpRequest. It is executed just before application gets the request. There are some predefined Valves you can use by just uncommenting them in server.xml configuration in tomcat. You can also develop your own Valve and use them after adding in configuration and in shared libs in tomcat.
More information can be read in the article:

Video showing how to use m2eclipse plugin

Look here:

ListPreference with values number type

In my Android application I tried to define preferences list with values of number type.
      android:dialogTitle="@string/preference_poll_list" />
I had to define lists in arrays.xml. But I had to define list poll_option_values as a string-array, like here:
    <array name="poll_option">
        <item>1 Minute</item>
        <item>2 Minutes</item>
        <item>5 Minutes</item>
        <item>10 Minutes</item>
        <item>20 Minutes</item>
    <string-array name="poll_option_values">
I couldn't use array type. Just another Android feature ;)

Saturday, 3 December 2011

Testing asynchronous actions using WebDriver (f.e. AJAX)

Here is a code snippet showing how to test ajax actions using WebDriver. You can use WebDriverWait.until method defining condition that checks if web page's structure has changed. In the WebDriverWait constructor you have to define timeout in seconds. If this time passes then method ends with an exception.
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition() {
  public Object apply(Object input) {
      try {
        WebElement elem = driver.findElement(;
        boolean condition = Here you can state condition
        return condition;
      } catch (StaleElementReferenceException e) {
        return false;