Coldspring 2 New Session Scope

21 views
Skip to first unread message

Dorian Puerta

unread,
Nov 14, 2011, 4:42:09 PM11/14/11
to coldspri...@googlegroups.com

Trying to get the new bean scope "Session" to work
 So i have my coldspring file setup like this:

.....
<!-- Services -->
    <bean id="CS.AbstractService" class="careerfair.extensions.components.model.AbstractService" abstract="true">
        <property name="CareerfairDAO"><ref bean= "CareerfairDAO" /></property>
        <property name="NotificationService"><ref bean="NotificationService" /></property>       
        <property name="sessionConfig"><ref bean="sessionConfig" /></property>       
    </bean>
   
    <bean id="SecurityService" class="careerfair.extensions.components.model.SecurityService" parent="CS.AbstractService">
        <property name="SecurityDAO"><ref bean="SecurityDAO" /></property>
        <property name="NTSecurity"><ref bean="NTSecurity" /></property>
    </bean>

 <!-- Util -->  
    <bean id="sessionConfig" class="careerfair.extensions.components.util.SessionConfig" scope="session">
          <constructor-arg name="isAdmin"><value>false</value></constructor-arg>
          <constructor-arg name="isLoggedIn"><value>false</value></constructor-arg>
          <constructor-arg name="User"><value>${user}</value></constructor-arg>
    </bean>
....

So the way i thought this would work was if I set the scope of "SessionConfig" to session, any properties i change within the bean (during runtime) would stay in the session scope.
So I ran this test within "SecurityService" bean

...
if (cgi.server_name eq "localhost") {
    getSessionConfig().setisLogged(1);
    writeoutput("setLoggedIn");
}

...

And then I checked values using two computers to see if the values would be unique between the two environments, but unfortunately the "SessionConfig" doesn’t appear to be functioning as a session scope bean.  Was wondering if I set this up correctly?


BTW Great work on this

Mark Mandel

unread,
Nov 14, 2011, 9:30:04 PM11/14/11
to coldspri...@googlegroups.com
So, if you do a 

coldspring.getBean('sessionConfig') it will return a new bean on each request that is tied to the current session.

The way things are set up, SecurityService is a singleton, and when it first gets fired up, it gets passed an instance of the sessionConfig, from that current session.

For that point on, it never gets refreshed, so it's always looking at the same object.

This is where being able to have lookup method injection would be super handy:
See:

But there is no reason you couldn't implement a proxy to this, or make your object BeanFactoryAware to be able to retrieve it as you please.

That make sense?

Mark


--
You received this message because you are subscribed to the Google Groups "ColdSpring-Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/coldspring-users/-/XRAjgIW91toJ.
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

cf.Objective(ANZ) + Flex - Nov 17, 18 - Melbourne Australia
http://www.cfobjective.com.au

2 Devs from Down Under Podcast

Reply all
Reply to author
Forward
0 new messages