Scala for Sling @ Jazzon 09

26 06 2009

Yesterday I gave a presentation at Jazoon 09 about using Scala for scripting RESTful web applications with Apache Sling.

In the session I showed how to take advantage of Scala to create RESTful web applications with Apache Sling. I demonstrated how to uses its DSL capability and support for XML literals to create type safe web site templates. In contrast to conventional web site template mechanisms (e.g. JSP), this does not rely on a pre-processor but rather uses pure Scala code.

There are Session slides and support material available here. The support material contains a fully workable demo application. A Scala scripting bundle for Sling is also included.

Advertisements




Puzzle: implement this

19 06 2009

This is something I stumbled on recently when trying to implement javax.jcr.NodeIterator in Scala.

Assume you are using a library which exports an Iterator2 interface:

public interface Iterator2 extends java.util.Iterator {}

Note that Iterator is a raw type and Iterator2 does not take any type parameters. So how would you implement Iterator2 in Scala?

Here is a start:

class MyIterator extends Iterator2 {
  def hasNext = false
  def remove = throw new Error
  def next: Nothing = throw new Error
}

But if the next method should return an actual value, what would be it’s return type? It turn’s out that any other type than Nothing results in a compiler error:

error overriding method next in trait Iterator of type ()E;
method next has incompatible type ()Any

So how would you implement Iterator2?





adding nodes in ASCII art – part 2

31 01 2008

I wrote a follow up on my article JCR with Scala: adding nodes in ASCII art over at my employers blog.

I discuss the goals I had in mind when designing the ‘ASCII art’ operators. This helps in understanding how these operators actually work and serve as preparation for a later post where I will show how properties fit into the picture.





Adding nodes in ASCII art (update)

23 01 2008

I just fixed the Treebuilder code from my previous article. It seems that this stupid editor keeps eating random lines from <pre> formated sections.





JCR with Scala: adding nodes in ASCII art

23 01 2008

I just wrote another blog on using JCR with Scala over at dev.day.com. This time I show how to define a new operator that lets you define a JCR tree structure in Scala code in such a way that the code will look like ASCII art.





JCR with Scala

16 01 2008

I recently got interested in Scala. Since my current work is related to JCR I decided to give it a try with Scala. See my post on my employers blog for a first impression.

I will blog here once in a while about my work with JCR and Scala.