1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.fatwire.gst.foundation.controller.action.support;
17
18 import COM.FutureTense.Interfaces.ICS;
19
20 import com.fatwire.gst.foundation.controller.AppContext;
21 import com.fatwire.gst.foundation.controller.action.Factory;
22 import com.fatwire.gst.foundation.controller.action.FactoryProducer;
23 import com.fatwire.gst.foundation.controller.support.WebContextUtil;
24
25
26
27
28
29
30
31
32
33 public class IcsFactoryUtil {
34
35
36
37
38
39
40
41 public static Factory getFactory(ICS ics) {
42 final Object o = ics.GetObj(Factory.class.getName());
43 if (o instanceof Factory) {
44 return (Factory) o;
45 }
46 Factory factory = null;
47 @SuppressWarnings("deprecation")
48 AppContext ctx = WebContextUtil.getWebAppContext(ics.getIServlet().getServlet().getServletContext());
49
50 FactoryProducer fp = ctx.getBean("factoryProducder", FactoryProducer.class);
51 if (fp != null) {
52 factory = fp.getFactory(ics);
53 ics.SetObj(Factory.class.getName(), factory);
54 }
55 if (factory == null)
56 throw new IllegalStateException(
57 "Could not find a FactoryProducer. Is the WebAppContext correctly configured. We found a "
58 + (ctx == null ? "null" : ctx.getClass().getName()) + " AppContext.");
59 return factory;
60
61 }
62 }