Hi Kai,
Actually it was working all the time. I was injecting @Session instead of 
@Request to get a session and was getting the exception no Service implemented 
it. I was able to inject a (not null) request object, but the session in it was 
still null, probably because this was too early in the pipeline or something 
(this was in the authentication service). I did find a couple of workarounds 
for my requirements and maybe they will help you too.
I wanted to inject Tapestry services into spring beans for two reasons:

1. I wanted access to Tapestry's Messages service to inject some properties I 
had defined in app.properties. Instead of injecting messages I just did this
<bean id="propertyConfigurer"
                
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
                <property name="locations">
                        <list>
                                <value>/WEB-INF/app.properties</value>
                                <value>/WEB-INF/security.properties</value>
                                <value>/WEB-INF/hibernate.properties</value>
                        </list>
                </property>
        </bean>
and then just using ${property.name} to inject the properties into my Spring 
beans.
2. I was using Spring's LDAP authentication provider and I wanted to store a 
User object in session once a user was successfully authenticated (and was 
hence trying to inject @Request). I got around this by extending Spring's 
LdapAuthenticationProvider and override its authenticate method. I was then 
able to store a user object in session like this.
@Override
        public Authentication authenticate(Authentication authentication)
                        throws AuthenticationException {
                authentication = super.authenticate(authentication);
                if(null != authentication && authentication.isAuthenticated()){ 
                
                        HttpServletRequest httpRequest = 
globals.getHTTPServletRequest();
HttpSession session = httpRequest.getSession(false);
                User user = new User();
                        user.setUsername(authentication.getName());
                User daoUser = userDao.getUser(authentication.getName());
                        if(null != user){
                 // fill some user details from the database such as name and 
email
                        }else{
                        // I just send an email to myself here saying this user 
doesn't have a profile, even though they logged in successfully from the ldap.
                                }
                        }
                
session.setAttribute("sso:my.app.path.to.your.user.object.User", user);
                }
                return authentication;
        }

You can just inject the user object anywhere in your page classes by 
us...@sessionstateprivate User user;private boolean userExists;
There are two downsides to this.1. If something goes wrong at this point, the 
user gets a full blown container error page, instead of your pretty error page 
defined in tapestry.2. If you restart your servlet container when the user is 
logged in (not that you would do that in production), the session object 
disappears even though Spring security still says the user is logged in. I 
haven't found a way around this yet.
I hope this helps.
Thanks,Jeshurun
--- On Wed, 10/6/10, Kai Weber <kai.we...@glorybox.de> wrote:

From: Kai Weber <kai.we...@glorybox.de>
Subject: Re: Injecting Tapestry Services into Spring beans
To: users@tapestry.apache.org
Received: Wednesday, October 6, 2010, 9:59 AM

* Jeshurun Daniel <sjeshu...@yahoo.ca>:

> Ok please ignore that it was just me being stupid. I got it working
> now. Thanks.

Could you tell us, what you had to do to got it working?

Kai

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Reply via email to