1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.directwebremoting.guice;
17
18 import com.google.inject.Key;
19 import com.google.inject.Injector;
20
21 import java.util.Map;
22
23 import org.directwebremoting.extend.Creator;
24
25 /**
26 * Specialized creator implementation that uses an injector to
27 * look up its instances. This class is used by {@link InternalCreatorManager}.
28 * @author Tim Peierls [tim at peierls dot net]
29 */
30 class InternalCreator implements Creator
31 {
32 InternalCreator(Injector injector, Key key, String scriptName)
33 {
34 this.injector = injector;
35 this.key = key;
36 this.scriptName = scriptName;
37 }
38
39 public void setProperties(Map params) throws IllegalArgumentException
40 {
41
42 }
43
44 public Class getType()
45 {
46 return (Class) key.getTypeLiteral().getType();
47 }
48
49 public Object getInstance() throws InstantiationException
50 {
51 return injector.getInstance(key);
52 }
53
54 public String getScope()
55 {
56 return Creator.PAGE;
57 }
58
59 public boolean isCacheable()
60 {
61 return true;
62 }
63
64 public String getJavascript()
65 {
66 return scriptName;
67 }
68
69 private final Injector injector;
70 private final Key key;
71 private final String scriptName;
72 }