1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.core.container.ri.servlet;
22
23 import javax.servlet.ServletContext;
24 import org.jdtaus.core.container.Container;
25 import org.jdtaus.core.container.ContainerFactory;
26 import org.jdtaus.core.container.Context;
27 import org.jdtaus.core.container.ContextFactory;
28 import org.jdtaus.core.container.Model;
29 import org.jdtaus.core.container.ModelFactory;
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public abstract class ServletContextFactories
44 {
45
46
47
48 public static Container getContainer()
49 {
50 Container instance =
51 (Container) ServletContextFactories.getServletContext().
52 getAttribute( Container.class.getName() );
53
54 if ( instance == null )
55 {
56 instance = ContainerFactory.newContainer();
57 ServletContextFactories.getServletContext().
58 setAttribute( Container.class.getName(), instance );
59
60 }
61
62 return instance;
63 }
64
65
66 public static Context getContext()
67 {
68 Context instance =
69 (Context) ServletContextFactories.getServletContext().
70 getAttribute( Context.class.getName() );
71
72 if ( instance == null )
73 {
74 instance = ContextFactory.newContext();
75 ServletContextFactories.getServletContext().
76 setAttribute( Context.class.getName(), instance );
77
78 }
79
80 return instance;
81 }
82
83
84 public static Model getModel()
85 {
86 Model instance =
87 (Model) ServletContextFactories.getServletContext().
88 getAttribute( Model.class.getName() );
89
90 if ( instance == null )
91 {
92 instance = ModelFactory.newModel();
93 ServletContextFactories.getServletContext().
94 setAttribute( Model.class.getName(), instance );
95
96 }
97
98 return instance;
99 }
100
101
102 public static ServletContext getServletContext()
103 {
104 return ServletFilter.getServletContext();
105 }
106
107
108 }