I create beens with Spring in ApplicationContext.xml like below:
<bean id="myClass" class="com.classes.MyClass">
<property name="Url" value="https://localhost"></property>
<property name="Name" value="admin"></property>
<property name="Password" value="admin"></property>
</bean>
package com.classes
public class MyClass {
private String Url;
private String Name;
private String Password;
public void setUrl(String url) {
Url = url;
}
public String getUrl() {
return Url;
}
public void setName(String name) {
Name = name;
}
public String getName() {
return Name;
}
public void setPassword(String password) {
Password = password;
}
public String getPassword() {
return Password;
}
}
here is the factory, I wonder there is anything wrong with it
public class SpringFactory implements FlexFactory {
private static final String SOURCE = "source";
public void initialize(String id, ConfigMap configMap) {
}
public FactoryInstance createFactoryInstance(String id, ConfigMap properties) {
SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties);
instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
return instance;
} // end method createFactoryInstance()
public Object lookup(FactoryInstance inst) {
SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst;
return factoryInstance.lookup();
}
static class SpringFactoryInstance extends FactoryInstance {
SpringFactoryInstance(SpringFactory factory, String id, ConfigMap properties) {
super(factory, id, properties);
}
public String toString() {
return "SpringFactory instance for id=" + getId() + " source=" + getSource() + " scope=" +
getScope();
}
public Object lookup() {
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());
String beanName = getSource();
try {
return appContext.getBean(beanName);
} catch (NoSuchBeanDefinitionException nexc) {
ServiceException e = new ServiceException();
String msg = "Spring service named '" + beanName
+ "' does not exist.";
e.setMessage(msg);
e.setRootCause(nexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throw e;
} catch (BeansException bexc) {
ServiceException e = new ServiceException();
String msg = "Unable to create Spring service named '"
+ beanName + "' ";
e.setMessage(msg);
e.setRootCause(bexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throw e;
}
}
}
}
But it threw Error creating bean with name Password: No property found
It only happens with the 3rd String property, if I only set 2 String property, and let the 3rd refer to another bean. It works. But everytime I put 3rd property there. It fails. Is there any restriction or configuration. Don't tell me that I made any typo or wrong naming, it wouldn't wrong because I checked very carefully.