This post is just a collection of troubleshooting tips that I've picked up during the years.
Saturday, November 9, 2013
Sunday, April 14, 2013
Environment configuration property injection using Java CDI
In Spring Framework, injecting environment properties is made simple using the context:property-placeholder
to configure property file locations and the @Value("#{propKey}")
annotation to specify the key of the property.
Java CDI does not have an equivalent out-of-the-box, but it's flexible and rolling your own is easy using a single qualifier
and a producer method.
Monday, March 18, 2013
How-to: RESTful Web services with JAX-RS and Spring
When providing services in a specific technology (i.e. EJB, JAX-WS, JAX-RS), it's wise to avoid mixing the business logic of your service and the technology that you are using to expose it to the outside world. This separation facilitates easier adoption of newer technologies and makes it easier to maintain and test services.
Tuesday, March 12, 2013
Testing Java classes with field injections
Dependency injection frameworks in Java give us 3 points of injection: constructor, field and setter methods. Many of us prefer field injection because we can skip writing setter methods and keep the number of lines to a minimum. The downside of field injection is that the class no longer can be used or tested without a dependency injection framework, for instance during unit-testing. In this post, I'm going to look at how we can unit-test a class with field injections.
Sunday, February 17, 2013
Working with JAXB for binding XML
Here are a few snippets for binding Java objects to XML using JAXB.
Sunday, February 10, 2013
Apache Wicket 6.5 vs. JSF 2.0
Having developed several web applications with JSF, and recently with Apache Wicket, I want to share my experience. On the web, Wicket has mostly positive buzz, but JSF seems to be hated by many (See http://ptrthomas.wordpress.com/2009/05/15/jsf-sucks/). I beg to differ.
Before I start, it should be noted that many of the frustrations and limitations of JSF discussed around the web have been have been addressed in version 2.0. And one more thing, the comparison aspects below are in no particular order.
Monday, January 28, 2013
How to become a better programmer?
By three methods we may learn wisdom:
First, by reflection, which is noblest;
Second, by imitation, which is easiest;
and third by experience, which is the bitterest.
- Confucius
Sunday, January 20, 2013
Java Web Services – bottom-top-down approach
Bottom-up approach. |
In the top-down approach, the WSDL is created first, and the Java artifacts are generated using wsimport tool.
Top-down approach. |
Sunday, January 13, 2013
JSF 2.0 Maven Archetype
Although most of the time this process takes only a couple of minutes, sometimes I forget how to connect different bits and end up reading documentation for half an hour. To avoid wasting time on things I've done many times, I created a Maven archetype with the following setup: JSF 2.0, CDI, PrimeFaces, SLF4J and Logback. The archetype is deploy-ready, containing "Hello world!" examples of the essentials, and can be pulled from GitHub.