Pages

Thursday, November 28, 2013

Monday, November 18, 2013

Considerations on using thirty party libraries to build your application.

Have you ever thought twice when you use a third party java library to implement your system? Well you should. Some of the reasons are
  1. Is the community active.(fix bugs pitfalls, and other aspects)
  2. Licensing
  3. Using many number of libraries many cause increase in dependencies on third parties.
  4. Some bugs in your system may be because of a third party library.
  5. Updating resources in the system(OS, jre, etc...) may cause the system to break and then we will have to replace the library with the updated one if exists, replace the library with another third-party software, folk the software and fix it, or re-implement the functionality by our own.
Having said that we still do need third party libraries in almost all implementations. But keeping these dependencies to a minimum is very important because of the above said reasons.

Sunday, November 17, 2013

spring webflow Introduction

What issues does spring webflow help overcome?

  1. Visualizing the flow is very difficult.
  2. The application has a lot of code accessing the HTTP session.
  3. Enforcing controlled navigation is important but not possible.
  4. Proper browser back button support seems unattainable.
  5. Browser and server get out of sync with "Back" button use.
  6. Multiple browser tabs causes concurrency issues with HTTP session data.
When spring webflow?
  1. There is a clear start and an end point.
  2. The user must go through a set of screens in a specific order.
  3. The changes are not finalized until the last step.
  4. Once complete it shouldn't be possible to repeat a transaction accidentally

How to avoid N + 1 problem in hibernate?

Wednesday, November 13, 2013

Sunday, November 10, 2013

Message broker or ESB?

Which one would you like to work with? or which one best suits with your requirement? Well in old traditional conceptions about both let me point out some key features.

A message broker is centralized (hub-spoke architecture) while an esb is not. Therefore a broker is a single point of failure. Again another fact is that a broker is only able vertical scaling and is unable to scale horizontally.

These are some articles I found on internet that describe this matter.

  1. http://bradleyboveinis.com/2013/03/27/bus-vs-broker/
  2. http://codebetter.com/drusellers/2009/05/29/why-messaging-5-bus-vs-broker/
  3. http://msmvps.com/blogs/peterritchie/archive/2011/09/18/enterprise-service-buses-brokers-message-queues-oh-my.aspx
So the most popular and the winner seems to be the bus architecture.

Some popular opensource esbs are
  1. Mule
  2. Apache Synapse
  3. Apache service mix
  4. wso2 esb

There are some other software the enterpise integration patterns such as spring integration, apache camel. Now are they also called messaged brokers or esbs? Well you can think of them as just libraries that help to integrate enterprise software using enterprise integration patterns. Below is a link I found that addresses this matter.

Saturday, November 9, 2013

Object pooling with spring framework

This can be done using the following simple code.

<bean id="simpleBeanTarget" class="com.mad.SimpleBean" scope="prototype">
</bean>

<bean id="poolTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">               <property name="targetBeanName" value="simpleBeanTarget" />
            <property name="maxSize" value="20" />
</bean>

<bean id="simpleBean" class="org.springframework.aop.framework.ProxyFactoryBean">
           <property name="targetSource" ref="poolTargetSource" />
</bean>

here the simpleBeanTarget is the bean which is pooled. poolTargetSource is the pooling  bean for the simple bean tareget.

Http client library for java

I've been searching for a java http client for one of my projects. then I came across a simple library called jakartha commons client. As it turns out, this library is at it's end of life. So I was wondering a good library implementation of http client. After many tryouts, it seems apache http components is the go to library for general needs of http client.

http://hc.apache.org/

However if you are a spring user, then spring also provides facilities for http client requests.
http://docs.spring.io/spring/docs/3.0.x/api/org/springframework/http/client/package-summary.html

Having said that, the scope of this implementation is very limited. So my personal preference is apache http components over spring implementation, unless the requirement is very basic.


Tuesday, November 5, 2013

Integration with apache camel

Want to get your hands on apache camel ? Visit the following link. It guides you to creating a nice spring integration project. This is a tutorial with 2 posts.

http://vrtoonjava.wordpress.com/2013/10/20/apache-camel-developing-application-from-the-scratch-part-1-2/

Another detailed project tutorial could be found in the following link.
http://camel.apache.org/tutorial-example-reportincident.html

A spring integration example

Want to get your hands on a spring integration example ? Visit the following link. It guides you to creating a nice spring integration project. This is a tutorial with 2 posts.

http://vrtoonjava.wordpress.com/2013/03/03/spring-integration-developing-application-from-the-scratch-part-1-2/


Show heap status in eclipse

This is very easy.
Go to windows->preferences then under general tab, there is a checkbox to show/hide head status.

Monday, November 4, 2013

Reasons for error The matching wildcard is strict, but no declaration can be found for element

This error messages can be found for two reasons.

  1. If you use a trailing slash in the schema location or name space. eg: http://www.springframework.org/schema/beans/       remove the slash to recorrect it
  2. if you do not metion version in it. eg: http://www.springframework.org/schema/integration/spring-integration.xsd instead use http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.2.xsd
This way you can get rid of the above error in the spring xml files.

Apache commons Net

Apache commons net is a library for client side for many internet protocols. some of the main protocols supported are


  1. FTP
  2. SMTP/POP3
  3. IMAP
  4. TELNET
  5. WHOIS
  6. FINGER
An example on how to send an email through this library can be found in this post.

Sunday, November 3, 2013

What is your structure of a web project?

What is your structure of JEE based web projects? See the following link. It will give you some tips on how to organize your classes in packages and maintain view files.

http://www.javacodegeeks.com/2013/11/what-is-your-structure-of-jee-based-web-projects.html

Batch Processing best practices

I came across a nice and a clean article that describes about best practices on batch processing. Thought these could be very important at some point of your career. Visit the following link.

http://java.dzone.com/articles/batch-processing-best

Setting up your application server with maven

SOA coordination and service discovery with apache zookeeper

When you scale an application that operates as a service, you need to track the number of services, information about the web services you are offering , how many instances of the same web service etc...

Say for an example we have deployed many instances of the same service and they are distributed. Then a client wants to use the service and wants to use one instance to perform the request. Then you could use Apache zookeeper to auto discover all the instance and pick up one to get the result.

In simple terms what it does is coordination and service discovery. You could find a good simple example on how to do this using the following link.

http://www.javacodegeeks.com/2013/11/coordination-and-service-discovery-with-apache-zookeeper.html

A good explanation on this can be found using the following article.
http://zookeeper.apache.org/doc/trunk/zookeeperOver.html

Official site of the software is at
http://zookeeper.apache.org/

Hazzlecast

Hazzlecast enables you to write in memory applications. Imagine that you have an application that is clustered and each instance needs to know about data in other applications without using data bases. This scenario is addressed by hazzlecast. It provides java developers an easy-to-use and powerful solution for data distribution that can be used as a clustering solution, a distributed cache and a NoSQL key-value store.

A simple example on how to use this system is explained in the following link.

http://www.javacodegeeks.com/2013/11/getting-started-with-hazelcast.html

Java lambdas

Java lambdas is a powerful feature that comes with java 8. The idea is, this is an anonymous function( has no identifier) that can be passed as method parameters  (Bit like javascript functions that can be passed as arguments to a function).  These are also called first class functions. An article on explaining this concept can be found here.

http://java.dzone.com/articles/java-lambda-expressions-basics

Graph data bases

Have you heard about graphical representation of data. Recently I came across a technology called graph databases. The idea is to represent data and relationships in a graph. An example of an implementation of such data bases is neo4j. A simple explanation on this phenomenon is given on the following link.

http://player.vimeo.com/video/56040747#t=0m14s