[JBoss Seam] - Seam messages and containsKey
by damianharvey
I had a bit of a performance problem with some pages that I have tracked back to my use of '.containsKey()' on the Seam messages Abstract Map.
eg:
| @In
| Map<String, String> messages; //This is the Seam messages bundle
|
| public void aMethod() {
| if(messages.containsKey("key.mykey")) {
| //do something
| }
| }
|
As containsKey isn't a method of the AbstractMap in org.jboss.seam.international.Messages, it goes into a mad run through all sorts of methods (ELResolver, Pages.java etc). The result of this is that a containsKey() on messages takes over 800 times longer than a get(). For 1800 properties in my messages.properties file it takes about 800ms compared to under 1ms for a get().
Nice to have found this as I had no idea that it would have such an impact. The easy solution would be to add a containsKey() to the AbstractMap in org.jboss.seam.international.Messages. This works well for me (and is under 1ms):
| public boolean containsKey(String key) {
| if(messages.get(key).equals(key)) {
| return false;
| } else {
| return true;
| }
| }
|
Cheers,
Damian.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100622#4100622
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100622
17Â years, 2Â months
[JBoss Seam] - Handling exception
by finc
Hi,
I use Glassfish v2, Seam 1.2.1, JTA, TopLink, JPA.
When I try execute any methods which not commit, thow any exception, for example:
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`dostal/uzivatele_role`, CONSTRAINT `fk_role_name_uzivatele_role` FOREIGN KEY (`role_name`) REFERENCES `roles` (`role_name`) ON UPDATE CASCADE)
Error Code: 1451
How I can handle this transaction exception?
I want in view show that action isn't access. Now exception throw only in server console.
I want use some localization. For example: Error Code is 1451 = Cannot insert because....
Thanks all!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100618#4100618
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100618
17Â years, 2Â months