810 likes | 1.02k Views
java . blogs. “The movement, the site, the technology”. Prepared by Mike Cannon-Brookes - June, 2003 mike@atlassian.com - http://www.atlassian.com. Agenda. Blogging & Java What is java.blogs? Technology behind javablogs.com. What is a weblog?. “News site” written by one person
E N D
java.blogs “The movement, the site, the technology” Prepared by Mike Cannon-Brookes - June, 2003 mike@atlassian.com - http://www.atlassian.com
Agenda • Blogging & Java • What is java.blogs? • Technology behind javablogs.com
What is a weblog? • “News site” written by one person • Online, chronological journal • Personal list of thoughts, links etc • Newest entries at the top of the page • Usually has an RSS version • Hard to categorize, easier to show you an example
Typical Blog Pieces Ugly Author Pic Silly Title Posts
Posts Nav Search Blog Roll About
Why read blogs? • Get a personal view point • Bloggers usually discuss latest content / ideas • In the Java world, often a good source of solutions and personal experience • Example: commons-logging & log4j • Comparison: best feature on Amazon? • book reviews!
Why write a blog? • Everyone has their own reasons • A place for personal expression • Share your thoughts, wisdom • Feel part of a community • Rant / rave / vent / discuss • BileBlog perfect example
RSS • Really Simple Syndication? • Rich Site Summary? • RSS is the “protocol” of the syndication world • An XML format representing a list of links • Used to syndicate weblogs in a machine readable format • It is a very simple format…
RSS Example <rss> <channel> <title>rebelutionary</title> <link>http://blogs.atlassian.com/rebelutionary/</link> <description>Mike Cannon-Brookes on J2EE, Java, software development, bug tracking, Atlassian, JIRA and whatever comes to mind.</description> <item> <title>The BileBlog is painfully accurate</title> <link>http://blogs.atlassian.com/rebelutionary/archives/000166.html</link> <description>Let me start by saying …</description> </item> <item> <title>Two Weeks Left to TSS </title> <link>http://blogs.atlassian.com/rebelutionary/archives/000165.html</link> <description>Less than two weeks left until TSS Symposium... </description> </item> . . . </channel> </rss>
Blog Syndication Blog 2 Blog 1 Blog 3 RSS(XML) HTML RSS(XML) HTML News Aggregator Reader
News Aggregators • Software to aggregate news from your personal list of favourite sites. • Popular: • AmphetaDesk (Perl) • NetNewsWire (OSX) • NewsCrawler (Win) • NewsMonster (Moz) • java.blogs is a ‘web based’ news aggregator for the Java community.
Blogging using Java • Lots of blog software written in Java • 3 biggest projects: • Roller, SnipSnap and Blojsom • Other projects include: • PersonalBlog, MiniBlog, CocoBlog etc.
Tools: Roller • www.rollerweblogger.org • The most advanced Java-based blogging tool • Supports comments, templating, RSS, XML-RPC, multi-user. • Deploys on Servlet container & JDBC database • Technologies used: • Persistence: Hibernate or Castor • MVC: Struts • Views: Velocity
Tools: SnipSnap • www.snipsnap.org • Innovative Java-based ‘Bliki’ (Blog + Wiki) • Features include a complex Wiki rendering engine, comments, search, RSS, XML-RPC • Standalone Jetty instance with McKoi DB • Technologies: • Views: JSP • Everything else hand rolled!
Tools: Blojsom • blojsom.sf.net • Java port of Bloxsom (Perl-based tool) • Uses the file system for persistence • Supports comments, RSS, XML-RPC, referrer tracking, searching. • Runs on JDK 1.4 w/ Servlet 2.3 container. • Technologies: • Flexible view dispatcher: JSP, Velocity or Freemarker
Tools: Wrap Up • If you’re looking to start a new blog, without software - try freeroller http://www.freeroller.net • No installation required • Completely web based • Good way to get blogging!
Agenda • Blogging & Java • What is java.blogs? • Technology behind javablogs.com
java.blogs Overview • www.javablogs.com • A web aggregator for Java focused weblogs • Currently aggregates: • Over 1.5 million words • Written in 18,000+ entries • Posted by 360+ bloggers
Information Flows Blogs (Internet) Thoughts RSS Feeds Bloggers java.blogs Browse Website Email Aggregated RSS Readers
java.blogs Features • Single ‘feed’ of all Java blog entries • Decentralized, uncontrolled, focused community • Each blog owner controls their own blog • Tracks “popular” entries • Popular entries show what the community reads • Text & date searchable content • eg find all entries about “AOP” this week • Daily email notifications • Keep up to date with most popular entries from within your email client
How is it different? • It is a true community of equals • Find a wide range of views on any topic • eg Over 30 entries discussing the impact of java.net within 24 hours of launch. • There is no ‘agenda’ - just personal views • “Good entries” rise to the top • More news than you can ever want • Now averaging over 200 entries / day
350 authors 1000 users Users in total control This is good and bad! Content is personal 100% opinions Analogy: having a conversation with 350 developers Few authors 290,000 users Centralised editorial Quality assurance Content is controlled Opinions in comments Analogy: reading a newspaper or magazine java.blogs vs TSS
java.net? • java.net contains Sun ‘by-invitation only’ weblogs • This is good for Javablogs.com! • Many new blogs to aggregate (java.net has RSS): • James Gosling, • Sam Ruby, • Mike Clark, etc • See http://weblogs.java.net/ for more information.
Agenda • Blogging & Java • What is java.blogs? • Technology behind javablogs.com
javablogs.com Components Mail (JavaMail & Velocity) Scheduling(Quartz & Atlassian Scheduler) java.blogs code (Java!) Persistence (OFBiz) Non-Web DB (Postgres) XML / SOAP (Electric XML & Glue) Presentation (SiteMesh, WebWork & JSP) Search & Indexing (Lucene) User Management (OSUser) Web MVC (WebWork)
Component Tour Scheduling Persistence Security MVC Indexing Mail Presentation
Component Tour: Scheduling Scheduling Persistence Security MVC Indexing Mail Presentation Components: Quartz & atlassian-scheduler
Scheduling: Quartz • www.part.net/quartz.html • J2EE job scheduling system • Alternatives? • Threads, util.Timer, external cron • Operates around a job/trigger model • Built in period and cron triggers • Extremely flexible, friendly component • USE: scheduling RSS retrieval, sending daily email updates, any periodic task • atlassian-scheduler is a Quartz XML config…
Scheduling: Atlassian Scheduler • Example: scheduler-config.xml <scheduler> <jobs> <job name="Updater" class="com...UpdateJob" /> <job name="DailyEmail" class="com...EmailJob" /> </jobs> <triggers> <trigger name="UpdaterTrigger" job="Updater"> <period>3m</period> <startDelay>3m</startDelay> </trigger> <trigger name=”MailTrigger" job="DailyEmail" type="cron"> <startDelay>1m</startDelay> <expression>00***?</expression> </trigger> </triggers> </scheduler>
Component Tour: Persistence Scheduling Persistence Security MVC Indexing Mail Presentation Component: OFBiz Entity Engine
Persistence: OFBiz EE • www.ofbiz.org - Open For Business project • “Different” persistence engine • Light wrapper around JDBC datasources • Proud to be relational! • Data entities are generic value objects • Entity, field, view and relation definitions are in XML • Use: all data persistence in Javablogs.
Persistence: OFBiz EE • Retrieving all blogs: Collection blogs = ee.findAll(“Blog”); • Retrieving a specific blog entity: Map idField = UtilMisc.toMap(“id”, id); GenericValue blog = ee.findByPrimaryKey("Blog", idField); • Getting and setting a field value: GenericValue blog = retrieveBlog(); String url = blog.getString(“url”); blog.set(“url”, newUrl); blog.store();
Persistence: OFBiz EE • Retrieving blog entries: Collection entries = blog.getRelated(“ChildEntry”); • Complex find operation: Map fields = UtilMisc.toMap(“author”, “bob”); List sortorders = UtilMisc.toList(“dateadded”); entries = ee.findByAnd(“Blog”, fields, sortorders);
Persistence: OFBiz EE • Automatically creates and updates tables • Code talks to the logical model • Logical model + field mappings = physical db OFBiz EE javablogs code Logical Model entitymodel.xml Physical Database Field Mappings fieldtypes-oracle.xml
Persistence: OFBiz EE • Sample entity from entitymodel.xml <entity entity-name= "BlogEntry" package-name= "" > <field name= "id" type= "numeric" col-name= ”entry_id" /> <field name= "blog" type= "numeric" /> <field name= "title" type= "long-varchar" /> <field name= "created" type= "date-time" /> ... <prim-key field= "id" /> <relation type= "one" title= "Parent" rel-entity-name= "Blog" > <key-map field-name= "blog" rel-field-name= "id" /> </ relation > </ entity >
Persistence: OFBiz EE • Sample of fieldtypes-postgres.xml <fieldtypemodel> <field-type-def type= "date-time" sql-type= "TIMESTAMP" java-type= "java.sql.Timestamp" /> <field-type-def type= "short-varchar" sql-type= "VARCHAR(60)" java-type= "String" /> <field-type-def type= "very-long" sql-type= "TEXT" java-type= "String" /> <field-type-def type= "credit-card-number" sql-type= "VARCHAR(40)" java-type= "String"> <validate name= "isAnyCard"/> </ field-type-def>
Component Tour: Indexing Scheduling Persistence Security MVC Indexing Mail Presentation Component: Jakarta Lucene
Indexing: Lucene • jakarta.apache.org/lucene • Thefull-text index and search component • Highly scalable and efficient architecture • Why use full text searching? • No more SQL: LIKE ‘%foo%’ • Used for full text search of blog entries
Component Tour: Security Scheduling Persistence Security MVC Indexing Mail Presentation Components: OSUser & atlassian-security
User Management: OSUser • www.opensymphony.com/osuser • Server-agnostic user management API • Handles user, group and profile data • Why needed? • User data different to other data • Pluggable storage providers (ie LDAP) • Writing portable J2EE auth code very hard
User Management: OSUser • Providers for storage: • EJB, JDBC, OFBiz, Hibernate, LDAP, XML files etc • Adapters for server integration • Weblogic, Orion, JBoss, Resin etc javablogs code providers adapters • Storage • users • groups • profiles Application Server OSUser
User Management: OSUser • Retrieving a specific user and their groups: User user = userManager.getUser(“fred”); Collection groups = user.getGroups(); • Retrieving a user’s profile: PropertySet profile = user.getPropertySet(); String country = profile.getString(“user.address.country”); Date signedUp = profile.getDate(“user.signup”); Long logins = profile.getLong(“user.numlogins”); • Creating a new user in the administrators group: User newUser = userManager.createUser(“mike”); newUser.setEmail(“mike@atlassian.com”); newUser.addToGroup(userManager.getGroup(“administrators”));
Security: atlassian-security • Security is worst part of Servlet spec • Not portable between servers • Very limited URL patterns • To perform effective security checks on a web application, need to roll your own framework. • atlassian-security is our solution to this • in process of being open sourced
atlassian-security architecture Concepts Integration Points
atlassian-security Services • Services allow you to check the roles required for any request • Two bundled services: • Path Service: looks at the request URL. Allows extremely flexible path lookups • /admin/*, **/admin/*, /admin/Setup* etc • WebWork Service: looks at the action being executed • Other examples could be IPService or KeyService.
atlassian-security PathService • PathService is configured in a security-paths.xml file: <security-paths> <path name= "admin"> <url-pattern>/secure/admin/*</url-pattern> <role-name>administrators</role-name> </path> <path name= "user"> <url-pattern>/secure/*</url-pattern> <role-name>users, developers</role-name> </path> </security-paths>
atlassian-security Interceptors • Problem: run code before / after security events • Events? login, logout, auth attempts etc. • Under the Servlet spec you can’t do this. • Solution: AOP-like interceptors • Example: used in java.blogs to store the date of last login, and number of logins
Component Tour: MVC Scheduling Persistence Security MVC Indexing Mail Presentation Component: OpenSymphony WebWork