Announcement Announcement Module
Collapse
No announcement yet.
How to reference a SingletonContext instance from a WebApplicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to reference a SingletonContext instance from a WebApplicationContext

    Hello,
    We are building a complex J2EE application with multiple layers, each layer having its own IoC container definition. Beside, we have multiple sibling web application which use beans from others layers. Everything is packaged in an EAR file.

    I've used the ContextSingletonBeanFactory ContextSingletonBeanFactoryLocator example to define a context hierarchy and to resolve beans from the lower layers and avoid duplication among the various WEB modules. http://http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/beans/factory/access/SingletonBeanFactoryLocator.html

    It works perfectly except for one of my web module.
    This module is referencing bean from the lower layer directly in the context-file, (the others are using the SingletonContextFactoryLocator programmatically)

    HTML Code:
    <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    		<property name="service">
    			<ref parent="autocompleterServiceDelegate"/>
    		</property>		
    		<property name="serviceName" value="rmiAutocompleterService"/>
    		<property name="serviceInterface" value="com.sgam.tanis.svc.client.delegate.IAutocompleterDelegate"/>
    		<property name="registryPort" value="${rmiPort}"/>
    </bean>	
    My question is how to reference a bean loaded in the EAR classloader from a WebApplicationContext.
    The reference documumentation states you should use the SingletonContext instances
    as the parents of the web-application Spring IoC container instances
    But I could not figured out how to do this.

    Can please someone help me, I'm stuck here.

    Patrick

  • #2
    Solved

    Ok after some more search in the forum, i've found the solution to my problem in this thread
    which was directing to Joris Kuipers excellent article on Singleton IoC containers.

    The parentContextKey does the trick

    HTML Code:
    <context-param>
            <param-name>parentContextKey</param-name>
            <param-value>com.sgam.tanis.delegate</param-value>
        </context-param>
    Sorry I have polluted this forum.

    Comment

    Working...
    X