You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Kerry Todyruik <ke...@todyruik.com> on 2001/12/12 00:37:50 UTC

Applying Avalon in a Servlet Environment

I've seen a few responses to how to implement Avalon in a servlet
environmet and the typical answer is to check out Cocoon.  Cocoon seems
to implement the main container only in one servlet.  What I needed to
do is make my main application container available to all of my servlets
in my application and have it properly started and shut down with the
Tomcat servlet engine.  I think this is more generic and might be a more
common requirement.

The approach I took was instead of having my main container residing in
one servlet, I made it a singleton.  Then I created an InitServlet as I
saw somewhere for initizlizing Log4j and set this to load at startup by
including it in the webapps web.xml file.  Just like Cocoon, I made the
InitServlet's init() and destroy() methods create and dispose of my main
container.

So the end result is the life of my main container then gets tied to the
starting and stopping of my tomcat server and all of my servlets can
access it.  Seems to work pretty well.

Any comments on this method?  I can post some code if there is any
interest.

Regards,
Kerry Todyruik


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Peter Donald <pe...@apache.org>.
On Fri, 21 Dec 2001 20:40, Vassilis Rizopoulos wrote:
> >On Wed, 12 Dec 2001 10:58, Jeff Turner wrote:
> >> I'd have thought that using Avalon in a servlet environment is *the*
> >> most common usage.
> >
> >Well I don't use it in any servlet environment atm ;)
> >
> >> Code would be interesting, even if it's not a working example. Maybe it
> >> could form the core of a "Avalon-in-a-servlet-environment starter kit",
> >> reusing all those cool things from Cocoon, like env abstraction,
> >> protocol handlers, error handling, profiling..
> >
> >Sounds like a great idea - any volunteers ?
>
> Phew, you guys, I just came back from three weeks of holiday and got close
> to 2000 emails on the list. I'm panicking here...:))). 

:)

> On this
> servlet-Avalon thing, I have done some work, I also had to figura out how
> to implement my container so that I could control my app. I actually have
> some docs written, and a small presentation (due to be given in January in
> the company I work for) and the code from a very sloppy code of a wiki
> server Avalon style (been awfully busy to complete the functionality and I
> still struggle with the definition of a good search interface for the
> search engine component). Maybe I can help too ???? :))

the more the merrier!

-- 
Cheers,

Pete

----------------------------------------------------
"The only way to discover the limits of the possible 
is to go beyond them into the impossible." 
                             -Arthur C. Clarke
----------------------------------------------------


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Incze Lajos <in...@mail.matav.hu>.
> Phew, you guys, I just came back from three weeks of holiday and got close to 2000 emails on the list. I'm panicking here...:))).
> On this servlet-Avalon thing, I have done some work, I also had to figura out how to implement my container so that I could control my app. I actually have some docs written, and a small presentation (due to be given in January in the company I work for) and the code from a very sloppy code of a wiki server Avalon style (been awfully busy to complete the functionality and I still struggle with the definition of a good search interface for the search engine component).
> Maybe I can help too ???? :))
> V.-
> 

Check out lucene. It's also jakarta project already.

incze

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Vassilis Rizopoulos <va...@zuehlke.com>.
>On Wed, 12 Dec 2001 10:58, Jeff Turner wrote:
>> I'd have thought that using Avalon in a servlet environment is *the*
>> most common usage. 
>
>Well I don't use it in any servlet environment atm ;)
>
>> Code would be interesting, even if it's not a working example. Maybe it
>> could form the core of a "Avalon-in-a-servlet-environment starter kit",
>> reusing all those cool things from Cocoon, like env abstraction,
>> protocol handlers, error handling, profiling..
>
>Sounds like a great idea - any volunteers ?
>
Phew, you guys, I just came back from three weeks of holiday and got close to 2000 emails on the list. I'm panicking here...:))).
On this servlet-Avalon thing, I have done some work, I also had to figura out how to implement my container so that I could control my app. I actually have some docs written, and a small presentation (due to be given in January in the company I work for) and the code from a very sloppy code of a wiki server Avalon style (been awfully busy to complete the functionality and I still struggle with the definition of a good search interface for the search engine component).
Maybe I can help too ???? :))
V.-


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ComponentManagerCreator (was: Applying Avalon in a Servlet Enviro nment)

Posted by Jeff Turner <je...@socialchange.net.au>.
On Thu, Dec 13, 2001 at 07:52:55PM +1100, Peter Donald wrote:
> Looks good. Does someone who can easily test it want to commit it into 
> excalibur ?

It does look good. Thanks Gregory!

I'll have a play and commit it (unless someone else gets there first).

--Jeff

> On Thu, 13 Dec 2001 05:52, Gregory Steuck wrote:
> > Just realized that I didn't include the servlet configuration section
> > into the javadoc. Please use the attached source file instead.
> 
> -- 
> Cheers,
> 
> Pete
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ComponentManagerCreator (was: Applying Avalon in a Servlet Enviro nment)

Posted by Peter Donald <pe...@apache.org>.
Looks good. Does someone who can easily test it want to commit it into 
excalibur ?

On Thu, 13 Dec 2001 05:52, Gregory Steuck wrote:
> Just realized that I didn't include the servlet configuration section
> into the javadoc. Please use the attached source file instead.

-- 
Cheers,

Pete

----------------------------------
   "Don't play dumb with me. 
I happen to be an expert at that" 
           - Maxwell Smart
----------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


ComponentManagerCreator (was: Applying Avalon in a Servlet Enviro nment)

Posted by Gregory Steuck <gr...@buildpoint.com>.
Just realized that I didn't include the servlet configuration section
into the javadoc. Please use the attached source file instead.

ComponentManagerCreator (was: Applying Avalon in a Servlet Environment)

Posted by Gregory Steuck <gr...@nest.cx>.
I happened to have written just the thing. Feel free to include it
into excalibur under Apache license. build.xml needs to be augmented
with:

 <exclude name="org/apache/avalon/excalibur/servlet/ComponentManagerCreator.java"
 unless="servlet.present"/>

To make it always build.

Any suggestions and fixes are certainly welcome.

>>>>> "Peter" == Peter Donald <pe...@apache.org> writes:

    Peter> Sounds like a great idea - any volunteers ?


Re: Applying Avalon in a Servlet Environment

Posted by Peter Donald <pe...@apache.org>.
On Wed, 12 Dec 2001 10:58, Jeff Turner wrote:
> I'd have thought that using Avalon in a servlet environment is *the*
> most common usage. 

Well I don't use it in any servlet environment atm ;)

> Code would be interesting, even if it's not a working example. Maybe it
> could form the core of a "Avalon-in-a-servlet-environment starter kit",
> reusing all those cool things from Cocoon, like env abstraction,
> protocol handlers, error handling, profiling..

Sounds like a great idea - any volunteers ?

-- 
Cheers,

Pete

----------------------------------
Ancient Go proverb: "Only amateurs 
try to come up with 'fancy' moves"
----------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Ian Lim <ma...@yahoo.com.sg>.
Hi

I am completely supportive of this idea.

Maybe can call something like Avalon Servlet Development Kit.

Cannot call it Avalon Development Kit because Avalon is not

only useful for servlet environment only.

Then maybe in future, we can have some other Development Kit like

Avalon Standalone Development Kit,

Avalone Embedded Development Kit

Just my 2 cents of thoughts :)

Regards
==========
Ian Lim
email: mallim_sg@yahoo.com.sg
homepage: http://www.webappcabaret.com/mallim

----- Original Message -----
From: "Jeff Turner" <je...@socialchange.net.au>
To: "Kerry Todyruik" <ke...@todyruik.com>
Cc: <av...@jakarta.apache.org>
Sent: Wednesday, December 12, 2001 07:58 AM
Subject: Re: Applying Avalon in a Servlet Environment


> On Tue, Dec 11, 2001 at 04:37:50PM -0700, Kerry Todyruik wrote:
> > I've seen a few responses to how to implement Avalon in a servlet
> > environmet and the typical answer is to check out Cocoon.  Cocoon seems
> > to implement the main container only in one servlet.  What I needed to
> > do is make my main application container available to all of my servlets
> > in my application and have it properly started and shut down with the
> > Tomcat servlet engine.  I think this is more generic and might be a more
> > common requirement.
> >
> > The approach I took was instead of having my main container residing in
> > one servlet, I made it a singleton.  Then I created an InitServlet as I
> > saw somewhere for initizlizing Log4j and set this to load at startup by
> > including it in the webapps web.xml file.  Just like Cocoon, I made the
> > InitServlet's init() and destroy() methods create and dispose of my main
> > container.
> >
> > So the end result is the life of my main container then gets tied to the
> > starting and stopping of my tomcat server and all of my servlets can
> > access it.  Seems to work pretty well.
> >
> > Any comments on this method?  I can post some code if there is any
> > interest.
>
> Sounds good :)
>
> I'd have thought that using Avalon in a servlet environment is *the*
> most common usage. With all the IoC in the Servlet API, Avalon seems a
> natural fit for writing more complex servlets..
>
> Code would be interesting, even if it's not a working example. Maybe it
> could form the core of a "Avalon-in-a-servlet-environment starter kit",
> reusing all those cool things from Cocoon, like env abstraction,
> protocol handlers, error handling, profiling..
>
> --Jeff
>
> > Regards,
> > Kerry Todyruik
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Paul Hammant <Pa...@yahoo.com>.
Ulrich,

>Strange, I'd have thought THE most common usage of Avalon would be with
>Phoenix (blocks and .sar applications and such). Actually what I am
>missing in Phoenix is some way to do HTTP - if we had that, then nobody
>would want or need to use Avalon in a servlet environment. 
>
Agree.

>To implement
>a basic HTTP server would be easy, to integrate a more full-featured one
>like Jo! or Tomcat would probably be not quite as easy, but the better
>choice in the long run.
>
Jo! works well.  We'll have to check with Hendrick to see if he moved to 
LogEnabled when we did.
Tomcat works but needs loads of work.
I forked another effort (Acme Web server) to Phoenix some months ago and 
have it under the Avalonia project at sourceforge.  It is a tiny basic 
webserver with marginal servelet support.

>Here's what I currently do: my Avalon/Phoenix services can be talked to
>over a socket connection and I invented a minimal protocol for that.
>Then I use my socket XSP taglib for Cocoon1 to seamlessly integrate
>these services into a Cocoon webapp. So I don't actually need to do HTTP
>into Phoenix, I just talk over the socket and leave the HTTP
>request/response handling to my webserver. Maybe this is less than
>ideal, but it's there and it works :)
>
And also does not break the "Servlet contract" which stipulates nothing 
more than javax.servlet.* visible in the classpath from the underlying 
server.

- Paul H




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Ulrich Mayring <ul...@denic.de>.
Jeff Turner wrote:
> 
> What advantage would Tomcat-in-Phoenix have over Tomcat on it's own? The
> contract with the user is still the servlet API, no?

No, we get rid of the servlet API this way, we're just using Tomcat's
webserver and let it handle the HTTP/request/response stuff and possibly
serving static HTML files by itself. My point was that I think if
Avalon/Phoenix had a component that does HTTP, then we won't need the
servlet API anymore. Two possibilities for this HTTP component would be
Tomcat or Jo!.

> In most environments I've worked in, people have firewalls blocking
> pretty much everything except port 80. IMHO, this accounts in no small
> part for the success of SOAP. Apache owns port 80; until Phoenix can
> talk AJP13, I can't use it (as much as I'd like to!).

An AJP13 component would be fine as well, but it ties you to the servlet
API. I'd rather have the webserver inside of Phoenix. The outside Apache
(or whatever) webserver can dispatch requests to the Phoenix webserver
via HTTP, we don't actually need AJP13 for that.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Paul Hammant <Pa...@yahoo.com>.
Stephen,

>Paul:
>
>Can you provide a summary of the current status of Catalina/Phoenix
>work.  We are currently using Tomcat 4.01 as a web gateway running 
>a servelet which in tern is connecting to an internal Phoenix managed
>set of blocks.  It would be so much nicer to include Catalina inside
>our application .. before heading down this path I wanted to 
>get an idea about its current status - open issues, etc.
>
Well the "Bay" subproject of Cornerstone is it.  Download the 4.01 
release of Catalina and unzip it inside the  <cornerstone>/apps/bay/ 
directory.  Runing "build bay main" will tell you if you have it correct 
or not.  You will end up with a SAR file that can be shoved into 
<Phoenix>/apps.  It you also put tools.jar from the JDK into Phoenix's 
lib dir then the examples work.

To commuicate internally with the other Phoenix apps, is non optimat at 
the present.  You can no choice but to evolve a socket or RMI 
solution.... which I guess is what you have at present.

Lastly, Bay at present is tied to demonstrating the examples from 
Tomcat.  Mounting your own application will probably require changes to 
the build script or (more likely) changes to the contents of the 
unzipped tomcat WEBAPPS dir.

Regards,

- Paul H


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Applying Avalon in a Servlet Environment

Posted by Stephen McConnell <mc...@osm.net>.

Paul Hammant wrote:
[snip]
> If we get Catalina working fully inside Phoenix then, in direct answer 
> to your quandry, we could have it listenening on AJP13 as normal.  The 
> small trouble is that Catalina is mounted as a kludge at the moment.

Paul:

Can you provide a summary of the current status of Catalina/Phoenix
work.  We are currently using Tomcat 4.01 as a web gateway running 
a servelet which in tern is connecting to an internal Phoenix managed
set of blocks.  It would be so much nicer to include Catalina inside
our application .. before heading down this path I wanted to 
get an idea about its current status - open issues, etc.

Cheers, Steve.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Paul Hammant <Pa...@yahoo.com>.
Jeff,

To supplement Ulrich's answer a little:

>What advantage would Tomcat-in-Phoenix have over Tomcat on it's own? The
>contract with the user is still the servlet API, no?
>
(For me at least) One virtual machine.  Arguably a leaner memory and 
disk usage.

>In most environments I've worked in, people have firewalls blocking
>pretty much everything except port 80. IMHO, this accounts in no small
>part for the success of SOAP. Apache owns port 80; until Phoenix can
>talk AJP13, I can't use it (as much as I'd like to!).
>
Phoenix hosted apps could, ultimately do all server tasks, that we might 
normally use Linux for.

We could, in time, have a Phoenix HTTP firewall, delegating internally 
(without sockets) to a Phoenix loadbalancer, possibly delegaing 
in-Phoenix again to a Phoenix WebServer. That webserver serverapp hosts 
sites and Webapps OR delegates internally again to other phoenix server 
apps (like JAMES or FtpServer) without using the Servlet API.

If we get Catalina working fully inside Phoenix then, in direct answer 
to your quandry, we could have it listenening on AJP13 as normal.  The 
small trouble is that Catalina is mounted as a kludge at the moment.

Regards,

- Paul H


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Jeff Turner <je...@socialchange.net.au>.
On Wed, Dec 12, 2001 at 10:13:34AM +0100, Ulrich Mayring wrote:
> Jeff Turner wrote:
> > 
> > I'd have thought that using Avalon in a servlet environment is *the*
> > most common usage. With all the IoC in the Servlet API, Avalon seems a
> > natural fit for writing more complex servlets..
> 
> Strange, I'd have thought THE most common usage of Avalon would be with
> Phoenix (blocks and .sar applications and such). Actually what I am
> missing in Phoenix is some way to do HTTP - if we had that, then nobody
> would want or need to use Avalon in a servlet environment. To implement
> a basic HTTP server would be easy, to integrate a more full-featured one
> like Jo! or Tomcat would probably be not quite as easy, but the better
> choice in the long run.

What advantage would Tomcat-in-Phoenix have over Tomcat on it's own? The
contract with the user is still the servlet API, no?

In most environments I've worked in, people have firewalls blocking
pretty much everything except port 80. IMHO, this accounts in no small
part for the success of SOAP. Apache owns port 80; until Phoenix can
talk AJP13, I can't use it (as much as I'd like to!).

Hence my preference for Avalon-in-Tomcat instead of Tomcat-in-Phoenix.

> Here's what I currently do: my Avalon/Phoenix services can be talked to
> over a socket connection and I invented a minimal protocol for that.
> Then I use my socket XSP taglib for Cocoon1 to seamlessly integrate
> these services into a Cocoon webapp. So I don't actually need to do HTTP
> into Phoenix, I just talk over the socket and leave the HTTP
> request/response handling to my webserver. Maybe this is less than
> ideal, but it's there and it works :)

That's neat.. decoupling the "engine" from the "frontend". 

--Jeff

> Ulrich
> 
> -- 
> Ulrich Mayring
> DENIC eG, Systementwicklung
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Ulrich Mayring <ul...@denic.de>.
Jeff Turner wrote:
> 
> I'd have thought that using Avalon in a servlet environment is *the*
> most common usage. With all the IoC in the Servlet API, Avalon seems a
> natural fit for writing more complex servlets..

Strange, I'd have thought THE most common usage of Avalon would be with
Phoenix (blocks and .sar applications and such). Actually what I am
missing in Phoenix is some way to do HTTP - if we had that, then nobody
would want or need to use Avalon in a servlet environment. To implement
a basic HTTP server would be easy, to integrate a more full-featured one
like Jo! or Tomcat would probably be not quite as easy, but the better
choice in the long run.

Here's what I currently do: my Avalon/Phoenix services can be talked to
over a socket connection and I invented a minimal protocol for that.
Then I use my socket XSP taglib for Cocoon1 to seamlessly integrate
these services into a Cocoon webapp. So I don't actually need to do HTTP
into Phoenix, I just talk over the socket and leave the HTTP
request/response handling to my webserver. Maybe this is less than
ideal, but it's there and it works :)

Ulrich

-- 
Ulrich Mayring
DENIC eG, Systementwicklung

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Jeff Turner <je...@socialchange.net.au>.
On Tue, Dec 11, 2001 at 04:37:50PM -0700, Kerry Todyruik wrote:
> I've seen a few responses to how to implement Avalon in a servlet
> environmet and the typical answer is to check out Cocoon.  Cocoon seems
> to implement the main container only in one servlet.  What I needed to
> do is make my main application container available to all of my servlets
> in my application and have it properly started and shut down with the
> Tomcat servlet engine.  I think this is more generic and might be a more
> common requirement.
> 
> The approach I took was instead of having my main container residing in
> one servlet, I made it a singleton.  Then I created an InitServlet as I
> saw somewhere for initizlizing Log4j and set this to load at startup by
> including it in the webapps web.xml file.  Just like Cocoon, I made the
> InitServlet's init() and destroy() methods create and dispose of my main
> container.
> 
> So the end result is the life of my main container then gets tied to the
> starting and stopping of my tomcat server and all of my servlets can
> access it.  Seems to work pretty well.
> 
> Any comments on this method?  I can post some code if there is any
> interest.

Sounds good :) 

I'd have thought that using Avalon in a servlet environment is *the*
most common usage. With all the IoC in the Servlet API, Avalon seems a
natural fit for writing more complex servlets..

Code would be interesting, even if it's not a working example. Maybe it
could form the core of a "Avalon-in-a-servlet-environment starter kit",
reusing all those cool things from Cocoon, like env abstraction,
protocol handlers, error handling, profiling..

--Jeff

> Regards,
> Kerry Todyruik
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Applying Avalon in a Servlet Environment

Posted by Peter Donald <pe...@apache.org>.
On Wed, 12 Dec 2001 10:37, Kerry Todyruik wrote:
> The approach I took was instead of having my main container residing in
> one servlet, I made it a singleton.  Then I created an InitServlet as I
> saw somewhere for initizlizing Log4j and set this to load at startup by
> including it in the webapps web.xml file.  Just like Cocoon, I made the
> InitServlet's init() and destroy() methods create and dispose of my main
> container.

Instead of making it a singleton you may want to instead create the object 
normally and then place it in the ServletContext so that all 
servlets/jsps/etc in same web app can access it via looking it up in that. So 
you would havce something like

MyComponent comp = ...;
getServletContext().setAttribute( MyComponent.ROLE, comp );

and everywhere you need to use it do something like

MyComponent comp = 
  (MyComponent)getServletContext().getAttribute( MyComponent.ROLE );

This seems to be the "J2EE" way - whatever that means ;)

That way it easy to add new services to the web application - just add a new 
servlet that creates a new componenet and retrieve the components from the 
ServletContext.

-- 
Cheers,

Pete

----------------------------------------------------------
Which is worse: Ignorance or Apathy? Who knows? Who cares?
----------------------------------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>