I use something like this: http://modelglue.pastebin.com/t04s19xG
This gets injected via coldspring anywhere I want the currently logged in member to be available. It is nothing more than an indirection allowing for a singleton to be injected. DW On Fri, Mar 5, 2010 at 11:05 AM, Doug Boude <[email protected]> wrote: > I'm pretty sure this is an easy question, but for some reason this morning > it is eluding me. > > The Scenario: > > I am using Coldspring and MG2. When my user logs in, I populate a user bean > that holds all the relevant user bits. I have a service layer object that is > injected with a worker object, both singletons. My worker object needs to > retrieve some of those "relevant user bits" I mentioned. In my thinking, if > I use Coldspring to inject a user bean into my worker object, it will be > getting an empty user object and not the populated one created during login. > II really don't like the idea of having my controller pass down the current > user object to the service layer and then on down to the worker...but > perhaps that is the "correct" way in my situation? > > What is the best way to provide my worker object with a reference to my > populated user bean? > > If it helps any, here are the snippets from my coldspring.xml ('TokenModel' > is the worker object I mentioned): > > <bean id="user" class="model.user" singleton="false"> > <constructor-arg name="keychain"><ref bean="keychain" /></constructor-arg> > <property name="dsn"> > <bean factory-bean="GlobalConfig" factory-method="getConfigSetting"> > <constructor-arg name="name"><value>dsn</value></constructor-arg> > </bean> > </property> > </bean> > <bean id="keychain" class="model.keychain" singleton="false"/> > <bean id="TokenModel" class="model.token"> > <property name="dsn"> > <bean factory-bean="GlobalConfig" factory-method="getConfigSetting"> > <constructor-arg name="name"><value>dsn</value></constructor-arg> > </bean> > </property> > </bean> > <bean id="SpreadsheetService" class="model.spreadsheetService"> > <property name="dsn"> > <bean factory-bean="GlobalConfig" factory-method="getConfigSetting"> > <constructor-arg name="name"><value>dsn</value></constructor-arg> > </bean> > </property> > <property name="TokenModel"> <ref bean="TokenModel" /> > </property> > </bean> > > Thanks for any input. > > Doug :0) > > -- > Model-Glue Sites: > Home Page: http://www.model-glue.com > Documentation: http://docs.model-glue.com > Bug Tracker: http://bugs.model-glue.com > Blog: http://www.model-glue.com/blog > > You received this message because you are subscribed to the Google > Groups "model-glue" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<model-glue%[email protected]> > For more options, visit this group at > http://groups.google.com/group/model-glue?hl=en -- “Come to the edge, he said. They said: We are afraid. Come to the edge, he said. They came. He pushed them and they flew.” Guillaume Apollinaire quotes -- Model-Glue Sites: Home Page: http://www.model-glue.com Documentation: http://docs.model-glue.com Bug Tracker: http://bugs.model-glue.com Blog: http://www.model-glue.com/blog You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en
