Working nine to five ...

This commit is contained in:
Viktor Klang 2010-02-20 23:56:25 +01:00
parent 682d944915
commit 05ac9d4bf5
23 changed files with 73 additions and 63 deletions

View file

@ -13,8 +13,7 @@ import se.scalablesolutions.akka.config.ScalaConfig._
import se.scalablesolutions.akka.util.{HashCode, Logging} import se.scalablesolutions.akka.util.{HashCode, Logging}
import scala.collection.mutable.HashMap import scala.collection.mutable.HashMap
import scala.collection.JavaConversions._
import org.scala_tools.javautils.Imports._
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.{Timer, TimerTask} import java.util.{Timer, TimerTask}
@ -411,7 +410,7 @@ object AMQP {
protected def setupChannel = { protected def setupChannel = {
connection = connectionFactory.newConnection(hostname, port) connection = connectionFactory.newConnection(hostname, port)
channel = connection.createChannel channel = connection.createChannel
channel.exchangeDeclare(exchangeName.toString, exchangeType.toString, passive, durable, autoDelete, configurationArguments.asJava) channel.exchangeDeclare(exchangeName.toString, exchangeType.toString, passive, durable, autoDelete, configurationArguments)
listeners.elements.toList.map(_._2).foreach(registerListener) listeners.elements.toList.map(_._2).foreach(registerListener)
if (shutdownListener.isDefined) connection.addShutdownListener(shutdownListener.get) if (shutdownListener.isDefined) connection.addShutdownListener(shutdownListener.get)
} }
@ -426,7 +425,7 @@ object AMQP {
listener.queueName, listener.queueName,
passive, durable, passive, durable,
listener.exclusive, listener.autoDelete, listener.exclusive, listener.autoDelete,
configurationArguments.asJava) configurationArguments)
} }
log.debug("Binding new queue for MessageConsumerListener [%s]", listener.queueName) log.debug("Binding new queue for MessageConsumerListener [%s]", listener.queueName)

View file

@ -8,7 +8,7 @@ import org.jgroups.{JChannel, View => JG_VIEW, Address, Message => JG_MSG, Exten
*/ */
class JGroupsClusterActor extends BasicClusterActor { class JGroupsClusterActor extends BasicClusterActor {
import ClusterActor._ import ClusterActor._
import org.scala_tools.javautils.Imports._ import scala.collection.JavaConversions._
type ADDR_T = Address type ADDR_T = Address
@ -32,7 +32,7 @@ class JGroupsClusterActor extends BasicClusterActor {
if (isActive && m.getSrc != channel.map(_.getAddress).getOrElse(m.getSrc)) me send Message(m.getSrc,m.getRawBuffer) if (isActive && m.getSrc != channel.map(_.getAddress).getOrElse(m.getSrc)) me send Message(m.getSrc,m.getRawBuffer)
def viewAccepted(view: JG_VIEW): Unit = def viewAccepted(view: JG_VIEW): Unit =
if (isActive) me send View(Set[ADDR_T]() ++ view.getMembers.asScala - channel.get.getAddress) if (isActive) me send View(Set[ADDR_T]() ++ view.getMembers - channel.get.getAddress)
def suspect(a: Address): Unit = def suspect(a: Address): Unit =
if (isActive) me send Zombie(a) if (isActive) me send Zombie(a)

View file

@ -84,7 +84,7 @@ class ShoalClusterActor extends BasicClusterActor {
* Creates a CallBack instance that deals with the cluster signalling * Creates a CallBack instance that deals with the cluster signalling
*/ */
protected def createCallback : CallBack = { protected def createCallback : CallBack = {
import org.scala_tools.javautils.Imports._ import scala.collection.JavaConversions._
val me = this val me = this
new CallBack { new CallBack {
def processNotification(signal : Signal) { def processNotification(signal : Signal) {
@ -93,7 +93,7 @@ class ShoalClusterActor extends BasicClusterActor {
if(isActive) { if(isActive) {
signal match { signal match {
case ms : MessageSignal => me send Message(ms.getMemberToken,ms.getMessage) case ms : MessageSignal => me send Message(ms.getMemberToken,ms.getMessage)
case jns : JoinNotificationSignal => me send View(Set[ADDR_T]() ++ jns.getCurrentCoreMembers.asScala - serverName) case jns : JoinNotificationSignal => me send View(Set[ADDR_T]() ++ jns.getCurrentCoreMembers - serverName)
case fss : FailureSuspectedSignal => me send Zombie(fss.getMemberToken) case fss : FailureSuspectedSignal => me send Zombie(fss.getMemberToken)
case fns : FailureNotificationSignal => me send Zombie(fns.getMemberToken) case fns : FailureNotificationSignal => me send Zombie(fns.getMemberToken)
case _ => log.debug("Unhandled signal: [%s]",signal) case _ => log.debug("Unhandled signal: [%s]",signal)

View file

@ -59,12 +59,12 @@ class AkkaServlet extends org.atmosphere.cpr.AtmosphereServlet with Logging {
* we need to handle that. * we need to handle that.
*/ */
override def createCometSupportResolver() : CometSupportResolver = { override def createCometSupportResolver() : CometSupportResolver = {
import org.scala_tools.javautils.Imports._ import scala.collection.JavaConversions._
new DefaultCometSupportResolver(config) { new DefaultCometSupportResolver(config) {
type CS = CometSupport[_ <: AtmosphereResource[_,_]] type CS = CometSupport[_ <: AtmosphereResource[_,_]]
override def resolveMultipleNativeSupportConflict(available : JList[Class[_ <: CS]]) : CS = { override def resolveMultipleNativeSupportConflict(available : JList[Class[_ <: CS]]) : CS = {
available.asScala.filter(_ != classOf[GrizzlyCometSupport]).toList match { available.filter(_ != classOf[GrizzlyCometSupport]).toList match {
case Nil => new GrizzlyCometSupport(config) case Nil => new GrizzlyCometSupport(config)
case x :: Nil => newCometSupport(x.asInstanceOf[Class[_ <: CS]]) case x :: Nil => newCometSupport(x.asInstanceOf[Class[_ <: CS]])
case _ => super.resolveMultipleNativeSupportConflict(available) case _ => super.resolveMultipleNativeSupportConflict(available)

View file

@ -46,11 +46,6 @@
<artifactId>netty</artifactId> <artifactId>netty</artifactId>
<version>3.2.0.ALPHA3</version> <version>3.2.0.ALPHA3</version>
</dependency> </dependency>
<dependency>
<groupId>org.scala-tools</groupId>
<artifactId>javautils</artifactId>
<version>2.7.4-0.1</version>
</dependency>
<!-- For Protocol/Serialization --> <!-- For Protocol/Serialization -->
<dependency> <dependency>
@ -68,11 +63,11 @@
<artifactId>jackson-mapper-asl</artifactId> <artifactId>jackson-mapper-asl</artifactId>
<version>1.2.1</version> <version>1.2.1</version>
</dependency> </dependency>
<dependency> <!--DOESN'T EXIST AS 2.8 port yet dependency>
<groupId>sbinary</groupId> <groupId>sbinary</groupId>
<artifactId>sbinary</artifactId> <artifactId>sbinary</artifactId>
<version>0.3</version> <version>0.3</version>
</dependency> </dependency-->
<dependency> <dependency>
<groupId>net.databinder</groupId> <groupId>net.databinder</groupId>
<artifactId>dispatch-json_2.8.0.Beta1</artifactId> <artifactId>dispatch-json_2.8.0.Beta1</artifactId>
@ -91,7 +86,7 @@
<dependency> <dependency>
<groupId>sjson.json</groupId> <groupId>sjson.json</groupId>
<artifactId>sjson</artifactId> <artifactId>sjson</artifactId>
<version>0.4</version> <version>0.5-SNAPSHOT-2.8.Beta1</version>
</dependency> </dependency>
<!-- For Testing --> <!-- For Testing -->

View file

@ -260,9 +260,10 @@ private[akka] sealed class ActiveObjectAspect {
} }
private def localDispatch(joinPoint: JoinPoint): AnyRef = { private def localDispatch(joinPoint: JoinPoint): AnyRef = {
import Actor.Sender.Self
val rtti = joinPoint.getRtti.asInstanceOf[MethodRtti] val rtti = joinPoint.getRtti.asInstanceOf[MethodRtti]
if (isOneWay(rtti)) actor ! Invocation(joinPoint, true, true) if (isOneWay(rtti)) {
(actor ! Invocation(joinPoint, true, true) ).asInstanceOf[AnyRef]
}
else { else {
val result = actor !! Invocation(joinPoint, false, isVoid(rtti)) val result = actor !! Invocation(joinPoint, false, isVoid(rtti))
if (result.isDefined) result.get if (result.isDefined) result.get
@ -357,7 +358,7 @@ private[akka] sealed class ActiveObjectAspect {
*/ */
private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Option[RestartCallbacks]) extends Actor { private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Option[RestartCallbacks]) extends Actor {
private val ZERO_ITEM_CLASS_ARRAY = Array[Class[_]]() private val ZERO_ITEM_CLASS_ARRAY = Array[Class[_]]()
private val ZERO_ITEM_OBJECT_ARRAY = Array[Object[_]]() private val ZERO_ITEM_OBJECT_ARRAY = Array[Object]()
private[actor] var target: Option[AnyRef] = None private[actor] var target: Option[AnyRef] = None
private var preRestart: Option[Method] = None private var preRestart: Option[Method] = None

View file

@ -73,7 +73,7 @@ object Actor extends Logging {
val PORT = config.getInt("akka.remote.server.port", 9999) val PORT = config.getInt("akka.remote.server.port", 9999)
object Sender{ object Sender{
implicit val Self: Option[Actor] = None object Self
} }
/** /**
@ -474,7 +474,7 @@ trait Actor extends TransactionManagement {
* actor.send(message) * actor.send(message)
* </pre> * </pre>
*/ */
def !(message: Any)(implicit sender: Option[Actor]) = { def !(message: Any)(implicit sender: Option[Actor] = None) = {
//FIXME 2.8 def !(message: Any)(implicit sender: Option[Actor] = None) = { //FIXME 2.8 def !(message: Any)(implicit sender: Option[Actor] = None) = {
if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages") if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages")
if (_isRunning) postMessageToMailbox(message, sender) if (_isRunning) postMessageToMailbox(message, sender)
@ -539,8 +539,7 @@ trait Actor extends TransactionManagement {
/* /*
//FIXME 2.8 def !!!(message: Any)(implicit sender: AnyRef = None): FutureResult = { def !!!(message: Any)(implicit sender: Option[Actor] = None): FutureResult = {
def !!!(message: Any)(implicit sender: AnyRef): FutureResult = {
if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages") if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages")
if (_isRunning) { if (_isRunning) {
val from = if (sender != null && sender.isInstanceOf[Actor]) Some(sender.asInstanceOf[Actor]) val from = if (sender != null && sender.isInstanceOf[Actor]) Some(sender.asInstanceOf[Actor])
@ -562,7 +561,7 @@ trait Actor extends TransactionManagement {
* <p/> * <p/>
* Works with both '!' and '!!'. * Works with both '!' and '!!'.
*/ */
def forward(message: Any)(implicit sender: Option[Actor]) = { def forward(message: Any)(implicit sender: Option[Actor] = None) = {
if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages") if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages")
if (_isRunning) { if (_isRunning) {
val forwarder = sender.getOrElse(throw new IllegalStateException("Can't forward message when the forwarder/mediator is not an actor")) val forwarder = sender.getOrElse(throw new IllegalStateException("Can't forward message when the forwarder/mediator is not an actor"))
@ -1027,7 +1026,8 @@ trait Actor extends TransactionManagement {
!message.isInstanceOf[List[_]] && !message.isInstanceOf[List[_]] &&
!message.isInstanceOf[scala.collection.immutable.Map[_, _]] && !message.isInstanceOf[scala.collection.immutable.Map[_, _]] &&
!message.isInstanceOf[scala.collection.immutable.Set[_]] && !message.isInstanceOf[scala.collection.immutable.Set[_]] &&
!message.isInstanceOf[scala.collection.immutable.Tree[_, _]] && //Removed in Scala 2.8
//!message.isInstanceOf[scala.collection.immutable.Tree[_, _]] &&
!message.getClass.isAnnotationPresent(Annotations.immutable)) { !message.getClass.isAnnotationPresent(Annotations.immutable)) {
Serializer.Java.deepClone(message) Serializer.Java.deepClone(message)
} else message } else message

View file

@ -19,8 +19,6 @@ import se.scalablesolutions.akka.config.ScalaConfig._
import se.scalablesolutions.akka.config.{AllForOneStrategy, OneForOneStrategy, FaultHandlingStrategy} import se.scalablesolutions.akka.config.{AllForOneStrategy, OneForOneStrategy, FaultHandlingStrategy}
import se.scalablesolutions.akka.util.{Logging} import se.scalablesolutions.akka.util.{Logging}
import org.scala_tools.javautils.Imports._
case object UnSchedule case object UnSchedule
case class SchedulerException(msg: String, e: Throwable) extends RuntimeException(msg, e) case class SchedulerException(msg: String, e: Throwable) extends RuntimeException(msg, e)
@ -66,7 +64,8 @@ object Scheduler extends Actor {
} }
override def shutdown = { override def shutdown = {
schedulers.values.asScala.foreach(_ ! UnSchedule) import scala.collection.JavaConversions._
schedulers.values.foreach(_ ! UnSchedule)
service.shutdown service.shutdown
} }

View file

@ -6,7 +6,7 @@ package se.scalablesolutions.akka.config
import scala.collection.mutable.HashSet import scala.collection.mutable.HashSet
import util.Logging import se.scalablesolutions.akka.util.Logging
object ConfiguratorRepository extends Logging { object ConfiguratorRepository extends Logging {

View file

@ -133,7 +133,7 @@ abstract class BasicClusterActor extends ClusterActor {
case RegisterLocalNode(s) => { case RegisterLocalNode(s) => {
log debug ("RegisterLocalNode: %s", s) log debug ("RegisterLocalNode: %s", s)
local = Node(local.endpoints + s) local = Node(s :: local.endpoints)
broadcast(Papers(local.endpoints)) broadcast(Papers(local.endpoints))
} }

View file

@ -267,7 +267,7 @@ class RemoteClientPipelineFactory(name: String,
/** /**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/ */
@ChannelPipelineCoverage {val value = "all"} @ChannelPipelineCoverage(value = "all")
class RemoteClientHandler(val name: String, class RemoteClientHandler(val name: String,
val futures: ConcurrentMap[Long, CompletableFutureResult], val futures: ConcurrentMap[Long, CompletableFutureResult],
val supervisors: ConcurrentMap[String, Actor], val supervisors: ConcurrentMap[String, Actor],

View file

@ -4,7 +4,7 @@
package se.scalablesolutions.akka.remote package se.scalablesolutions.akka.remote
import se.scalablesolutions.akka.serialization.Serializable.SBinary //import se.scalablesolutions.akka.serialization.Serializable.SBinary
import se.scalablesolutions.akka.serialization.{Serializer, Serializable, SerializationProtocol} import se.scalablesolutions.akka.serialization.{Serializer, Serializable, SerializationProtocol}
import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.{RemoteRequest, RemoteReply} import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.{RemoteRequest, RemoteReply}
@ -14,7 +14,7 @@ object RemoteProtocolBuilder {
private var SERIALIZER_JAVA: Serializer.Java = Serializer.Java private var SERIALIZER_JAVA: Serializer.Java = Serializer.Java
private var SERIALIZER_JAVA_JSON: Serializer.JavaJSON = Serializer.JavaJSON private var SERIALIZER_JAVA_JSON: Serializer.JavaJSON = Serializer.JavaJSON
private var SERIALIZER_SCALA_JSON: Serializer.ScalaJSON = Serializer.ScalaJSON private var SERIALIZER_SCALA_JSON: Serializer.ScalaJSON = Serializer.ScalaJSON
private var SERIALIZER_SBINARY: Serializer.SBinary = Serializer.SBinary //private var SERIALIZER_SBINARY: Serializer.SBinary = Serializer.SBinary
private var SERIALIZER_PROTOBUF: Serializer.Protobuf = Serializer.Protobuf private var SERIALIZER_PROTOBUF: Serializer.Protobuf = Serializer.Protobuf
@ -29,9 +29,9 @@ object RemoteProtocolBuilder {
def getMessage(request: RemoteRequest): Any = { def getMessage(request: RemoteRequest): Any = {
request.getProtocol match { request.getProtocol match {
case SerializationProtocol.SBINARY => //case SerializationProtocol.SBINARY =>
val renderer = Class.forName(new String(request.getMessageManifest.toByteArray)).newInstance.asInstanceOf[SBinary[_ <: AnyRef]] // val renderer = Class.forName(new String(request.getMessageManifest.toByteArray)).newInstance.asInstanceOf[SBinary[_ <: AnyRef]]
renderer.fromBytes(request.getMessage.toByteArray) // renderer.fromBytes(request.getMessage.toByteArray)
case SerializationProtocol.SCALA_JSON => case SerializationProtocol.SCALA_JSON =>
val manifest = SERIALIZER_JAVA.in(request.getMessageManifest.toByteArray, None).asInstanceOf[String] val manifest = SERIALIZER_JAVA.in(request.getMessageManifest.toByteArray, None).asInstanceOf[String]
SERIALIZER_SCALA_JSON.in(request.getMessage.toByteArray, Some(Class.forName(manifest))) SERIALIZER_SCALA_JSON.in(request.getMessage.toByteArray, Some(Class.forName(manifest)))
@ -50,9 +50,9 @@ object RemoteProtocolBuilder {
def getMessage(reply: RemoteReply): Any = { def getMessage(reply: RemoteReply): Any = {
reply.getProtocol match { reply.getProtocol match {
case SerializationProtocol.SBINARY => //case SerializationProtocol.SBINARY =>
val renderer = Class.forName(new String(reply.getMessageManifest.toByteArray)).newInstance.asInstanceOf[SBinary[_ <: AnyRef]] // val renderer = Class.forName(new String(reply.getMessageManifest.toByteArray)).newInstance.asInstanceOf[SBinary[_ <: AnyRef]]
renderer.fromBytes(reply.getMessage.toByteArray) // renderer.fromBytes(reply.getMessage.toByteArray)
case SerializationProtocol.SCALA_JSON => case SerializationProtocol.SCALA_JSON =>
val manifest = SERIALIZER_JAVA.in(reply.getMessageManifest.toByteArray, None).asInstanceOf[String] val manifest = SERIALIZER_JAVA.in(reply.getMessageManifest.toByteArray, None).asInstanceOf[String]
SERIALIZER_SCALA_JSON.in(reply.getMessage.toByteArray, Some(Class.forName(manifest))) SERIALIZER_SCALA_JSON.in(reply.getMessage.toByteArray, Some(Class.forName(manifest)))
@ -70,12 +70,12 @@ object RemoteProtocolBuilder {
} }
def setMessage(message: Any, builder: RemoteRequest.Builder) = { def setMessage(message: Any, builder: RemoteRequest.Builder) = {
if (message.isInstanceOf[Serializable.SBinary[_]]) { /*if (message.isInstanceOf[Serializable.SBinary[_]]) {
val serializable = message.asInstanceOf[Serializable.SBinary[_ <: Any]] val serializable = message.asInstanceOf[Serializable.SBinary[_ <: Any]]
builder.setProtocol(SerializationProtocol.SBINARY) builder.setProtocol(SerializationProtocol.SBINARY)
builder.setMessage(ByteString.copyFrom(serializable.toBytes)) builder.setMessage(ByteString.copyFrom(serializable.toBytes))
builder.setMessageManifest(ByteString.copyFrom(serializable.getClass.getName.getBytes)) builder.setMessageManifest(ByteString.copyFrom(serializable.getClass.getName.getBytes))
} else if (message.isInstanceOf[Message]) { } else*/ if (message.isInstanceOf[Message]) {
val serializable = message.asInstanceOf[Message] val serializable = message.asInstanceOf[Message]
builder.setProtocol(SerializationProtocol.PROTOBUF) builder.setProtocol(SerializationProtocol.PROTOBUF)
builder.setMessage(ByteString.copyFrom(serializable.toByteArray)) builder.setMessage(ByteString.copyFrom(serializable.toByteArray))
@ -98,12 +98,12 @@ object RemoteProtocolBuilder {
} }
def setMessage(message: Any, builder: RemoteReply.Builder) = { def setMessage(message: Any, builder: RemoteReply.Builder) = {
if (message.isInstanceOf[Serializable.SBinary[_]]) { /*if (message.isInstanceOf[Serializable.SBinary[_]]) {
val serializable = message.asInstanceOf[Serializable.SBinary[_ <: Any]] val serializable = message.asInstanceOf[Serializable.SBinary[_ <: Any]]
builder.setProtocol(SerializationProtocol.SBINARY) builder.setProtocol(SerializationProtocol.SBINARY)
builder.setMessage(ByteString.copyFrom(serializable.toBytes)) builder.setMessage(ByteString.copyFrom(serializable.toBytes))
builder.setMessageManifest(ByteString.copyFrom(serializable.getClass.getName.getBytes)) builder.setMessageManifest(ByteString.copyFrom(serializable.getClass.getName.getBytes))
} else if (message.isInstanceOf[Message]) { } else*/ if (message.isInstanceOf[Message]) {
val serializable = message.asInstanceOf[Message] val serializable = message.asInstanceOf[Message]
builder.setProtocol(SerializationProtocol.PROTOBUF) builder.setProtocol(SerializationProtocol.PROTOBUF)
builder.setMessage(ByteString.copyFrom(serializable.toByteArray)) builder.setMessage(ByteString.copyFrom(serializable.toByteArray))

View file

@ -244,7 +244,7 @@ class RemoteServerPipelineFactory(
/** /**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/ */
@ChannelPipelineCoverage {val value = "all"} @ChannelPipelineCoverage(value = "all")
class RemoteServerHandler( class RemoteServerHandler(
val name: String, val name: String,
val openChannels: ChannelGroup, val openChannels: ChannelGroup,

View file

@ -1,7 +1,7 @@
/** /**
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se> * Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
*/ */
/*
package se.scalablesolutions.akka.serialization package se.scalablesolutions.akka.serialization
// --- PRIMITIVES --- // --- PRIMITIVES ---
@ -373,3 +373,4 @@ case class BinaryStringByteArrayMap(val value: Map[String, Array[Byte]]) extends
def fromBytes(bytes: Array[Byte]) = BinaryStringByteArrayMap(fromByteArray[Map[String, Array[Byte]]](bytes)) def fromBytes(bytes: Array[Byte]) = BinaryStringByteArrayMap(fromByteArray[Map[String, Array[Byte]]](bytes))
def toBytes: Array[Byte] = toByteArray(value) def toBytes: Array[Byte] = toByteArray(value)
} }
*/

View file

@ -7,12 +7,12 @@ package se.scalablesolutions.akka.serialization
import org.codehaus.jackson.map.ObjectMapper import org.codehaus.jackson.map.ObjectMapper
import com.google.protobuf.Message import com.google.protobuf.Message
import reflect.Manifest import reflect.Manifest
import sbinary.DefaultProtocol //import sbinary.DefaultProtocol
import java.io.{StringWriter, ByteArrayOutputStream, ObjectOutputStream} import java.io.{StringWriter, ByteArrayOutputStream, ObjectOutputStream}
import sjson.json.{Serializer=>SJSONSerializer} import sjson.json.{Serializer=>SJSONSerializer}
object SerializationProtocol { object SerializationProtocol {
val SBINARY = 1 //val SBINARY = 1
val SCALA_JSON = 2 val SCALA_JSON = 2
val JAVA_JSON = 3 val JAVA_JSON = 3
val PROTOBUF = 4 val PROTOBUF = 4
@ -60,10 +60,10 @@ object Serializable {
* </pre> * </pre>
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/ */
trait SBinary[T <: AnyRef] extends Serializable { /*trait SBinary[T <: AnyRef] extends Serializable {
def fromBytes(bytes: Array[Byte]): T def fromBytes(bytes: Array[Byte]): T
def toBytes: Array[Byte] def toBytes: Array[Byte]
} } */
/** /**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>

View file

@ -29,7 +29,7 @@ class SerializerFactory {
def getJava: Java.type = Java def getJava: Java.type = Java
def getJavaJSON: JavaJSON.type = JavaJSON def getJavaJSON: JavaJSON.type = JavaJSON
def getScalaJSON: ScalaJSON.type = ScalaJSON def getScalaJSON: ScalaJSON.type = ScalaJSON
def getSBinary: SBinary.type = SBinary //def getSBinary: SBinary.type = SBinary
def getProtobuf: Protobuf.type = Protobuf def getProtobuf: Protobuf.type = Protobuf
} }
@ -165,7 +165,7 @@ object Serializer {
/** /**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/ */
object SBinary extends SBinary /*object SBinary extends SBinary
class SBinary { class SBinary {
import sbinary.DefaultProtocol._ import sbinary.DefaultProtocol._
@ -176,6 +176,6 @@ object Serializer {
def in[T](array : Array[Byte], clazz: Option[Class[T]])(implicit bin : Reads[T]): T = fromByteArray[T](array) def in[T](array : Array[Byte], clazz: Option[Class[T]])(implicit bin : Reads[T]): T = fromByteArray[T](array)
def in[T](array : Array[Byte])(implicit bin : Reads[T]): T = fromByteArray[T](array) def in[T](array : Array[Byte])(implicit bin : Reads[T]): T = fromByteArray[T](array)
} } */
} }

View file

@ -68,7 +68,7 @@ final class HashTrie[K, +V] private (root: Node[K, V]) extends Map[K, V] with Pe
} }
object HashTrie { object HashTrie {
def apply[K, V](pairs: (K, V)*) = pairs.foldLeft(new HashTrie[K, V]) { _ + _ } def apply[K, V](pairs: (K, V)*) = pairs.foldLeft((new HashTrie[K, V]).asInstanceOf[Map[K,V]]) { _ + _ }
def unapplySeq[K, V](map: HashTrie[K, V]) = map.toSeq def unapplySeq[K, V](map: HashTrie[K, V]) = map.toSeq
} }

View file

@ -4,7 +4,7 @@
package se.scalablesolutions.akka.util package se.scalablesolutions.akka.util
import stm.Transaction import se.scalablesolutions.akka.stm.Transaction
/** /**
* Reference that can hold either a typed value or an exception. * Reference that can hold either a typed value or an exception.

View file

@ -173,11 +173,19 @@ class TransactionalMap[K, V] extends Transactional with scala.collection.mutable
ref.swap(new HashTrie[K, V]) ref.swap(new HashTrie[K, V])
def -=(key: K) = remove(key) def -=(key: K) = {
remove(key)
this
}
def +=(key: K, value: V) = put(key, value) def +=(key: K, value: V) = put(key, value)
def remove(key: K) = ref.swap(ref.get.get - key) def remove(key: K) = {
val map = ref.get.get
val oldValue = map.get(key)
ref.swap(ref.get.get - key)
oldValue
}
def get(key: K): Option[V] = ref.get.get.get(key) def get(key: K): Option[V] = ref.get.get.get(key)

View file

@ -23,8 +23,7 @@ import org.apache.thrift.protocol._
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/ */
trait CassandraSession extends Closeable with Flushable { trait CassandraSession extends Closeable with Flushable {
import scala.collection.jcl.Conversions._ import scala.collection.JavaConversions._
import org.scala_tools.javautils.Imports._
import java.util.{Map => JMap, List => JList} import java.util.{Map => JMap, List => JList}
protected val client: Cassandra.Client protected val client: Cassandra.Client
@ -91,7 +90,7 @@ trait CassandraSession extends Closeable with Flushable {
def ++|(key: String, batch: Map[String, List[ColumnOrSuperColumn]], consistencyLevel: Int): Unit = { def ++|(key: String, batch: Map[String, List[ColumnOrSuperColumn]], consistencyLevel: Int): Unit = {
val jmap = new java.util.HashMap[String, JList[ColumnOrSuperColumn]] val jmap = new java.util.HashMap[String, JList[ColumnOrSuperColumn]]
for (entry <- batch; (key, value) = entry) jmap.put(key, value.asJava) for (entry <- batch; (key, value) = entry) jmap.put(key, value)
client.batch_insert(keyspace, key, jmap, consistencyLevel) client.batch_insert(keyspace, key, jmap, consistencyLevel)
} }

View file

@ -17,14 +17,14 @@ import com.sun.jersey.spi.container.WebApplication
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a> * @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/ */
class AkkaServlet extends ServletContainer { class AkkaServlet extends ServletContainer {
import org.scala_tools.javautils.Imports._ import scala.collection.JavaConversions._
override def initiate(resourceConfig: ResourceConfig, webApplication: WebApplication) = { override def initiate(resourceConfig: ResourceConfig, webApplication: WebApplication) = {
//Kernel.boot // will boot if not already booted by 'main' //Kernel.boot // will boot if not already booted by 'main'
val configurators = ConfiguratorRepository.getConfigurators val configurators = ConfiguratorRepository.getConfigurators
resourceConfig.getClasses.addAll(configurators.flatMap(_.getComponentInterfaces).asJava) resourceConfig.getClasses.addAll(configurators.flatMap(_.getComponentInterfaces))
resourceConfig.getProperties.put( resourceConfig.getProperties.put(
"com.sun.jersey.spi.container.ResourceFilters", "com.sun.jersey.spi.container.ResourceFilters",
Config.config.getList("akka.rest.filters").mkString(",")) Config.config.getList("akka.rest.filters").mkString(","))

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sjson.json</groupId>
<artifactId>sjson</artifactId>
<version>0.5-SNAPSHOT-2.8.Beta1</version>
<packaging>jar</packaging>
</project>