title: Spring and passing parameters to factory-method in runtime
body: <p>The documentation of method context.getBean(name, user) says</p>
  
  <blockquote>
    <p>Allows for specifying explicit constructor arguments / factory method
    arguments</p>
  </blockquote>
  
  <p>but no matter what I do (tried everything), with the most logical setting I get this when the beans are being loaded up during initialization:</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException:
  Error creating bean with name 'fileValidator' defined in
  PortletContext resource
  [/WEB-INF/classes/context/customer-form-portlet.xml]: Unsatisfied
  dependency expressed through constructor argument with index 0 of type
  [com.liferay.portal.model.User]: Ambiguous factory method argument
  types - did you specify the correct bean references as factory method
  arguments?
      org.springframework.beans.factory.UnsatisfiedDependencyException:
  Error creating bean with name 'fileValidator' defined in
  PortletContext resource
  [/WEB-INF/classes/context/customer-form-portlet.xml]: Unsatisfied
  dependency expressed through constructor argument with index 0 of type
  [com.liferay.portal.model.User]: Ambiguous factory method argument
  types - did you specify the correct bean references as factory method
  arguments?
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;bean id="fileValidator" 
        class="cz.instance.transl.validation.file.FileValidator" 
        factory-method="createInstance" /&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>private FileValidator(User user) {
      this.user = user;
  }
  
  public static FileValidator createInstance(User user) {
      return new FileValidator(user);
  }
  </code></pre>
  
  <p>The commentary says you can do it,  but if you specify constructor arguments in xml definiton of that bean or not, it fails.</p>