1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.fatwire.gst.foundation.groovy.context;
17
18 import groovy.lang.GroovyClassLoader;
19
20 import javax.servlet.ServletContext;
21
22 import COM.FutureTense.Interfaces.ICS;
23
24 import com.fatwire.gst.foundation.controller.AppContext;
25 import com.fatwire.gst.foundation.controller.action.ActionLocator;
26 import com.fatwire.gst.foundation.controller.action.Factory;
27 import com.fatwire.gst.foundation.controller.action.Injector;
28 import com.fatwire.gst.foundation.controller.action.support.ClassActionLocator;
29 import com.fatwire.gst.foundation.controller.action.support.DefaultWebAppContext;
30 import com.fatwire.gst.foundation.controller.action.support.RenderPageActionLocator;
31 import com.fatwire.gst.foundation.controller.support.WebAppContextLoader;
32 import com.fatwire.gst.foundation.groovy.GroovyElementCatalogLoader;
33 import com.fatwire.gst.foundation.groovy.GroovyLoader;
34 import com.fatwire.gst.foundation.groovy.action.GroovyActionLocator;
35
36
37
38
39
40
41
42
43 public class GroovyWebContext extends DefaultWebAppContext {
44 private GroovyClassLoader classLoader;
45
46
47
48
49
50
51
52 public GroovyWebContext(ServletContext context, AppContext app) {
53 super(context, app);
54 classLoader = new GroovyClassLoader();
55 String path = getServletContext().getRealPath("/WEB-INF/gsf-groovy");
56 classLoader.addClasspath(path);
57
58 }
59
60
61
62
63 public ActionLocator createActionLocator() {
64
65
66
67
68
69
70
71 Injector injector = getBean("injector", Injector.class);
72 ActionLocator root = getRootActionLocator(injector);
73
74 GroovyLoader loader = getGroovyLoader();
75
76 GroovyActionLocator groovyLocator = new GroovyActionLocator(root, injector);
77 groovyLocator.setGroovyLoader(loader);
78
79 final ClassActionLocator cal = new ClassActionLocator(groovyLocator, injector);
80 return cal;
81
82 }
83
84
85
86
87 protected GroovyLoader getGroovyLoader() {
88 return new GroovyElementCatalogLoader(getServletContext());
89 }
90
91 protected ActionLocator getRootActionLocator(Injector injector) {
92 return new RenderPageActionLocator(injector);
93 }
94
95 @Override
96 public Factory getFactory(ICS ics) {
97 Factory base = super.getFactory(ics);
98 GroovyFactory fg = new GroovyFactory(ics, getClassLoader(), base);
99 return fg;
100 }
101
102 public ClassLoader getClassLoader() {
103 return classLoader;
104 }
105
106 }