question: protected Object lookupService ( ) throws Exception { Object service = null ; ServiceTemplate templ ; if ( template == null ) { Class < ? > [ ] types = ( serviceClass == null ? null : new Class [ ] { serviceClass } ) ; Entry [ ] entry = ( serviceName == null ? null : new Entry [ ] { new Name ( serviceName ) } ) ; templ = new ServiceTemplate ( null , types , entry ) ; } else { templ = template ; } LookupLocator [ ] lookupLocators = null ; if ( locators != null ) { lookupLocators = new LookupLocator [ locators . length ] ; for ( int i = 0 ; i < locators . length ; i ++ ) { String locator = locators [ i ] ; if ( ! locator . startsWith ( "jini://" ) ) { locator = "jini://" + locator ; } lookupLocators [ i ] = new LookupLocator ( locator ) ; } } ServiceDiscoveryManager serviceDiscovery = null ; try { serviceDiscovery = SharedDiscoveryManagement . getBackwardsServiceDiscoveryManager ( groups , lookupLocators , null ) ; ServiceItem returnObject = serviceDiscovery . lookup ( templ , null , timeout ) ; if ( returnObject != null ) { service = returnObject . service ; } } finally { if ( serviceDiscovery != null ) { try { serviceDiscovery . terminate ( ) ; } catch ( Exception e ) { logger . warn ( "Failed to terminate service discovery, ignoring" , e ) ; } } } return service ; }
target:  A helper method to lookup the service.