> -----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]

Reply via email to