Or take a look at this code sample from our app:
public class LoginListener implements ApplicationListener
{
protected Log log = LogFactoryImpl.getLog(getClass());
private UserManager userManager;
/**
* @param userManager the userManager to set
*/
public void setUserManager(UserManager userManager) {
this.userManager = userManager;
}
/**
* @see
org.springframework.context.ApplicationListener#onApplicationEvent(org.sprin
gframework.context.ApplicationEvent)
*/
public void onApplicationEvent(ApplicationEvent event) {
// check failed event
if(event instanceof AuthenticationSuccessEvent)
{
AuthenticationSuccessEvent authenticationSuccessEvent =
(AuthenticationSuccessEvent) event;
String username =
authenticationSuccessEvent.getAuthentication().getName();
User user = userManager.getUserByUsername(username);
user.setLastLogin(new Date());
int loginCount = 0;
if(user.getLoginCount()!= null)
{
loginCount = user.getLoginCount().intValue();
}
loginCount++;
user.setLoginCount(new Integer(loginCount));
try
{
userManager.saveUser(user);
}
catch (UserExistsException e)
{
log.error("Error during updating last login for user
["+username+"]",e);
}
}
}
}
_____
Von: Michael Horwitz [mailto:[EMAIL PROTECTED]
Gesendet: Montag, 13. August 2007 10:01
An: [email protected]
Betreff: Re: [appfuse-user] Add new function after login
ACEGI generate Spring application events on login. You will need to create a
listener to log the appropriate events - do a search on this list, or look
at Spring events on the Spring framework site for more information.
Mike.
On 8/11/07, BruceLee <HYPERLINK "mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]>
wrote:
Team,
I want to add some function e.g. storing login date to database after login.
What is the hook to add this? Using a filter, interceptor or override some
class?
My env: 1.9.4 WebWork
Thanks! -Bruce
--
View this message in context: HYPERLINK
"http://www.nabble.com/Add-new-function-after-login-tf4252462s2369.html#a121
02596"http://www.nabble.com/Add-new-function-after-login-tf4252462s2369.html
#a12102596
Sent from the AppFuse - User mailing list archive at HYPERLINK
"http://Nabble.com"Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: HYPERLINK
"mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]
.java.net
For additional commands, e-mail: HYPERLINK
"mailto:[EMAIL PROTECTED]"[EMAIL PROTECTED]
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 12.08.2007
11:03
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 12.08.2007
11:03