0% found this document useful (0 votes)
4 views2 pages

Spring Framework Machine Operations

The document contains a Java application that demonstrates the use of Spring Framework for dependency injection. It defines an interface 'Machine' with two implementations: 'LatheMachine' and 'MillingMachine'. The 'Workshop' class uses a 'Machine' instance to operate, and the configuration is provided in an XML file, specifying the beans and their dependencies.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Spring Framework Machine Operations

The document contains a Java application that demonstrates the use of Spring Framework for dependency injection. It defines an interface 'Machine' with two implementations: 'LatheMachine' and 'MillingMachine'. The 'Workshop' class uses a 'Machine' instance to operate, and the configuration is provided in an XML file, specifying the beans and their dependencies.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

package [Link].

app;

import [Link];
import [Link];

interface Machine {
void operate();
}

class LatheMachine implements Machine {


public void operate() {
[Link]("Operating Lathe Machine...");
}
}

class MillingMachine implements Machine {


public void operate() {
[Link]("Operating Milling Machine...");
}
}

class Workshop {
private Machine machine;

public void setMachine(Machine machine) {


[Link] = machine;
}

public void startWork() {


[Link]();
}
}

public class IndustryApp {


public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("[Link]");
Workshop workshop = (Workshop) [Link]("workshop");
[Link]();
}
}
<beans xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link]
[Link]

<bean id="latheMachine" class="[Link]"/>


<bean id="millingMachine" class="[Link]"/>

<bean id="workshop" class="[Link]">


<property name="machine" ref="latheMachine"/>
</bean>

</beans>

You might also like