Blog Insights
Mobile Grails
I threw out iWebKit immediately because it only targets iPhone, iPod Touch and iPad. While iUI "now supports most smartphones & tablets" it's current version is 0.40alpha1. Furthermore the Grails plugin doesn't appear to have been updated in the past 2 years. This left me with Spring Mobile Grails and jQuery...Injecting Spring Beans into Java Servlets
If you are working in a Java Web Application and you are using Spring IoC Container in your application, there is a chance that you might have to inject Spring Beans into a Java Servlet. Since there is not a direct way to inject Spring Beans into a Java Servlet, you...Static Caching in Drupal
If you’re a PHP veteran, then you know static caching is a relatively simple thing to do in PHP, but it can result in inconsistent behavior and sloppy code, such as adding an extra parameter to a function for the sole purpose of resetting that function’s internal cache. Drupal’s static caching...Hibernate Date vs Timestamp
I encountered a subtle hibernate mapping issue involving Dates and Timestamps. The following test recreates this issue. package com.sourceallies.logging; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; import java.util.List; import javax.annotation.Resource; import org.apache.commons.lang.time.DateUtils; import org.hibernate.Criteria; import org.hibernate.SessionFactory; import org.hibernate.classic.Session; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; import com.sourceallies.Person; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @TransactionConfiguration(defaultRollback=false) public class HibernateDateTimeTest { @Resource ...Hibernate Logging
Through the years I've encountered a recurring requirement. Partners need to log changes to the database for auditing and legal purposes. To satisfy this requirement you could add logging to every save/update/delete call in your code. Or better yet, you could create an aspect that wraps these...Back to Basics: hashCode() & equals()
So we all know that if we implement equals() we must override hashCode() too. But why? The best explanation of this commandment can be found in Effective Java (2nd Edition) starting on page 45. If you're like me, you like to see a problem in running code....Next Step in Agility
I often find that teams that have adopted Agile practices quickly plateau. They often start by scheduling a daily stand up, planning in iterations, take time for a retrospective, and modify their estimation process. These are common first steps in the agile adoption process. Teams have varied success and commitments...Learning a new Language
I attended a No Fluff Just Stuff Symposium a few weeks ago. One of the main emphasis during the weekend was learning new languages that are available on the JVM. While there are a variety of reasons that we need to take time to learn new programming languages, one of...Spring Injection with @Resource, @Autowired and @Inject
Annotations public interface Party { } 'Person' is a component and it implements 'Party'. package com.sourceallies.person; ... @Component public class Person implements Party { } 'Organization' is a component and it implements 'Party'. package com.sourceallies.organization; ... @Component public class Organization implements Party { } I setup a Spring context that scans both of these packages for beans marked with '@Component'. <context:component-scan base-package="com.sourceallies.organization"/> <context:component-scan base-package="com.sourceallies.person"/> @Resource private Party party;</pre> ```java @Autowired private Party...Debugging memory leaks with VisualVM
At work I had run into a memory leak when scrolling through large result sets returned from Hibernate. I thought I had fixed it by performing a evict()/clear()/flush() in the HibernateTemplate that I was using but suddenly the leak was back. I was using VisualVm to monitor the...