Create bean in spring

Hello !
Can anyone point me the possibility of adding new bean into Spring application context.
I'm interested in some API call of bundled spring plugin.
Idea is provide a intention action for my plugin to create spring beans when Spring Facet is configured in my project.
I realize that this can be done manually by patching XML, but maybe there's more convenient way of doing this ?

0

Evgeny Shepelyuk wrote:

Hello !
Can anyone point me the possibility of adding new bean into Spring application context.
I'm interested in some API call of bundled spring plugin.
Idea is provide a intention action for my plugin to create spring beans when Spring Facet is configured in my project.
I realize that this can be done manually by patching XML, but maybe there's more convenient way of doing this ?


You can do it using DOM, maybe this would be a little more convenient.
Get SpringModel for this file from SpringManager#getLocalSpringModel,
get the DOM root of type Beans
(SpringModel.getRoots().get(0).getRootElement()), call addBean() there
and tune the resulting object as you wish (for example,
getId().setStringValue("foo")).

0
Avatar
Permanently deleted user

Thanx for information. Though i can not find those calls in my version of IDEA/Spring plugin. I will keep searching that direction.

0

Thanx for information. Though i can not find those calls in my version of IDEA/Spring plugin. I will keep searching that direction.


What's your version? SpringManager and Beans were in the IDEA-bundled
Spring plugin for ages.

0
Avatar
Permanently deleted user

IDEA build - > 7935
Spring plugin from same build

1. SpringManager.getInstance(Project).getLocalSpringModel(XmlFile)
need some XmlFile
where i should take it ?

2.
>>get the DOM root of type Beans
>>(SpringModel.getRoots().get(0).getRootElement()), call addBean() there

Interface SpringModel doesn't have method getRoots()

Edited by: Evgeny Shepelyuk on Aug 12, 2008 8:40 PM

0

IDEA build - > 7935
Spring plugin from same build

1. SpringManager.getInstance(Project).getLocalSpringModel(XmlFile)
need some XmlFile
where i should take it ?


You know where to add your bean (which file should it be), don't you?
That's it.

2.

>>> get the DOM root of type Beans
>>> (SpringModel.getRoots().get(0).getRootElement()), call addBean() there


Interface SpringModel doesn't instance method getRoots()


SpringModel extends DomModel, which has
List>]]> getRoots();

Or not?

0
Avatar
Permanently deleted user

You know where to add your bean (which file should it be), don't you?
That's it.

No i don't' know. That's the idea of my question. Is there any API to call it and let it decide where inject new bean declarion.
So as i see there's no way except patching XML.

SpringModel extends DomModel, which has
List<DomFileElement<T>> getRoots();

Or not?

Yes you're 100% correct.

Thnx for your help !

0

>>

>> You know where to add your bean (which file should it be), don't you?
>> That's it.

No i don't' know. That's the idea of my question. Is there any API to call it and let it decide where inject new bean declarion.
So as i see there's no way except patching XML.

If you know how to patch XML you should know the file to patch it in.
And then if you want you can use DomElement's.

As for letting decide, you should do it yourself, or let the user do it.
There is SpringManager#getAllModels(Module) that will give you all
Spring config files visible from particular module, this should help.

0
Avatar
Permanently deleted user

thnx 4 help !

0

请先登录再写评论。