You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ovidiu EFTIMIE <oe...@assemblee-nat.fr> on 2003/10/30 19:06:57 UTC

Connection pool and MessageRessources

Hi,
I'm working with Struts 1.1 and I have a problem with the MessageRessource and I
don't know to handle it  the right way.
In my application I have two constraints,among others :) ,
- i must use an oci connection to the database
- the error messages will be stored in the database
For that I took two aproaches :
## One ##:  I have written a Struts plugin which builds the connection pool, and
I've extended MessageRessourceFactory and MessageRessources with my own classes
DBRessourceFactory and DBRessource to have my own mechanism for message
retrivial. My problem is now how can I get a connection to the database from the
connection pool I've just made ? Is there a way to communicate between my plugin
and my DBRessource class ?


## Two ##: I make a class which will handle the connection pool creation and the
retrivial of messages from the database.
It will look like this :
public class MessagesDBPool extends MessageRessources implements
PlugIn,Serializable {
    public MessageDBPool (){
        super();
    }
    public MessageDBPool(MessageRessourcesFactory factory,String config){
        this(factory,config,false);
    }
    public MessageDBPool(MessageRessourcesFactory factory,String config,boolean
returnNull){
        super(factory,config,returnNull);
    }
    public void init(ActionServlet servlet, ModuleConfig config) throws
ServletException{
        //pool initialisation here
    }
    public void destroy(){
        //destroy pool here
    }
}
Can I do this in the first place ?

Now the question is which one of this two solutions can work? Is there another
way to do this ?
Any suggestions are welcome .

Thanks,
Ovidiu EFTIMIE




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Connection pool and MessageRessources

Posted by Ovidiu EFTIMIE <oe...@assemblee-nat.fr>.
The think is we're not using OJB for this application, but your struts extension
is very interesting  and i'll keep it in my mind for future projects.

Thanks for yout response
Ovidiu

----- Original Message ----- 
From: "James Mitchell" <jm...@apache.org>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Friday, October 31, 2003 4:13 PM
Subject: RE: Connection pool and MessageRessources


> > -----Original Message-----
> > From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > Sent: Friday, October 31, 2003 5:34 AM
> > To: Struts Users Mailing List
> > Subject: Re: Connection pool and MessageRessources
> >
> >
> > Hi James,
> > I've studied your solution, and I've noticed that you use a
> > different connection
> > to the database and not the one that should be availble in an struts
> > application, and I think that could be a point of failure.
>
> No, actually you have that part wrong.  See, my extension uses OJB which
> is configured from it's own xml file and not from the struts-config.xml.
>
> Using the existing API (without any special hacks), you have no
> way to pass a connection, the DataSourceConfig, or even get at
> the ModuleConfig from any subclass of MessageResources.  That's why my
> solution works without requiring any special coding.
>
> My extension is designed to run independently of your application's
> persistence mechanism(s), but if you happen to be using OJB, it's
> all good.
>
> Somewhere on my todo list, is to implement the same extension using each
> of the major ORM frameworks.  But like all things, it takes time, and
> since I can't put food on the table writing Struts extensions, it'll
> have to wait.
>
>
> >
> > That is why I'm
> > trying tu use the same connection pool as the rest of the application.
>
> If your app used OJB, you could do exactly that.
>
> >
> > Ovidiu
> >
>
>
> --
> James Mitchell
> Software Engineer / Struts Evangelist
> http://www.struts-atlanta.org
> 678.910.8017 (c)
> 770.822.3359 (h)
> AIM:jmitchtx
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Connection pool and MessageRessources

Posted by James Mitchell <jm...@apache.org>.
> -----Original Message-----
> From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr] 
> Sent: Friday, October 31, 2003 5:34 AM
> To: Struts Users Mailing List
> Subject: Re: Connection pool and MessageRessources
> 
> 
> Hi James,
> I've studied your solution, and I've noticed that you use a 
> different connection
> to the database and not the one that should be availble in an struts
> application, and I think that could be a point of failure. 

No, actually you have that part wrong.  See, my extension uses OJB which
is configured from it's own xml file and not from the struts-config.xml.

Using the existing API (without any special hacks), you have no 
way to pass a connection, the DataSourceConfig, or even get at 
the ModuleConfig from any subclass of MessageResources.  That's why my
solution works without requiring any special coding.

My extension is designed to run independently of your application's
persistence mechanism(s), but if you happen to be using OJB, it's 
all good.

Somewhere on my todo list, is to implement the same extension using each
of the major ORM frameworks.  But like all things, it takes time, and
since I can't put food on the table writing Struts extensions, it'll 
have to wait.


> 
> That is why I'm
> trying tu use the same connection pool as the rest of the application.

If your app used OJB, you could do exactly that.

> 
> Ovidiu
> 


--
James Mitchell
Software Engineer / Struts Evangelist
http://www.struts-atlanta.org
678.910.8017 (c)
770.822.3359 (h)
AIM:jmitchtx



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Connection pool and MessageRessources

Posted by Ovidiu EFTIMIE <oe...@assemblee-nat.fr>.
Hi James,
I've studied your solution, and I've noticed that you use a different connection
to the database and not the one that should be availble in an struts
application, and I think that could be a point of failure. That is why I'm
trying tu use the same connection pool as the rest of the application.

Ovidiu

----- Original Message ----- 
From: "James Mitchell" <jm...@apache.org>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Thursday, October 30, 2003 7:18 PM
Subject: RE: Connection pool and MessageRessources


> Hi Ovidiu
>
> I also wrote my own DBMessageResources.  With a simple hack, I was able
> to overcome the limitations of the existing API.
>
> The source code and example are available for download at:
>
>
> http://sourceforge.net/project/showfiles.php?group_id=49385&release_id=1
> 54972
>
>
>
> --
> James Mitchell
> Software Engineer / Struts Evangelist
> http://www.struts-atlanta.org
> 678.910.8017 (c)
> 770.822.3359 (h)
> AIM:jmitchtx
>
>
>
>
> > -----Original Message-----
> > From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > Sent: Thursday, October 30, 2003 1:07 PM
> > To: struts-user@jakarta.apache.org
> > Subject: Connection pool and MessageRessources
> >
> >
> > Hi,
> > I'm working with Struts 1.1 and I have a problem with the
> > MessageRessource and I
> > don't know to handle it  the right way.
> > In my application I have two constraints,among others :) ,
> > - i must use an oci connection to the database
> > - the error messages will be stored in the database
> > For that I took two aproaches :
> > ## One ##:  I have written a Struts plugin which builds the
> > connection pool, and
> > I've extended MessageRessourceFactory and MessageRessources
> > with my own classes
> > DBRessourceFactory and DBRessource to have my own mechanism
> > for message
> > retrivial. My problem is now how can I get a connection to
> > the database from the
> > connection pool I've just made ? Is there a way to
> > communicate between my plugin
> > and my DBRessource class ?
> >
> >
> > ## Two ##: I make a class which will handle the connection
> > pool creation and the
> > retrivial of messages from the database.
> > It will look like this :
> > public class MessagesDBPool extends MessageRessources implements
> > PlugIn,Serializable {
> >     public MessageDBPool (){
> >         super();
> >     }
> >     public MessageDBPool(MessageRessourcesFactory
> > factory,String config){
> >         this(factory,config,false);
> >     }
> >     public MessageDBPool(MessageRessourcesFactory
> > factory,String config,boolean
> > returnNull){
> >         super(factory,config,returnNull);
> >     }
> >     public void init(ActionServlet servlet, ModuleConfig
> > config) throws
> > ServletException{
> >         //pool initialisation here
> >     }
> >     public void destroy(){
> >         //destroy pool here
> >     }
> > }
> > Can I do this in the first place ?
> >
> > Now the question is which one of this two solutions can work?
> > Is there another
> > way to do this ?
> > Any suggestions are welcome .
> >
> > Thanks,
> > Ovidiu EFTIMIE
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Connection pool and MessageRessources

Posted by James Mitchell <jm...@apache.org>.
As far as what will happen in the future, Struts will be using Resources
from the commons sandbox (well, once it is released).

You should take a look over there for more ideas.

Thanks and good luck!!



--
James Mitchell
Software Engineer / Struts Evangelist
http://www.struts-atlanta.org
678.910.8017 (c)
770.822.3359 (h)
AIM:jmitchtx




> -----Original Message-----
> From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr] 
> Sent: Friday, October 31, 2003 11:30 AM
> To: Struts Users Mailing List
> Subject: Re: Connection pool and MessageRessources
> 
> 
> Yes I know it is very tighly integrated with Struts, and 
> actualy  we're comply
> with all things you've enumerated below.
>     The validator will not be used because all validation 
> will be done with
> javascript already present in the jsp page, and the only 
> server side validation
> we'll have will be to find out if the client has disabled 
> javascript, and  we'll
> not be using <bean:message> beacause we'll not have a multi 
> language site.
> 
> I know that my solution cannot be universally applied, and 
> it's just a way to
> overcome Struts limitations regarding the MessageRessources.
> I'll hope that in future versions something similar with your 
> extension could be
> integrated into Struts, because is a little bit frustrating 
> to manage error
> messages(for example) in two separate places (an Oracle table and
> application.properties as in my case).
> 
> Thanks for your response, and I hope Id didn't took a lot of your time
> 
> Ovidiu
> 
> ----- Original Message ----- 
> From: "James Mitchell" <jm...@apache.org>
> To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
> Sent: Friday, October 31, 2003 4:13 PM
> Subject: RE: Connection pool and MessageRessources
> 
> 
> > You might not be realizing just how deeply the MesageResources is
> > integrated with Struts.
> >
> > Your solution won't work if:
> >
> >   * your app is using the validator
> >
> >   * any of your jsp pages are using <bean:message>
> >
> >   * any of your jsp pages use tags that use MessageResources
> >     (which are any that use xyzKey such as srcKey,
> >      pageKey, altKey, etc)
> >
> >
> > As far as application modification goes, the extension I
> > created is a simple config change in struts-config, and voila!
> >
> >
> > --
> > James Mitchell
> > Software Engineer / Struts Evangelist
> > http://www.struts-atlanta.org
> > 678.910.8017 (c)
> > 770.822.3359 (h)
> > AIM:jmitchtx
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > > Sent: Friday, October 31, 2003 7:23 AM
> > > To: Struts Users Mailing List
> > > Subject: Re: Connection pool and MessageRessources
> > >
> > >
> > > I think I've found a solution.
> > > I'll make an object (eventualy a struts PlugIn), DBMessage
> > > which receivies a
> > > connection from my connection pool and retrives the error
> > > messages from the
> > > database, and this object will not extend MessageRessources.
> > > Then in my actions I'll have :
> > >
> > > DbMessage dbmesg = (DbMessage)servlet.getAttribute("DBMESG");
> > > String  message = dbmesg.getMessage("error_code");
> > > ActionErrors errors = new ActionError();
> > > errors.add("code",new ActionError("foo",message));
> > >
> > > where foo is defined in my application.properties as
> > > foo = {0}
> > >
> > > How that sounds ?
> > >
> > >
> > > Ovidiu
> > >
> > > ----- Original Message ----- 
> > > From: "James Mitchell" <jm...@apache.org>
> > > To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
> > > Sent: Thursday, October 30, 2003 7:18 PM
> > > Subject: RE: Connection pool and MessageRessources
> > >
> > >
> > > > Hi Ovidiu
> > > >
> > > > I also wrote my own DBMessageResources.  With a simple
> > > hack, I was able
> > > > to overcome the limitations of the existing API.
> > > >
> > > > The source code and example are available for download at:
> > > >
> > > >
> > > >
> > > http://sourceforge.net/project/showfiles.php?group_id=49385&re
> > > lease_id=1
> > > > 54972
> > > >
> > > >
> > > >
> > > > --
> > > > James Mitchell
> > > > Software Engineer / Struts Evangelist
> > > > http://www.struts-atlanta.org
> > > > 678.910.8017 (c)
> > > > 770.822.3359 (h)
> > > > AIM:jmitchtx
> > > >
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Ovidiu EFTIMIE 
> [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > > > > Sent: Thursday, October 30, 2003 1:07 PM
> > > > > To: struts-user@jakarta.apache.org
> > > > > Subject: Connection pool and MessageRessources
> > > > >
> > > > >
> > > > > Hi,
> > > > > I'm working with Struts 1.1 and I have a problem with the
> > > > > MessageRessource and I
> > > > > don't know to handle it  the right way.
> > > > > In my application I have two constraints,among others :) ,
> > > > > - i must use an oci connection to the database
> > > > > - the error messages will be stored in the database
> > > > > For that I took two aproaches :
> > > > > ## One ##:  I have written a Struts plugin which builds the
> > > > > connection pool, and
> > > > > I've extended MessageRessourceFactory and MessageRessources
> > > > > with my own classes
> > > > > DBRessourceFactory and DBRessource to have my own mechanism
> > > > > for message
> > > > > retrivial. My problem is now how can I get a connection to
> > > > > the database from the
> > > > > connection pool I've just made ? Is there a way to
> > > > > communicate between my plugin
> > > > > and my DBRessource class ?
> > > > >
> > > > >
> > > > > ## Two ##: I make a class which will handle the connection
> > > > > pool creation and the
> > > > > retrivial of messages from the database.
> > > > > It will look like this :
> > > > > public class MessagesDBPool extends MessageRessources 
> implements
> > > > > PlugIn,Serializable {
> > > > >     public MessageDBPool (){
> > > > >         super();
> > > > >     }
> > > > >     public MessageDBPool(MessageRessourcesFactory
> > > > > factory,String config){
> > > > >         this(factory,config,false);
> > > > >     }
> > > > >     public MessageDBPool(MessageRessourcesFactory
> > > > > factory,String config,boolean
> > > > > returnNull){
> > > > >         super(factory,config,returnNull);
> > > > >     }
> > > > >     public void init(ActionServlet servlet, ModuleConfig
> > > > > config) throws
> > > > > ServletException{
> > > > >         //pool initialisation here
> > > > >     }
> > > > >     public void destroy(){
> > > > >         //destroy pool here
> > > > >     }
> > > > > }
> > > > > Can I do this in the first place ?
> > > > >
> > > > > Now the question is which one of this two solutions can work?
> > > > > Is there another
> > > > > way to do this ?
> > > > > Any suggestions are welcome .
> > > > >
> > > > > Thanks,
> > > > > Ovidiu EFTIMIE
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > 
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: 
> struts-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> > > struts-user-help@jakarta.apache.org
> > > > >
> > > >
> > > >
> > > >
> > > 
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: 
> struts-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: 
> struts-user-help@jakarta.apache.org
> > > >
> > >
> > >
> > > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: 
> struts-user-help@jakarta.apache.org
> > >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Connection pool and MessageRessources

Posted by Ovidiu EFTIMIE <oe...@assemblee-nat.fr>.
Yes I know it is very tighly integrated with Struts, and actualy  we're comply
with all things you've enumerated below.
    The validator will not be used because all validation will be done with
javascript already present in the jsp page, and the only server side validation
we'll have will be to find out if the client has disabled javascript, and  we'll
not be using <bean:message> beacause we'll not have a multi language site.

I know that my solution cannot be universally applied, and it's just a way to
overcome Struts limitations regarding the MessageRessources.
I'll hope that in future versions something similar with your extension could be
integrated into Struts, because is a little bit frustrating to manage error
messages(for example) in two separate places (an Oracle table and
application.properties as in my case).

Thanks for your response, and I hope Id didn't took a lot of your time

Ovidiu

----- Original Message ----- 
From: "James Mitchell" <jm...@apache.org>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Friday, October 31, 2003 4:13 PM
Subject: RE: Connection pool and MessageRessources


> You might not be realizing just how deeply the MesageResources is
> integrated with Struts.
>
> Your solution won't work if:
>
>   * your app is using the validator
>
>   * any of your jsp pages are using <bean:message>
>
>   * any of your jsp pages use tags that use MessageResources
>     (which are any that use xyzKey such as srcKey,
>      pageKey, altKey, etc)
>
>
> As far as application modification goes, the extension I
> created is a simple config change in struts-config, and voila!
>
>
> --
> James Mitchell
> Software Engineer / Struts Evangelist
> http://www.struts-atlanta.org
> 678.910.8017 (c)
> 770.822.3359 (h)
> AIM:jmitchtx
>
>
>
>
> > -----Original Message-----
> > From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > Sent: Friday, October 31, 2003 7:23 AM
> > To: Struts Users Mailing List
> > Subject: Re: Connection pool and MessageRessources
> >
> >
> > I think I've found a solution.
> > I'll make an object (eventualy a struts PlugIn), DBMessage
> > which receivies a
> > connection from my connection pool and retrives the error
> > messages from the
> > database, and this object will not extend MessageRessources.
> > Then in my actions I'll have :
> >
> > DbMessage dbmesg = (DbMessage)servlet.getAttribute("DBMESG");
> > String  message = dbmesg.getMessage("error_code");
> > ActionErrors errors = new ActionError();
> > errors.add("code",new ActionError("foo",message));
> >
> > where foo is defined in my application.properties as
> > foo = {0}
> >
> > How that sounds ?
> >
> >
> > Ovidiu
> >
> > ----- Original Message ----- 
> > From: "James Mitchell" <jm...@apache.org>
> > To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
> > Sent: Thursday, October 30, 2003 7:18 PM
> > Subject: RE: Connection pool and MessageRessources
> >
> >
> > > Hi Ovidiu
> > >
> > > I also wrote my own DBMessageResources.  With a simple
> > hack, I was able
> > > to overcome the limitations of the existing API.
> > >
> > > The source code and example are available for download at:
> > >
> > >
> > >
> > http://sourceforge.net/project/showfiles.php?group_id=49385&re
> > lease_id=1
> > > 54972
> > >
> > >
> > >
> > > --
> > > James Mitchell
> > > Software Engineer / Struts Evangelist
> > > http://www.struts-atlanta.org
> > > 678.910.8017 (c)
> > > 770.822.3359 (h)
> > > AIM:jmitchtx
> > >
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > > > Sent: Thursday, October 30, 2003 1:07 PM
> > > > To: struts-user@jakarta.apache.org
> > > > Subject: Connection pool and MessageRessources
> > > >
> > > >
> > > > Hi,
> > > > I'm working with Struts 1.1 and I have a problem with the
> > > > MessageRessource and I
> > > > don't know to handle it  the right way.
> > > > In my application I have two constraints,among others :) ,
> > > > - i must use an oci connection to the database
> > > > - the error messages will be stored in the database
> > > > For that I took two aproaches :
> > > > ## One ##:  I have written a Struts plugin which builds the
> > > > connection pool, and
> > > > I've extended MessageRessourceFactory and MessageRessources
> > > > with my own classes
> > > > DBRessourceFactory and DBRessource to have my own mechanism
> > > > for message
> > > > retrivial. My problem is now how can I get a connection to
> > > > the database from the
> > > > connection pool I've just made ? Is there a way to
> > > > communicate between my plugin
> > > > and my DBRessource class ?
> > > >
> > > >
> > > > ## Two ##: I make a class which will handle the connection
> > > > pool creation and the
> > > > retrivial of messages from the database.
> > > > It will look like this :
> > > > public class MessagesDBPool extends MessageRessources implements
> > > > PlugIn,Serializable {
> > > >     public MessageDBPool (){
> > > >         super();
> > > >     }
> > > >     public MessageDBPool(MessageRessourcesFactory
> > > > factory,String config){
> > > >         this(factory,config,false);
> > > >     }
> > > >     public MessageDBPool(MessageRessourcesFactory
> > > > factory,String config,boolean
> > > > returnNull){
> > > >         super(factory,config,returnNull);
> > > >     }
> > > >     public void init(ActionServlet servlet, ModuleConfig
> > > > config) throws
> > > > ServletException{
> > > >         //pool initialisation here
> > > >     }
> > > >     public void destroy(){
> > > >         //destroy pool here
> > > >     }
> > > > }
> > > > Can I do this in the first place ?
> > > >
> > > > Now the question is which one of this two solutions can work?
> > > > Is there another
> > > > way to do this ?
> > > > Any suggestions are welcome .
> > > >
> > > > Thanks,
> > > > Ovidiu EFTIMIE
> > > >
> > > >
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> > > >
> > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Connection pool and MessageRessources

Posted by James Mitchell <jm...@apache.org>.
You might not be realizing just how deeply the MesageResources is
integrated with Struts.

Your solution won't work if:

  * your app is using the validator

  * any of your jsp pages are using <bean:message>

  * any of your jsp pages use tags that use MessageResources
    (which are any that use xyzKey such as srcKey, 
     pageKey, altKey, etc)


As far as application modification goes, the extension I 
created is a simple config change in struts-config, and voila!


--
James Mitchell
Software Engineer / Struts Evangelist
http://www.struts-atlanta.org
678.910.8017 (c)
770.822.3359 (h)
AIM:jmitchtx




> -----Original Message-----
> From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr] 
> Sent: Friday, October 31, 2003 7:23 AM
> To: Struts Users Mailing List
> Subject: Re: Connection pool and MessageRessources
> 
> 
> I think I've found a solution.
> I'll make an object (eventualy a struts PlugIn), DBMessage 
> which receivies a
> connection from my connection pool and retrives the error 
> messages from the
> database, and this object will not extend MessageRessources.
> Then in my actions I'll have :
> 
> DbMessage dbmesg = (DbMessage)servlet.getAttribute("DBMESG");
> String  message = dbmesg.getMessage("error_code");
> ActionErrors errors = new ActionError();
> errors.add("code",new ActionError("foo",message));
> 
> where foo is defined in my application.properties as
> foo = {0}
> 
> How that sounds ?
> 
> 
> Ovidiu
> 
> ----- Original Message ----- 
> From: "James Mitchell" <jm...@apache.org>
> To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
> Sent: Thursday, October 30, 2003 7:18 PM
> Subject: RE: Connection pool and MessageRessources
> 
> 
> > Hi Ovidiu
> >
> > I also wrote my own DBMessageResources.  With a simple 
> hack, I was able
> > to overcome the limitations of the existing API.
> >
> > The source code and example are available for download at:
> >
> >
> > 
> http://sourceforge.net/project/showfiles.php?group_id=49385&re
> lease_id=1
> > 54972
> >
> >
> >
> > --
> > James Mitchell
> > Software Engineer / Struts Evangelist
> > http://www.struts-atlanta.org
> > 678.910.8017 (c)
> > 770.822.3359 (h)
> > AIM:jmitchtx
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > > Sent: Thursday, October 30, 2003 1:07 PM
> > > To: struts-user@jakarta.apache.org
> > > Subject: Connection pool and MessageRessources
> > >
> > >
> > > Hi,
> > > I'm working with Struts 1.1 and I have a problem with the
> > > MessageRessource and I
> > > don't know to handle it  the right way.
> > > In my application I have two constraints,among others :) ,
> > > - i must use an oci connection to the database
> > > - the error messages will be stored in the database
> > > For that I took two aproaches :
> > > ## One ##:  I have written a Struts plugin which builds the
> > > connection pool, and
> > > I've extended MessageRessourceFactory and MessageRessources
> > > with my own classes
> > > DBRessourceFactory and DBRessource to have my own mechanism
> > > for message
> > > retrivial. My problem is now how can I get a connection to
> > > the database from the
> > > connection pool I've just made ? Is there a way to
> > > communicate between my plugin
> > > and my DBRessource class ?
> > >
> > >
> > > ## Two ##: I make a class which will handle the connection
> > > pool creation and the
> > > retrivial of messages from the database.
> > > It will look like this :
> > > public class MessagesDBPool extends MessageRessources implements
> > > PlugIn,Serializable {
> > >     public MessageDBPool (){
> > >         super();
> > >     }
> > >     public MessageDBPool(MessageRessourcesFactory
> > > factory,String config){
> > >         this(factory,config,false);
> > >     }
> > >     public MessageDBPool(MessageRessourcesFactory
> > > factory,String config,boolean
> > > returnNull){
> > >         super(factory,config,returnNull);
> > >     }
> > >     public void init(ActionServlet servlet, ModuleConfig
> > > config) throws
> > > ServletException{
> > >         //pool initialisation here
> > >     }
> > >     public void destroy(){
> > >         //destroy pool here
> > >     }
> > > }
> > > Can I do this in the first place ?
> > >
> > > Now the question is which one of this two solutions can work?
> > > Is there another
> > > way to do this ?
> > > Any suggestions are welcome .
> > >
> > > Thanks,
> > > Ovidiu EFTIMIE
> > >
> > >
> > >
> > >
> > > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: 
> struts-user-help@jakarta.apache.org
> > >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Connection pool and MessageRessources

Posted by Ovidiu EFTIMIE <oe...@assemblee-nat.fr>.
I think I've found a solution.
I'll make an object (eventualy a struts PlugIn), DBMessage which receivies a
connection from my connection pool and retrives the error messages from the
database, and this object will not extend MessageRessources.
Then in my actions I'll have :

DbMessage dbmesg = (DbMessage)servlet.getAttribute("DBMESG");
String  message = dbmesg.getMessage("error_code");
ActionErrors errors = new ActionError();
errors.add("code",new ActionError("foo",message));

where foo is defined in my application.properties as
foo = {0}

How that sounds ?


Ovidiu

----- Original Message ----- 
From: "James Mitchell" <jm...@apache.org>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Thursday, October 30, 2003 7:18 PM
Subject: RE: Connection pool and MessageRessources


> Hi Ovidiu
>
> I also wrote my own DBMessageResources.  With a simple hack, I was able
> to overcome the limitations of the existing API.
>
> The source code and example are available for download at:
>
>
> http://sourceforge.net/project/showfiles.php?group_id=49385&release_id=1
> 54972
>
>
>
> --
> James Mitchell
> Software Engineer / Struts Evangelist
> http://www.struts-atlanta.org
> 678.910.8017 (c)
> 770.822.3359 (h)
> AIM:jmitchtx
>
>
>
>
> > -----Original Message-----
> > From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr]
> > Sent: Thursday, October 30, 2003 1:07 PM
> > To: struts-user@jakarta.apache.org
> > Subject: Connection pool and MessageRessources
> >
> >
> > Hi,
> > I'm working with Struts 1.1 and I have a problem with the
> > MessageRessource and I
> > don't know to handle it  the right way.
> > In my application I have two constraints,among others :) ,
> > - i must use an oci connection to the database
> > - the error messages will be stored in the database
> > For that I took two aproaches :
> > ## One ##:  I have written a Struts plugin which builds the
> > connection pool, and
> > I've extended MessageRessourceFactory and MessageRessources
> > with my own classes
> > DBRessourceFactory and DBRessource to have my own mechanism
> > for message
> > retrivial. My problem is now how can I get a connection to
> > the database from the
> > connection pool I've just made ? Is there a way to
> > communicate between my plugin
> > and my DBRessource class ?
> >
> >
> > ## Two ##: I make a class which will handle the connection
> > pool creation and the
> > retrivial of messages from the database.
> > It will look like this :
> > public class MessagesDBPool extends MessageRessources implements
> > PlugIn,Serializable {
> >     public MessageDBPool (){
> >         super();
> >     }
> >     public MessageDBPool(MessageRessourcesFactory
> > factory,String config){
> >         this(factory,config,false);
> >     }
> >     public MessageDBPool(MessageRessourcesFactory
> > factory,String config,boolean
> > returnNull){
> >         super(factory,config,returnNull);
> >     }
> >     public void init(ActionServlet servlet, ModuleConfig
> > config) throws
> > ServletException{
> >         //pool initialisation here
> >     }
> >     public void destroy(){
> >         //destroy pool here
> >     }
> > }
> > Can I do this in the first place ?
> >
> > Now the question is which one of this two solutions can work?
> > Is there another
> > way to do this ?
> > Any suggestions are welcome .
> >
> > Thanks,
> > Ovidiu EFTIMIE
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Connection pool and MessageRessources

Posted by James Mitchell <jm...@apache.org>.
Hi Ovidiu

I also wrote my own DBMessageResources.  With a simple hack, I was able
to overcome the limitations of the existing API.

The source code and example are available for download at:

 
http://sourceforge.net/project/showfiles.php?group_id=49385&release_id=1
54972



--
James Mitchell
Software Engineer / Struts Evangelist
http://www.struts-atlanta.org
678.910.8017 (c)
770.822.3359 (h)
AIM:jmitchtx




> -----Original Message-----
> From: Ovidiu EFTIMIE [mailto:oeftimie.teamlog@assemblee-nat.fr] 
> Sent: Thursday, October 30, 2003 1:07 PM
> To: struts-user@jakarta.apache.org
> Subject: Connection pool and MessageRessources
> 
> 
> Hi,
> I'm working with Struts 1.1 and I have a problem with the 
> MessageRessource and I
> don't know to handle it  the right way.
> In my application I have two constraints,among others :) ,
> - i must use an oci connection to the database
> - the error messages will be stored in the database
> For that I took two aproaches :
> ## One ##:  I have written a Struts plugin which builds the 
> connection pool, and
> I've extended MessageRessourceFactory and MessageRessources 
> with my own classes
> DBRessourceFactory and DBRessource to have my own mechanism 
> for message
> retrivial. My problem is now how can I get a connection to 
> the database from the
> connection pool I've just made ? Is there a way to 
> communicate between my plugin
> and my DBRessource class ?
> 
> 
> ## Two ##: I make a class which will handle the connection 
> pool creation and the
> retrivial of messages from the database.
> It will look like this :
> public class MessagesDBPool extends MessageRessources implements
> PlugIn,Serializable {
>     public MessageDBPool (){
>         super();
>     }
>     public MessageDBPool(MessageRessourcesFactory 
> factory,String config){
>         this(factory,config,false);
>     }
>     public MessageDBPool(MessageRessourcesFactory 
> factory,String config,boolean
> returnNull){
>         super(factory,config,returnNull);
>     }
>     public void init(ActionServlet servlet, ModuleConfig 
> config) throws
> ServletException{
>         //pool initialisation here
>     }
>     public void destroy(){
>         //destroy pool here
>     }
> }
> Can I do this in the first place ?
> 
> Now the question is which one of this two solutions can work? 
> Is there another
> way to do this ?
> Any suggestions are welcome .
> 
> Thanks,
> Ovidiu EFTIMIE
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org