This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ReturnAs[A, B] { | |
def as(a:A):B | |
} | |
object ReturnAs{ | |
implicit def f2ReturnAs[A, B](f:A => B):ReturnAs[A, B] = | |
new ReturnAs[A, B]{ | |
def as(a:A) = f(a) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait BookshopService { | |
def list[R : Return[List[Book]]#As]:R = | |
Return(Bookshop.stock) | |
def listByPublisher[R : Return[List[Book]]#As](publisher:String):R = | |
Return(Bookshop.stock.filter(_.publisher equalsIgnoreCase publisher)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Book { | |
implicit val booksAsXml: Return[List[Book]]#As[XmlResponse] = | |
(books:List[Book]) => | |
XmlResponse( | |
<books>{books.flatMap{b => | |
<book publisher={b.publisher} title={b.title}/>}} | |
</books>) | |
implicit val booksAsPlainText: ReturnAs[List[Book], PlainTextResponse] = | |
(books:List[Book]) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object BookshopHttpService extends BookshopService with RestHelper { | |
serve { | |
// xml services | |
case "bookshop" :: "books" :: Nil XmlGet _ => list[XmlResponse] | |
case "bookshop" :: "books" :: publisher :: Nil XmlGet _ => listByPublisher[XmlResponse](publisher) | |
// plain text services | |
case "bookshop" :: "books" :: Nil Get _ => list[PlainTextResponse] | |
case "bookshop" :: "books" :: publisher :: Nil Get _ => listByPublisher[PlainTextResponse](publisher) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app | |
xmlns="http://java.sun.com/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
version="2.5" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> | |
<filter> | |
<filter-name>hazel-filter</filter-name> | |
<filter-class>com.hazelcast.web.WebFilter</filter-class> | |
<init-param> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Message: java.lang.RuntimeException: java.io.NotSerializableException: java.lang.Object | |
com.terracotta.session.SerializedAttributeStore$SerializedAttribute.<init>(SerializedAttributeStore.java:98) | |
com.terracotta.session.SerializedAttributeStore$SerializedAttributeWithCache.<init>(SerializedAttributeStore.java:141) | |
com.terracotta.session.SerializedAttributeStore.put(SerializedAttributeStore.java:60) | |
com.terracotta.session.SessionData.bindAttribute(SessionData.java:414) | |
com.terracotta.session.SessionData.__tc_wrapped_setAttributeReturnOld(SessionData.java:306) | |
com.terracotta.session.SessionData.setAttributeReturnOld(SessionData.java) | |
com.terracotta.session.SessionData.setAttribute(SessionData.java:298) | |
net.liftweb.http.provider.servlet.HTTPServletSession.setAttribute(HTTPServletSession.scala:41) | |
net.liftweb.http.ContainerVar$$anonfun$net$liftweb$http$ContainerVar$$localSet$1.apply(Vars.scala:182) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def doSync[F](f: => F): F = S.session match { | |
case Full(s) => { | |
// lock the session while the Var-specific lock object is found/created | |
val lockName = name + VarConstants.lockSuffix | |
val lockObj: Object = s.synchronized { | |
localGet(s, lockName) match { | |
case Full(lock: Object) => lock | |
case _ => val lock = new Object | |
localSet(s, lockName, null) | |
lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_SCRIPT_PATH="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")" | |
_SCRIPT_DIR=`dirname "${_SCRIPT_PATH}"}` | |
_EXTRADOC_HOME=${_SCRIPT_DIR}/.. | |
export TOOL_CLASSPATH="${_EXTRADOC_HOME}/target/scala_2.8.0/classes:${_EXTRADOC_HOME}/src/main/resources" | |
export JAVA_OPTS="-Xms512M -Xmx2048M -Xss1M -XX:MaxPermSize=128M" | |
scala -classpath ${TOOL_CLASSPATH} com.novocode.extradoc.ExtraDoc "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Locale | |
import net.liftweb.common.Box | |
import net.liftweb.util.Helpers.{tryo,randomString} | |
import net.liftweb.http.provider.HTTPRequest | |
import net.liftweb.http.{LiftRules,RequestMemoize} | |
object localeMemo extends RequestMemoize[Int, Locale] { | |
override protected def __nameSalt = randomString(20) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.ListBuffer | |
import akka.actor.{Actor,ActorRef} | |
import akka.actor.Actor._ | |
import akka.routing.{ Listeners, Listen } | |
//Represents a domain event | |
trait Event | |
//A builder to create domain entities | |
trait EntityBuilder[Entity] { |