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
| package controllers | |
| import play.api.mvc._ | |
| import org.ancelin.play2.couchbase.plugins.CouchbaseN1QLPlugin._ | |
| import play.api.libs.json.Json | |
| import play.api.libs.concurrent.Execution.Implicits._ | |
| import play.api.libs.iteratee.{Enumerator, Enumeratee} | |
| case class Person(fname: String, age: Int) |
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 Streams extends Controller { | |
| def stream = Action { | |
| val operations: Enumerator[JsValue] = Enumerator.generateM[JsValue] { | |
| Promise.timeout( | |
| Some( Json.obj( | |
| "id" -> UUID.randomUUID().toString(), | |
| "amount" -> Random.nextInt(1000), | |
| "access" -> if (Random.nextBoolean) "public" else "private" | |
| ) ), |
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
| case class Operation(id: String, amount: Int, access: String) | |
| object Application extends Controller { | |
| val format = Json.format[Operation] | |
| def userFeed(role: String, lower: Int, high: Int) = Action { | |
| val enumerator: Enumerator[Array[Byte]] = WS.url("http://host:port/stream").withTimeout(-1).getStream |
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
| package controllers | |
| import play.api.mvc.{Action, Controller} | |
| import play.api.libs.iteratee.{Concurrent, Enumeratee} | |
| import play.api.libs.json.{Json, JsValue} | |
| import play.api.libs.EventSource | |
| import play.api.libs.ws.WSEnumerator | |
| import models._ | |
| import play.api.libs.concurrent.Execution.Implicits._ |
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
| package play.api.libs.ws | |
| import play.api.libs.iteratee.{Enumeratee, Concurrent, Enumerator} | |
| import play.api.libs.concurrent.Execution.Implicits._ | |
| import com.ning.http.client._ | |
| import com.ning.http.client.AsyncHandler.STATE | |
| import play.api.Logger | |
| import scala.concurrent.{Future, Promise} |
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 static reactor.Fn.$; | |
| @Inject | |
| Service service; | |
| Reactor reactor = R.create(); | |
| reactor.on($("parse"), new Consumer<Event<String>>() { | |
| public void call(Event<String> ev) { | |
| service.handleEvent(ev); |
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 sbt._ | |
| import Keys._ | |
| import play.Project._ | |
| object ApplicationBuild extends Build { | |
| val appName = "test" | |
| val appVersion = "1.0-SNAPSHOT" | |
| val appDependencies = Seq( |
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
| package controllers | |
| import collection.JavaConversions._ | |
| import collection.mutable.ArrayBuffer | |
| import java.net._ | |
| import com.couchbase.client.CouchbaseClient | |
| import play.api.mvc._ | |
| import play.api._ |
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
| public void lookup() { | |
| while (Thread.currentThread() == m_logTestThread) { | |
| ServiceReference logServiceRef = | |
| m_context.getServiceReference(LogService.class.getName()); | |
| if (logServiceRef != null) { | |
| try { | |
| LogService logService = | |
| (LogService) m_context.getService(logServiceRef); | |
| if (logService != null) { | |
| logService.log(LogService.LOG_INFO, "ping"); |
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 org.junit.Assert; | |
| import java.lang.ref.WeakReference; | |
| public class MemoryLeakChecker<T> { | |
| private static final int MAXGC = 50; | |
| private final WeakReference<T> reference; | |
| private final int calls; |