private void registerSpies(BeanDefinitionRegistry registry, SpyDefinition definition,
                             Set<String> existingBeans) {
    try {
      registerSpy(definition,
        determineBeanName(existingBeans, definition, registry));
    } catch (RuntimeException ex) {
      throw new IllegalStateException(
        "Unable to register spy bean " + definition.getTypeToSpy(), ex);
    }
  }
Factory method used by defined beans to actually create the mock.

@param mockDefinition the mock definition
@param name the bean name
@return the mock instance
spock-spring/src/main/java/org/spockframework/spring/mock/SpockMockPostprocessor.java