Hi James, finally it worked , but I haven't tested completely , but it seems it will be okey :))
inside my factory class firstly I used "MessageResourcesFactory.createFactory().createResources(config)" code fragment to create file based MessageResource object of Struts , but it didn't worked correctly, actualy it caused infinite loop in my factory class, I think MessageResourcesFactory.createFactory() returns same same instanse of my factory class, again and again calling same method on same instance,, I dont know exatly why , insted of "MessageResourcesFactory.createFactory().createResources(config)" I decided to use MessageResourcesConfig to get factory class, this code segment copied from initMesssageResources method of ActionServlet, it seem it works !!!!!! Craig if you read this lines , is this way okey , are there any better way to create struts messageResources object ??? another problem is how can I access message properties from my factory class, only config parameter is accessible , I want to use a message property to decide which kind of MessageResource will be created !!! to do this I am currently using config parameter, *********************MY FACTORY CLASS ******************************* *********************MY FACTORY CLASS ******************************* *********************MY FACTORY CLASS ******************************* public class TebMessageResourcesFactory extends MessageResourcesFactory { public MessageResources createResources(String config) { if (config == null || "Database".equalsIgnoreCase(config) || "VeriTabani".equalsIgnoreCase(config) ) // return own MessageResources object that reads messages from DATABASE return new TebMessageResources(this, config, this.returnNull); else { // return struts MessageResources object that reads messages from FILE SYSTEM MessageResourcesConfig messageResConfig = new MessageResourcesConfig(); String factory = messageResConfig.getFactory(); MessageResourcesFactory.setFactoryClass(factory); MessageResourcesFactory factoryObject = MessageResourcesFactory.createFactory(); return factoryObject.createResources(config); } } *********************END OF MY FACTORY CLASS ******************************* *********************END OF MY FACTORY CLASS ******************************* *********************END OF MY FACTORY CLASS ******************************* Looks good to me. -- James Mitchell Software Engineer / Struts Evangelist http://www.struts-atlanta.org 770-822-3359 AIM:jmitchtx > -----Original Message----- > From: Seyhan BASMACI (Internet Yazilimlari Yetkilisi) > [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 07, 2003 10:18 AM > To: James Mitchell > Cc: Struts Users Mailing List > Subject: RE: is there any way to load Message Resources from > back-end database instead of properties files? > > > hi James , I am still working on it , but I have a simple question , > beside database based MessageResources, I still want to use > present file based MessageResources feature of struts(in the > case of any problem with my message code), > I am using config parameter to specify which kind of > Message will be created , > if the config parameter is not database , to create > struts message resources I am using > > "MessageResourcesFactory.createFactory().createResources(config) " , > > is that correct???? or enough to do this ? > > > /************ here is code fragment ********/ > > public class TebMessageResourcesFactory extends MessageResourcesFactory > > > public MessageResources createResources(String config) { > > if (config == null || "Database".equalsIgnoreCase(config) ) > > // return own MessageResources class that reads > messages from DATABASE > > return new TebMessageResources(this, config, > this.returnNull); > > else > > // return struts MessageResources class that reads > messages from FILE SYSTEM > > return > MessageResourcesFactory.createFactory().createResources(config); > } > > > > -----Original Message----- > From: James Mitchell [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 06, 2003 2:12 PM > To: Seyhan BASMACI (Internet Yazilimlari Yetkilisi) > Cc: Struts Users Mailing List > Subject: RE: is there any way to load Message Resources from back-end > database instead of properties files? > > > > we have own tables that holds locations, resources and messages, > > I have a persistent class that gets all data from database. > > I need is a class that extends the class that reads messages > > from properties files, override the method that reads from disk file, > > You need 2 classes minimum. > > public class MyMessageResourcesFactory extends MessageResourcesFactory { > public MessageResources createResources(String config) { > return new MyMessageResources(this, config, this.returnNull); > } > } > > public class MyMessageResources extends MessageResources > implements Serializable { > public MyMessageResources(MessageResourcesFactory factory, String > config) { > this(factory, config, false); > } > public MyMessageResources(MessageResourcesFactory factory, String > config, boolean returnNull) { > super(factory, config, returnNull); > } > > public String getMessage(Locale locale, String key) { > //call your DAO here > } > } > > You would tell Struts to use your implementation by configuring it in the > struts-config: > > <message-resources > factory="com.company.project.whatever.MyMessageResourcesFactory" > parameter="{whatever you put here is passed to the > factory as 'config'}"> > </message-resources> > > > My hack for supporting multiple keys and Modules was to use the > parameter to > designate alternate keys and/or modules. > > Let me know if that helps you. > > > -- > James Mitchell > Software Engineer / Struts Evangelist > http://www.struts-atlanta.org > 770-822-3359 > AIM:jmitchtx > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]