code: private void setSerializationId(ConfigurableListableBeanFactory beanFactory) {
  
  		if (beanFactory instanceof DefaultListableBeanFactory) {
  
  			String id = this.id;
  			if (id == null) {
  				List<String> list = new ArrayList<>(
  						Arrays.asList(beanFactory.getBeanDefinitionNames()));
  				Collections.sort(list);
  				String names = list.toString();
  				logger.debug("Generating bean factory id from names: " + names);
  				id = UUID.nameUUIDFromBytes(names.getBytes()).toString();
  			}
  
  			logger.info("BeanFactory id=" + id);
  			((DefaultListableBeanFactory) beanFactory).setSerializationId(id);
  
  		}
  		else {
  			logger.warn(
  					"BeanFactory was not a DefaultListableBeanFactory, scoped proxy beans "
  							+ "cannot be serialized.");
  		}
  
  	}
docs: If the bean factory is a DefaultListableBeanFactory, then it can serialize scoped
  beans and deserialize them in another context (even in another JVM), as long as the
  IDs of the bean factories match. This method sets up the serialization ID to be
  either the ID provided to the scope instance, or if that is null, a hash of all the
  bean names.
  @param beanFactory The bean factory to configure.