1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.services.information;
18
19 import java.util.Map;
20
21 import javax.servlet.ServletConfig;
22 import javax.servlet.ServletRequest;
23 import javax.servlet.http.HttpServletRequest;
24 import javax.servlet.http.HttpServletRequestWrapper;
25
26 import org.apache.pluto.factory.Factory;
27 import org.apache.pluto.services.information.DynamicInformationProvider;
28 import org.apache.pluto.services.information.InformationProviderService;
29 import org.apache.pluto.services.information.StaticInformationProvider;
30
31 import org.apache.jetspeed.aggregator.CurrentWorkerContext;
32
33 /***
34 * Factory class for getting Information Provider access
35 *
36 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
37 * @version $Id: InformationProviderServiceImpl.java 587813 2007-10-24 08:20:39Z woonsan $
38 */
39 public class InformationProviderServiceImpl implements Factory, InformationProviderService
40 {
41 private javax.servlet.ServletConfig servletConfig;
42 private final StaticInformationProvider staticInformationProvider;
43
44 public InformationProviderServiceImpl(StaticInformationProvider staticInformationProvider, ServletConfig config)
45 {
46 this.staticInformationProvider = staticInformationProvider;
47
48 }
49
50 public void init(ServletConfig config, Map properties) throws Exception
51 {
52
53 }
54
55 public StaticInformationProvider getStaticProvider()
56 {
57 return staticInformationProvider;
58 }
59
60 public DynamicInformationProvider getDynamicProvider(HttpServletRequest request)
61 {
62 DynamicInformationProvider provider = null;
63
64 boolean isParallel = CurrentWorkerContext.getParallelRenderingMode();
65 ServletRequest servletRequest = null;
66
67 if (isParallel)
68 {
69
70
71 servletRequest = ((HttpServletRequestWrapper) request).getRequest();
72
73
74 if (servletRequest instanceof HttpServletRequestWrapper)
75 {
76 servletRequest = ((HttpServletRequestWrapper) servletRequest).getRequest();
77 }
78
79 synchronized (servletRequest)
80 {
81 provider = (DynamicInformationProvider) servletRequest.getAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider");
82 }
83 }
84 else
85 {
86 provider = (DynamicInformationProvider) request.getAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider");
87 }
88
89 if (provider == null)
90 {
91 provider = new DynamicInformationProviderImpl(request, servletConfig);
92
93 if (isParallel)
94 {
95 synchronized (servletRequest)
96 {
97 servletRequest.setAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider", provider);
98 }
99 }
100 else
101 {
102 request.setAttribute("org.apache.jetspeed.engine.core.DynamicInformationProvider", provider);
103 }
104 }
105
106 return provider;
107 }
108
109 /***
110 * <p>
111 * destroy
112 * </p>
113 *
114 * @see org.apache.pluto.factory.Factory#destroy()
115 * @throws java.lang.Exception
116 */
117 public void destroy() throws Exception
118 {
119
120 }
121 }