Pure-Essence.Net

Posts Tagged ‘java

Java concurrency – Multiple queue monitors

Posted by: pureessence on: June 25, 2011

At work, I’ve implemented a queue monitor batch application. Due to business rule changes, it now needs to monitor two queues. Instead of creating another batch application, I really wanted to stick with the same application but just create two threads, each monitoring its own queue. However, the twist I need is to have the [...]

Grails: I will not use you

Posted by: pureessence on: June 8, 2011

After the cijug presentation on Grails, I’ve decided I will not use it. I know Grails is hot and cool but I don’t like it. It’s probably just a personal preference. Why don’t I want to use Grails It’s built on spring and hibernate, so why not just use them directly? It’s just adding another [...]

Dynamically invoke methods using spring config

Posted by: pureessence on: March 25, 2011

A business rule at work requires some flexible configurations. I attempted to fulfill the need by create different spring batch steps/tasklets to execute each requirement based on a property value. For example, step 1 will need to execute methodOne on the class Repository with the appropriate parameters. The method signature & parameters are determined by [...]

itext page number (page x of y)

Posted by: pureessence on: November 14, 2010

I was looking for a complete example of how to dynamically generate the page numbers when you create the pdf using iText and I couldn’t find one. This is based on the example in the iText in Action book but I added my “refactoring” if you will. I hope this helps someone. If not, it [...]

Java instaniate an abstract class… sort of…

Posted by: pureessence on: August 27, 2010

At work I had to create some test data for a junit test. The function I’m testing expects a super abstract class to be passed in and I need to test the same function for bunch of child classes. I wish I could just pass in the parent class but since it’s abstract I cannot [...]

Setting private property without setter in Java

Posted by: pureessence on: August 25, 2010

Not really a new trick but I had to look for the syntax today to use reflection to set a private property on an object to use it in a junit test.

Java: BETTER way to traverse a map

Posted by: pureessence on: March 12, 2010

While reviewing the findbugs report (WMI_WRONG_MAP_ITERATOR) for a new project at work, I learned a better way to traverse a map in Java. In fact, since the first day I started coding in Java, I never thought twice about how to traverse a map. You always traverse the keys and use the key to get [...]

Java List/Array syntax

Posted by: pureessence on: December 30, 2009

Something I always forget, a shortcut array syntax for Java:

Java: static declaration of collection

Posted by: pureessence on: December 17, 2008

I don’t know if this is a new feature in Java 5 that I did not know before or I just did not know this is possible in Java. But I learned today that you can do static declaration of collection types as below:

Eclipse run java code easily

Posted by: pureessence on: December 11, 2008

Eclipse has a scrapbook function that allows you to run Java code on the fly. Sometimes you just want to test out a simple piece of code without having to create another Java class, execute it in the main method or create a junit to test it out. For example, today I wanted to make [...]


My most adorable Pomeranians

Categories

Archives

SocialVibe


Follow

Get every new post delivered to your Inbox.