Results 1 to 2 of 2

Thread: How to reference a SingletonContext instance from a WebApplicationContext

  1. #1
    Join Date
    Apr 2008
    Posts
    2

    Default 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. #2
    Join Date
    Apr 2008
    Posts
    2

    Default 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •