Spring Integration: A lightweight integration Approach

Today’s application expects access of all business in enterprise environment regardless of application technologies, which require, seamless integration with desperate systems.
This integration can be achieved through wiring of desperate systems using Middleware technologies. Continue reading

Advertisements

Java Version History

Java Version History
Thought to share some of the old Java version released
New features in Java SE 7
Code named Dolphin and released on July 28, 2011.
  • Strings in switch Statement
  • Type Inference for Generic Instance Creation
  • Multiple Exception Handling
  • Support for Dynamic Languages
  • Try with Resources
  • Java nio Package
  • Binary Literals, underscore in literals
  • Diamond Syntax
New features in Java SE 6
Code named Mustang and released on December 11, 2006
  • Scripting Language Support
  • JDBC 4.0 API
  • Java Compiler API
  • Pluggable Annotations
  • Native PKI, Java GSS, Kerberos and LDAP support.
  • Integrated Web Services.
  • Lot more enhancements.
New features in J2SE 5.0
Code named Tiger and released on September 30, 2004.
  • Generics
  • Enhanced for Loop
  • Autoboxing/Unboxing
  • Typesafe Enums
  • Varargs
  • Static Import
  • Metadata (Annotations)
  • Instrumentation
New features in J2SE 1.4
Code named Merlin and released on February 6, 2002 (first release under JCP)
  • XML Processing
  • Java Print Service
  • Logging API
  • Java Web Start
  • JDBC 3.0 API
  • Assertions
  • Preferences API
  • Chained Exception
  • IPv6 Support
  • Regular Expressions
  • Image I/O API
New features in J2SE 1.3
Code named Kestrel and released on May 8, 2000.
  • Java Sound
  • Jar Indexing
  • A huge list of enhancements in almost all the java area.

New features in J2SE 1.2

Code named Playground and released on December 8, 1998.

  • Collections framework.
  • Java String memory map for constants.
  • Just In Time (JIT) compiler.
  • Jar Signer for signing Java ARchive (JAR) files.
  • Policy Tool for granting access to system resources.
  • Java Foundation Classes (JFC) which consists of Swing 1.0, Drag and Drop, and Java 2D class libraries.
  • Java Plug-in
  • Scrollable result sets, BLOB, CLOB, batch update, user-defined types in JDBC.
  • Audio support in Applets.

New features in JDK 1.1

  • JDBC (Java Database Connectivity)
  • Inner Classes
  • Java Beans
  • RMI (Remote Method Invocation)
  • Reflection (introspection only)

JDK Version 1.0

Codenamed Oak and released on January 23, 1996.
Wishing you a happy new year!

Java Kicks Ruby on Rails in the Butt

Java Kicks Ruby on Rails in the Butt
— “What would you think if I told you that you can develop a web application at least ten times faster with Rails than you can with a typical Java framework?” Oops! Ten times faster! Well, after these comments I decided to learn Ruby on Rails. I need to know the true key of the productivity and programmer happiness.

Class member variable initialization

While declaring the class member variables we have to be very confident about the behavior of the member variables. For example some variable are constant and will be same across the class life cycle and some are instance variables which will be tightly bind with the object (instance) of the class.

When an instance of a class is created using new, initialization of the class’s instance variables create for each unique instance.

Always use the static for the member variable which doesn’t change across the objects of the class.

I would try to check the performance using the below code sample:

public class TestClassVariable {

public TestClassVariable() {

// do nothing

}

public String country[] = { “India”, “USA”, “China”, “UK” };

public static void main(String s[]) {

long start, end;

int[] a = new int[1000000];

start = System.currentTimeMillis();

for (int j = 0; j length; j++) {

TestClassVariable tstClassVar = new TestClassVariable();

}

end = System.currentTimeMillis();

System.out.println(end – start + ” “

+ ” milli seconds execution time”);

}

}

Result: 94 milli seconds execution time

In the above code we used country as class instance variable and it takes 94MS but as we know country could be make as static member variable because it will be not going to change across the instances so the correct way to use as static member variable.

So we can change the program slightly and see the figures again


public class TestClassVariable {

public TestClassVariable() {

// do nothing

}

public static String country[] = { “India”, “USA”, “China”, “UK” };

public static void main(String s[]) {

long start, end;

int[] a = new int[1000000];

start = System.currentTimeMillis();

for (int j = 0; j length; j++) {

TestClassVariable tstClassVar = new TestClassVariable();

}

end = System.currentTimeMillis();

System.out.println(end – start + ” “

+ “milli seconds execution time”);

}

}

Result: 16 milli seconds execution time

We could easily figure it out the performance get enhance 6 times then the original one



Calling object inside the loop

We could use to create the object inside or outside of the loop depends upon the behavior of the class.
If any class having class member variable then class needs to be inside the loop and that will limit their scope which is good to garbage collect but if class used as Utility class and doesn’t have member class variable then we could declare the class out side of the loop and used inside the loop.
Below example shows there are only 32 ms would take to instantiate the object inside the loop but best thing is that it would limit the scope which is good during garbage collection

public class TestLoop {
public static void main(String s[]) {
long start, end;
int[] a = new int[1000000];
start = System.currentTimeMillis();
TestName tname1 = new TestName();
for (int i = 0; i
// tname1=new TestName();
}
end = System.currentTimeMillis();
System.out.println(end – start + ” milli “
+ “seconds for One Time Loop”);
start = System.currentTimeMillis();
for (int j = 0; j
TestName tname = new TestName();
}
end = System.currentTimeMillis();
System.out.println(end – start + ” “
+ “milli seconds loop calling object inside Loop “);
}
}
Result: 0 milli seconds for One Time Loop
32 milli seconds for loop calling object inside Loop

As per above example you could see the declaring the object inside loop doesn’t have much impact on performance.

In below example explain the two ways to declare the object option 1 inside declaration and option 2 out side declaration.

Option 1:
for (int i=0; i
{
Object obj = tempList.get(i);
o. doOperation();
}
Option 2:
Object o;
for (int i=0; i
{
o = tempList.get(i);
o.doOperation();
}

We could say that Option1 better as it restricts scope of ‘obj’ variable to the for block. From a performance perspective, it might not have any effects in Java, but it might have in lower level compilers. They might put the variable in a register if you do the first.
Construction of an object using new is totally different from just declaring it, of course.
I think readability is more important than performance and from a readability standpoint, the first code is definitely better.
But if you have utility class which doesn’t have member variables we could instantiate once and reuse across the code.

In the below example I am trying to explain the utility class which could be instantiate once and use across the application.

import java.util.Calendar;
import java.util.Date;
public class TestLoop {
public static void main(String s[]) {
long start, end;
int[] a = new int[1000000];
Calendar cal = Calendar.getInstance();
start = System.currentTimeMillis();
for (int i = 0; i
Date dt = cal.getTime();
}
end = System.currentTimeMillis();
System.out.println(end – start + ” milli “
+ “seconds for Instantiating object out side Loop”);
start = System.currentTimeMillis();
TestName tname = null;
for (int j = 0; j
Date dt = Calendar.getInstance().getTime();
}
end = System.currentTimeMillis();
System.out.println(end – start + ” “
+ “milli seconds Instantiating object inside Loop “);
}
}
0 milli seconds for Instantiating object out side Loop
797 milli seconds Instantiating object inside Loop