You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Nader Aeinehchi <na...@aeinehchi.com> on 2004/04/21 23:51:31 UTC

What is the primary purpose of Serviceable interface?

Hi

I am trying to understand the primay usage of Serviceable interface.

In Merlin documentation, I find an example where a service consumer looks up for a certain service.  This service consumer implements Serviceable interface.

1. Do I understand it correctly that Serviceable interface is supposed to be implemented by service consumers?
2. Can service providers implement Serviceable interface?
3. Intuitively, I would suppose that service providers should Serviceable interface and not service consumers.  How does Merlin think?

--------------------------------
 

Excerpt from Merlin examples:

public class HelloComponent extends AbstractLogEnabled 
  implements Initializable, Serviceable, Disposable
{
    RandomGenerator m_random = null;
    Identifiable m_identifiable = null;
   /**
    * Servicing of the component by the container during 
    * which service dependencies declared under the component
    * can be resolved using the supplied service manager.
    *
    * @param manager the service manager
    * @avalon.dependency type="tutorial.RandomGenerator:1.0"
    *    key="random"
    * @avalon.dependency type="tutorial.Identifiable"
    */
    public void service( ServiceManager manager )
      throws ServiceException
    {
        m_random = (RandomGenerator) manager.lookup( "random" );
        m_identifiable = 
          (Identifiable) manager.lookup( Identifiable.class.getName() );
    }


Best Regards
 
--
Nader Aeinehchi
Aasenhagen 66 E
2020 Skedsmokorset
NORWAY
Direct and Mobile +47 41 44 29 57
Tel (private): +47 64 83 09 08
Fax +47 64 83 08 07
www.aeinehchi.com


Re: What is the primary purpose of Serviceable interface?

Posted by Stephen McConnell <mc...@apache.org>.
Nader Aeinehchi wrote:

> Stephen,
> 
> Thanks for the clarifications.
> 
> Here comes new questions based on
> 
> 1. Is Serviceable == ServiceConsumer in Merlin?  

It's not a definition I would use.

The Serviceable interface is just a interface that defines a delivery 
strategy.  Is is the definition of a mechanisms that a component 
implementation can use to receive a ServiceManager instance.

> If no, is there any
> ServiceConsumer like interface in Merlin?

Any component that is a consumer of external services needs to acquire a 
ServiceManager in order to lookup its dependents.  Merlin can provide a 
ServiceManager to a component using one of two possible delivery strategies:

    1. by supplying a populated ServiceManager as a constructor
       argument

    2. by invoking the service operation declared by the Serviceable
       interface

The entries in the supplied ServiceManager are established relative to 
the @avalon.dependency key="some-key" type="org.whatever.SomeService" 
tag declaration by the component.

> 2. What interface does a service provider implement in Merlin? Is there any?

A service provider declares that it provides a service using the 
@avalon.service type="org.whatever.SomeService" tag.  The value of the 
type attribute is typically an interface classname that the component 
will normally implement.

> If the component class needs a
> 
>>service manager, then the container will create a new service manager
>>based on the information in the component model.
> 
> 
> 3. Is service manager created on demand? Or is it some vital built-in
> component(service) of a given container?

On demand - as part of the lifecycle processing handled under the 
ComponentFactory class in the activation/impl package.

Cheers, Stephen.

-- 

|---------------------------------------|
| Magic by Merlin                       |
| Production by Avalon                  |
|                                       |
| http://avalon.apache.org              |
|---------------------------------------|

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


Re: What is the primary purpose of Serviceable interface?

Posted by Nader Aeinehchi <na...@aeinehchi.com>.
Stephen,

Thanks for the clarifications.

Here comes new questions based on

1. Is Serviceable == ServiceConsumer in Merlin?  If no, is there any
ServiceConsumer like interface in Merlin?
2. What interface does a service provider implement in Merlin? Is there any?

If the component class needs a
> service manager, then the container will create a new service manager
> based on the information in the component model.

3. Is service manager created on demand? Or is it some vital built-in
component(service) of a given container?

Thanks.


Best Regards

--
Nader Aeinehchi
Aasenhagen 66 E
2020 Skedsmokorset
NORWAY
Direct and Mobile +47 41 44 29 57
Tel (private): +47 64 83 09 08
Fax +47 64 83 08 07
www.aeinehchi.com

----- Original Message -----
From: "Stephen McConnell" <mc...@apache.org>
To: "Avalon Developers List" <de...@avalon.apache.org>
Sent: Thursday, April 22, 2004 12:46 AM
Subject: Re: What is the primary purpose of Serviceable interface?


> Nader Aeinehchi wrote:
>
> > Hi
> >
> > I am trying to understand the primay usage of Serviceable interface.
> >
> > In Merlin documentation, I find an example where a service consumer
looks up for a certain service.  This service consumer implements
Serviceable interface.
> >
> > 1. Do I understand it correctly that Serviceable interface
> > is supposed to be implemented by service consumers?
>
> Correct.
>
> A ServiceManager is simply a lifecycle artifact provided by the
> container to a component that either implements the Serviceable
> interface, or declares a ServiceManager as a constructor argument.  The
> service manager will be pre-populated with services accessible using the
> keys the the consumer component declares.
>
> > 2. Can service providers implement Serviceable interface?
>
> Yes - if they are dependent on other services (in which case they would
> be a consumer of the services that they declare as dependencies).
>
> > 3. Intuitively, I would suppose that service providers should
> > Serviceable interface and not service consumers.
>
> I think there is a word missing in the above sentence.
>
> > How does Merlin think?
>
> When you describe a component that leverages IoC, you want to that
> component to be unconcerned with the problems of resolving the services
> it needs - so we hand this job over to the container.  The container
> looks at the component type information associated with the component
> class and from this creates a component model.  The container then
> assembles the model during which components that can provide
> corresponding services are assigned as providers.  When an instance of
> the component is required, the container runs the component instance
> through it's deployment lifecycle.  If the component class needs a
> service manager, then the container will create a new service manager
> based on the information in the component model.
>
> Stephen.
>
> > --------------------------------
> >
> >
> > Excerpt from Merlin examples:
> >
> > public class HelloComponent extends AbstractLogEnabled
> >   implements Initializable, Serviceable, Disposable
> > {
> >     RandomGenerator m_random = null;
> >     Identifiable m_identifiable = null;
> >    /**
> >     * Servicing of the component by the container during
> >     * which service dependencies declared under the component
> >     * can be resolved using the supplied service manager.
> >     *
> >     * @param manager the service manager
> >     * @avalon.dependency type="tutorial.RandomGenerator:1.0"
> >     *    key="random"
> >     * @avalon.dependency type="tutorial.Identifiable"
> >     */
> >     public void service( ServiceManager manager )
> >       throws ServiceException
> >     {
> >         m_random = (RandomGenerator) manager.lookup( "random" );
> >         m_identifiable =
> >           (Identifiable) manager.lookup( Identifiable.class.getName() );
> >     }
> >
> >
> > Best Regards
> >
> > --
> > Nader Aeinehchi
> > Aasenhagen 66 E
> > 2020 Skedsmokorset
> > NORWAY
> > Direct and Mobile +47 41 44 29 57
> > Tel (private): +47 64 83 09 08
> > Fax +47 64 83 08 07
> > www.aeinehchi.com
> >
> >
>
>
> --
>
> |---------------------------------------|
> | Magic by Merlin                       |
> | Production by Avalon                  |
> |                                       |
> | http://avalon.apache.org              |
> |---------------------------------------|
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> For additional commands, e-mail: dev-help@avalon.apache.org


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


Re: What is the primary purpose of Serviceable interface?

Posted by Stephen McConnell <mc...@apache.org>.
Nader Aeinehchi wrote:

> Hi
> 
> I am trying to understand the primay usage of Serviceable interface.
> 
> In Merlin documentation, I find an example where a service consumer looks up for a certain service.  This service consumer implements Serviceable interface.
> 
> 1. Do I understand it correctly that Serviceable interface 
> is supposed to be implemented by service consumers?

Correct.

A ServiceManager is simply a lifecycle artifact provided by the 
container to a component that either implements the Serviceable 
interface, or declares a ServiceManager as a constructor argument.  The 
service manager will be pre-populated with services accessible using the 
keys the the consumer component declares.

> 2. Can service providers implement Serviceable interface?

Yes - if they are dependent on other services (in which case they would 
be a consumer of the services that they declare as dependencies).

> 3. Intuitively, I would suppose that service providers should 
> Serviceable interface and not service consumers.  

I think there is a word missing in the above sentence.

> How does Merlin think?

When you describe a component that leverages IoC, you want to that 
component to be unconcerned with the problems of resolving the services 
it needs - so we hand this job over to the container.  The container 
looks at the component type information associated with the component 
class and from this creates a component model.  The container then 
assembles the model during which components that can provide 
corresponding services are assigned as providers.  When an instance of 
the component is required, the container runs the component instance 
through it's deployment lifecycle.  If the component class needs a 
service manager, then the container will create a new service manager 
based on the information in the component model.

Stephen.

> --------------------------------
>  
> 
> Excerpt from Merlin examples:
> 
> public class HelloComponent extends AbstractLogEnabled 
>   implements Initializable, Serviceable, Disposable
> {
>     RandomGenerator m_random = null;
>     Identifiable m_identifiable = null;
>    /**
>     * Servicing of the component by the container during 
>     * which service dependencies declared under the component
>     * can be resolved using the supplied service manager.
>     *
>     * @param manager the service manager
>     * @avalon.dependency type="tutorial.RandomGenerator:1.0"
>     *    key="random"
>     * @avalon.dependency type="tutorial.Identifiable"
>     */
>     public void service( ServiceManager manager )
>       throws ServiceException
>     {
>         m_random = (RandomGenerator) manager.lookup( "random" );
>         m_identifiable = 
>           (Identifiable) manager.lookup( Identifiable.class.getName() );
>     }
> 
> 
> Best Regards
>  
> --
> Nader Aeinehchi
> Aasenhagen 66 E
> 2020 Skedsmokorset
> NORWAY
> Direct and Mobile +47 41 44 29 57
> Tel (private): +47 64 83 09 08
> Fax +47 64 83 08 07
> www.aeinehchi.com
> 
> 


-- 

|---------------------------------------|
| Magic by Merlin                       |
| Production by Avalon                  |
|                                       |
| http://avalon.apache.org              |
|---------------------------------------|

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