Java Archives - Intertech Blog

JAXB Tutorial: Customized Namespace Prefixes Example using NamespacePrefixMapper

Do you need to specify what namespace prefixes are used in your JAXB marshaled XML? For example, do you want to see  in the generated XML instead of ? If so, this JAXB tutorial will walk you through those steps. If you are using the default JAXB implementation provided with Java 6 or later, you can configure the namespace prefixes by extending the  and setting a property to tell the marshaller to use your extension. For more details on marshalling JAXB objects to XML, review… Read More

JAXB Tutorial: How to Marshal and Unmarshal XML

This JAXB tutorial describes how to use JAXB to marshal and unmarshal XML strings using either Spring or the standard javax.xml.bind interfaces. The samples below are using XML strings instead of files, but could easily be adapted to files if needed. Spring’s Jaxb2Marshaller Configuration To use Spring’s , you will need the spring-oxm dependency, which you may already have, since it is used by other major spring components. To configure the  in your Spring context, add the config XML below.  Be sure to add… Read More

Spring Security Active Directory LDAP Example

At a recent client, I was tasked with securing their web applications using Spring Security and their internal Active Directory (AD) LDAP server. I scoured the web and went through a lot of trial and error until I finally found the configuration that worked in their environment.  Based on some of the comments and questions I found on the web, the problems that I was facing seemed to be shared by others. Here’s a Spring Security Active Directory example to show how… Read More

Android Adapters (and AdapterViews)

Android’s Adapter is described in the API documentation, as “a bridge between an AdapterView and the underlying data for that view” (see here).  An AdapterView is a group of widgets (aka view) components in Android that include the ListView, Spinner, and GridView.  In general, these are the widgets that provide the selecting capability in the user interface (read about AdapterView widgets here).  What is not mentioned in the documentation is that the AdapterView also provides the layout of the underlying data… Read More

Android Non-UI to UI Thread Communications (Part 5 of 5)

This is the last post in my series regarding Android thread communications.  Parts 1 through 4 are linked in below. Part 1 Part 2 Part 3 Part 4 In this series, I have so far outlined four different approaches for how Android non-user interface threads can communicate user interface (UI) updates back to the UI thread.  As you have learned in this series, new threads to perform longer running work is the way to build applications and to avoid Android Not… Read More

Android Non-UI to UI Thread Communications (Part 4 of 5)

In parts 1-3 of this series, I have explored three different means for an Android non-UI thread to communicate user interface updates to the UI thread. The links below are to the series posts. Part 1 Part 2 Part 3 In this fourth installment, I want to show you how to use a broadcasts and a broadcast receiver to provide non-UI to UI thread communications. Background non-UI thread to UI thread comms As background for those jumping into the middle… Read More

Android Non-UI to UI Thread Communications (Part 3 of 5)

Continuing my series on Android non-UI thread-to-UI thread communications, this post covers use of the Handler Framework to facilitate the communications.  See here for Part 1 and Part 2 of the series. Non-UI threads are not allowed to make updates to the UI.  Trying to do too much work (as defined as not allowing the user to interact with the UI for more than 5 seconds) on the UI thread leads to ANR errors.  In the first two posts, I showed how… Read More

Android Non-UI to UI Thread Communications (Part 2 of 5)

This is the second part of my series of blog posts on Android non-UI thread-to-UI thread communications. See here for the start of the series.  As a refresher, this series of posts is about how non-UI threads can communicate back to the UI thread in an Android application in order to update the user interface.  Non-UI threads are not allowed to make updates to the UI.  Trying to do too much work (as defined as not allowing the user to interact… Read More

Android Non-UI to UI Thread Communications (Part 1 of 5)

Android UI Thread and ANR On the Android platform, applications operate, by default, on one thread.  This thread is called the UI thread.  It is often called that because this single thread displays the user interface and listens for events that occur when the user interacts with the app. Developers quickly learn that if code running on that thread hogs that single thread and prevents user interaction (for more than 5 seconds), it causes Android to throw up the infamous Android… Read More

Writing Android Apps on an Android Device – AIDE

First a word for my sponsor It has been more than a couple of months since my last blog post.  For every seven years of employment, my company gives its employees a two month sabbatical.  I just spent my sabbatical traveling Australia and New Zealand!  Below are a couple of pictures from my trip – one of Uluru in Australia and one of the Fox Glacier in New Zealand (If you look close you can see a few dots on the lower… Read More