01 package net.sf.annocon.examples.autowiring;
02
03 import net.sf.annocon.annotations.Context;
04 import net.sf.annocon.annotations.Service;
05 import net.sf.annocon.utils.autowiring.AutowiringUtil;
06
07 /**
08 * Example of autowiring service properties by name.
09 *
10 * @author Achim Huegen
11 */
12 @Context
13 public class AutowiringByNameContext
14 {
15 @Service(id = "ActionCaller")
16 public AutowireTarget getActionCaller()
17 {
18 AutowireTarget caller = new AutowireTarget();
19 AutowiringUtil.autowirePropertiesByName(this, caller);
20 return caller;
21 }
22
23 @Service(id = "PrintAction")
24 public Runnable getPrintAction()
25 {
26 return new Thread("PrintAction");
27 }
28
29 @Service(id = "StartAction")
30 public Runnable getStartAction()
31 {
32 return new Thread("StartAction");
33 }
34
35 }
|