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