Thursday, January 8, 2015

Finally Enabling multiple logon for the same user | Available from Fix pack 9

This was something that was not available for a long time but with the new fix pack. This is available. I might have an old blog where i had mentioned, it was not available in the previous versions.

Many WebSphere Commerce websites are using REST services to serve both mobile and desktop pages then it's important to allow multiple logon for the same user from different channels in a simple way. To activate this feature a specific tag should be added to the wc-server.xml in the SessionManagement section

<allowmultiplelogonforsameuser display="false" enabled="true"></allowmultiplelogonforsameuser>

Tuesday, January 6, 2015

Performance Improvements StringBuilder and ArrayList and HashMap

Use StringBuilder if Synchronization is not required.

I have used StringBuffer when performing concatenations on string and is far better than using Immutable Strings in Java but if you don't need the synchronization, which most likely could be the case so use StringBuilder

Quote from StringBuilder API:
This class [StringBuilder] provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations.

Using ArrayList vs LinkedList

LinkedList is great when you don't know the size of the list as it helps.

The default initial capacity of an ArrayList is pretty small (10 from Java 1.4 - 1.7).
But since the underlying implementation is an array, the array must be re-sized if you add a lot of elements.
To avoid the high cost of resizing when you know you're going to add a lot of elements, construct the ArrayList with a higher initial capacity. What's important is to initialize the list when you know upfront the size of the ArrayList and if it is going to be more than 10

List catalogDataVOList = new ArrayList<CatalogDataVO>((int) resultCount);


Use HashMap vs Hashtable:
If Synchronization is not required use HashMap, Hashtable is a syncrhonized version and typically non synchronized objects perform better.