Skip to main content
 

Another java project "goes guava"

Another java project "goes guava"

Originally shared by James Snell

More Abdera2 Updates... this is a copy of an email I just sent to the Abdera-dev mailing list...

----------

Ok, for those of you who may not have seen it, I posted another major update to the Abdera2 code yesterday. Where as the first round of updates focused primarily on updating dependencies and the introduction of the Activity Streams capability, this update focused more on API Refactoring and the introduction of two new major dependencies: the Joda-Time Library (http://joda-time.sourceforge.net/) and the Google Guava Libraries (http://code.google.com/p/guava-libraries/).

First up, Joda-Time... for those who aren't familiar with it, joda-time is a comprehensive code library for working with dates, times, durations, intervals, etc. When I wrote the first version of the Abdera Feed Object Model API, there wasn't a good open-source implementation of the ISO8601 DateTime format required by the Atom specification available so I wrote a fairly limited, down and dirty implementation in the form of the AtomDate class. It had decent performance, fairly good coverage and got the job done. Joda-Time, however, has emerged since as a top quality rich implementation of the 8601 standard... so even though it is a breaking change to the existing Feed Object Model API, I have gone through an have replaced Abdera's own implementation with Joda-Time's DateTime class, which, when used in combination with the mechanisms provided by the Google Guava libraries, provides for some very interesting and compelling new capabilities.

Which, of course, brings me to Guava. This library is a collection of extremely useful utility classes from google. This update brings significant deep integration with Guava in a number of ways, the most important of which is the new Selector API that I introduced as part of the first Abdera2 checkin.

Among many other things, Guava defines a number of interfaces and utility classes aimed at making it easier for developers to write quality, functional, readable code that has a more natural flow to it. It is easiest to show by example.

In Abdera 1.x, if I wanted, for instance, to extract a list of entries from an Atom feed that had been edited after a specific date and time, it would look something like this...

AtomDate ad = new AtomDate("2011-09-10T12:12:12Z");

List list = feed.getEntries();

List selected = new ArrayList();

for (Entry entry : list) {

if (entry.getEdited() != null) {

if (entry.getEdited().after(ad.getDate()))

selected.add(entry);

}

}

Note that feed.getEntries() will return every entry from the feed whether we want it or not. We then have to iterate back over that list, check to make sure there's an edited date, compare those and build up a new list. The code is ugly and cumbersome and inefficient. With the code I just checked in, the same process looks like this...

import static org.abdera.abdera2.model.selector.Selectors.*;

import static org.abdera.abdera2.common.date.DateTimes.*;

List list =

feed.getEntries(

edited(after(dt("2011-09-10T12:12:12Z")))

);

The portion, edited(after(dt("..."))) constructs a Selector that filters the list of items returned by getEntries(), keeping us from having to iterate back over the list.

Suppose we wanted to add another condition to the mix.. say some custom selector that checks for the presence of a particular extension... We can implement our CustomSelector by extending the AbstractSelector class, and merely append that in to the code above like so...

import static org.abdera.abdera2.model.selector.Selectors.*;

import static org.abdera.abdera2.common.date.DateTimes.*;

Selector customSel = new AbstractSelector { ... }

List list =

feed.getEntries(

edited(after(dt("2011-09-10T12:12:12Z")))

.and(customSel)

);

Underlying the Selector API a large chunk of the Guava API... specifically the Predicate, Function, and Constraint interfaces. The Selector interface actually extends from Predicate and Constraint and provides a mechanism for being cast as a Function.

A broad range of utility methods have been provided that create constructors for many of the most common cases, in particular DateTime related operations. Look at the following classes for those utility methods...

org.apache.abdera2.common.date.DateTimes

org.apache.abdera2.common.selector.Selector.Utils

org.apache.abdera2.model.selector.Selectors (for Atom specific utilities)

org.apache.abdera2.activities.extra.Extra (for Activity Streams specific utilities)

The Selector mechanism has been baked into both the Atom and Activity Streams APIs now. For instance, suppose we have an Activity stream but we only want a max of 10 activities for which a given user is the intended target (using the Activity Streams Audience Targeting Extension.. which I can explain later .. lol).. We could get that list of entries using...

PersonObject person = new PersonObject();

person.setId("acct:john.doe@example.org");

Iterable list = stream.getItems(isTo(person).limit(10));

Additional changes in this update include....

1. Refactoring classes into immutable thread-safe objects. This will be an ongoing change. As much as possible, a Factory/Builder model for most basic object types will be used as opposed to the more traditional getter/setter model. The motivation behind this change is simple in that it helps make more a much more scalable architecture and significantly more readable code.

For instance, if you wish to construct a Cache-Control header, you can use a simple fluent builder api...

CacheControl cc =

CacheControl

.make()

.isPublic(true)

.noTransform(true)

.maxAge(1000)

.get();

Likewise if you wish to construct a new WebLink HTTP Header,

WebLink link =

WebLink

.make()

.iri("http://example.org")

.rel("alternate")

.title("Home")

.get();

The pattern is simple and consistent throughout.

2. Added support for Guava objects in the URI Template implementation... specifically, a URI Template Context can now include the Guava Multimap, Supplier and Optional values. In addition, support for java.util.concurrent.Future, java.lang.ref.Reference and java.util.concurrent.Callable were also added. The one caveat when using Future, however, is that the context will not wait for a value to become available. The Context calls Future.get() and takes whatever it gets back as the value so before you use a Future in a URI Template, make sure it's been completed.

3. org.apache.abdera2.common.text.CharUtils has been refactored. This class was always a bit of a hacky mess. It's been cleaned up significantly around a new CodepointMatcher that is modeled after Guava's CharMatcher interface. Codepoint matcher, however, is designed to work specifically with Unicode Codepoints rather than Java Chars. For the most part, CharUtils and CodepointMatcher are internal classes that the majority of users won't ever have to mess with.

4. Filter/FilterChain has been refactored. This is the part of the Server framework that allows you to plug in a chain of filters before invoking a Publishing Protocol Provider. Previously, the Filter and FilterChain interfaces were very specific to the Server API.. they have been refactored into generic Chain and Task interfaces and moved to org.apache.abdera2.common.misc.*. This allows the use of Chain anywhere you may need a simple interceptor framework...

A trivial example,

Task lower =

new Task() {

public Void apply(

String input,

Chain flow) {

if (input == null) return null;

return flow.next(input.toLowerCase());

}

};

Function print =

new Function() {

public Void apply(String input) {

System.out.println(input);

return null;

}

};

Function chain = new Chain(print,lower);

chain.apply("HELLO!");

The Google Guava api does provide the means of composing multiple Function objects together such that the output of one flows into the input of another, but it only works in one direction.. the Chain here allows you to intercept inputs and outputs.

There are a number of other additions here and there throughout the code, and there will be more to come. One MAJOR change that I'm currently exploring is the use of Guice as a complete replacement for the Classpath-based configuration model we currently have. Let's face it, the current stuff provides a significant amount of flexibility and power, but initialization is slow. Guice is significantly faster and much more powerful than what we currently have.

Anyway, that's it for now.------

 

Creepy

Creepy

 

Not sure what's the process for proposing new rel attributes for XFN..

Not sure what's the process for proposing new rel attributes for XFN..

In any case posting this here for feedback.

Add a new supplementary rel value 'verified' that combines with other rel attributes to indicate that the source believes that this relationship is valid (by using an OAuth API or other means.. For example:

<a href="http://inuus.com" rel="me verified">Paul

 

Creepy

Creepy

 

 

New winged goats on the Cell space mural.

New winged goats on the Cell space mural.

 

 

from incoming :)

from incoming :)

Originally shared by Alejandro Fernandez-Lovo

We've lost enough already.... Don't take Bacon away!!!!

 

Couldn't agree more...

Couldn't agree more...

Originally shared by Brad Templeton

When I saw the news about Steve Jobs it was a shock. But the news that Dennis Ritchie has died was much more like a blow. I didn't know him super well, we attended Usenix together for many years, but he was mostly a quiet man, not the sort to seek the limelight.

Dennis was instrumental in two things -- the C language and Unix -- which are the foundation of almost all the computing in the world today. Certainly much of C came from its predecessors like B and BCPL, and many things in Unix from its predecessors like Multics, but these two focal points were where all of 60s and early 70s computer science came together, and spread out. Of course Linux and MacOS and Android are very direct descendants of Unix, but even Windows is filled with ideas from Unix.

Far more than Steve Jobs, pretty much all your computing is based on Dennis' work. Last week Google noted Jobs at the bottom of the home page, a very rare honour. But Dennis Ritchie would be even more deserving of it.

 

Infocom should be a good steward of the former Six Apart assets.

Infocom should be a good steward of the former Six Apart assets.

Though the weird part is when you go to Typepad the footer says:

Copyright © 2011, TypePad, Inc. All rights reserved.

Typepad, Inc?

Originally shared by Brad Fitzpatrick

http://techcrunch.com/2011/01/24/sayonara-six-apart-brand-and-six-apart-japan/

 

#musicmonday

Unun stuff is pretty rare to this day. I couldn't find anything from this era on youtube, but you can try out these track samples. Kung Fu Blue is quite fun, right Garth Webb?

 

Slashdot PT cruiser - license plate LINUXPT

Slashdot PT cruiser - license plate LINUXPT

 

 

Tommy lounging at the Butler & the Chef with Joel (the chef and 3rd favorite person).

Tommy lounging at the Butler & the Chef with Joel (the chef and 3rd favorite person). We used to have breakfast here every day when we lived in the neighborhood. It's nice to see South Park improving. The B&C plans to upgrade next door and http://www.public bikes.com has opened a showroom.

 

 

Check out this place if you find yourself in Pacific Heights. Great pastries and Four Barrel coffee.

Check out this place if you find yourself in Pacific Heights. Great pastries and Four Barrel coffee.

 

Thanks to Dave Aiello I now know that Movable Type is ten years old today.

Thanks to Dave Aiello I now know that Movable Type is ten years old today.

I'll always have a soft-spot for MT. I can still vividly remember Anil Dash copying MT binaries onto six USB thumb drives at a time when preparing for a big conference. Fun times!

And here's to Six Apart KK and the vibrant community that keeps MT (and Melody) going strong!

 

Am I the only one that finds it odd that Say Media fedex'd me a notice that Kevin Sladeck is selling 200k shares?

Am I the only one that finds it odd that Say Media fedex'd me a notice that Kevin Sladeck is selling 200k shares?

I was assuming my stock was only useful as a fond memory.

Oh and TIL that secondmarket.com has social networking features, who knew!

 

This one is for the Java programmers out there.

This one is for the Java programmers out there.

Originally shared by Kevin Bourrillion

At long last... Guava 10.0 has been released!

It's been a long wait since 9 (almost six months!), but I think you won't be disappointed; there's tons of new stuff in here. CacheBuilder/Cache, EventBus, Range and ContiguousSet, Optional, UnsignedLongs, MapJoiner and MapSplitter, the completion of Equivalence, many more new classes, dozens of new methods, and hundreds of smaller improvements scattered all over.

If this comes as good news to you, please join me in thanking the team:Charles Fry (release-master this time, took MANY bullets for us), Chris Povirk Kurt Alfred Kluever and our summer Deranged Intern Louis Wasserman. And as always, the number of other Googlers (and one non-Googler!) who contributed is too many to even list.

Please upgrade, and please help us spread the word!

Now back to work on 11.0 I go. :-)

 

Another funny strip from Manu. Be sure to follow him for lots more geeky humor!

Another funny strip from Manu. Be sure to follow him for lots more geeky humor!

Originally shared by Manu Cornet

http://www.bonkersworld.net/well-timed-book-release/ (This probably won’t make any sense for those not obsessively up to date with IT news.)

 

Interesting article about how Peets, the progenitor of Starbucks, is becoming more and more like them.

Interesting article about how Peets, the progenitor of Starbucks, is becoming more and more like them.

Luckily there's a plenty of alternatives brewing around here. Oakland's Blue Bottle Coffee is still tops for me. How about you? Have you seen places like Blue Bottle spring up in your area?

 

Ouch. hi5 folks let me know if I can help you find your next gig.

Ouch. hi5 folks let me know if I can help you find your next gig.

I think the real reason they're able to get by with less hardware is because they now have a ton less traffic and the new site runs on newer hardware.

I also note that it appears that they're still running on tomcat + netscalers for now:

curl -v http://www.hi5.com/friend/displayHomePage.do 2>&1|egrep 'Server:|NSC'

< Server: Apache-Coyote/1.1

< Set-Cookie: NSC_bqq-tfswfst-ofxvj=e246bb343660;expires=Tue, 20-Sep-11 10:20:46 GMT;path=/

 

Hi Qiwenm

Hi Qiwenm

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Add your other Accounts on the web to your profile:

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Hi Stephen!

Hi Stephen!

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Add your other Accounts on the web to your profile:

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Hi Sana!

Hi Sana!

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Add your other Accounts on the web to your profile:

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Hi Fahad!

Hi Fahad!

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Add your other accounts on the web to your profile:

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Thanks for adding me to a circle on Google+.

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Add links to any other Accounts you have on the web to your profile:

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Hi Rohama

Hi Rohama,

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Be sure to add your other Accounts on the web to your profile!

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Hi Ferjani

Hi Ferjani,

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Be sure to add your other accounts on the web to your profile!

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Hi Gourav

Hi Gourav,

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Be sure to add your other accounts on the web to your profile!

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

Hi Hande

Hi Hande,

Thanks for adding me to a circle on Google+. I work at Google on the Connected Sites team. We build tools that help your friends find you. There are a number of things you can do to help:

Be sure to add your other Accounts on the web to your profile!

1) Click on your profile https://plus.google.com/me

2) Click on "Edit Profile"

3) Click on "Other Profiles"

4) Add links!

If you have a Hotmail or Yahoo account don't forget to import your contacts here:

https://plus.google.com/circles/find

Also consider visiting the Connected Accounts settings page where you can connect your various accounts:

https://plus.google.com/settings/connectedaccounts

Thanks again for using Google+!

Paul

 

 

Blackwood Gin and Tonic. So delicious!

Blackwood Gin and Tonic. So delicious!

 

Thanks for adding me Sage -- be sure to link your accounts on your profile for better friend suggestions!

Thanks for adding me Sage -- be sure to link your accounts on your profile for better friend suggestions!

 

Thanks for adding me Stéphane. Be sure to link your accounts on your profile for better friend suggestions!

Thanks for adding me Stéphane. Be sure to link your accounts on your profile for better friend suggestions!

 

Here's the start of the Google+ APIs. Read-only People and Activities

Here's the start of the Google+ APIs. Read-only People and Activities

Opensocial folks shouldn't fret -- oauth2, json activity streams and poco all overlap nicely with the ongoing work for OpenSocial V2.

Originally shared by Chris Chabot

A journey of a thousand miles begins with a single step. Lao-tzu

I’m super excited about how the Google+ project brings the richness and nuance of real life sharing to software, and today we’re announcing our first step towards bringing this to your apps as well by launching the Google+ public data APIs.

These APIs allow you to retrieve the public profile information and public posts of the Google+ users, and they lay the foundation for us to build on together - Nothing great is ever built in a vacuum so I’m excited to start the conversation about what the Google+ platform should look like.

Please follow the link to the blog post to find out what exactly we’re launching and you can find the technical details on how to use this on our new developer site at http://developers.google.com/+

I’d also like to take a moment to introduce my team who will be joining me on working with our developer community (ie: you!) and answering any questions you may have about the Google+ platform on our discussion forums.

We’ll all also be doing a bunch of Hangouts over the next few days and beyond to talk to you directly and hear what you think of the +Platform as well as helping with any coding questions you may have, so make sure to add them to your Google+ developers circle!

Timothy Jordan

Jonathan Beri

Ade Oshineye

Will Norris

Jenny Murphy

Wolff Dobson

Now let's see lots of re-shares on this post & let's get this party started!

 

Nerds in Mountain View.

Nerds in Mountain View.

 

There's a hint of fall in the air.

There's a hint of fall in the air. The tomato harvest is in and Julie has started freezing sauce for the rainy days ahead....

 

My DynDNS secondary is up for renewal.

My DynDNS secondary is up for renewal. $40/year seems a bit steep just to do 3-4 zone transfers per year. Anyone have alternate recommendations?

 

Halloween displays are out early this year.

Halloween displays are out early this year.

 

The things you find in the incoming stream...

The things you find in the incoming stream...

[not resharing since the original was to a limited audience...]

 

Welcome to G+

Welcome to G+

Hope you have fun. Our mobile apps are top-notch :)

 

Heath Ceramics moving their tile creation and showroom to 20,000 square feet at 18th & Florida.

Heath Ceramics moving their tile creation and showroom to 20,000 square feet at 18th & Florida.

 

Reverse polarity -- fixed.

Reverse polarity -- fixed.

Using this handy testing tool I found eight outlets with reversed polarity this weekend. Fixing it was fairly straightforward -- cut the power and rewire the outlets so the hot and and neutral wires are connected properly.

If you live in an older house I'd highly recommend getting one of these since reversed polarity can harm sensitive electronics and creates a shock hazard.

 

Tomato season is going slow this year.

Tomato season is going slow this year. Only two varieties are available at the Verdure farm stand this week, lots more coming in next week.

 

Another foggy Saturday.

Another foggy Saturday.

 

OpenSocial is heading to SXSW, but only if you vote for these panels!

OpenSocial is heading to SXSW, but only if you vote for these panels!

Distributed Web Frameworks: The Future of Social

Link: http://panelpicker.sxsw.com/ideas/view/10692

Revolution! Open Apps Will Change the Enterprise

Link: http://panelpicker.sxsw.com/ideas/view/12817

Building Social Apps for Business Using Opensocial

Link: http://panelpicker.sxsw.com/ideas/view/12187

 

Guy Kawasaki's post on historical Apple logos brought to mind Beagle Brothers.

Guy Kawasaki's post on historical Apple logos brought to mind Beagle Brothers. Imagine a software company with Trader Joe's marketing -- all captured for posterity here:

http://stevenf.com/beagle/

 

Just got an email that Plaxo is discontinuing bare OpenId support and only allowing Google/Yahoo/Hotmail/Facebook...

Just got an email that Plaxo is discontinuing bare OpenId support and only allowing Google/Yahoo/Hotmail/Facebook for login. Despite OpenId's shortcomings it's sad to see things regress.

-----------------------------

Hello from Plaxo,

In an effort to improve our login experience for users, Plaxo.com is simplifying and standardizing our sign in options. As such, Plaxo will discontinue support of generic OpenID logins as of 08/23/2011. Instead we're offering login via Google, Yahoo, Hotmail, or Facebook oAuth -- or you can, of course, create a Plaxo specific account.

How will this affect me?

If you use a Google, Yahoo, Hotmail or Facebook openid to login, just click the appropriate button when signing in. Plaxo will ask for permission to use your account credentials; click accept/grant and then go on using Plaxo as you normally would.

If you use any other openid to login, please visit our Forgot Password and follow the instructions for Reset Password, which will create you a Plaxo specific password.

 

Don't forget Doctor Who this weekend.

Don't forget Doctor Who this weekend. I'll be buying it off Amazon and watching on the Google TV instead of suffering through Comcast's SD and BBC America's commercial interruptions...