RE: Help me how to exposing service and consume it

"Roberto Juarez" <[email protected]>
Newsgroups gmane.comp.jakarta.avalon.user
Message-ID <1586DE6EBC0FF742BBC32EECA73847318ACC20@omnilogic05ma.OTMA.OMNILOGIC.ES>
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!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.