{"id":138,"date":"2006-03-14T02:50:47","date_gmt":"2006-03-14T06:50:47","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=138"},"modified":"2011-12-17T12:19:05","modified_gmt":"2011-12-17T16:19:05","slug":"thinking-about-spring-cross-webapp-niftyness-with-fiona","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2006\/03\/thinking-about-spring-cross-webapp-niftyness-with-fiona\/","title":{"rendered":"Thinking about Spring Cross-WebApp niftyness with Fiona"},"content":{"rendered":"<p>What fun we had at LAMS.<\/p>\n<p><!--more--><br \/>\nThe really critical bit that Chuck missed before:<br \/>\n.\/kernel\/component\/src\/java\/org\/sakaiproject\/component\/kernel\/component\/ContextLoader.java<br \/>\npublic class ContextLoader extends<br \/>\norg.springframework.web.context.ContextLoader<br \/>\n{<br \/>\nprotected ApplicationContext loadParentContext(ServletContext servletContext)<br \/>\nthrows BeansException<br \/>\n{<br \/>\n\/\/ get the component manager (we know it&#8217;s a SpringCompMgr) and from that the shared AC<br \/>\nConfigurableApplicationContext sharedAc = ((SpringCompMgr) ComponentManager<br \/>\n.getInstance()).getApplicationContext();<br \/>\nreturn sharedAc;<br \/>\n}<br \/>\n}<br \/>\n.\/kernel\/component\/src\/java\/org\/sakaiproject\/component\/kernel\/component\/SpringCompMgr.java<br \/>\npublic class SpringCompMgr implements ComponentManager<br \/>\npublic synchronized void addChildAc()<br \/>\n{<br \/>\nm_childCount++;<br \/>\n}<br \/>\npublic synchronized void removeChildAc()<br \/>\n{<br \/>\nm_childCount&#8211;;<br \/>\n\/\/ when we get back to 0, close our AC<br \/>\nif (m_childCount == 0)<br \/>\n{<br \/>\nclose();<br \/>\n}<br \/>\n}<br \/>\norg.sakaiproject.util.ContextLoaderListener<br \/>\n.\/kernel\/component\/src\/java\/org\/sakaiproject\/util\/ContextLoaderListener.java<br \/>\npublic class ContextLoaderListener extends<br \/>\norg.springframework.web.context.ContextLoaderListener<br \/>\npublic void contextInitialized(ServletContextEvent event)<br \/>\n{<br \/>\nsuper.contextInitialized(event);<br \/>\n\/\/ increment the count of children for the component manager<br \/>\n((SpringCompMgr) ComponentManager.getInstance()).addChildAc();<br \/>\n}<br \/>\n\/**<br \/>\n* Close the root web application context.<br \/>\n*\/<br \/>\npublic void contextDestroyed(ServletContextEvent event)<br \/>\n{<br \/>\nsuper.contextDestroyed(event);<br \/>\n\/\/ decrement the count of children for the component manager<br \/>\n((SpringCompMgr) ComponentManager.getInstance()).removeChildAc();<br \/>\n}<br \/>\n.\/comp-test-app2\/src\/webapp\/WEB-INF\/web.xml<br \/>\n<context-param>\n<param-name>contextSharedLocation<\/param-name>\n<param-value>\/WEB-INF\/shared.xml<\/param-value>\n<\/context-param><br \/>\n&#8230;\n<listener>\n<listener-class>org.sakaiproject.util.ContextLoaderListener<\/listener-class>\n<\/listener>\n.\/comp-test-app2\/src\/webapp\/WEB-INF\/shared.xml<br \/>\n<beans><br \/>\n<!-- shared components hosted here --><br \/>\n<bean id=\"org.sakaiproject.api.test.components.Api6\"\nclass=\"org.sakaiproject.component.test.components.Component6\"\ninit-method=\"init\"\ndestroy-method=\"destroy\"\nsingleton=\"true\">\n<property name=\"value\"><value>[s6 c6 a2]<\/value><\/property>\n<\/bean><br \/>\n<\/beans><br \/>\n.\/kernel\/component\/src\/config\/org\/sakaiproject\/config\/shared_components.xml<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What fun we had at LAMS.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-138","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=138"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/138\/revisions"}],"predecessor-version":[{"id":2211,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/138\/revisions\/2211"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}