Tuesday, September 18, 2012

How to Avoid Getter and Setter Methods in JAVA, JSF and any POJO's

The lombok java utility helps to avoid getter and setter methods in java, especially in JSF and any POJO's 

After Installing it (very simple 2 click process) and add the same jar to your project's classpath.

Here is an example of how to avoid getters and setters in java using lombak.jar , scala does that but just to avoid getters and setters this utility is more than enough.

public class Person{
public String name;
public int age;
public int getAge(){
   return this.age;
public void setAge(int argAge){
 this.age = argAge;
//[...] Other Getters and Setters HERE.

To convert the POJO use the "@Data" annotation as follows. 

@Data public class Person{
   public String name;
   public int age;
That's it deploy / code / refactor / life is short - Enjoy!

  • There are more handy and specific annotations head over to the website.
  • Reduces all the noisy clutter methods in the class, no need for the lombak jar to be present during runtime.
  • Works like magic with IBatis & JRebel also!
  • Your IDE still sees the getter and setter methods as though they exist. (Atleast in eclipse it does for me! )
  • Reduces the code size of the project by at least 30%. 

Many Thanks to the lombak team!

Thursday, April 19, 2012

JMS Jboss behind NAT firewall

JMS clients like swing or remote clients were unable to connect to the JBOSS server because of random ports and the ip address of the machine which was not the same as the internal ip address of the machine from the cloud provider. When JBOSS starts it has to bind with the ip address of

  1. Open inbound port 443, the JMS client was unable to connect to the server.
  2. The following ports were opened on inbound.
    • 8083, and 8093
    • 8080,
    • 1098-1099,
    • 8009,
    • 4444-4445 & 4457
  3. Once the above ports were opened, the JMS client is able to connect to that IP address.
  4. At this point the server basically returns the host name (name of the box devjmsserver) , since that was not a FQDN like devserverjms.domain.com it failed. 
    1. For this reason a host name was created and a subdomain under the main domain was created to point to this public ip address.
  5. The FQDN now created was devserverjms.maindomain.com
    • Still the JMS client is not able to connect to the server.
  6. On the server listing all the ports that the jboss server was listening to, it picked random ports greater than the >1024 < 65000
    1. netstat -tulnp will list all the ports
  7. The jboss server on startup assigns random ports, we have to “fix” the ports that the server is listening to. 
    1. For this we have to edit the /home/jboss/jboss-5.1.0.GA/server/default/deploy/messaging/remoting-bisocket-service.xml and edit the serverBindProperty and serverConnectorProperty to a fixed non clashing port, for this test environment we gave it as 7914.
  8. Now running the client it is able to resolve and connect to it and send messages to that server.

Wednesday, March 14, 2012

Cassandra super column

An excellent article on Cassandra super column


From cassandra learning resources at this link.


Monday, March 12, 2012

MySQL Group_concat (transposing rows into columns)

To find out the columns in a table in mysql where you might need it programatically. You can use the information schema.

 SELECT group_concat(column_name) as columnNames

 FROM information_schema.columns




This would produce the  output as a single row instead of columns.


The group_concat transposes a result set from rows into columns, which is very ideal and can save some compute logic on the application side.