If you look at the interface for PlugIn, you'll see that the initialize method is given references to the servlet and the ModuleConfig in whose context it is being initialized, so you could hold a reference to the servlet in your PlugIn until the destroy method is called.

If you are just designing these classes now, you might be interested in an emerging toolkit to link Struts to the Spring framework (which could be used to do what your ServiceFactory does) -- see http://struts.sourceforge.net/struts-spring/index.html That library is very new, but that just means that you can help make it better instead of writing your own!

I'm not sure to which java file you're referring when you ask about the performance hit.

Joe


At 12:34 AM +0530 12/12/03, Gopal Venkata Achi wrote:
Hi,
Thanks for the info on PlugIn.
We are doing something like below:

public class ServiceFactory implements PlugIn

{

public ServiceInterface createService() throws ClassNotFoundException, IllegalAccessException, InstantiationException{

String className = servlet.getInitParameter(ServiceConst.SERVICE_CLASS_KEY);

className = (className != null) ? className : ServiceConst.SERVICE_CLASS_NAME;

return (ServiceInterface) Class.forName(className).newInstance();

}

}

So, it means the ServiceFactory is available in the application scope, and possible to access it as below:

ServiceFactory serviceFactory = (ServiceFactory)getApplicationObject(ServiceConst.SERVICE_FACTORY_KEY);

Now, the question is, where do we set up the Key-Value, for accessing the application scope objects?

and what is the "servlet" object used in this example?

and another question is, (un-related to above topic), will there be any performance hit, if the java file is growing larger?

I appreciate your help,

Thanks & Regards,

Gopal

        -----Original Message-----
        From: Ted Husted [mailto:[EMAIL PROTECTED]
        Sent: Thu 12/11/2003 12:39 PM
        To: Struts Users Mailing List
        Cc:
        Subject: Re: PlugIn Interface implementation



        The purpose of the plugin interface is to give people a chance to
        initialize their own resources without subclassing ActionServlet or
        creating their own.

        Typically, you would not use the PlugIn class directly, but whatever
        resources it initialized (and then placed in Application scope under a
        known name).

In any event, you should definately remove any service methods from the
Action class and place these on some other object. A very good candidate
for a service layer is the Chain of Command package, now in the Jakarta
Commons Sandbox. Another likely suspect is HiveMind (also in the
Sandbox).


HTH, Ted.

Gopal Venkata Achi wrote:
> Hi All,
>
> Has anyone experienced with PlugIn interface implementation?
> We are thinking of abstracting the service calls from the action class and creating the service layer which implements PlugIn.
> Please suggest me on what is the advantage that we get by implementing this PlugIn, and is this PlugIn is a kind of marker interface, does it allow me to create different methods while implementing?
> In implementing class, what are all objects that we have access to?
>
> I appreciate any help/suggestions in this regard.
>
> Regards,
> Gopal
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> 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]


--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "We want beef in dessert if we can get it there."
-- Betty Hogan, Director of New Product Development, National Cattlemen's Beef Association



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to