[jboss-user] [JBoss Seam] - Re: ResourceBundle in Database

pbrewer_uk do-not-reply at jboss.com
Fri May 4 11:00:22 EDT 2007


I have implemented a database resource bundle using entities in Seam - its too verbose to post, but here are the steps to implement it:

1. Create the entity beans/ tables. To accurately match the ResourceBundle concept, I created a Resource Bundle table and a child Resource Message table (see below)

2. Have a look at (in addition to the links provided by Udo):
http://java.sun.com/developer/JDCTechTips/2005/tt1018.html#2
http://java.sun.com/javase/6/docs/api/java/util/ResourceBundle.html

3. Implement a DBContol (to control caching of the resource bundle) and create a DBResourceBundle that is a subclass of java.util.ResourceBundle to load the data from your entities.

4. Override the "org.jboss.seam.core.resourceBundle" component to use the DBControl and DBResourceBundle.

5. Override the "org.jboss.seam.core.messages" component to avoid indefinite caching of the resource bundle - caching will now be done by your DBControl created in step 3.

6. You may also need to override the "org.jboss.seam.theme.themeSelector" component to look at your DBControl / DBResourceBundle.

7. Update your components.xml to use the "component" tag instead of "core:XXX" tags for the overridden seam components.

Table layout:

  | create table RESOURCE_BUNDLE
  | (
  |   BUNDLE_ID     NUMBER(19) not null,
  |   LANGUAGE      VARCHAR(2),
  |   COUNTRY       VARCHAR(2),
  |   VARIANT       VARCHAR(50),
  |   BASE_NAME     VARCHAR(500) not null,
  |   LAST_MODIFIED DATE, -- can use this on the DBControl to clear cache
  |   IB_DESCRIPTION   VARCHAR(50)
  | )
  | 
  | create table RESOURCE_MESSAGE
  | (
  |   MESSAGE_ID VARCHAR(10) not null, -- PK
  |   BUNDLE_ID  VARCHAR(10) not null, -- FK to RESOURCE_BUNDLE
  |   KEY        VARCHAR(500) not null,
  |   VALUE      VARCHAR(4000) not null
  | )
  | 

Hope that helps a little, Pete.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043237#4043237

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043237



More information about the jboss-user mailing list