Hi,

You want to do something like:

class MyComponent implements Serviceable
{
    ServiceManager manager;

    public service(ServiceManager manager)
    {
        this.manager = manager;
    }

    public AnObjectForSomeRequest createSomething(...) throws
ServiceException
    {
        AnObjectForSomeRequest result = (AnObjectForSomeRequest)
            manager.lookup("componentname");

        return result;
    }

    ...

}

The service methods (and all lifecycle methods for that matter)
are called automatically by the container...

Hope this helps,
- Filip


> Hi all,
>
> I'm a new Avalon user (through Cocoon) and I find myself using a pattern
> a lot that seems a little contrary to the spirit of Avalon, but I guess
> I don't know enough what a better alternative would be (or even if my
> suspicion is true).
>
> The pattern is shown below.  When my component creates an object that
> itself needs to look up services, etc. it seems like there should be a
> better way than calling service(), etc. manually.
>
> Basically, I'd like to do what Cocoon does with its sitemap components
> in my own components (where the container manages the object instances,
> but it's just used within the context of a single request).
>
> Thanks,
>
> Pete
>
> class MyComponent implements Serviceable
> {
>     ServiceManager manager;
>
>     public service(ServiceManager manager)
>     {
>         this.manager = manager;
>     }
>
>     public AnObjectForSomeRequest createSomething(...) throws
> ServiceException
>     {
>         AnObjectForSomeRequest result = new AnObjectForSomeRequest();
> result.service(this.manager);
>         ...
>         return result;
>     }
>
>     ...
>
> }
>
> class AnObjectForSomeRequest implements Serviceable
> {
>     ...
> }
>
> --
> NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien...
> Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService
>
> Jetzt kostenlos anmelden unter http://www.gmx.net
>
> +++ GMX - die erste Adresse f�r Mail, Message, More! +++
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to