BasicContext.java
01 package net.sf.annocon.examples.basic;
02 
03 import net.sf.annocon.annotations.Context;
04 import net.sf.annocon.annotations.Service;
05 
06 /**
07  * Basic example of a context class. Defines a calculator service
08  * that is linked with two other services.
09  *
10  @author Achim Huegen
11  */
12 @Context 
13 public class BasicContext
14 {
15   @Service(id = "Calculator", instantiationModel="prototype")
16   public Calculator getCalculator()
17   {
18     return new Calculator(getAdder(), getSubtracter());
19   }
20 
21   @Service(id = "Subtracter", instantiationModel="singleton")
22   private Subtracter getSubtracter()
23   {
24     return new Subtracter();
25   }
26 
27   @Service(id = "Adder", instantiationModel="singleton")
28   private Adder getAdder()
29   {
30     return new Adder();
31   }
32 
33 }