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

  • James Equalizer
    started a topic How to reference a bean from a bean?

    How to reference a bean from a bean?

    Hello all,

    I know this may sound like a stupid question but for some organizational reason I am trying to reference a bean from a bean (instead of a class) as follows (ps: the beanRef attribute is fake of course):

    in application-context.xml:
    <bean name="myService" beanRef="serviceX"/>

    in local-context.xml:
    <bean name=serviceX" class="com.james.someClass"/>

    Is this kind of configuration possible with Spring 2.5? If so how? I've been searching around the web but couldn't find any workaround to this.

    Thanks for any help,
    James
    Last edited by James Equalizer; Jan 23rd, 2008, 04:20 AM.

  • James Equalizer
    replied
    Well actually the root context where lies the alias is the main context used by the spring web services MessageDispatcherServlet defined in web.xml. That's why I am bit stuck in terms of hacking around. Thanks anyhow

    Leave a comment:


  • Marten Deinum
    replied
    Why?

    Why not simply declare that context as the root/super parent?! Why hack around??

    Leave a comment:


  • James Equalizer
    replied
    How about no parent/child relationship context in my case, like some kind of helper context where beans declaration could be shared throughout all the hierarchy?

    Thanks,
    James

    Leave a comment:


  • Marten Deinum
    replied
    No... The parents knows nothing of it's children, the children know of the parent.

    Leave a comment:


  • James Equalizer
    replied
    Thanks. I have tried to use an alias but thing is the bean I am trying to reach is in a child context therefore the aliasing does not work. I'm looking now for a way to look into beans of child contexts, would that be possible?

    Many thanks,
    James

    Leave a comment:


  • Marten Deinum
    replied
    Have a look at the alias tag. That way you can define an alias for a bean already defined. It is only defining an alias, you cannot set any additional properties.

    Leave a comment:

Working...
X