Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swing editor ui for applicationContext.xml beans?

Tags:

java

spring

I asked this in spring forums but got no answer, and I just discovered stackoverflow, so Ill try here.

I am using spring 2.0.5. In my app I need to let the user add/modify/delete (via the UI) beans that are described in the applicationContext.xml file. The beans that are to be edited are all of the same class (like a db table crud editor really, but faster do develop and easier to evolve regarding the code).

I have been searching the web and forums and cannot find any existing code. I guess my need is quite usual, does somebody know some code I can leverage?

If not, is there at least a way to get the xml (as a string) element from a java bean?

thanks in advance.

like image 933
Persimmonium Avatar asked Jul 27 '26 09:07

Persimmonium


1 Answers

The Spring IDE plugin for Eclipse has tools for editing the application context, and the source code is available, so that might be one place to start.

I don't believe there's a way to get the XML bean definition from, for example, a BeanFactory object. Remember that a given bean might not even have an XML definition; it might be autowired, for example.

Another approach might be to use a library such as Dom4J to parse and manipulate the XML of the applicationContext.xml file. You could easily get a particular bean definition by doing, for example,

document.selectSingleNode("//bean/beans[name='beanNameIWantToEdit']")

Then you could change properties, etc., on that node. You can also get the full XML text of that node by doing node.asXML().

like image 128
Jacob Mattison Avatar answered Jul 28 '26 23:07

Jacob Mattison



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!