code: public static String getApplicationPID(BundleContext bundleContext, String applicationName) {
          String applicationPID = null;
  
          if (FrameworkState.isValid()) {
              ServiceReference<?> appRef = getApplicationServiceRef(bundleContext, applicationName);
              if (appRef != null) {
                  //not actually sure what the difference is between service.pid and ibm.extends.source.pid but this is the way it is done everywhere else!
                  applicationPID = (String) appRef.getProperty(Constants.SERVICE_PID);
                  String sourcePid = (String) appRef.getProperty("ibm.extends.source.pid");
                  if (sourcePid != null) {
                      applicationPID = sourcePid;
                  }
              }
          }
          return applicationPID;
  
      }
docs: Get the internal OSGi identifier for the Application with the given name
  
  @param bundleContext The context to use to find the Application reference
  @param applicationName The application name to look for
  @return The application pid