Looks like the Javadoc of the service(ServiceManager) method of the component that 
uses the services is wrong. Here you are a service method that works 

  /**
   * Servicing of the component by the container during 
   * which service dependencies declared under the component
   * can be resolved using the supplied service manager.
   *
   * @param serviceManager the service manager
   * @avalon.dependency 
type="avalon.merlin.service.manual.interfaces.random.RandomGenerator:1.0"  key="random"
   * @avalon.dependency 
type="avalon.merlin.service.manual.interfaces.identity.Identifiable"  key="simple"
   */
  public void service(ServiceManager serviceManager) throws ServiceException {
    getLogger().debug("[service start]");
    
    serviceManager.lookup("random");
    serviceManager.lookup("simple");
    
    getLogger().debug("[service end]");
  }

And this is a service method that fails

  /**
   * Servicing of the component by the container during 
   * which service dependencies declared under the component
   * can be resolved using the supplied service manager.
   *
   * @param serviceManager the service manager
   * @avalon.dependency 
type="avalon.merlin.service.manual.interfaces.random.RandomGenerator:1.0"  key="random"
   * @avalon.dependency 
type="avalon.merlin.service.manual.interfaces.identity.Identifiable" NOTE HOW I FORGET 
THE KEY
   */
  public void service(ServiceManager serviceManager) throws ServiceException {
    getLogger().debug("[service start]");
    
    serviceManager.lookup("random");
    serviceManager.lookup("simple");//THIS WILL FAIL AT RUNTIME
    
    getLogger().debug("[service end]");
  }


To make the previous method work you need to lookup by interface name, not by key

  /**
   * Servicing of the component by the container during 
   * which service dependencies declared under the component
   * can be resolved using the supplied service manager.
   *
   * @param serviceManager the service manager
   * @avalon.dependency 
type="avalon.merlin.service.manual.interfaces.random.RandomGenerator:1.0"  key="random"
   * @avalon.dependency 
type="avalon.merlin.service.manual.interfaces.identity.Identifiable"
   */
  public void service(ServiceManager serviceManager) throws ServiceException {
    getLogger().debug("[service start]");
    
    serviceManager.lookup("random");
    serviceManager.lookup(Identifiable.class.getName());
    
    getLogger().debug("[service end]");
  }

Cheers

Roberto.

> -----Mensaje original-----
> De:   ANDI KUSNADI [SMTP:[EMAIL PROTECTED]
> Enviado el:   viernes, 03 de septiembre de 2004 7:29
> Para: [EMAIL PROTECTED]
> Asunto:       Help me how to exposing service  and consume it
> 
> 
> Dear all,
> 
> i am  try tutorial from merlin e.g auto and manual but when i execute it's show up 
> erro messgage says unknown key="random" why it's happening ?
> 
> i am appreciate for the help
> 
> Thank you
> 
> andi kusnadi
> 
>               
> ---------------------------------
> Do you Yahoo!?
> New and Improved Yahoo! Mail - 100MB free storage!

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

Reply via email to