Embracing the Messiness in Search of Epic Solutions

Tag: Groovy

  • Spring + Ehcache: XML-less Spring Configuration for Ehcache 2.x vs Ehcache 3.x

    BACKGROUND The documentation on the web regarding Ehcache 3.x configuration using Spring is rather lacking. There is apparently a very distinct difference in Spring Java-based configuration between Ehcache 2.x vs Ehcache 3.x. Spring + Ehcache 2.x Dependency:- Spring configuration:- Spring + Ehcache 3.x Dependency:- Spring configuration:- Read More…

  • Groovy: Log Annotation

    PROBLEM My personal goal of 2017 is to write less useless-yet-neccessary code, such as initializing a logger:- SOLUTION Groovy provides several useful annotations that allow us to inject a logger instance into the class. Here’s a rewrite of the above example:- If we insist of using the same variable ( LOGGER ), we can do… Read More…

  • LdapTemplate: javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name ‘…’

    BACKGROUND Let’s assume we have the following LDAP configuration… When running any LDAP query, the following exception is thrown:- SOLUTION There are 3 solutions to this problem. Query against Gobal Catalog To prevent the referral issues when dealing with Active Directory, we may query against the Global Catalog by using port 3268. The possible downside… Read More…

  • LdapTemplate: AttributesMapper vs ContextMapper

    BACKGROUND When using Spring’s LdapTemplate, there are two ways to transform the queried results: AttributesMapper and ContextMapper. Here’s the comparison between these mapper classes. AttributesMapper If you are migrating your existing LDAP queries to Spring’s LdapTemplate, AttributesMapper seems ideal because you can copy most of the code over because it provides javax.naming.directory.Attributes. However, you have… Read More…

  • Spring: Component Scan Selected Classes

    PROBLEM Let’s assume we have a package with the following classes where each class is either annotated with Spring’s @Service, @Component, @Controller or @Repository. When writing unit test, we want Spring to component scan class A and class B. SOLUTION Before we begin, we configure Log4j to log Spring in debug level. Step 1 If… Read More…

  • Guava: Testing equals(..) and hashcode(..)

    PROBLEM Let’s assume we want to test the following equals(..):- A correctly implemented equals(..) must be reflexive, symmetric, transitive, consistent and handles null comparison. In another word, you have to write test cases to pass at least these 5 rules. Anything less is pure bullshit. SOLUTION You can write these tests yourself… or you can… Read More…