Use Grails to build feedlr.com Web sites

Source: Internet
Author: User
Tags execution fast web grails root directory

Multi-platform micro-blogging robot platform driven by Feedlr:feed

Micro-blogging is a new thing in the Web 2.0 era created by Twitter. On micro-blogs, people use short language to post messages anytime, anywhere, and get instant news from their friends. Thanks to its ease of use and real-time features, Twitter has been heating up since its launch in 06 and has more than 3 million users. In particular, in the 08-year period, Twitter changed its role as a geek toy in its infancy, apparently evolving to the mainstream. With the rise of Twitter, there are also a lot of other micro-blogs. Only domestic there is the chirp, rice, and do what and so on. The rise of micro-blogging provides a new way to communicate online.

Twitter as the originator and most successful example of microblogging, its excellent API interface work. Through the Twitter API, developers have developed a number of novel and useful Twitter third-party applications. My starting point for FEEDLR is to create a service that allows users to customize their feed bots, with core features similar to the popular twitterfeed on Twitter, and the ability to Twitter, tweet, Cook, and do 4 micro-blogging platforms.

Through FEEDLR, users can set up micro-blog broadcast accounts, to keep track of their interest in the Rss/atom feed content. Once updated, FEEDLR will automatically send the new content to the designated microblogging platform. FEEDLR online So far, users have established a customized news broadcast robot, DIY free weather prediction robot, different micro-blog message synchronization robot, and even domestic earthquake real-time monitoring robot and so on. And through the domestic micro-blogging service SMS Notification Services, all of the above feed content of domestic users can be free on the phone by SMS received.

The choice of the Grails framework

Grails is an up-and-coming, fast Web development framework based on the groovy language, running on top of the JVM, and designed like rails, which was launched in early 08 with version 1.0. Through the groovy language and innovative architecture, Grails skillfully integrates sophisticated enterprise-class JEE Open source components, spring,hibernate, and so on, using rails-like "by-convention design" concepts bundled into a complete Web development Framework. The complexity of the JEE development process is replaced by groovy's flexible dynamic features and the streamlined configuration of the agreed design, while preserving the stability and performance advantages of enterprise-class components, which can be described as bringing rails-style rapid development to the abyss of JEE developers. I come from JEE background, there is a certain basis for groovy language, choosing grails to build FEEDLR is a natural choice, but also to experience Grails's complete development process in a real project without too many constraints.

How to implement FEEDLR core functions FEEDLR core functions with Grails

The core functions of FEEDLR include regular query user feed updates, update feed content to micro-blog, plus to enhance the user experience of a number of AJAX implementations and OpenID login. Here is a description of the implementation of these functions.

Timed Query Feed update

FEEDLR's most core function is to periodically poll the user submitted feed, find new entries, so through the micro-blog API sent to the microblog. This functionality can be easily achieved by using Grails's quartz plug-ins. Quartz is a wide open source Java library for precise control of timed tasks. Quartz is powerful because it is compatible with UNIX cron syntax. In Grails, Quartz is one of the core plug-ins that come with the framework, and it's convenient to perform timed tasks with Quartz plug-ins. Create a new quartz timed task that only needs to be performed under the Grails project root directory

grails create-job

When prompted for a job name, Grails automatically generates a new job program file in the grails-app/jobs/directory. Grails jobs are named after Xxxjob.groovy, and are stored in the Grails-app/jobs directory, and Grails automatically traverses the job directory when it starts, and executes each of the defined runs at timed intervals. A job file is used to define a timed execution pattern that defines timing logic through the UNIX cron syntax. For example, the job that FEEDLR uses to poll feeds is roughly like this:

class UpdateFeedsJob {
  def feedService 
  def cronExpression = "0 * * * * ?" //每分钟执行一次
  def execute() {  
    feedService.updateFeeds()
  }
}

Cron expression "0 * * * *?" Represents one execution per minute. The logic that needs to be performed is specified by defining an Execute () method. Feedservice is a Grails service class that has been defined to query feed updates, using Rome to parse feeds. Note that there is no need to instantiate the Feedservice variable, as long as the variable name of the service to be used is defined by the rules that are designed by convention, Grails automatically finds the service class Feedservice, injects it into the updatefeedsjob, and The service instance is paid to the Feedservice variable, which sounds magical. This way, grails triggers a updatefeedsjob every minute to query the feed for updates.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.