You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Ugo Cei <u....@cbim.it> on 2001/12/04 18:29:49 UTC

[Cocoon+Avalon] Adding a new ComponentSelector

Hi People,

I'm trying to create a reusable component for use in Cocoon and in other 
applications, so I decided to create an Avalon component for this, 
called Authenticator. Since I need different components for the 
Authenticator role, I also created an AuthenticatorSelector.

Now I'm trying to use my component in a Cocoon action. This is a snippet 
of code from the "act" method of my Action:

     ComponentSelector selector = null;
     try
       {
         selector = (ComponentSelector) manager.lookup
           (Authenticator.ROLE + "Selector");
       }
     catch(ComponentException ce)
       {
         AuthenticatorSelector as = new AuthenticatorSelector();
         as.setLogger(getLogger());
         as.compose(manager);
         as.configure(conf);
         selector = as;

         // HOW TO ADD SELECTOR TO MANAGER HERE?
       }

The first time the action is invoked, the lookup method fails and a new 
selector is created, but I want that on the following invocations, the 
lookup method returns the previously created selector instance.

Is it possible? Is this the correct way of using Avalon selectors? I 
must confess that after having read two or three times "Developing with 
Apache Avalon", I still don't grasp most of it :).

	Thanks in advance and sorry for the crossposting,

		Ugo


-- 
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it


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


Re: [Cocoon+Avalon] AutoComposable Components [was Adding a new ComponentSelector]

Posted by Adrian Geissel <ag...@zenark.com>.
Thanks again - and it was to be my last question on this thread ;) Good to
have the doc anyway.

Cheers
Adrian

----- Original Message -----
From: Berin Loritsch <bl...@apache.org>
To: <co...@xml.apache.org>
Sent: Thursday, December 06, 2001 2:33 PM
Subject: Re: [Cocoon+Avalon] AutoComposable Components [was Adding a new
ComponentSelector]


> Adrian Geissel wrote:
>
> > thanks - one question: is initializable called before or after
> > Composable.compose()?
> > I also would like access to the ComponentManager at that time.
>
>
> Please read the paper at the following link:
>
> http://jakarta.apache.org/avalon/developing.pdf
>
> It answers all the questions you are about to ask.
>
> The short answer is yes, Composable comes before Initializable.
>
>
> --
>
> "They that give up essential liberty to obtain a little temporary safety
>   deserve neither liberty nor safety."
>                  - Benjamin Franklin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [Cocoon+Avalon] AutoComposable Components [was Adding a new ComponentSelector]

Posted by Berin Loritsch <bl...@apache.org>.
Adrian Geissel wrote:

> thanks - one question: is initializable called before or after
> Composable.compose()?
> I also would like access to the ComponentManager at that time.


Please read the paper at the following link:

http://jakarta.apache.org/avalon/developing.pdf

It answers all the questions you are about to ask.

The short answer is yes, Composable comes before Initializable.


-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [Cocoon+Avalon] AutoComposable Components [was Adding a new ComponentSelector]

Posted by Adrian Geissel <ag...@zenark.com>.
thanks - one question: is initializable called before or after
Composable.compose()?
I also would like access to the ComponentManager at that time.

Adrian

----- Original Message -----
From: Berin Loritsch <bl...@apache.org>
To: <co...@xml.apache.org>
Sent: Thursday, December 06, 2001 1:51 PM
Subject: Re: [Cocoon+Avalon] AutoComposable Components [was Adding a new
ComponentSelector]


> Adrian Geissel wrote:
>
> > Hi,
> >
> > I have a closely related question, as follows:
> >
> > Is there a mechanism within Cocoon/Avalon to declare a Composable
Component
> > to be Composed during the Cocoon boot routine?
> >
> > I'm thinking of a background processor that lives in parallel to Cocoon,
and
> > is initialized as Cocoon boots and destructed during shut-down (using
the
> > Startable interface).
>
> In Excalibur 4.0 (the official release), ExcaliburComponentManager was
changed
>
> to be Initializable.  When the ECM is initialized, it goes through and
initializes
> all the components that were declared for the ECM.
>
>
>
>
> --
>
> "They that give up essential liberty to obtain a little temporary safety
>   deserve neither liberty nor safety."
>                  - Benjamin Franklin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [Cocoon+Avalon] AutoComposable Components [was Adding a new ComponentSelector]

Posted by Berin Loritsch <bl...@apache.org>.
Adrian Geissel wrote:

> Hi,
> 
> I have a closely related question, as follows:
> 
> Is there a mechanism within Cocoon/Avalon to declare a Composable Component
> to be Composed during the Cocoon boot routine?
> 
> I'm thinking of a background processor that lives in parallel to Cocoon, and
> is initialized as Cocoon boots and destructed during shut-down (using the
> Startable interface).

In Excalibur 4.0 (the official release), ExcaliburComponentManager was changed

to be Initializable.  When the ECM is initialized, it goes through and initializes
all the components that were declared for the ECM.




-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [Cocoon+Avalon] AutoComposable Components [was Adding a new ComponentSelector]

Posted by Adrian Geissel <ag...@zenark.com>.
Hi,

I have a closely related question, as follows:

Is there a mechanism within Cocoon/Avalon to declare a Composable Component
to be Composed during the Cocoon boot routine?

I'm thinking of a background processor that lives in parallel to Cocoon, and
is initialized as Cocoon boots and destructed during shut-down (using the
Startable interface).

Any pointers?
Thanks
Adrian

----- Original Message -----
From: Peter Royal <pr...@managingpartners.com>
To: <co...@xml.apache.org>; Ugo Cei <u....@cbim.it>
Cc: Avalon Developers List <av...@jakarta.apache.org>
Sent: Wednesday, December 05, 2001 4:28 PM
Subject: Re: [Cocoon+Avalon] Adding a new ComponentSelector


> On Wednesday 05 December 2001 11:10 am, Ugo Cei wrote:
> > > You can't! You'll have to add your component to the cocoon.xconf file.
> >
> > Sigh. I suspected it, but I cannot figure out HOW to do it, can you give
> > me a hint?
>
> This is covered in the cocoon-dev archives @ http://marc.theaimsgroups.com
>
> The easiest way is to use the component-instance tag. Ala:
>
> <component-instance class="your.java.Class" role="your.ROLE"/>
>
> -pete
>
> --
> peter royal -> proyal@managingpartners.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [Cocoon+Avalon] Adding a new ComponentSelector

Posted by Peter Royal <pr...@managingpartners.com>.
On Wednesday 05 December 2001 11:10 am, Ugo Cei wrote:
> > You can't! You'll have to add your component to the cocoon.xconf file.
>
> Sigh. I suspected it, but I cannot figure out HOW to do it, can you give
> me a hint?

This is covered in the cocoon-dev archives @ http://marc.theaimsgroups.com

The easiest way is to use the component-instance tag. Ala:

<component-instance class="your.java.Class" role="your.ROLE"/>

-pete

-- 
peter royal -> proyal@managingpartners.com

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [Cocoon+Avalon] Adding a new ComponentSelector

Posted by Peter Royal <pr...@managingpartners.com>.
On Wednesday 05 December 2001 11:10 am, Ugo Cei wrote:
> > You can't! You'll have to add your component to the cocoon.xconf file.
>
> Sigh. I suspected it, but I cannot figure out HOW to do it, can you give
> me a hint?

This is covered in the cocoon-dev archives @ http://marc.theaimsgroups.com

The easiest way is to use the component-instance tag. Ala:

<component-instance class="your.java.Class" role="your.ROLE"/>

-pete

-- 
peter royal -> proyal@managingpartners.com

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


Re: [Cocoon+Avalon] Adding a new ComponentSelector

Posted by Ugo Cei <u....@cbim.it>.
giacomo wrote:


> You can't! You'll have to add your component to the cocoon.xconf file.


Sigh. I suspected it, but I cannot figure out HOW to do it, can you give 
me a hint?


> Giacomo

Thanks,

	Ugo

-- 
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it


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


Re: [Cocoon+Avalon] Adding a new ComponentSelector

Posted by Ugo Cei <u....@cbim.it>.
giacomo wrote:


> You can't! You'll have to add your component to the cocoon.xconf file.


Sigh. I suspected it, but I cannot figure out HOW to do it, can you give 
me a hint?


> Giacomo

Thanks,

	Ugo

-- 
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: [Cocoon+Avalon] Adding a new ComponentSelector

Posted by giacomo <gi...@apache.org>.
On Tue, 4 Dec 2001, Ugo Cei wrote:

> Hi People,
>
> I'm trying to create a reusable component for use in Cocoon and in other
> applications, so I decided to create an Avalon component for this,
> called Authenticator. Since I need different components for the
> Authenticator role, I also created an AuthenticatorSelector.
>
> Now I'm trying to use my component in a Cocoon action. This is a snippet
> of code from the "act" method of my Action:
>
>      ComponentSelector selector = null;
>      try
>        {
>          selector = (ComponentSelector) manager.lookup
>            (Authenticator.ROLE + "Selector");
>        }
>      catch(ComponentException ce)
>        {
>          AuthenticatorSelector as = new AuthenticatorSelector();
>          as.setLogger(getLogger());
>          as.compose(manager);
>          as.configure(conf);
>          selector = as;
>
>          // HOW TO ADD SELECTOR TO MANAGER HERE?

You can't! You'll have to add your component to the cocoon.xconf file.

Giacomo

>        }
>
> The first time the action is invoked, the lookup method fails and a new
> selector is created, but I want that on the following invocations, the
> lookup method returns the previously created selector instance.
>
> Is it possible? Is this the correct way of using Avalon selectors? I
> must confess that after having read two or three times "Developing with
> Apache Avalon", I still don't grasp most of it :).
>
> 	Thanks in advance and sorry for the crossposting,
>
> 		Ugo
>
>
>


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


Re: [Cocoon+Avalon] Adding a new ComponentSelector

Posted by giacomo <gi...@apache.org>.
On Tue, 4 Dec 2001, Ugo Cei wrote:

> Hi People,
>
> I'm trying to create a reusable component for use in Cocoon and in other
> applications, so I decided to create an Avalon component for this,
> called Authenticator. Since I need different components for the
> Authenticator role, I also created an AuthenticatorSelector.
>
> Now I'm trying to use my component in a Cocoon action. This is a snippet
> of code from the "act" method of my Action:
>
>      ComponentSelector selector = null;
>      try
>        {
>          selector = (ComponentSelector) manager.lookup
>            (Authenticator.ROLE + "Selector");
>        }
>      catch(ComponentException ce)
>        {
>          AuthenticatorSelector as = new AuthenticatorSelector();
>          as.setLogger(getLogger());
>          as.compose(manager);
>          as.configure(conf);
>          selector = as;
>
>          // HOW TO ADD SELECTOR TO MANAGER HERE?

You can't! You'll have to add your component to the cocoon.xconf file.

Giacomo

>        }
>
> The first time the action is invoked, the lookup method fails and a new
> selector is created, but I want that on the following invocations, the
> lookup method returns the previously created selector instance.
>
> Is it possible? Is this the correct way of using Avalon selectors? I
> must confess that after having read two or three times "Developing with
> Apache Avalon", I still don't grasp most of it :).
>
> 	Thanks in advance and sorry for the crossposting,
>
> 		Ugo
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org