code: public static Object getServiceByFilter( BundleContext bc, String ldapFilter, long timeout )
      {
          try
          {
              Filter filter = bc.createFilter( ldapFilter );
              ServiceTracker tracker = new ServiceTracker( bc, filter, null );
              tracker.open();
              Object svc = tracker.waitForService( timeout );
              if( svc == null )
              {
                  throw new ServiceLookupException( "gave up waiting for service " + ldapFilter );
              }
              // increment the service use count to keep it valid after the ServiceTracker is closed
              return bc.getService( tracker.getServiceReference() );
          }
          catch ( InvalidSyntaxException exc )
          {
              throw new ServiceLookupException( exc );
          }
          catch ( InterruptedException exc )
          {
              throw new ServiceLookupException( exc );
          }
      }
docs: Returns a service matching the given filter.
  
  @param bc bundle context for accessing the OSGi registry
  @param ldapFilter LDAP filter to be matched by the service. The class name must be part of the
  filter.
  @param timeout maximum wait period in milliseconds
  @return matching service (not null)
  @throws ServiceLookupException when no matching service has been found after the timeout