public interface Module {
void execute();
}
public class ModuleA implements Module {
@Override
public void execute() {
System.out.println("Module A executed.");
}
}
public class Application {
private Module module;
public Application(Module module) {
this.module = module;
}
public void run() {
module.execute();
}
public static void main(String[] args) {
Module module = new ModuleA();
Application application = new Application(module);
application.run();
}
}
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:delta="http://www.example.org/schema/delta-core"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.example.org/schema/delta-core
http://www.example.org/schema/delta-core/delta-core.xsd">
<delta:module id="moduleA" class="com.example.ModuleA" />
<bean id="application" class="com.example.Application">
<constructor-arg ref="moduleA" />
</bean>
</beans>