code: public static ServiceReference<Application> getApplicationServiceRef(BundleContext bundleContext, String applicationName) {
          ServiceReference<Application> appRef = null;
  
          if (FrameworkState.isValid()) {
              Collection<ServiceReference<Application>> appRefs;
              try {
                  appRefs = bundleContext.getServiceReferences(Application.class,
                                                               FilterUtils.createPropertyFilter("name", applicationName));
              } catch (InvalidSyntaxException e) {
                  throw new ConfigException(e);
              }
  
              if (appRefs != null && appRefs.size() > 0) {
                  if (appRefs.size() > 1) {
                      throw new ConfigException(Tr.formatMessage(tc, "duplicate.application.name.CWMCG0202E", applicationName));
                  }
                  appRef = appRefs.iterator().next();
              }
          }
  
          return appRef;
      }
docs: Get the Application ServiceReferences which has the given name, or null if not found
  
  @param bundleContext The context to use to find the application service references
  @param applicationName The application name to look for
  @return A ServiceReference for the given application