views:

93

answers:

3

i need to alert or warn the user.. while user login into particular account 'your account has been expired next week' like that.. my user table having validfrom and validto date. Before 1 week of validto date.. i need to warn users at every time login.

my application using strus2..

for above business logic i need any schedular.. otherwise any easy way.. pl help me

A: 

You can adapt your login function to handle different states:

  • Valid
  • Invalid Username Password
  • Expired
  • Expired within a week

So no scheduler needed.

Gamecat
+1  A: 

When the user logs in subtract the validto date from todays date, if it is less then or equal to 7 days then show the alert.

No scheduler needed, no database changes.

I take it you already have a check to see if todays date is greater then the validto date to prevent someone with an expired account from logging in.

Mark Robinson
A: 

If you anticipate that you will be needing to do the calculation multiple times you might set up a job. For example if you were displaying lists of accounts due to expire in a week and this was a common transaction. In that case you might want to have a look at the Quartz scheduler.

The Spring Framework has good integration with the Quartz scheduler. Here is an example of a scheduling configuration that expires classified ad postings every hour from an open source project I am working on:

    <!-- Scheduled Jobs -->
<bean id="expiryJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
 <property name="targetObject" ref="postingDAO" />
 <property name="targetMethod" value="expirePostings" />
</bean>

<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="expiryJob" />
    <!-- run every hour -->
    <property name="cronExpression" value="0 0 * * * ?" /> 
</bean>
<!--
<bean id="extraTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="expiryJob" />
    <property name="cronExpression" value="0 * * * * ?" /> 
</bean>
-->
<!-- A list of Triggers to be scheduled and executed by Quartz -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
        <list>
            <ref bean="cronTrigger"/>
            <!-- <ref bean="extraTrigger"/> -->
        </list>
    </property>
</bean>
Peter Kelley