Code as follows
Caching class
package com.mypackage.Cache
mport org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.action.ActionServlet;
public class Cacheimplements PlugIn
{
private static Cacheinstance = null;
private ModuleConfig module = null;
private ActionServlet action = null;
public Cache()
{
if (instance == null)
instance = this;
}
public static Cache getInstance()
{
if (instance == null)
instance = new Cache();
return instance;
}
public void init(ActionServlet action, ModuleConfig module)
{
this.action = action;
this.module = module;
put your code in here to fire off any caching of data
}
public void destroy()
{
instance = null;
action = null;
module = null;
any cleanup code.
}
Add the following into your Struts-config.xml file
<plug-in className="com.mypackage.Cache">
</plug-in>
Parameters can be supplied to the class using the
<set-property property="" value=""/>
inclusion between the plug-in statements. You would then have a local
declaration in the Cache class with getter and setter methods to access the
parameter.
Hope this helps.
Richard
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 13 August 2004 15:29
To: [EMAIL PROTECTED]
Subject: RE: Caching Framework
As I am very new to struts, it would be very helpful if you can point me to
some sample code.
Thanks for support from everybody.
Regds
Ravi
-----Original Message-----
From: Richard Cave [mailto:[EMAIL PROTECTED]
Sent: Friday, August 13, 2004 7:16 PM
To: 'Struts Users Mailing List'
Subject: RE: Caching Framework
Ravi,
We've just implemented a master data load using the same technique as Eric.
Appears to be working very well.
Richard
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 13 August 2004 14:54
To: [EMAIL PROTECTED]
Subject: RE: Caching Framework
That's really a great idea Erik.
Can you please point me to some example.
Thanks Erik,
Regds
Ravi
-----Original Message-----
From: Erik Weber [mailto:[EMAIL PROTECTED]
Sent: Friday, August 13, 2004 7:21 PM
To: Struts Users Mailing List
Subject: Re: Caching Framework
Ravi, without getting real complicated, I use PlugIns to do this!
Implement org.apache.struts.action.PlugIn. You only need to write two
methods -- init and destroy. In your init method, gather some data store
it as application scope attributes (you get a reference to the
controller Servlet in the init method). Finally, register your PlugIn
with struts-config.xml. When your Struts app initializes, your PlugIn's
init method is invoked. Your JSPs now have easy access to the cached
data, as do your Actions.
Erik
[EMAIL PROTECTED] wrote:
>Hi,
>
>Is there any Caching framework available for struts ?
>
>For eg: I need to cache some list of objects ...etc.,
>
>Ravi
>
>
>
>
>
>Confidentiality Notice
>
>The information contained in this electronic message and any
>attachments to this message are intended for the exclusive use of the
>addressee(s) and may contain confidential or privileged information. If
>you are not the intended recipient, please notify the sender at Wipro
>or [EMAIL PROTECTED] immediately and destroy all copies of this
>message
and any attachments.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Confidentiality Notice
The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain confidential or privileged information. If you are not the intended
recipient, please notify the sender at Wipro or [EMAIL PROTECTED]
immediately and destroy all copies of this message and any attachments.
---------------------------------------------------------------------
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]
Confidentiality Notice
The information contained in this electronic message and any attachments to
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or
[EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.
---------------------------------------------------------------------
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]