Results 1 to 2 of 2

Thread: Alias name use within child context

  1. #1
    Join Date
    Aug 2004
    Posts
    6

    Default Alias name use within child context

    I have an application that is being developed that utilizes several other components. Some using Spring and Hibernate. What I want to be able to do is create a top level context for the application that contains things such as the session factory and txn proxy template. For the components they will just have thier bean definitions etc. But I want the components to be able to use the session factory and txn template declared in the application context. My understanding is that I can do so by declaring aliases on the factory and template thru the use of the names attr. Those alias names would be how the components would refrence them. From what I read and infer from Java doc etc., this should work fine. But instead I am getting a NoSuchBeanDefinitionException when the reference to the alias is used.

    Here is my app context...
    Code:
        <bean id="ics.eBillDS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            ...	
        </bean>
    
        <bean id="ics.propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            ....
        </bean>
    
        <bean id="ics.sessionFactory" name="ebill.sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
            ....
        </bean>
    
        <bean id="ics.transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
    	<property name="sessionFactory">
    		<ref local="ics.sessionFactory" />
    	</property>
        </bean>
    
        <bean id="ics.txProxyTemplate" name="ebill.txProxyTemplate"  class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    	<property name="transactionManager">
    		<ref local="ics.transactionManager" />
    	</property>
    	<property name="transactionAttributes">
    		<props>
    			<prop key="*">PROPAGATION_REQUIRED</prop>
    		</props>
    	</property>
    </bean>
    Here is my context for the component or child context
    Code:
    <beans>
         <bean id="ebill.testDelegate" parent="ebill.txProxyTemplate">
            <property name="target">
                <bean id="ebill.testDAOTarget" class="com.amfam.ics.common.service.test.TestDelegate" />
            </property>
        </bean>
    </beans>
    The alias on the txProxyTemplate matches the parent id on the testDelegate bean. Is this a case where you don't have a choice when using the parent attr?

    I know this should be simple, so I've got to be missing something here. If not, how are others doing this type of configuration of components.
    --randy

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    When referencing a parent bean, I, usually, use its id.
    Also, consider marking your templates as abstract.
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

Similar Threads

  1. Hibernate Long Session Per Flow?
    By akw in forum Web Flow
    Replies: 21
    Last Post: Dec 12th, 2005, 08:06 PM
  2. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  3. Replies: 3
    Last Post: Jul 27th, 2005, 10:41 AM
  4. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM

Posting Permissions

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