|
From: THOMAS, J. (SBCSI) <jt...@sb...> - 2004-06-23 18:15:39
|
In my case I have my own factory which uses a xml file to model different beans and other type's of componenents.I would like to add objects created by my factory into the spring context,and also share objects created in Spring factory in my factory, Iam not sure how it can be done. It will be nice if spring gives us feature to plug in user defined factories into spring context. -----Original Message----- From: Seth Ladd [mailto:se...@eh...] Sent: Wednesday, June 23, 2004 11:09 AM To: spr...@li... Subject: Re: [Springframework-developer] custom XML config files -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 | Using the example above we could use a simple macro which turns | | <connector url="..." timeout="2000"/> | | into | | <bean class="MyConnectorBean"> | <property name="url"><value>...</value></property> | <property name="timeout"><value>2000</value></property> | </bean> | | This could be a trivial optional transformation step written in a little | Java code, where the ActiveMQXmlBeanFactory could derive from the Spring | XmlBeanFactory and install a custom transformer into the | XmlBeanDefinitionReader so that any XML notation the ActiveMQ factory | knew about could be transformed into normal Spring XML ready for Spring | to do its thing. One way to do that would be XSLT. I've often considered doing just that type of thing. For instance, our views.xml file is getting huge. That type of file really lends itself to a shortened version. Then, using XSLT at runtime, we can transform the views optimized XML into a full Spring BEANS xml file. I'd rather see this: <jstl url="/WEB-INF/jsp/foo.jsp" /> than: <bean class="org.springframework.servlet.view.JstlView"> ~ <property name="url"> ~ <value>/WEB-INF/jsp/foo.jsp</value> ~ </property> </bean> Other nice things about this is a DTD can be created for the shortened version, to allow for validating and smoother XSLT. Also, if others need to extend the shorted form, they can either edit the XSLT file, or better yet, just start writing spring BEANS elements. The XSLT file should just recognize the native spring beans elements and transfer them over. A XstlBeanFactory would do the trick there. Given an XML file, and a XSLT file, it should transform then delegate to XmlBeanFactory. Ideas? Thoughts? This might be a good middle ground for those that like XML and those that want to see the XML verbosity reduced somehow. Seth -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3-nr1 (Windows XP) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFA2cctKZsFSwtW+wIRAqLRAJ90cmj7E+J4O70gy0K5IwADpWMRcgCdHrbU TQKCg6TDIF8yGEysAilxxIk= =JRgu -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: THOMAS, J. (SBCSI) <jt...@sb...> - 2004-06-23 19:36:59
|
Thanks for your response, Can it be plugged into the Spring MVC,?? Ie can we add out own context in the Spring MVC framework. -----Original Message----- From: Seth Ladd [mailto:se...@eh...] Sent: Wednesday, June 23, 2004 11:22 AM To: spr...@li... Subject: Re: [Springframework-developer] custom XML config files -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 THOMAS, JAYANT (SBCSI) wrote: | In my case I have my own factory which uses a xml file to model different | beans and other type's of componenents.I would like to add objects created | by my factory into the spring context,and also share objects created in | Spring factory in my factory, Iam not sure how it can be done. It will be | nice if spring gives us feature to plug in user defined factories into | spring context. I believe you can set a parent context to a context. Would that solve your problem? Seth -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3-nr1 (Windows XP) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFA2coqKZsFSwtW+wIRAsDIAJ9Fq5VrUwX6Hr2MJqAj5RpEgnVrYQCfaYFd bFjo7egDXoRzM3YQUo/tKqo= =rOd5 -----END PGP SIGNATURE----- ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Seth L. <se...@eh...> - 2004-06-23 19:44:30
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 THOMAS, JAYANT (SBCSI) wrote: | Thanks for your response, Can it be plugged into the Spring MVC,?? Ie can we | add out own context in the Spring MVC framework. Depends how you want to plug it in. Take a look at the ContextListener, which created the initial applicationContext. That might let you specify the BeanFactory class, or would be easy to subclass. You can have multiple listeners start up, but I wouldn't know how to set one as the parent of the other. You can subclass the ContextServlet, and use the load ordering of servlets to start each context. Then, as the child is started, you can look into the app scope, find the parent, and bind it up. Should be possible, Seth -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3-nr1 (Windows XP) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFA2d2YKZsFSwtW+wIRAl7yAJ4yzQ0um0lhMOZBaJ1Iv3xIcZ/kLgCgiyYr E6yXIM8e9UFxoV2250vjoUY= =/FVH -----END PGP SIGNATURE----- |
|
From: Mason, R. <ros...@vi...> - 2004-06-24 06:48:17
|
This would be really useful. For applications that are constucted by = spring it is much eaiser, quicker and less error prone to be working = with a domain-specific config file with a dtd/xsd to describe/validate = as you go. +1 >-----Original Message----- >From: spr...@li... >[mailto:spr...@li...]On Behalf >Of jas...@ma... >Sent: Thursday, 24 June 2004 1:32 PM >To: spr...@li... >Subject: Re: [Springframework-developer] custom XML config files > > > >On 23 Jun 2004, at 19:08, Seth Ladd wrote: > >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> >> | Using the example above we could use a simple macro which turns >> | >> | <connector url=3D"..." timeout=3D"2000"/> >> | >> | into >> | >> | <bean class=3D"MyConnectorBean"> >> | <property name=3D"url"><value>...</value></property> >> | <property name=3D"timeout"><value>2000</value></property> >> | </bean> >> | >> | This could be a trivial optional transformation step written in a=20 >> little >> | Java code, where the ActiveMQXmlBeanFactory could derive from the=20 >> Spring >> | XmlBeanFactory and install a custom transformer into the >> | XmlBeanDefinitionReader so that any XML notation the=20 >ActiveMQ factory >> | knew about could be transformed into normal Spring XML ready for=20 >> Spring >> | to do its thing. >> >> One way to do that would be XSLT. I've often considered doing just=20 >> that >> type of thing. For instance, our views.xml file is getting=20 >huge. That >> type of file really lends itself to a shortened version. Then, using >> XSLT at runtime, we can transform the views optimized XML into a full >> Spring BEANS xml file. >> >> I'd rather see this: >> >> <jstl url=3D"/WEB-INF/jsp/foo.jsp" /> >> >> than: >> >> <bean class=3D"org.springframework.servlet.view.JstlView"> >> ~ <property name=3D"url"> >> ~ <value>/WEB-INF/jsp/foo.jsp</value> >> ~ </property> >> </bean> >> >> Other nice things about this is a DTD can be created for the=20 >shortened >> version, to allow for validating and smoother XSLT. Also, if others >> need to extend the shorted form, they can either edit the=20 >XSLT file, or >> better yet, just start writing spring BEANS elements. The XSLT file >> should just recognize the native spring beans elements and transfer=20 >> them >> over. >> >> A XstlBeanFactory would do the trick there. Given an XML file, and a >> XSLT file, it should transform then delegate to XmlBeanFactory. >> >> Ideas? Thoughts? This might be a good middle ground for those that >> like XML and those that want to see the XML verbosity=20 >reduced somehow. > >XSLT is certainly one way of doing it. Either way, whether its some=20 >Java code that does the transformation, or XSLT the effect is the same=20 >- we get a shortened XML file (along with a custom DTD / XSD) for=20 >easier editing. > >Personally I find XSLT to be a PITA so would rather a little=20 >simple bit=20 >of Java code to navigate over a DOM tree and turn elements into normal=20 >Spring XML but each to their own. So long as the hooks are there to=20 >easily modify the DOM before Spring starts to process it, folks could=20 >use Java code or XSLT to transform the DOM. > >James >------- >http://radio.weblogs.com/0112098/ > > > >------------------------------------------------------- >This SF.Net email sponsored by Black Hat Briefings & Training. >Attend Black Hat Briefings & Training, Las Vegas July 24-29 -=20 >digital self defense, top technical experts, no vendor pitches,=20 >unmatched networking opportunities. Visit www.blackhat.com >_______________________________________________ >Springframework-developer mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: <jas...@ma...> - 2004-06-24 09:49:27
Attachments:
patch.txt
|
Agreed. OK, its a trivial change but I've gone ahead and made a patch to allow application developers to reuse Spring's XmlBeanFactory to create custom application config files. |
|
From: Seth L. <se...@eh...> - 2004-06-23 18:21:37
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 THOMAS, JAYANT (SBCSI) wrote: | In my case I have my own factory which uses a xml file to model different | beans and other type's of componenents.I would like to add objects created | by my factory into the spring context,and also share objects created in | Spring factory in my factory, Iam not sure how it can be done. It will be | nice if spring gives us feature to plug in user defined factories into | spring context. I believe you can set a parent context to a context. Would that solve your problem? Seth -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3-nr1 (Windows XP) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFA2coqKZsFSwtW+wIRAsDIAJ9Fq5VrUwX6Hr2MJqAj5RpEgnVrYQCfaYFd bFjo7egDXoRzM3YQUo/tKqo= =rOd5 -----END PGP SIGNATURE----- |