docs: @Override
      public ResourceFactory createResourceFactory(Map<String, Object> props) throws Exception {
  
          Hashtable<String, Object> mailSessionSvcProps = new Hashtable<String, Object>();
  
          Map<String, Object> annotationProps = new HashMap<String, Object>();
  
          for (Map.Entry<String, Object> prop : props.entrySet()) {
              Object value = prop.getValue();
              annotationProps.put(prop.getKey(), value);
          }
  
          String application = (String) annotationProps.remove("application");
          String module = (String) annotationProps.remove("module");
          String component = (String) annotationProps.remove("component");
          String jndiName = (String) annotationProps.remove(MailSessionService.JNDI_NAME);
          String description = (String) annotationProps.remove(MailSessionService.DESCRIPTION);
          String storeProtocol = (String) annotationProps.remove(MailSessionService.STOREPROTOCOL);
          String transportProtocol = (String) annotationProps.remove(MailSessionService.TRANSPORTPROTOCOL);
          String host = (String) annotationProps.remove(MailSessionService.HOST);
          String user = (String) annotationProps.remove(MailSessionService.USER);
          String password = (String) annotationProps.remove(MailSessionService.PASSWORD);
          String from = (String) annotationProps.remove(MailSessionService.FROM);
          String storeProtocolClass = (String) annotationProps.remove(MailSessionService.STOREPROTOCOLCLASSNAME);
          String transportProtocolClass = (String) annotationProps.remove(MailSessionService.TRANSPORTPROTOCOLCLASSNAME);
          String property = (String) annotationProps.remove(MailSessionService.PROPERTY);
          String mailSessionID = getMailSessionID(application, module, component, jndiName);
  
          StringBuilder filter = new StringBuilder(FilterUtils.createPropertyFilter(ID, mailSessionID));
          filter.insert(filter.length() - 1, '*');
          // Fail if server.xml is already using the id
          if (!removeExistingConfigurations(filter.toString()))
              throw new IllegalArgumentException(mailSessionID); // internal error, shouldn't ever have been permitted in server.xml
  
          mailSessionSvcProps.put(MailSessionService.JNDI_NAME, jndiName);
          if (description != null)
              mailSessionSvcProps.put(MailSessionService.DESCRIPTION, description);
          if (storeProtocol != null)
              mailSessionSvcProps.put(MailSessionService.STOREPROTOCOL, storeProtocol);
          if (transportProtocol != null)
              mailSessionSvcProps.put(MailSessionService.TRANSPORTPROTOCOL, transportProtocol);
          if (host != null)
              mailSessionSvcProps.put(MailSessionService.HOST, host);
          if (user != null)
              mailSessionSvcProps.put(MailSessionService.USER, user);
          if (password != null)
              mailSessionSvcProps.put(MailSessionService.PASSWORD, password);
          if (from != null)
              mailSessionSvcProps.put(MailSessionService.FROM, from);
          if (storeProtocolClass != null)
              mailSessionSvcProps.put(MailSessionService.STOREPROTOCOLCLASSNAME, storeProtocolClass);
          if (transportProtocolClass != null)
              mailSessionSvcProps.put(MailSessionService.TRANSPORTPROTOCOLCLASSNAME, transportProtocolClass);
          if (property != null)
              mailSessionSvcProps.put(MailSessionService.PROPERTY, property);
  
          if (application != null) {
              mailSessionSvcProps.put("application", application);
              if (module != null) {
                  mailSessionSvcProps.put("module", module);
                  if (component != null)
                      mailSessionSvcProps.put("component", component);
              }
          }
  
          MailSessionResourceFactory mss = new MailSessionResourceFactory();
          mss.processProperties(mailSessionSvcProps);
  
          // MailSessionService does not use the Resource, pass null
          mss.createResource(null);
  
          return mss;
      }