1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package ch.elca.el4j.services.remoting.protocol;
19
20 import java.util.HashMap;
21 import java.util.Map;
22 import java.util.Properties;
23
24 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
25 import org.springframework.web.context.support.AbstractRefreshableWebApplicationContext;
26 import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
27
28 import ch.elca.el4j.services.monitoring.notification.CoreNotificationHelper;
29 import ch.elca.el4j.services.remoting.RemotingServiceExporter;
30
31
32
33
34
35
36
37
38
39 public abstract class AbstractInetSocketAddressWebProtocol
40 extends AbstractInetSocketAddressProtocol {
41
42
43
44
45 private String m_contextPath;
46
47
48
49
50 private Map m_urlMappings = new HashMap();
51
52
53
54
55
56 private Map m_urlMappingsInitialized = new HashMap();
57
58
59
60
61 public String getContextPath() {
62 return m_contextPath;
63 }
64
65
66
67
68
69 public void setContextPath(String contextPath) {
70 m_contextPath = contextPath;
71 }
72
73
74
75
76 public void afterPropertiesSet() throws Exception {
77 super.afterPropertiesSet();
78 CoreNotificationHelper.notifyIfEssentialPropertyIsEmpty(
79 getContextPath(), "contextPath", this);
80 }
81
82
83
84
85 public void prepareExporterDependentBeans(
86 RemotingServiceExporter exporterBean) {
87
88
89
90
91
92
93 if (exporterBean.getApplicationContext()
94 instanceof AbstractRefreshableWebApplicationContext) {
95 AbstractRefreshableWebApplicationContext parentAppContext
96 = (AbstractRefreshableWebApplicationContext) exporterBean
97 .getApplicationContext();
98 Properties mappings = new Properties();
99 mappings.put("/" + exporterBean.getServiceName(), exporterBean
100 .getBeanName());
101 SimpleUrlHandlerMapping urlMapping = new SimpleUrlHandlerMapping();
102 urlMapping.setMappings(mappings);
103
104 m_urlMappings.put(exporterBean.getBeanName(), urlMapping);
105
106 ConfigurableListableBeanFactory configurableBeanFactory
107 = parentAppContext.getBeanFactory();
108 configurableBeanFactory.registerSingleton("handlerMappingForBean"
109 + exporterBean.getBeanName(), urlMapping);
110 }
111 }
112
113
114
115
116 public void finalizeExporterDependentBeans(
117 RemotingServiceExporter exporterBean) {
118
119
120
121
122 String beanName = exporterBean.getBeanName();
123 if (!m_urlMappingsInitialized.containsKey(beanName)
124 && m_urlMappings.containsKey(beanName)) {
125 SimpleUrlHandlerMapping urlMapping
126 = (SimpleUrlHandlerMapping) m_urlMappings
127 .get(beanName);
128 m_urlMappingsInitialized.put(beanName, urlMapping);
129 urlMapping.setApplicationContext(exporterBean
130 .getApplicationContext());
131 }
132 }
133 }