ModelGlue with CS2

16 views
Skip to first unread message

Chris Blackwell

unread,
Jan 24, 2012, 8:28:29 AM1/24/12
to coldspring-users
I've got a patch mostly working but i'm slightly stuck.

The CS1.2 compatible ModelGlueConfiguration.xml that contains the frameworks core beans defines beans for the Reactor and Transfer factories.  I guess in CS1.2 these were never looked at unless requested, but CS2 is throwing an error because the cfc's don't exists even though they are never used.

One solution would be to remove them and require the user to include them in their app's beans if required, but i wondered if there was any other way around this as i'm trying to minimize the changes required.

Cheers, Chris

Mark Mandel

unread,
Jan 24, 2012, 9:14:20 AM1/24/12
to coldspri...@googlegroups.com
ColdSpring call getComponentMetaData() on all it's beans. I don't think there is a way not to make it do that (be curious as to the stack trace you are getting, so I can work out if it would even be possible, but I doubt it), and I assume that is where your issue lies.

There are 2 ways, but basically one concept - you need to check if the framework Reactor / Transfer exists, and then programatically add in the BeanDefinitions for the ormAdapter and ormService beans.

1) Write a custom xml namespace for model glue to use internally.
This is the cleanest from an implementation point of view, but is a bit more work. The parse() method in a AbstractBeanDefinitionParser gives you a nice simple hook to add in your own bean definitions to the BeanRegistry.

2) This is probably a bit less work to do - but add a BeanDefinitionRegistryPostProcessor to your XML configuration.

This will enable you to intercept very early on in the instantiation process - such that you can manually add and remove your own beans. 

From either approach, you can look for the existance of either of these frameworks, and add the required services as you need them.

These approaches need more than just API documentation, but I'm happy to point you towards existing code that shows you how it works.

Mark


--
You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
To post to this group, send email to coldspri...@googlegroups.com.
To unsubscribe from this group, send email to coldspring-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/coldspring-users?hl=en.



--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast

Chris Blackwell

unread,
Jan 24, 2012, 12:04:02 PM1/24/12
to coldspri...@googlegroups.com
oh that is very cool.. i like that.

I went with option 2

so what i've done is 
 - add the required schema's to the core xml file, i think this should be compatible with CS1.2? (haven't tested yet)
 - alter ModelGlue's ColdspringBootstrapper to detect which version of CS is available, 
 - if its CS2 also include an extra file with a bean definition for "ColdSpring2RegistryCleaner"
 - ColdSpring2RegistryCleaner checks for the existence of transfer and reactor and if not available removes the beans (if they exist)

This is working nicely in the site i'm currently developing.  I'll have to merge my changes with the latest MG and see if all the unit tests pass.  If they do i'll submit a patch to the team and see what they think

Thanks for the help

Chris

Mark Mandel

unread,
Jan 24, 2012, 9:25:38 PM1/24/12
to coldspri...@googlegroups.com
Oh nice - so you just remove rather than add - that makes sense.

Nice one :)

Mark
Reply all
Reply to author
Forward
0 new messages