[JBoss Seam] - Re: howto display the an enum object internationalized
by knaas
What we did was to create an EnumConverter that uses the resource bundle for internationalization. We just defined a convention "packagename.classname.enumvalue=Some text".
If we find something in the resource bundle, use it, otherwise just use the toString value of the enum.
Something like this code.
|
| @Override
| public String getAsString(final FacesContext context, final UIComponent component, final Object object) throws ConverterException
| {
| String retVal = null;
| if (object instanceof Enum)
| {
| Enum instance = (Enum)object;
| final String resourceKey = instance.getClass().getName() + "." + instance.name();
| try
| {
| retVal = ResourceBundle.instance().getString(resourceKey);
| }
| catch (MissingResourceException e)
| {
| //Ignore
| }
| if (StringUtils.isEmpty(retVal))
| {
| retVal = instance.name();
| }
| }
| return retVal;
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071203#4071203
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071203
18Â years, 8Â months
[JBossCache] - Data integrity in a clustered jboss cache
by itchy75
Hello,
Im' using JBoss Cache (tree cache) in a cluster environment. I try to do the following tings :
1. get a value from the cache = get(Fqn, key)
2. modify this value
3. put the value in cache = put(Fqn, key, value)
I use SERIALIZABLE isolation level and PESSIMISTIC lock.
The problem is when two programs running on differents servers modify the value at the same time.
| Server 1 Server 2
| x = getvalue();
| x++ x =getValue();
| put x in cache x++
| put xin cache
|
If the value was bound to 0, it should be 2 at the end (serializable) but x=1 at the end of the execution.
The questions are :
- How could I serialize an operation in a clustered cache (ie reading/modify/persist a value in cache) ? I try to manage the transaction myself with transaction manager but it doesn't work.
- I also understood from documentation that SERIALIZABLE isolation level lock the node when you read or write value in the cache. I am using jboss cache in a spring context and no transaction attributes are defined. In this case, when the transaction is initialized/commited if I use SERIALIZABLE is used ?
- Is it possible to use spring to declare a cache transaction on classes' method ?
Thanks a lot.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4071200#4071200
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4071200
18Â years, 8Â months