You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Oleg V Alexeev <go...@penza.net> on 2001/06/19 07:44:55 UTC

Re[4]: [PROPOSAL] Struts Extensions

Hello Niall,

Tuesday, June 19, 2001, 7:59:53 AM, you wrote:

NP> Oleg,

NP> Do you not think that if there was easier/standard mechanism in Struts to
NP> initialise resources it would  be valid to use that for your bean-factory,
NP> even if you still needed to sub-class ActionServlet to do your
NP> processPreprocess stuff?

Standart init mechanism - yes, of course. But I talk about more
abilities to extend struts functionality without extending
ActionServlet.

I think that struts needs simple and flexible engine to work with
plugins. Of course some extensions can be turn on as external servlets
(load its own resources, init some application scope objects and stay
here), but there are tasks with needs to perform activity at key
positions of request processing in ActionServlet. For example - before
or after form validation, before or after call of perform() method.

To support flexible extensions mechanism in struts there must exist
such additions as -

1. Load all struts-config to the memory by ActionServlet only. Now it
   needs to extend initDigester() to process additional configuration
   sections in struts-config. May be it needs to supply additional
   info about intercept of extension related info (class name, for
   example).
2. Register extension classes in struts-config and instantiate it at
   servlet load time.
3. Add ability for extensions to register to some request processing
   moments. For example - for form processing, for post-, pre-perfom
   processing.
   
On the whole -
 a. Full application config contains in struts-config
    and this config can be processed without ActionServlet extending,
 b. ActionServlet can load so named 'extensions' (read info about it
    from struts-config, create class instance, call init method and
    pass to it servlet config object)
 c. Each extension can be described in struts-config as
    activity-subscriber to get control at pre- form validation moment,
    for example (ActionServlet can accumulate such info from
    struts-config and at key points call registered intercepters).

>> -----Original Message-----
>> From: Oleg V Alexeev [mailto:gonza@penza.net]
>> Sent: 11 June 2001 21:00
>> To: struts-dev@jakarta.apache.org
>> Subject: Re[2]: [PROPOSAL] Struts Extensions
>>
>>
>> Hello Martin,
>>
>> But how about such situation as follows. I can store bean-factory
>> object in application scope. I can use it in any action to perform
>> bean producing. But main idea of bean-factory is to perform
>> _automatic_ bean generation by name of the action. For example - in
>> struts-config or in external config file I define mapping between
>> action and some kind of bean. All beans from mappings must be created to
>> be ready to use it in appropriate actio at request processing phase before
>> Action.perfom method call. How can I do it without
>> extending ActionServlet? I think there is one way to implement this
>> with current struts API - extend ActionServlet and redefine
>> processPreprocess method to perform all 'before Action.perfom' stuff.
>>
>> So struts control-gear can be extended to to register external classes
>> or servlets to perform some activity at key points of request
>> processing - ActionForm processing, Action processing, etc. Now it can
>> be implemented only via ActionServlet extending - is not scalable
>> solution for my mind.
>>
>> Sunday, June 10, 2001, 11:20:22 PM, you wrote:
>>
>> MC> I like this idea. I think David is right - a lot of people do extend
>> MC> ActionServlet just to initialize resources. While this idea
>> wouldn't remove
>> MC> all of the reasons to build a custom servlet, it would provide a
>> MC> systematic - and potentially simpler - way to solve a common problem.
>>
>> MC> --
>> MC> Martin Cooper
>>
>>
>> MC> ----- Original Message -----
>> MC> From: "David Winterfeldt" <dw...@yahoo.com>
>> MC> To: <st...@jakarta.apache.org>
>> MC> Sent: Sunday, June 10, 2001 11:37 AM
>> MC> Subject: Re: [PROPOSAL] Struts Extensions
>>
>>
>> >> It might be nice if there was a way to register an
>> >> interface with the ActionServlet in the config file
>> >> for it to initialize a service.  All the
>> >> ValidatorServlet I made does is parse the xml file
>> >> with the Digester and put an object into application
>> >> scope.  If a class could be registered, then a servlet
>> >> wouldn't hang around for no reason and it wouldn't
>> >> need to be defined in the web.xml.  And it sounds like
>> >> a lot of people extend the ActionServlet just to
>> >> initialize resources on startup.
>> >>
>> >> David
>> >>
>> >> --- Ted Husted <hu...@apache.org> wrote:
>> >> > I agree that most extensions would be best written
>> >> > as independant
>> >> > servlets that plug into the application alongside
>> >> > the Struts
>> >> > ActionServlet. Though, I'm not sure they would need
>> >> > to register with the
>> >> > ActionServlet to access other parts of the
>> >> > framework.
>> >> >
>> >> > I haven't worked with the Digester directly, but
>> >> > most of the other
>> >> > Struts services are already exposed through the
>> >> > application context.
>> >> > Custom tags, for example, already access the Action
>> >> > Mappings this way.
>> >> > So any other servlet in the application (since
>> >> > that's all JSP's are)
>> >> > should be able to do the same.
>> >> >
>> >> > Another example is the Generic Connection Pool. The
>> >> > datasource is
>> >> > exposed through the application context and other
>> >> > services, like the
>> >> > TagLibs JDBC tags, can use the pool without knowing
>> >> > anything about
>> >> > Struts (or Struts knowing anything about them).
>> >> >
>> >> > So I would suggest that if there are other services
>> >> > that an extension
>> >> > needs to share that we expose them through the
>> >> > Application context.
>> >> >
>> >> > Oleg V Alexeev wrote:
>> >> >
>> >> > > To support flexible extensions mechanism for
>> >> > struts there are can be
>> >> > > made some additions to the core structure of the
>> >> > framework -
>> >> > >
>> >> > > 1. Add ability to register components or external
>> >> > servlets (at
>> >> > >    application level) via struts-config file.
>> >> > > 2. Give such external components or servlets
>> >> > ability to use action
>> >> > >    mappings database from ActionServlet.
>> >> > > 3. Extend core API of struts to support pluggable
>> >> > extensions - for
>> >> > >    example use event model or direct calls via
>> >> > registrations in action
>> >> > >    mappiongs database.
>> >> > >
>> >> > > The best way for my mind is to write external
>> >> > servlets, register it in
>> >> > > struts ActionServlet and use it as external
>> >> > services. This approach
>> >> > > can be useful in case of mutliple ActionServlet
>> >> > instances in one
>> >> > > application - every ActionServlet subscribe to use
>> >> > and uses some
>> >> > > amount of external services.
>> >>
>> >>
>> >> __________________________________________________
>> >> Do You Yahoo!?
>> >> Get personalized email addresses from Yahoo! Mail - only $35
>> >> a year!  http://personal.mail.yahoo.com/
>>
>>
>>
>>
>> --
>> Best regards,
>>  Oleg                            mailto:gonza@penza.net
>>
>>
>>




-- 
Best regards,
 Oleg                            mailto:gonza@penza.net