title: Basis of Dependency injection framework
body: <p>I want to write my own simple DI framework.
  I want that it perform only this simple case like Spring does:</p>
  
  <pre><code>public interface IWriter {
      public void writer(String s);
  }
  
  @Service
  public class MySpringBeanWithDependency {
      private IWriter writer;
  
      @Autowired
      public void setWriter(IWriter writer) {
          this.writer = writer;
      }
  
      public void run() {
          String s = "This is my test";
          writer.writer(s);
      }
  }
  
  @Service
  public class NiceWriter implements IWriter {
      public void writer(String s) {
          System.out.println("The string is " + s);
      }
  }
  
  public class Main extends TestCase {
  
      @Test
      public void test() {
  
          ApplicationContext context = new ClassPathXmlApplicationContext(
                  "META-INF/beans.xml");
          MySpringBeanWithDependency test = (MySpringBeanWithDependency) context
                  .getBean("mySpringBeanWithDependency");
          test.run();
      }
  }
  </code></pre>
  
  <p>The same case, but mb without an XML-file.</p>
  
  <p>Can somebody explain the concept of this type of frameworks and write some code.</p>