Hi,
I wrote a portal service which will need to execute some business logic at a specified time eg at the end of the month. I wrote the follwing code to do that.
public class SchedulerService implements ISchedulerService{
private IServiceContext mm_serviceContext;
public void init(IServiceContext serviceContext)
{
mm_serviceContext = serviceContext;
}
public void afterInit()
{
while(true)
{
Date currentDate = new Date(System.currentTimeMillis());
Calendar cal = new GregorianCalendar();
cal.setTime(currentDate);
int currentMonth = cal.get(Calendar.MONTH);
Date dateAfterFiveHours = new Date(currentDate.getTime() + 56060*1000);
cal.setTime(dateAfterFiveHours);
int monthAfterFiveHours = cal.get(Calendar.MONTH);
if(currentMonth != monthAfterFiveHours)
{
// Call some method in another class }
}
}
public void configure(com.sapportals.portal.prt.service.IServiceConfiguration configuration)
{
}
public void destroy()
{
}
public void release()
{
}
public IServiceContext getContext()
{
return mm_serviceContext;
}
public String getKey()
{
return KEY;
}
}
Is it correct to write the logic in while(true) loop?
I am asking this because when I deploy the service into the server from NWDS my NWDS is hanging up and server is crashing (and I then need to unistall and reinstall the server again). It happens only when I try to deploy this service and everthing else in the world works fine.
It will be great if someone can throw light on this.
Thanks & Regards,
Sudhir