Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is the solution, I am posting it, might be helpful to someone in future: </p> <p>The Bean class:</p> <pre><code>public class RunManager { private String jarPath; private String osName; private String architecture; public RunManager() { } public RunManager(String[] args) { this.jarPath = args[0]; this.osName = args[1]; this.architecture = args[2]; } public String getJarPath() { return jarPath; } public void setJarPath(String jarPath) { this.jarPath = jarPath; } public String getOsName() { return osName; } public void setOsName(String osName) { this.osName = osName; } public String getArchitecture() { return architecture; } public void setArchitecture(String architecture) { this.architecture = architecture; } } </code></pre> <p>The initialization of the ApplicationContext:</p> <pre><code>DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); BeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(RunManager.class).addConstructorArgValue(args).getBeanDefinition(); beanFactory.registerBeanDefinition("runManager", beanDefinition); GenericApplicationContext genericApplicationContext = new GenericApplicationContext(beanFactory); genericApplicationContext.refresh(); ApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] { "application-context.xml" }, genericApplicationContext); </code></pre> <p>The injection of this bean reference to another bean of application-context.xml:</p> <pre><code>&lt;bean id="configuration" class="jym.tan.movielibrary.configuration.Configuration" &gt; &lt;property name="runManager" ref="runManager" /&gt; &lt;/bean&gt; </code></pre> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload