I have searched in this site a lot of spring.. but i'm really new to this.. so here is my question:
I have 3 main classes i'm gonna put it like this..
public class User
{
private String name;
private ArrayList<Car> cars;
public ArrayList<Car> getCars()
{
return cars;
}
public void setCars(ArrayList<Car> cars)
{
this.cars= cars;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class Car
{
private String type;
private ArrayList<Wheel> wheels;
public ArrayList<Wheel> getWheels()
{
return wheels;
}
public void setWheels(ArrayList<Wheel> wheels)
{
this.wheels= wheels;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type= type;
}
}
public class Wheel
{
private String name;
public String getName() {
return name;
}
public void setType(String name) {
this.name= name;
}
}
That's the Java code.. this is just an example. So i have 3 classes, as u see one is the user that can have one or many cars, then is the car that can have one or many wheels..
In my Spring.xml i want to do something like this..
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<bean id="car1" class="Car">
<property name="type" value="motorcycle"/>
</bean>
<bean id="wheel1" class="Wheel">
<property name="name" value="one"/>
</bean>
<bean id="wheel2" class="Wheel">
<property name="name" value="two"/>
</bean>
<bean id="user1" class="User">
<property name="name" value="Me"/>
<property name="cars">
<list value-type="Car">
<ref bean="car1">
<property name="wheels">
<ref bean="wheel1">
<ref bean="wheel2">
</property">
</ref>
</list>
</property>
</bean>
If u see this spring.. i want to create the user instance and the cars and wheels by spring-code.. but it won't let me do this.. cause i can't create a ref bean with a property children.. so i can't add wheels to my ref bean car.. how can i do this? or this can't be done this way, maybe is another solution to this.. dunno.. Thanks in advance..
Sorry for my bad english.