Its fairly simple to imlement a cron job.

First Create a *cron.xml* in your web/WEB-INF folder. (Along with web.xml
appengine-web.xml etc.)

It contains the definition of the servlet the cron will perform. The url is
the url for your servlet and schedule is the timing.

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/cron/myjob</url>
<description>Process my job every 1 hours</description>
<schedule>every 1 hours</schedule>
</cron>
</cronentries>

It is important to secure cron jobs from unauthorized access. So you can add
the entries in web.xml

<!-- Admin Only -->
<security-constraint>
<web-resource-collection>
<url-pattern>/cron/*</url-pattern>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>



and finally you should have some servlet def in web.xml

<servlet>
<servlet-name>myjob</servlet-name>
<servlet-class>org.maksud.gwt.app.servlets.MyJobServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> myjob </servlet-name>
<url-pattern>/cron/myjob</url-pattern>
</servlet-mapping>


Remeber the cron will call get method. So you must implement doGet in your
servlet.

And as always google and appengine docs are your best friend.

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to