1 8 package org.codehaus.loom.components.assembler.data; 9 10 import java.util.Iterator ; 11 import java.util.Map ; 12 import org.apache.avalon.framework.service.ServiceException; 13 import org.apache.avalon.framework.service.ServiceManager; 14 import org.apache.avalon.framework.service.Serviceable; 15 16 23 public class Component4 24 implements Serviceable 25 { 26 29 public void service( final ServiceManager manager ) 30 throws ServiceException 31 { 32 final Map services = 33 (Map )manager.lookup( Service1.class.getName() + "{}" ); 34 System.out.println( "Passed the following services: " + 35 services.keySet() ); 36 if( 3 != services.size() ) 37 { 38 final String message = 39 "Expected to get 3 services but got " + services.size(); 40 throw new ServiceException( Service1.class.getName() + "{}", 41 message ); 42 } 43 44 final Iterator iterator = services.keySet().iterator(); 45 while( iterator.hasNext() ) 46 { 47 final String key = (String )iterator.next(); 48 final Service1 service1 = (Service1)services.get( key ); 49 if( null == service1 ) 50 { 51 final String message = "Expected non null service entry for " + 52 key; 53 throw new ServiceException( Service1[].class.getName(), 54 message ); 55 } 56 } 57 } 58 } 59 | Popular Tags |