Olaf Bergner wrote: ------------------------------------------------- So, while what Niclas and Stephen said is certainly true and obviously the road where greater honour and glory are to be found I would still suggest that you simply start by writing something like
public class MyApplicationLauncher extends AbstractLogEnabled implements Initializable, Executable, ... { public void initialize() throws Exception { ... }
public void execute() throws Exception { // Here goes the code you would normally put into your "public static void main(String[] args)" method } }
and you will know that once merlin has initialized your app launcher it will call its execute() method.
-------------------------
Yes I did. I tried writing more than one components and defining those in build.xml with activation="startup" and both were loaded by Merlin as expected and the lifecycle methods were executed in the expected sequence .
Now I also studied and ran the sample web server example that we have. Why are multiple components defined with activation="startup".
We are loading all the required jars using the <classpath> in build.xml.
And then can't we simply have that "SimpleWebServerComponent" use dependencies from the classpath and do its job.
I commented out one of the components defined with activation="startup" in build.xml and the server still worked fine ( to the best of my knowledge ).
So why did we have more than one components with activation="startup" in our build.xml.
SimpleWebServerComponent is using other components but it is this component only which holds the meat for us, shouldn't this the only one with activation="startup"
Why the need to have multiple components with activation="startup" arise in this web server in particular and real world applications in general.
Thanks a lot again guys. Just hang in with me for a little while and I'll get it going.
Mathews.
From: "Olaf Bergner" <[EMAIL PROTECTED]> Reply-To: "Avalon framework users" <[EMAIL PROTECTED]> To: "Avalon framework users" <[EMAIL PROTECTED]> Subject: RE: Non component class as the starting point Date: Mon, 19 Jan 2004 23:06:23 +0100
> -----Original Message-----
> From: Mathews Julien [mailto:[EMAIL PROTECTED]
> Sent: Monday, January 19, 2004 10:10 PM
>
> Olaf Bergner wrote:
>
> Avalon was probably conceived and developed by people who
> >focused on client/server architectures, often obeying a request/response
> >pattern. Such applications often simply start a listener thread once
> >initialization has completed and wait for incoming requests. So
> apart from
> >the code that creates the listener thread there's no easily identifiable
> >"main" method.
>
> Whatever u guys say makes perfect sense, but I'm still going nuts
> on a very
> basic question.
That wasn't my intention. Let me know if I could lend you a hand getting out
of that straight jacket ;-)
> When we say "merlin target\classes -execute", my classes folder has many > components, but merlin goes and loads( starts or whatever )the > HelloComponent among those. And then HelloComponent has dependencies. > > So like I run a program from a jar file, the " java -jar" looks into the > manifest to find the Main Class, which acts as the starting point of my > Application. In Merlin tutorials, the HelloComponent is acting as the > starting point. How does merlin know that it should hit > HelloComponent and > not the other components under the same package that might be > implementing > life cycle interfaces just like HelloComponent. > > So how does "merlin -execute" determine that starting point. > Doesn't it use > "block.xml" ? >
Merlin DOES NOT KNOW such thing as an application's starting point, much
like a J2EE application server does not know about starting points of
applications deployed in it. What it knows about is the Avalon lifecycle
interfaces and the contracts surrounding those. What this means is that when
you say "merlin target\classes -execute" merlin will indeed read in
block.xml, instantiate each component found in there, call the lifecycle
methods (initialize(), ...) on those components in the order specified by
the Avalon framework and that's all it does (forgive me, Stephen ...). As
far as I know there's no way of telling merlin that it should direct its
attention first to component A and then to component B.
> If yes then in block.xml I can have more than one <components> under one > <container>, then how would Merlin find out which one to start with. > > If is starting point a totally irrelevant concept in Merlin's case. > > I don't know if I'm making myself clear. >
You are making yourself perfectly clear. Seems like I cannot make myself clear. Looking at HelloComponent you will notice that it implements LogEnabled, Initializable, Executable, Disposable (and Hello). So what happens when you say "merlin target\classes -execute" is
1. Merlin will read in block.xml and inspect its contents.
2. Merlin will instantiate HelloComponent.
3. Merlin will call enableLogging() on this component.
4. Merlin will call initialize() on this component.
5. Merlin will call execute() on this component.
6. Merlin will call dispose() on this component.
7. Merlin will faithfully hand your component over to the JVM's garbage collector.
(8. Merlin will shut down, since you used the -execute switch.)
So, while what Niclas and Stephen said is certainly true and obviously the road where greater honour and glory are to be found I would still suggest that you simply start by writing something like
public class MyApplicationLauncher extends AbstractLogEnabled implements Initializable, Executable, ... { public void initialize() throws Exception { ... }
public void execute() throws Exception
{
// Here goes the code you would normally put into your "public static void
main(String[] args)" method
}
}
and you will know that once merlin has initialized your app launcher it will
call its execute() method.
Hope this helps,
Olaf
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Check out the coupons and bargains on MSN Offers! http://shopping.msn.com/softcontent/softcontent.aspx?scmId=1418
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]