Sunday, January 9, 2011

Implement a simple cache with java

The class LinkedHashMap has the method removeEldestEntry() that is called before
put() method so here you can remove the eldest element from the cache.


Map mapCache = new LinkedHashMap()
{
@Override
protected boolean removeEldestEntry(Entry eldest) {
//remove after 2 hours
Calendar cal = Calendar.getInstance();
long howLongAgoInMs = System.currentTimeMillis()-eldest.getValue().lastTimeTouched;
long twoHoursInMs = 2 * 60 * 60 * 1000;
if(howLongAgoInMs > twoHoursInMs){
return true;
}
return false;
}
};

Saturday, January 8, 2011

SAP NWDS, Web Dynpro: Add Destination/R3 fails

Problem:
In the SAP Netweaver Developer Studio you want to add a Destination
Window->Preferences->Destinations->R3 Destinations.

Applys to: NWDS 7, Windows 7

Cause:

Solution:
-vm
C:\DEV\Java\jdk1.5.0_22\bin\javaw.exe
-showsplash
com.sap.netweaver.developerstudio
--launcher.XXMaxPermSize
256m
-vmargs
-Xmx512m
-Xms128m
-XX:PermSize=32m
-XX:MaxPermSize=256m
-Dfile.encoding=UTF-8
-Dosgi.requiredJavaVersion=1.5
-Dos.name='Windows XP'

SAP NWDI: concurrent-lock-denied check failed

Problem:
When trying to revert an activity you get the error:
concurrent-lock-denied check failed
See also:
http://forums.sdn.sap.com/thread.jspa?threadID=1805846&tstart=15

Solution:
Restart your J2EE Server where the NWDI is running.