Presentation is loading. Please wait.

Presentation is loading. Please wait.

Weblogs and Java Dave Johnson Roller Weblogger project Prepared for the Triangle Java User’s Group February 16 th, 2004.

Similar presentations


Presentation on theme: "Weblogs and Java Dave Johnson Roller Weblogger project Prepared for the Triangle Java User’s Group February 16 th, 2004."— Presentation transcript:

1 Weblogs and Java Dave Johnson Roller Weblogger project Prepared for the Triangle Java User’s Group February 16 th, 2004

2 0 - Today’s talk What’s a weblog and why have weblogs become such an important part of the Java community? How you can use weblogs in software development projects. And about the XDoclet-driven architecture of the Roller Weblogger.

3 What is a weblog? “A blog is a web page made up of usually short, frequently updated posts that are arranged chronologically—like a what's new page or a journal. The content and purposes of blogs varies greatly—from links and commentary about other web sites, to news about a company/person/idea, to diaries, photos, poetry, mini- essays, project updates, even fiction.” - The Blogger.com site “Weblogs are often-updated sites that point to articles elsewhere on the web, often with comments, and to on-site articles.” – Dave Winer

4 History of weblogging One could consider the “what’s new” pages at CERN, NCSA, and Netscape in the early 1990’s to be the first weblogs. The term weblog originated in late 1997, there were only a couple dozen such sites then. Radio, Blogger, LiveJournal services sprang up during the 1999-2001 dot-com boom. 2002-2003 brings war-blogs, mainstream media blogs, mo-blogging, and political campaign blogs.

5 1 - The Java weblog community 2002: a couple Java blogs and FreeRoller 2003: explosion of Java blogs  Thousands of JRoller Java blogs  Hundreds of independently hosted Java blogs  Javablogs.com community aggregator  Sun’s Java.NET weblogs  JBoss blogs, Codehaus blogs, etc.

6 JRoller.com Free Java-oriented weblogging service Started as FreeRoller by Anthony Eden in 2002. Javalobby took over in October 2003, re- branded, and now hosts more than 2000 blogs.

7 Javablogs.com Hub of the Java weblogging community. Started by Atlassian, makers of JIRA issue tracking software. Anybody can register a weblog here, but non-Java blogs are discouraged.

8 Sun’s Java.NET community site Launched just before JavaONE in July 2003 Weblogs and Wiki are prominently featured Java gurus invited to populate weblogs

9 Java news you can use… http://www.thauvin.net/blog/ http://www.thauvin.net/blog/ Fresh Java links everyday from Erik Thauvin, featured in JDJ http://www.raibledesigns.com http://www.raibledesigns.com Struts, XHTML, CSS, JavaScript tips, and Java webapp tips from Matt Raible http://www.simongbrown.com/blog/ http://www.simongbrown.com/blog/ JSP and J2EE webapp tips from WROX author Simon Brown http://www.russellbeattie.com/notebook/ http://www.russellbeattie.com/notebook/ Mobile app. dev. trends from Russell Beattie http://www.neward.net/ted/weblog http://www.neward.net/ted/weblog Ted Neward published a rough draft of Effective Enterprise Java on his blog http://www.beust.com/weblog/ http://www.beust.com/weblog/ S/W dev. discussion from Cedric Buest, Senior S/W Engineer, BEA http://jroller.org/page/cpurdy http://jroller.org/page/cpurdy S/W dev. discussion from Cameron Purdy, CEO Tangosol http://fishbowl.pastiche.org/ http://fishbowl.pastiche.org/ S/W dev. discussion from Charles Miller of Atlassian. And of course: http://jroller.com http://javablogs.com http://weblogs.java.net http://jroller.com http://javablogs.com http://weblogs.java.net

10 2 – Weblog software features We already discussed the basics. A weblog is:  An online journal, news site, diary  A personal publishing system  Entries in reverse chronological order Let’s discuss how weblog software makes it easy to write online.

11 Easy to update your site Easy to add a new weblog entry, even if you have no knowledge of HTML. Easy to categorize posts. Easy to edit old posts. Use a WYSIWYG editor, HTML, or use Wiki syntax.

12 Common features Permalinks: every post gets it’s own unique and permanent URL. Comments: Some weblogs allow comments on each post, some do not – it’s up to the author. RSS Newsfeeds: so that “subscribers” may read your weblog in a Newsreader. Page Templates: so you can customize the look, feel, and layout of your weblog. Referrer Tracking and Trackback: so you know who is writing about or linking to your weblog entries. Blog-rolling: displaying a list of favorite weblogs and websites.

13 Anatomy of a weblog

14 3 - Weblog infrastructure Weblogging is supported by an extensive infrastructure that is built around:  Data formats: RSS, Atom, OPML  Web service APIs: Blogger API, Atom  And good old HTTP Let’s talk about that infrastructure and the applications that build upon it to support weblogging…

15 Newsfeed syndication A newsfeed is simply an XML representation of titles and entries from a website, made available at a URL. A weblog page: http://jroller.com/page/fatehttp://jroller.com/page/fate A weblog RSS feed: http://jroller.com/rss/fatehttp://jroller.com/rss/fate Most newsfeeds are RSS or RDF. Serious weblog readers use newreaders: on JRoller over 70% of requests come from newsreader software.

16 Example RSS newsfeed

17 XML-RPC interface XML-RPC based Blogger API allows posting and editing of weblog entries from weblog client software. MetaWeblog API adds support for titles. XML-RPC was invented to serve this purpose. History of weblog APIs: http://www.xml.com/pub/a/2003/10/15/dive.html http://www.xml.com/pub/a/2003/10/15/dive.html

18 Clients Blog clients allow you to:  Post to your own weblog  Post comments to other weblogs Newsreader clients, allow you to:  Subscribe to and read RSS newsfeeds  Import/export subscription lists as OPML

19 SharpReader – desktop newsreader http://sharpreader.com

20 Bloglines.com – web newsreader http://bloglines.com

21 w:bloggar – blogging client http://www.wbloggar.com

22 4 – Weblogs & communities “the web grows communities, almost without trying, because the web is the only media that allows it’s users to communicate with each other directly, publicly, and immediately” - Derek Powazek, Design for Communities Communities are important to technology development and adoption. Weblogs are not the only technology that enable online community, communication, and collaboration. What’s so special about weblogs in community building?

23 Weblogs vs. email A mailing-list is also a great place for community discussion, but flames and noise can be a problem. Spam is making e-mail less and less valuable. Email can complement weblogs  Blogging via e-mail  Mailing-list to weblog gateways  Comment notification via email Email publishes to a select group, the content is free-form, haphazard, and unrestricted. The problem is that email has little "memory" (you cant refer to a previous email) and no permanence (an email doesn't park itself on your intranet, to be seen, shared, repurposed, etc.. for later use). -Jordan Frank, Traction Software

24 Weblogs vs. newsgroups Threaded newsgroups and web forums are a great place for community discussions, but flames and noise can drive people away. You can opt-out with a kill file. Weblogs provide an opt-in model – you only read, subscribe, and link to blogs you like. This also provides filtering. Forums can complement weblogs – a threaded forum could be used for weblog comments.

25 Weblogs vs. web pages Project and group web pages always seem to grow stale. Generally speaking, web pages are static and difficult to update. This is true even in a web savvy group with great web design/editing tools. Weblogs are easy to keep up to date and require no special publishing tools. Weblogs replace “homepages” The vanity page is dead; long live the Blog. The vanity Web page has lost momentum. People who posted one have already done so, and the growth has slowed. Most are uninteresting and uninspired. Cat pictures dominate too many of them. – John Dvorak

26 Weblogs vs. Wikis Wikis provide:  A collaborative space for a community  Anybody can edit or add any page via web interface  Super simple syntax means, no need for HTML Wikis can function as weblogs and can produce RSS feeds Wikis & weblogs are easily integrated

27 Weblog as community “it’s this multitude [of separate sites] that gives the weblog community model it’s strength. Because a person has control over his own piece of community landscape, he feels a powerful ownership of his space that’s lacking in traditional community sites.” Design For Community, Derek Powazek http://www.powazek.com/

28 Weblog Community Aggregators Javablogs.com is not the only one… “A Community Aggregator is a portal-like web application that displays weblog posts from a group of closely related but separately hosted weblogs and provides synthetic newsfeeds so that readers may subscribe to the group as a whole.” Enabled by RSS syndication Provide aggregated RSS feeds Subscription lists in OPML format

29 Planet Apache Community aggregator for Apache developer weblogs. Similar sites for:  Dot Net blogs  Python blogs  GNOME blogs  Mono blogs  Fedora blogs  Debian blogs  Lisp blogs  Etc. …

30 Question #1 Why have weblogs have become such an important part of the Java community?  Ease of publishing empowers developers to share  This resulted in lots of great developer weblogs  Weblogs are great for community building

31 5 – Weblogs at work More and more people are discovering weblogs and wikis are useful on the job and behind the firewall. Let’s talk about some specific uses for weblogs in the workplace.

32 K-logging K-logs: weblogs for knowledge management, a term originated by Jon Robb former CEO of UserLand. Every employee blogs on a daily basis  Goals and progress  Opinions and links to outside news and analysis Managers subscribe to employee weblogs, directors subscribe to their manager, and so on up the chain. Weblog archives act as knowledge base that may be commented upon and linked to. http://groups.yahoo.com/group/klogs

33 It all sounds so good, but… Will it work? Local blogger Mark Pilgrim points out that:  “most people are not good writers”  “most companies don’t see the value of having people document anything”  “most people are not passionate about their work”  “people only have so much writing in them everyday”

34 Enterprise blogging use-cases Enterprise Weblogging vendor Traction software suggests a number of use cases for weblogs behind the firewall:  Personal notebook  Corporate communications  Program management  Product management  Operations log  Internal news  Communities of interest

35 Enterprise Blogging

36 In my experience… Weblogs are useful for timely news and status  Announce new builds and new documents  News of big changes to code-base  Weekly or daily status reports Wikis are useful as collaborative space  Serves as software project homepage  Record rough specs and feature ideas  Consultants can document progress and issues  Testers can document ever changing test setups

37 6 – Roller demo Making a post with Roller Making a post with w:bloggar Using Roller’s Wiki integration features Managing categories Managing bookmarks

38 7 – Roller Architecture Roller is an open source J2EE weblogging system that manages weblog data in a relational database.  Editor UI – Struts and JSP  Page and RSS rendering – Velocity  Database access – Hibernate (or Castor)

39 Layered architecture

40 7.1 Roller Persistence Layer

41 Persistence Layer in context

42 Example code: a query // Find all entries in a website since a given date QueryFactory factory = mStrategy.getQueryFactory(); Query query = factory.createQuery(WeblogEntryData.class.getName()); Condition specifiedWebsite = factory.createCondition("website", Query.EQ, website); Condition specifiedDate = factory.createCondition( “pubTime", Query.GT, date); List conditions = new LinkedList(); conditions.add(specifiedWebsite); conditions.add(specifiedDate); query.setWhere(factory.createCondition(Query.AND, conditions)); List entries = query.execute();

43 7.2 Roller Business Layer Defined by set of manager interfaces. And a set of persistent domain objects.

44 Business Layer in context

45 Roller Data Model

46 Example POJO: XDoclet markup /** * @castor.class name="website" table="website" id="id" * key-generator="UUID" auto-complete="true" * @hibernate.class table="website" * @struts.form include-all="true" */ public class WebsiteData extends org.roller.persistence.PersistentObject implements java.io.Serializable { /** * @castor.field set-method="setDescription" * @castor.field-sql name="description" * dirty="check" sql-dirty="check" * @hibernate.property column="description" * non-null=“false" unique="false" */ public java.lang.String getDescription() { return this.description; } public void setDescription(java.lang.String description) { this.description = description; }

47 XDoclet code generation, part I XDoclet makes it easy to keep O/R mapping files in sync with Java source code.

48 7.3 Roller Presentation Layer Editor UI implemented with Struts and JSP, using Struts form beans generated by XDoclet. JSP pages use:  Struts HTML form tags  JSTL core and I18N tags  Custom Roller JSP tags Roller pages and RSS feeds are implemented using Velocity templates.

49 Presentation Layer in context

50 Example Action: XDoclet markup /** * @struts.action path="/BookmarkSave" name="bookmarkFormEx" * validate="true" input="/BookmarkEdit.do“ * * @struts.action-forward name="Bookmarks" * path="/Bookmarks.do?method=selectFolder" */ public class BookmarkSave extends Action { public ActionForward execute( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {...

51 XDoclet code generation, part II XDoclet makes it easy to keep deployment descriptors in sync with Java source code.

52 7.4 Roller Page Rendering Weblog users want almost complete control over page layout and design For a variety of reasons, we can’t allow them to edit JSP files Instead, pages are defined by Velocity templates  PageServlet renders user-defined pages  FlavorServlet renders predefined formats

53 Example: a weblog page template #showWebsiteTitle() #includePage("_css") #showRSSAutodiscoveryLink() #showWebsiteTitle() #showWebsiteDescription() #showWeblogCategoryChooser() #showWeblogEntries("_day" 15) Calendar #showWeblogCalendar() RSS Feeds #showRSSBadge() #showRSSLinks() Links #showBookmarks("Blogroll" true false) #showBookmarks("News" true false) Navigation #showBasicNavBar(true) #showEditorNavBar(true) Referers #showReferers(30 20)

54 Example: a day page template #showDayPermalink( $day ) #showEntryDate( $day ) #foreach( $entry in $entries ) $entry.title #showEntryText($entry) ($entry.pubTime) #showEntryPermalink( $entry ) #showCommentsPageLink( $entry ) #end #showLinkbacks( $day )

55 Example: the RSS template $utilities.textToHTML($website.name,true) $websiteURL $utilities.textToHTML($website.description,true) en-us Copyright #formatDate("yyyy" $now) $emailAddress #set( $entries = $pageModel.getRecentWeblogEntriesArray($entryCount) ) #foreach( $entry in $entries ) $utilities.textToHTML($entry.title,true) $absBaseURL$entry.permaLink $entry.getRss09xDescription( $entryLength ) #end

56 Roller Page Velocity Servlets Page Servlet mapped to /page/ Flavor Servlet mapped to /flavor/ and to /rss/

57 7.7 Roller: Lessons Learned Initially, FreeRoller suffered from severe performance and load-related stability problems. Now, JRoller runs smoothly and puts minimal load on the Java Lobby server. Most important performance improvements  Caching, Caching, and more Caching  Proper use of connections - Open Session in View  Database Indexes

58 Caching, Caching, Caching Server-side Page and RSS feed caching via OSCache Enable client-side caching by supporting HTTP IF- MODIFIED-SINCE header. Cache last update time for each weblog so checking IF- MODIFIED-SINCE needs no database query. Caching keeps database hits to absolute minimum.

59 Example: RSS feed caching

60 Open Session in View Cannot give each HTTP session it’s own database connection – that won’t scale. Pattern documented by Hibernate folks, a “persistence session” corresponds to a database connection. Each incoming request gets a connection from the connection pool and uses it for all processing. When response is complete, request’s connection is returned to the pool.

61 Open Session in View - sequence

62 Database indexes Biggest single performance improvement. Watch for queries that examine lots of rows, make sure key fields are indexed.

63 8 – Conclusion Go sign up for your new blog at JRoller.com Thanks for listening! Any questions?


Download ppt "Weblogs and Java Dave Johnson Roller Weblogger project Prepared for the Triangle Java User’s Group February 16 th, 2004."

Similar presentations


Ads by Google