diff --git a/README b/README
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/akka-amqp/src/main/java/akka/amqp/ExampleSessionJava.java b/akka-amqp/src/main/java/akka/amqp/ExampleSessionJava.java
deleted file mode 100644
index 5764877c3c..0000000000
--- a/akka-amqp/src/main/java/akka/amqp/ExampleSessionJava.java
+++ /dev/null
@@ -1,267 +0,0 @@
-package akka.amqp;
-
-import org.multiverse.api.latches.StandardLatch;
-import scala.Option;
-import akka.actor.ActorRef;
-import akka.actor.ActorRegistry;
-import akka.actor.UntypedActor;
-import akka.actor.UntypedActorFactory;
-
-import akka.amqp.rpc.RPC;
-import akka.remote.protocol.RemoteProtocol;
-
-import akka.japi.Function;
-import akka.japi.Procedure;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-@SuppressWarnings({"unchecked"})
-public class ExampleSessionJava {
-
- public static void main(String... args) {
- new ExampleSessionJava();
- }
-
- public ExampleSessionJava() {
- printTopic("DIRECT");
- direct();
-
- printTopic("CALLBACK");
- callback();
-
- printTopic("EASY STRING PRODUCER AND CONSUMER");
- easyStringProducerConsumer();
-
- printTopic("EASY PROTOBUF PRODUCER AND CONSUMER");
- easyProtobufProducerConsumer();
-
- printTopic("EASY STRING RPC");
- easyStringRpc();
-
- printTopic("EASY PROTOBUF RPC");
- easyProtobufRpc();
-
- // postStop everything the amqp tree except the main AMQP supervisor
- // all connections/consumers/producers will be stopped
- AMQP.shutdownAll();
-
- ActorRegistry.shutdownAll();
-
- printTopic("Happy hAkking :-)");
-
- System.exit(0);
- }
-
- private void printTopic(String topic) {
-
- System.out.println("");
- System.out.println("==== " + topic + " ===");
- System.out.println("");
- try {
- TimeUnit.SECONDS.sleep(2);
- } catch (InterruptedException ignore) {
- }
- }
-
- private void direct() {
- // defaults to amqp://guest:guest@localhost:5672/
- ActorRef connection = AMQP.newConnection();
-
- AMQP.ExchangeParameters exchangeParameters = new AMQP.ExchangeParameters("my_direct_exchange", Direct.getInstance());
-
- ActorRef deliveryHandler = UntypedActor.actorOf(DirectDeliveryHandlerActor.class);
-
- AMQP.ConsumerParameters consumerParameters = new AMQP.ConsumerParameters("some.routing", deliveryHandler, exchangeParameters);
- ActorRef consumer = AMQP.newConsumer(connection, consumerParameters);
-
-
- ActorRef producer = AMQP.newProducer(connection, new AMQP.ProducerParameters(exchangeParameters));
- producer.sendOneWay(new Message("@jonas_boner: You sucked!!".getBytes(), "some.routing"));
- }
-
- private void callback() {
-
- final CountDownLatch channelCountdown = new CountDownLatch(2);
-
- ActorRef connectionCallback = UntypedActor.actorOf(ConnectionCallbackActor.class);
- connectionCallback.start();
-
- AMQP.ConnectionParameters connectionParameters = new AMQP.ConnectionParameters(connectionCallback);
- ActorRef connection = AMQP.newConnection(connectionParameters);
-
- ActorRef channelCallback = UntypedActor.actorOf(new UntypedActorFactory() {
- public UntypedActor create() {
- return new ChannelCallbackActor(channelCountdown);
- }
- });
- channelCallback.start();
-
- AMQP.ExchangeParameters exchangeParameters = new AMQP.ExchangeParameters("my_callback_exchange", Direct.getInstance());
- AMQP.ChannelParameters channelParameters = new AMQP.ChannelParameters(channelCallback);
-
- ActorRef dummyHandler = UntypedActor.actorOf(DummyActor.class);
- AMQP.ConsumerParameters consumerParameters = new AMQP.ConsumerParameters("callback.routing", dummyHandler, exchangeParameters, channelParameters);
-
- ActorRef consumer = AMQP.newConsumer(connection, consumerParameters);
-
- ActorRef producer = AMQP.newProducer(connection, new AMQP.ProducerParameters(exchangeParameters, channelParameters));
-
- // Wait until both channels (producer & consumer) are started before stopping the connection
- try {
- channelCountdown.await(2, TimeUnit.SECONDS);
- } catch (InterruptedException ignore) {
- }
- connection.stop();
- }
-
- public void easyStringProducerConsumer() {
- ActorRef connection = AMQP.newConnection();
-
- String exchangeName = "easy.string";
-
- // listen by default to:
- // exchange = optional exchangeName
- // routingKey = provided routingKey or .request
- // queueName = .in
- Procedure procedure = new Procedure() {
- public void apply(String message) {
- System.out.println("### >> Received message: " + message);
- }
- };
- AMQP.newStringConsumer(connection, procedure, exchangeName);
-
- // send by default to:
- // exchange = exchangeName
- // routingKey = .request
- AMQP.ProducerClient producer = AMQP.newStringProducer(connection, exchangeName);
-
- producer.send("This shit is easy!");
- }
-
- public void easyProtobufProducerConsumer() {
-
- ActorRef connection = AMQP.newConnection();
-
- String exchangeName = "easy.protobuf";
-
- Procedure procedure = new Procedure() {
- public void apply(RemoteProtocol.AddressProtocol message) {
- System.out.println("### >> Received message: " + message);
- }
- };
-
- AMQP.newProtobufConsumer(connection, procedure, exchangeName, RemoteProtocol.AddressProtocol.class);
-
- AMQP.ProducerClient producerClient = AMQP.newProtobufProducer(connection, exchangeName);
-
- producerClient.send(RemoteProtocol.AddressProtocol.newBuilder().setHostname("akkarocks.com").setPort(1234).build());
- }
-
- public void easyStringRpc() {
-
- ActorRef connection = AMQP.newConnection();
-
- String exchangeName = "easy.stringrpc";
-
- // listen by default to:
- // exchange = exchangeName
- // routingKey = .request
- // queueName = .in
- RPC.newStringRpcServer(connection, exchangeName, new Function() {
- public String apply(String request) {
- System.out.println("### >> Got request: " + request);
- return "Response to: '" + request + "'";
- }
- });
-
- // send by default to:
- // exchange = exchangeName
- // routingKey = .request
- RPC.RpcClient stringRpcClient = RPC.newStringRpcClient(connection, exchangeName);
-
- Option response = stringRpcClient.call("AMQP Rocks!");
- System.out.println("### >> Got response: " + response);
-
- final StandardLatch standardLatch = new StandardLatch();
- stringRpcClient.callAsync("AMQP is dead easy", new Procedure() {
- public void apply(String request) {
- System.out.println("### >> This is handled async: " + request);
- standardLatch.open();
- }
- });
- try {
- standardLatch.tryAwait(2, TimeUnit.SECONDS);
- } catch (InterruptedException ignore) {
- }
- }
-
-
- public void easyProtobufRpc() {
-
- ActorRef connection = AMQP.newConnection();
-
- String exchangeName = "easy.protobuf.rpc";
-
- RPC.newProtobufRpcServer(connection, exchangeName, new Function() {
- public RemoteProtocol.AddressProtocol apply(RemoteProtocol.AddressProtocol request) {
- return RemoteProtocol.AddressProtocol.newBuilder().setHostname(request.getHostname()).setPort(request.getPort()).build();
- }
- }, RemoteProtocol.AddressProtocol.class);
-
- RPC.RpcClient protobufRpcClient =
- RPC.newProtobufRpcClient(connection, exchangeName, RemoteProtocol.AddressProtocol.class);
-
- scala.Option response =
- protobufRpcClient.call(RemoteProtocol.AddressProtocol.newBuilder().setHostname("localhost").setPort(4321).build());
-
- System.out.println("### >> Got response: " + response);
- }
-}
-
-class DummyActor extends UntypedActor {
- public void onReceive(Object message) throws Exception {
- // not used
- }
-}
-
-class ChannelCallbackActor extends UntypedActor {
-
- private final CountDownLatch channelCountdown;
-
- public ChannelCallbackActor(CountDownLatch channelCountdown) {
- this.channelCountdown = channelCountdown;
- }
-
- public void onReceive(Object message) throws Exception {
- if (Started.getInstance().getClass().isAssignableFrom(message.getClass())) {
- System.out.println("### >> Channel callback: Started");
- channelCountdown.countDown();
- } else if (Restarting.getInstance().getClass().isAssignableFrom(message.getClass())) {
- } else if (Stopped.getInstance().getClass().isAssignableFrom(message.getClass())) {
- System.out.println("### >> Channel callback: Stopped");
- } else throw new IllegalArgumentException("Unknown message: " + message);
- }
-}
-
-class ConnectionCallbackActor extends UntypedActor {
-
- public void onReceive(Object message) throws Exception {
- if (Connected.getInstance().getClass().isAssignableFrom(message.getClass())) {
- System.out.println("### >> Connection callback: Connected!");
- } else if (Reconnecting.getInstance().getClass().isAssignableFrom(message.getClass())) {
- } else if (Disconnected.getInstance().getClass().isAssignableFrom(message.getClass())) {
- System.out.println("### >> Connection callback: Disconnected!");
- } else throw new IllegalArgumentException("Unknown message: " + message);
- }
-}
-
-class DirectDeliveryHandlerActor extends UntypedActor {
-
- public void onReceive(Object message) throws Exception {
- if (Delivery.class.isAssignableFrom(message.getClass())) {
- Delivery delivery = (Delivery) message;
- System.out.println("### >> @george_bush received message from: " + new String(delivery.payload()));
- } else throw new IllegalArgumentException("Unknown message: " + message);
- }
-}
diff --git a/akka-amqp/src/main/scala/akka/amqp/AMQP.scala b/akka-amqp/src/main/scala/akka/amqp/AMQP.scala
deleted file mode 100644
index ec029bc1cd..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/AMQP.scala
+++ /dev/null
@@ -1,489 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import akka.actor.{Actor, ActorRef}
-import akka.actor.Actor._
-import akka.config.Supervision.OneForOneStrategy
-import com.rabbitmq.client.{ReturnListener, ShutdownListener, ConnectionFactory}
-import ConnectionFactory._
-import com.rabbitmq.client.AMQP.BasicProperties
-import java.lang.{String, IllegalArgumentException}
-import reflect.Manifest
-import akka.japi.Procedure
-import akka.dispatch.Dispatchers
-
-/**
- * AMQP Actor API. Implements Connection, Producer and Consumer materialized as Actors.
- *
- * @see akka.amqp.ExampleSession
- *
- * @author Irmo Manie
- */
-object AMQP {
-
- lazy val consumerDispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("amqp-consumers").build
- lazy val producerDispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher("amqp-producers").build
- /**
- * Parameters used to make the connection to the amqp broker. Uses the rabbitmq defaults.
- */
- case class ConnectionParameters(
- host: String = DEFAULT_HOST,
- port: Int = DEFAULT_AMQP_PORT,
- username: String = DEFAULT_USER,
- password: String = DEFAULT_PASS,
- virtualHost: String = DEFAULT_VHOST,
- initReconnectDelay: Long = 5000,
- connectionCallback: Option[ActorRef] = None) {
-
- // Needed for Java API usage
- def this() = this (DEFAULT_HOST, DEFAULT_AMQP_PORT, DEFAULT_USER, DEFAULT_PASS, DEFAULT_VHOST, 5000, None)
-
- // Needed for Java API usage
- def this(host: String, port: Int, username: String, password: String, virtualHost: String) =
- this (host, port, username, password, virtualHost, 5000, None)
-
- // Needed for Java API usage
- def this(host: String, port: Int, username: String, password: String, virtualHost: String, initReconnectDelay: Long, connectionCallback: ActorRef) =
- this (host, port, username, password, virtualHost, initReconnectDelay, Some(connectionCallback))
-
- // Needed for Java API usage
- def this(connectionCallback: ActorRef) =
- this (DEFAULT_HOST, DEFAULT_AMQP_PORT, DEFAULT_USER, DEFAULT_PASS, DEFAULT_VHOST, 5000, Some(connectionCallback))
-
- }
-
- /**
- * Additional parameters for the channel
- */
- case class ChannelParameters(
- shutdownListener: Option[ShutdownListener] = None,
- channelCallback: Option[ActorRef] = None,
- prefetchSize: Int = 0) {
-
- // Needed for Java API usage
- def this() = this (None, None)
-
- // Needed for Java API usage
- def this(channelCallback: ActorRef) = this (None, Some(channelCallback))
-
- // Needed for Java API usage
- def this(shutdownListener: ShutdownListener, channelCallback: ActorRef) =
- this (Some(shutdownListener), Some(channelCallback))
- }
-
- /**
- * Declaration type used for either exchange or queue declaration
- */
- sealed trait Declaration
- case object NoActionDeclaration extends Declaration {
- def getInstance() = this // Needed for Java API usage
- }
- case object PassiveDeclaration extends Declaration {
- def getInstance() = this // Needed for Java API usage
- }
- case class ActiveDeclaration(durable: Boolean = false, autoDelete: Boolean = true, exclusive: Boolean = false) extends Declaration {
-
- // Needed for Java API usage
- def this() = this (false, true, false)
-
- // Needed for Java API usage
- def this(durable: Boolean, autoDelete: Boolean) = this (durable, autoDelete, false)
- }
-
- /**
- * Exchange specific parameters
- */
- case class ExchangeParameters(
- exchangeName: String,
- exchangeType: ExchangeType = Topic,
- exchangeDeclaration: Declaration = ActiveDeclaration(),
- configurationArguments: Map[String, AnyRef] = Map.empty) {
-
- // Needed for Java API usage
- def this(exchangeName: String) =
- this (exchangeName, Topic, ActiveDeclaration(), Map.empty)
-
- // Needed for Java API usage
- def this(exchangeName: String, exchangeType: ExchangeType) =
- this (exchangeName, exchangeType, ActiveDeclaration(), Map.empty)
-
- // Needed for Java API usage
- def this(exchangeName: String, exchangeType: ExchangeType, exchangeDeclaration: Declaration) =
- this (exchangeName, exchangeType, exchangeDeclaration, Map.empty)
- }
-
- /**
- * Producer specific parameters
- */
- case class ProducerParameters(
- exchangeParameters: Option[ExchangeParameters] = None,
- producerId: Option[String] = None,
- returnListener: Option[ReturnListener] = None,
- channelParameters: Option[ChannelParameters] = None) {
- def this() = this (None, None, None, None)
-
- // Needed for Java API usage
- def this(exchangeParameters: ExchangeParameters) = this (Some(exchangeParameters), None, None, None)
-
- // Needed for Java API usage
- def this(exchangeParameters: ExchangeParameters, producerId: String) =
- this (Some(exchangeParameters), Some(producerId), None, None)
-
- // Needed for Java API usage
- def this(exchangeParameters: ExchangeParameters, returnListener: ReturnListener) =
- this (Some(exchangeParameters), None, Some(returnListener), None)
-
- // Needed for Java API usage
- def this(exchangeParameters: ExchangeParameters, channelParameters: ChannelParameters) =
- this (Some(exchangeParameters), None, None, Some(channelParameters))
-
- // Needed for Java API usage
- def this(exchangeParameters: ExchangeParameters, producerId: String, returnListener: ReturnListener, channelParameters: ChannelParameters) =
- this (Some(exchangeParameters), Some(producerId), Some(returnListener), Some(channelParameters))
- }
-
- /**
- * Consumer specific parameters
- */
- case class ConsumerParameters(
- routingKey: String,
- deliveryHandler: ActorRef,
- queueName: Option[String] = None,
- exchangeParameters: Option[ExchangeParameters] = None,
- queueDeclaration: Declaration = ActiveDeclaration(),
- selfAcknowledging: Boolean = true,
- channelParameters: Option[ChannelParameters] = None) {
- if (queueName.isEmpty) {
- queueDeclaration match {
- case ActiveDeclaration(true, _, _) =>
- throw new IllegalArgumentException("A queue name is required when requesting a durable queue.")
- case PassiveDeclaration =>
- throw new IllegalArgumentException("A queue name is required when requesting passive declaration.")
- case _ => () // ignore
- }
- }
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef) =
- this (routingKey, deliveryHandler, None, None, ActiveDeclaration(), true, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, channelParameters: ChannelParameters) =
- this (routingKey, deliveryHandler, None, None, ActiveDeclaration(), true, Some(channelParameters))
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, selfAcknowledging: Boolean) =
- this (routingKey, deliveryHandler, None, None, ActiveDeclaration(), selfAcknowledging, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, selfAcknowledging: Boolean, channelParameters: ChannelParameters) =
- this (routingKey, deliveryHandler, None, None, ActiveDeclaration(), selfAcknowledging, Some(channelParameters))
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, queueName: String) =
- this (routingKey, deliveryHandler, Some(queueName), None, ActiveDeclaration(), true, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, queueName: String, queueDeclaration: Declaration, selfAcknowledging: Boolean, channelParameters: ChannelParameters) =
- this (routingKey, deliveryHandler, Some(queueName), None, queueDeclaration, selfAcknowledging, Some(channelParameters))
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, exchangeParameters: ExchangeParameters) =
- this (routingKey, deliveryHandler, None, Some(exchangeParameters), ActiveDeclaration(), true, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, exchangeParameters: ExchangeParameters, channelParameters: ChannelParameters) =
- this (routingKey, deliveryHandler, None, Some(exchangeParameters), ActiveDeclaration(), true, Some(channelParameters))
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, exchangeParameters: ExchangeParameters, selfAcknowledging: Boolean) =
- this (routingKey, deliveryHandler, None, Some(exchangeParameters), ActiveDeclaration(), selfAcknowledging, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, queueName: String, exchangeParameters: ExchangeParameters) =
- this (routingKey, deliveryHandler, Some(queueName), Some(exchangeParameters), ActiveDeclaration(), true, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, queueName: String, exchangeParameters: ExchangeParameters, queueDeclaration: Declaration) =
- this (routingKey, deliveryHandler, Some(queueName), Some(exchangeParameters), queueDeclaration, true, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, queueName: String, exchangeParameters: ExchangeParameters, queueDeclaration: Declaration, selfAcknowledging: Boolean) =
- this (routingKey, deliveryHandler, Some(queueName), Some(exchangeParameters), queueDeclaration, selfAcknowledging, None)
-
- // Needed for Java API usage
- def this(routingKey: String, deliveryHandler: ActorRef, queueName: String, exchangeParameters: ExchangeParameters, queueDeclaration: Declaration, selfAcknowledging: Boolean, channelParameters: ChannelParameters) =
- this (routingKey, deliveryHandler, Some(queueName), Some(exchangeParameters), queueDeclaration, selfAcknowledging, Some(channelParameters))
-
- // How about that for some overloading... huh? :P (yes, I know, there are still possibilities left...sue me!)
- // Who said java is easy :(
- }
-
- def newConnection(connectionParameters: ConnectionParameters = new ConnectionParameters()): ActorRef = {
- val connection = actorOf(new FaultTolerantConnectionActor(connectionParameters))
- supervisor.startLink(connection)
- connection ! Connect
- connection
- }
-
- // Needed for Java API usage
- def newConnection(): ActorRef = {
- newConnection(new ConnectionParameters())
- }
-
- def newProducer(connection: ActorRef, producerParameters: ProducerParameters): ActorRef = {
- val producer: ActorRef = Actor.actorOf(new ProducerActor(producerParameters))
- producer.dispatcher = producerDispatcher
- connection.startLink(producer)
- producer ! Start
- producer
- }
-
- def newConsumer(connection: ActorRef, consumerParameters: ConsumerParameters): ActorRef = {
- val consumer: ActorRef = actorOf(new ConsumerActor(consumerParameters))
- consumer.dispatcher = consumerDispatcher
- val handler = consumerParameters.deliveryHandler
- if (handler.isUnstarted) handler.dispatcher = consumerDispatcher
- if (handler.supervisor.isEmpty) consumer.startLink(handler)
- connection.startLink(consumer)
- consumer ! Start
- consumer
- }
-
- /**
- * Convenience
- */
- class ProducerClient[O](client: ActorRef, routingKey: String, toBinary: ToBinary[O]) {
- // Needed for Java API usage
- def send(request: O): Unit = {
- send(request, None)
- }
- // Needed for Java API usage
- def send(request: O, replyTo: String): Unit = {
- send(request, Some(replyTo))
- }
-
- def send(request: O, replyTo: Option[String] = None) = {
- val basicProperties = new BasicProperties
- basicProperties.setReplyTo(replyTo.getOrElse(null))
- client ! Message(toBinary.toBinary(request), routingKey, false, false, Some(basicProperties))
- }
-
- def stop() = client.stop
- }
-
- // Needed for Java API usage
- def newStringProducer(connection: ActorRef,
- exchangeName: String): ProducerClient[String] = {
- newStringProducer(connection, Some(exchangeName))
- }
-
- // Needed for Java API usage
- def newStringProducer(connection: ActorRef,
- exchangeName: String,
- routingKey: String): ProducerClient[String] = {
- newStringProducer(connection, Some(exchangeName), Some(routingKey))
- }
-
- // Needed for Java API usage
- def newStringProducer(connection: ActorRef,
- exchangeName: String,
- routingKey: String,
- producerId: String): ProducerClient[String] = {
- newStringProducer(connection, Some(exchangeName), Some(routingKey), Some(producerId))
- }
-
- def newStringProducer(connection: ActorRef,
- exchangeName: Option[String],
- routingKey: Option[String] = None,
- producerId: Option[String] = None): ProducerClient[String] = {
-
- if (exchangeName.isEmpty && routingKey.isEmpty) {
- throw new IllegalArgumentException("Either exchange name or routing key is mandatory")
- }
- val exchangeParameters = exchangeName.flatMap(name => Some(ExchangeParameters(name)))
- val rKey = routingKey.getOrElse("%s.request".format(exchangeName.get))
-
- val producerRef = newProducer(connection, ProducerParameters(exchangeParameters, producerId))
- val toBinary = new ToBinary[String] {
- def toBinary(t: String) = t.getBytes
- }
- new ProducerClient(producerRef, rKey, toBinary)
- }
-
- // Needed for Java API usage
- def newStringConsumer(connection: ActorRef,
- handler: Procedure[String],
- exchangeName: String): ActorRef = {
- newStringConsumer(connection, handler.apply _, Some(exchangeName))
- }
-
- // Needed for Java API usage
- def newStringConsumer(connection: ActorRef,
- handler: Procedure[String],
- exchangeName: String,
- routingKey: String): ActorRef = {
- newStringConsumer(connection, handler.apply _, Some(exchangeName), Some(routingKey))
- }
-
- // Needed for Java API usage
- def newStringConsumer(connection: ActorRef,
- handler: Procedure[String],
- exchangeName: String,
- routingKey: String,
- queueName: String): ActorRef = {
- newStringConsumer(connection, handler.apply _, Some(exchangeName), Some(routingKey), Some(queueName))
- }
-
- def newStringConsumer(connection: ActorRef,
- handler: String => Unit,
- exchangeName: Option[String],
- routingKey: Option[String] = None,
- queueName: Option[String] = None): ActorRef = {
-
- if (exchangeName.isEmpty && routingKey.isEmpty) {
- throw new IllegalArgumentException("Either exchange name or routing key is mandatory")
- }
-
- val deliveryHandler = actorOf( new Actor {
- def receive = { case Delivery(payload, _, _, _, _, _) => handler.apply(new String(payload)) }
- } ).start
-
- val exchangeParameters = exchangeName.flatMap(name => Some(ExchangeParameters(name)))
- val rKey = routingKey.getOrElse("%s.request".format(exchangeName.get))
- val qName = queueName.getOrElse("%s.in".format(rKey))
-
- newConsumer(connection, ConsumerParameters(rKey, deliveryHandler, Some(qName), exchangeParameters))
- }
-
-
- // Needed for Java API usage
- def newProtobufProducer[O <: com.google.protobuf.Message](connection: ActorRef,
- exchangeName: String): ProducerClient[O] = {
- newProtobufProducer(connection, Some(exchangeName))
- }
-
- // Needed for Java API usage
- def newProtobufProducer[O <: com.google.protobuf.Message](connection: ActorRef,
- exchangeName: String,
- routingKey: String): ProducerClient[O] = {
- newProtobufProducer(connection, Some(exchangeName), Some(routingKey))
- }
-
- // Needed for Java API usage
- def newProtobufProducer[O <: com.google.protobuf.Message](connection: ActorRef,
- exchangeName: String,
- routingKey: String,
- producerId: String): ProducerClient[O] = {
- newProtobufProducer(connection, Some(exchangeName), Some(routingKey), Some(producerId))
- }
-
- def newProtobufProducer[O <: com.google.protobuf.Message](connection: ActorRef,
- exchangeName: Option[String],
- routingKey: Option[String] = None,
- producerId: Option[String] = None): ProducerClient[O] = {
-
- if (exchangeName.isEmpty && routingKey.isEmpty) {
- throw new IllegalArgumentException("Either exchange name or routing key is mandatory")
- }
- val exchangeParameters = exchangeName.flatMap(name => Some(ExchangeParameters(name)))
- val rKey = routingKey.getOrElse("%s.request".format(exchangeName.get))
-
- val producerRef = newProducer(connection, ProducerParameters(exchangeParameters, producerId))
- new ProducerClient(producerRef, rKey, new ToBinary[O] {
- def toBinary(t: O) = t.toByteArray
- })
- }
-
- // Needed for Java API usage
- def newProtobufConsumer[I <: com.google.protobuf.Message](connection: ActorRef,
- handler: Procedure[I],
- exchangeName: String,
- clazz: Class[I]): ActorRef = {
- implicit val manifest = Manifest.classType[I](clazz)
- newProtobufConsumer[I](connection, handler.apply _, Some(exchangeName))
- }
-
- // Needed for Java API usage
- def newProtobufConsumer[I <: com.google.protobuf.Message](connection: ActorRef,
- handler: Procedure[I],
- exchangeName: String,
- routingKey: String,
- clazz: Class[I]): ActorRef = {
- implicit val manifest = Manifest.classType[I](clazz)
- newProtobufConsumer[I](connection, handler.apply _, Some(exchangeName), Some(routingKey))
- }
-
- // Needed for Java API usage
- def newProtobufConsumer[I <: com.google.protobuf.Message](connection: ActorRef,
- handler: Procedure[I],
- exchangeName: String,
- routingKey: String,
- queueName: String,
- clazz: Class[I]): ActorRef = {
- implicit val manifest = Manifest.classType[I](clazz)
- newProtobufConsumer[I](connection, handler.apply _, Some(exchangeName), Some(routingKey), Some(queueName))
- }
-
- def newProtobufConsumer[I <: com.google.protobuf.Message](connection: ActorRef,
- handler: I => Unit,
- exchangeName: Option[String],
- routingKey: Option[String] = None,
- queueName: Option[String] = None)(implicit manifest: Manifest[I]): ActorRef = {
-
- if (exchangeName.isEmpty && routingKey.isEmpty) {
- throw new IllegalArgumentException("Either exchange name or routing key is mandatory")
- }
-
- val deliveryHandler = actorOf(new Actor {
- def receive = { case Delivery(payload, _, _, _, _, _) => handler.apply(createProtobufFromBytes[I](payload)) }
- }).start
-
- val exchangeParameters = exchangeName.flatMap(name => Some(ExchangeParameters(name)))
- val rKey = routingKey.getOrElse("%s.request".format(exchangeName.get))
- val qName = queueName.getOrElse("%s.in".format(rKey))
-
- newConsumer(connection, ConsumerParameters(rKey, deliveryHandler, Some(qName), exchangeParameters))
- }
-
-
- /**
- * Main supervisor
- */
- class AMQPSupervisorActor extends Actor {
- import self._
-
- faultHandler = OneForOneStrategy(List(classOf[Throwable]))
-
- def receive = {
- case _ => {} // ignore all messages
- }
- }
-
- private val supervisor = actorOf(new AMQPSupervisorActor).start
-
- def shutdownAll() = {
- supervisor.shutdownLinkedActors
- }
-
- /**
- * Serialization stuff
- */
-
- trait FromBinary[T] {
- def fromBinary(bytes: Array[Byte]): T
- }
-
- trait ToBinary[T] {
- def toBinary(t: T): Array[Byte]
- }
-
- private val ARRAY_OF_BYTE_ARRAY = Array[Class[_]](classOf[Array[Byte]])
-
- private[amqp] def createProtobufFromBytes[I <: com.google.protobuf.Message](bytes: Array[Byte])(implicit manifest: Manifest[I]): I = {
- manifest.erasure.getDeclaredMethod("parseFrom", ARRAY_OF_BYTE_ARRAY: _*).invoke(null, bytes).asInstanceOf[I]
- }
-}
diff --git a/akka-amqp/src/main/scala/akka/amqp/AMQPMessage.scala b/akka-amqp/src/main/scala/akka/amqp/AMQPMessage.scala
deleted file mode 100644
index af9fb2cbb6..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/AMQPMessage.scala
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import akka.actor.ActorRef
-import com.rabbitmq.client.AMQP.BasicProperties
-import com.rabbitmq.client.ShutdownSignalException
-
-sealed trait AMQPMessage
-sealed trait InternalAMQPMessage extends AMQPMessage
-
-case class Message(
- payload: Array[Byte],
- routingKey: String,
- mandatory: Boolean = false,
- immediate: Boolean = false,
- properties: Option[BasicProperties] = None) extends AMQPMessage {
-
- // Needed for Java API usage
- def this(payload: Array[Byte], routingKey: String) = this(payload, routingKey, false, false, None)
-
- // Needed for Java API usage
- def this(payload: Array[Byte], routingKey: String, mandatory: Boolean, immediate: Boolean) =
- this(payload, routingKey, mandatory, immediate, None)
-
- // Needed for Java API usage
- def this(payload: Array[Byte], routingKey: String, properties: BasicProperties) =
- this(payload, routingKey, false, false, Some(properties))
-
- // Needed for Java API usage
- def this(payload: Array[Byte], routingKey: String, mandatory: Boolean, immediate: Boolean, properties: BasicProperties) =
- this(payload, routingKey, mandatory, immediate, Some(properties))
-}
-
-case class Delivery(
- payload: Array[Byte],
- routingKey: String,
- deliveryTag: Long,
- isRedeliver: Boolean,
- properties: BasicProperties,
- sender: Option[ActorRef]) extends AMQPMessage
-
-// connection messages
-case object Connect extends AMQPMessage
-
-case object Connected extends AMQPMessage {
- def getInstance() = this // Needed for Java API usage
-}
-case object Reconnecting extends AMQPMessage {
- def getInstance() = this // Needed for Java API usage
-}
-case object Disconnected extends AMQPMessage {
- def getInstance() = this // Needed for Java API usage
-}
-
-case object ChannelRequest extends InternalAMQPMessage
-
-// channel messages
-case object Start extends AMQPMessage
-
-case object Started extends AMQPMessage {
- def getInstance() = this // Needed for Java API usage
-}
-case object Restarting extends AMQPMessage {
- def getInstance() = this // Needed for Java API usage
-}
-case object Stopped extends AMQPMessage {
- def getInstance() = this // Needed for Java API usage
-}
-
-// delivery messages
-case class Acknowledge(deliveryTag: Long) extends AMQPMessage
-case class Acknowledged(deliveryTag: Long) extends AMQPMessage
-case class Reject(deliveryTag: Long) extends AMQPMessage
-case class Rejected(deliveryTag: Long) extends AMQPMessage
-class RejectionException(deliveryTag: Long) extends RuntimeException
-
-// internal messages
-private[akka] case class Failure(cause: Throwable) extends InternalAMQPMessage
-case class ConnectionShutdown(cause: ShutdownSignalException) extends InternalAMQPMessage
-case class ChannelShutdown(cause: ShutdownSignalException) extends InternalAMQPMessage
-
-private[akka] class MessageNotDeliveredException(
- val message: String,
- val replyCode: Int,
- val replyText: String,
- val exchange: String,
- val routingKey: String,
- val properties: BasicProperties,
- val body: Array[Byte]) extends RuntimeException(message)
diff --git a/akka-amqp/src/main/scala/akka/amqp/ConsumerActor.scala b/akka-amqp/src/main/scala/akka/amqp/ConsumerActor.scala
deleted file mode 100644
index d0324f05c6..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/ConsumerActor.scala
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import collection.JavaConversions
-
-import akka.util.Logging
-
-import com.rabbitmq.client.AMQP.BasicProperties
-import com.rabbitmq.client.{Channel, Envelope, DefaultConsumer}
-import akka.amqp.AMQP._
-
-private[amqp] class ConsumerActor(consumerParameters: ConsumerParameters)
- extends FaultTolerantChannelActor(
- consumerParameters.exchangeParameters, consumerParameters.channelParameters) {
- import consumerParameters._
-
- var listenerTag: Option[String] = None
-
- def specificMessageHandler = {
- case Acknowledge(deliveryTag) => acknowledgeDeliveryTag(deliveryTag, true)
- case Reject(deliveryTag) => rejectDeliveryTag(deliveryTag, true)
- case message: Message =>
- handleIllegalMessage("%s can't be used to send messages, ignoring message [%s]".format(this, message))
- case unknown =>
- handleIllegalMessage("Unknown message [%s] to %s".format(unknown, this))
- }
-
- protected def setupChannel(ch: Channel) = {
-
- channelParameters.foreach(params => ch.basicQos(params.prefetchSize))
-
- val exchangeName = exchangeParameters.flatMap(params => Some(params.exchangeName))
- val consumingQueue = exchangeName match {
- case Some(exchange) =>
- val queueDeclare: com.rabbitmq.client.AMQP.Queue.DeclareOk = {
- queueName match {
- case Some(name) =>
- declareQueue(ch, name, queueDeclaration)
- case None =>
- log.debug("Declaring new generated queue for %s", toString)
- ch.queueDeclare
- }
- }
- log.debug("Binding new queue [%s] with [%s] for %s", queueDeclare.getQueue, routingKey, toString)
- ch.queueBind(queueDeclare.getQueue, exchange, routingKey)
- queueDeclare.getQueue
- case None =>
- // no exchange, use routing key as queuename
- log.debug("No exchange specified, creating queue using routingkey as name (%s)", routingKey)
- declareQueue(ch, routingKey, queueDeclaration)
- routingKey
- }
-
-
- val tag = ch.basicConsume(consumingQueue, false, new DefaultConsumer(ch) with Logging {
- override def handleDelivery(tag: String, envelope: Envelope, properties: BasicProperties, payload: Array[Byte]) {
- try {
- val deliveryTag = envelope.getDeliveryTag
- log.debug("Passing a message on to %s", toString)
- import envelope._
- deliveryHandler ! Delivery(payload, getRoutingKey, getDeliveryTag, isRedeliver, properties, someSelf)
-
- if (selfAcknowledging) {
- log.debug("Self acking...")
- acknowledgeDeliveryTag(deliveryTag, false)
- }
- } catch {
- case cause =>
- log.error(cause, "Delivery of message to %s failed", toString)
- self ! Failure(cause) // pass on and re-throw exception in consumer actor to trigger restart and connect
- }
- }
- })
- listenerTag = Some(tag)
- log.info("Intitialized %s", toString)
- }
-
- private def declareQueue(ch: Channel, queueName: String, queueDeclaration: Declaration): com.rabbitmq.client.AMQP.Queue.DeclareOk = {
- queueDeclaration match {
- case PassiveDeclaration =>
- log.debug("Passively declaring new queue [%s] for %s", queueName, toString)
- ch.queueDeclarePassive(queueName)
- case ActiveDeclaration(durable, autoDelete, exclusive) =>
- log.debug("Actively declaring new queue [%s] for %s", queueName, toString)
- val configurationArguments = exchangeParameters match {
- case Some(params) => params.configurationArguments
- case _ => Map.empty
- }
- ch.queueDeclare(queueName, durable, exclusive, autoDelete, JavaConversions.asJavaMap(configurationArguments.toMap))
- case NoActionDeclaration => new com.rabbitmq.client.impl.AMQImpl.Queue.DeclareOk(queueName, 0, 0) // do nothing here
- }
- }
-
- private def acknowledgeDeliveryTag(deliveryTag: Long, remoteAcknowledgement: Boolean) = {
- log.debug("Acking message with delivery tag [%s]", deliveryTag)
- channel.foreach {
- ch =>
- ch.basicAck(deliveryTag, false)
- if (remoteAcknowledgement) {
- deliveryHandler ! Acknowledged(deliveryTag)
- }
- }
- }
-
- private def rejectDeliveryTag(deliveryTag: Long, remoteAcknowledgement: Boolean) = {
- log.debug("Rejecting message with delivery tag [%s]", deliveryTag)
- // FIXME: when rabbitmq 1.9 arrives, basicReject should be available on the API and implemented instead of this
- log.warning("Consumer is rejecting delivery with tag [%s] - " +
- "for now this means we have to self terminate and kill the channel - see you in a second.")
- channel.foreach {
- ch =>
- if (remoteAcknowledgement) {
- deliveryHandler ! Rejected(deliveryTag)
- }
- }
- throw new RejectionException(deliveryTag)
- }
-
- private def handleIllegalMessage(errorMessage: String) = {
- log.error(errorMessage)
- throw new IllegalArgumentException(errorMessage)
- }
-
- override def preRestart(reason: Throwable) = {
- listenerTag = None
- super.preRestart(reason)
- }
-
- override def postStop = {
- listenerTag.foreach(tag => channel.foreach(_.basicCancel(tag)))
- self.shutdownLinkedActors
- super.postStop
- }
-
- override def toString =
- "AMQP.Consumer[id= " + self.id +
- ", exchangeParameters=" + exchangeParameters +
- ", queueDeclaration=" + queueDeclaration + "]"
-}
-
diff --git a/akka-amqp/src/main/scala/akka/amqp/ExampleSession.scala b/akka-amqp/src/main/scala/akka/amqp/ExampleSession.scala
deleted file mode 100644
index 0e14f1b3bb..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/ExampleSession.scala
+++ /dev/null
@@ -1,268 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import rpc.RPC
-import rpc.RPC.{RpcClientSerializer, RpcServerSerializer}
-import akka.actor.{Actor, ActorRegistry}
-import Actor._
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-import java.lang.String
-import akka.amqp.AMQP._
-import akka.remote.protocol.RemoteProtocol.AddressProtocol
-
-object ExampleSession {
-
- def main(args: Array[String]) = {
-
- printTopic("DIRECT")
- direct
-
- printTopic("FANOUT")
- fanout
-
- printTopic("TOPIC")
- topic
-
- printTopic("CALLBACK")
- callback
-
- printTopic("EASY STRING PRODUCER AND CONSUMER")
- easyStringProducerConsumer
-
- printTopic("EASY PROTOBUF PRODUCER AND CONSUMER")
- easyProtobufProducerConsumer
-
- printTopic("RPC")
- rpc
-
- printTopic("EASY STRING RPC")
- easyStringRpc
-
- printTopic("EASY PROTOBUF RPC")
- easyProtobufRpc
-
- printTopic("Happy hAkking :-)")
-
- // postStop everything the amqp tree except the main AMQP supervisor
- // all connections/consumers/producers will be stopped
- AMQP.shutdownAll
-
- ActorRegistry.shutdownAll
- System.exit(0)
- }
-
- def printTopic(topic: String) {
-
- println("")
- println("==== " + topic + " ===")
- println("")
- TimeUnit.SECONDS.sleep(2)
- }
-
- def direct = {
-
- // defaults to amqp://guest:guest@localhost:5672/
- val connection = AMQP.newConnection()
-
- val exchangeParameters = ExchangeParameters("my_direct_exchange", Direct)
-
- val consumer = AMQP.newConsumer(connection, ConsumerParameters("some.routing", actorOf(new Actor { def receive = {
- case Delivery(payload, _, _, _, _, _) => log.info("@george_bush received message from: %s", new String(payload))
- }}), None, Some(exchangeParameters)))
-
- val producer = AMQP.newProducer(connection, ProducerParameters(Some(exchangeParameters)))
- producer ! Message("@jonas_boner: You sucked!!".getBytes, "some.routing")
- }
-
- def fanout = {
-
- // defaults to amqp://guest:guest@localhost:5672/
- val connection = AMQP.newConnection()
-
- val exchangeParameters = ExchangeParameters("my_fanout_exchange", Fanout)
-
- val bushConsumer = AMQP.newConsumer(connection, ConsumerParameters("@george_bush", actorOf(new Actor { def receive = {
- case Delivery(payload, _, _, _, _, _) => log.info("@george_bush received message from: %s", new String(payload))
- }}), None, Some(exchangeParameters)))
-
- val obamaConsumer = AMQP.newConsumer(connection, ConsumerParameters("@barack_obama", actorOf(new Actor { def receive = {
- case Delivery(payload, _, _, _, _, _) => log.info("@barack_obama received message from: %s", new String(payload))
- }}), None, Some(exchangeParameters)))
-
- val producer = AMQP.newProducer(connection, ProducerParameters(Some(exchangeParameters)))
- producer ! Message("@jonas_boner: I'm going surfing".getBytes, "")
- }
-
- def topic = {
-
- // defaults to amqp://guest:guest@localhost:5672/
- val connection = AMQP.newConnection()
-
- val exchangeParameters = ExchangeParameters("my_topic_exchange", Topic)
-
- val bushConsumer = AMQP.newConsumer(connection, ConsumerParameters("@george_bush", actorOf(new Actor { def receive = {
- case Delivery(payload, _, _, _, _, _) => log.info("@george_bush received message from: %s", new String(payload))
- }}), None, Some(exchangeParameters)))
-
- val obamaConsumer = AMQP.newConsumer(connection, ConsumerParameters("@barack_obama", actorOf(new Actor { def receive = {
- case Delivery(payload, _, _, _, _, _) => log.info("@barack_obama received message from: %s", new String(payload))
- }}), None, Some(exchangeParameters)))
-
- val producer = AMQP.newProducer(connection, ProducerParameters(Some(exchangeParameters)))
- producer ! Message("@jonas_boner: You still suck!!".getBytes, "@george_bush")
- producer ! Message("@jonas_boner: Yes I can!".getBytes, "@barack_obama")
- }
-
- def callback = {
-
- val channelCountdown = new CountDownLatch(2)
-
- val connectionCallback = actorOf(new Actor { def receive = {
- case Connected => log.info("Connection callback: Connected!")
- case Reconnecting => () // not used, sent when connection fails and initiates a reconnect
- case Disconnected => log.info("Connection callback: Disconnected!")
- }})
- val connection = AMQP.newConnection(new ConnectionParameters(connectionCallback = Some(connectionCallback)))
-
- val channelCallback = actorOf(new Actor { def receive = {
- case Started => {
- log.info("Channel callback: Started")
- channelCountdown.countDown
- }
- case Restarting => // not used, sent when channel or connection fails and initiates a restart
- case Stopped => log.info("Channel callback: Stopped")
- }})
- val exchangeParameters = ExchangeParameters("my_callback_exchange", Direct)
- val channelParameters = ChannelParameters(channelCallback = Some(channelCallback))
-
- val consumer = AMQP.newConsumer(connection, ConsumerParameters("callback.routing", actorOf(new Actor { def receive = {
- case _ => () // not used
- }}), None, Some(exchangeParameters), channelParameters = Some(channelParameters)))
-
- val producer = AMQP.newProducer(connection, ProducerParameters(Some(exchangeParameters)))
-
- // Wait until both channels (producer & consumer) are started before stopping the connection
- channelCountdown.await(2, TimeUnit.SECONDS)
- connection.stop
- }
-
- def easyStringProducerConsumer = {
- val connection = AMQP.newConnection()
-
- val exchangeName = "easy.string"
-
- // listen by default to:
- // exchange = optional exchangeName
- // routingKey = provided routingKey or .request
- // queueName = .in
- AMQP.newStringConsumer(connection, message => println("Received message: "+message), Some(exchangeName))
-
- // send by default to:
- // exchange = exchangeName
- // routingKey = .request
- val producer = AMQP.newStringProducer(connection, Some(exchangeName))
-
- producer.send("This shit is easy!")
- }
-
- def easyProtobufProducerConsumer = {
- val connection = AMQP.newConnection()
-
- val exchangeName = "easy.protobuf"
-
- def protobufMessageHandler(message: AddressProtocol) = {
- log.info("Received "+message)
- }
-
- AMQP.newProtobufConsumer(connection, protobufMessageHandler _, Some(exchangeName))
-
- val producerClient = AMQP.newProtobufProducer[AddressProtocol](connection, Some(exchangeName))
- producerClient.send(AddressProtocol.newBuilder.setHostname("akkarocks.com").setPort(1234).build)
- }
-
- def rpc = {
-
- val connection = AMQP.newConnection()
-
- val exchangeName = "my_rpc_exchange"
-
- /** Server */
- val serverFromBinary = new FromBinary[String] {
- def fromBinary(bytes: Array[Byte]) = new String(bytes)
- }
- val serverToBinary = new ToBinary[Int] {
- def toBinary(t: Int) = Array(t.toByte)
- }
- val rpcServerSerializer = new RpcServerSerializer[String, Int](serverFromBinary, serverToBinary)
-
- def requestHandler(request: String) = 3
-
- val rpcServer = RPC.newRpcServer(connection, exchangeName, rpcServerSerializer, requestHandler _,
- routingKey = Some("rpc.in.key"), queueName = Some("rpc.in.key.queue"))
-
-
- /** Client */
- val clientToBinary = new ToBinary[String] {
- def toBinary(t: String) = t.getBytes
- }
- val clientFromBinary = new FromBinary[Int] {
- def fromBinary(bytes: Array[Byte]) = bytes.head.toInt
- }
- val rpcClientSerializer = new RpcClientSerializer[String, Int](clientToBinary, clientFromBinary)
-
- val rpcClient = RPC.newRpcClient(connection, exchangeName, rpcClientSerializer, Some("rpc.in.key"))
-
- val response = rpcClient.call("rpc_request")
- log.info("Response: " + response)
- }
-
- def easyStringRpc = {
-
- val connection = AMQP.newConnection()
-
- val exchangeName = "easy.stringrpc"
-
- // listen by default to:
- // exchange = exchangeName
- // routingKey = .request
- // queueName = .in
- RPC.newStringRpcServer(connection, exchangeName, request => {
- log.info("Got request: "+request)
- "Response to: '"+request+"'"
- })
-
- // send by default to:
- // exchange = exchangeName
- // routingKey = .request
- val stringRpcClient = RPC.newStringRpcClient(connection, exchangeName)
-
- val response = stringRpcClient.call("AMQP Rocks!")
- log.info("Got response: "+response)
-
- stringRpcClient.callAsync("AMQP is dead easy") {
- case response => log.info("This is handled async: "+response)
- }
- }
-
- def easyProtobufRpc = {
-
- val connection = AMQP.newConnection()
-
- val exchangeName = "easy.protobuf.rpc"
-
- def protobufRequestHandler(request: AddressProtocol): AddressProtocol = {
- AddressProtocol.newBuilder.setHostname(request.getHostname.reverse).setPort(request.getPort).build
- }
-
- RPC.newProtobufRpcServer(connection, exchangeName, protobufRequestHandler)
-
- val protobufRpcClient = RPC.newProtobufRpcClient[AddressProtocol, AddressProtocol](connection, exchangeName)
-
- val response = protobufRpcClient.call(AddressProtocol.newBuilder.setHostname("localhost").setPort(4321).build)
-
- log.info("Got response: "+response)
- }
-}
diff --git a/akka-amqp/src/main/scala/akka/amqp/ExchangeType.scala b/akka-amqp/src/main/scala/akka/amqp/ExchangeType.scala
deleted file mode 100644
index b29e1e7170..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/ExchangeType.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-sealed trait ExchangeType
-case object Direct extends ExchangeType {
- def getInstance() = this // Needed for Java API usage
- override def toString = "direct"
-}
-case object Topic extends ExchangeType {
- def getInstance() = this // Needed for Java API usage
- override def toString = "topic"
-}
-case object Fanout extends ExchangeType {
- def getInstance() = this // Needed for Java API usage
- override def toString = "fanout"
-}
-case object Match extends ExchangeType {
- def getInstance() = this // Needed for Java API usage
- override def toString = "match"
-}
diff --git a/akka-amqp/src/main/scala/akka/amqp/FaultTolerantChannelActor.scala b/akka-amqp/src/main/scala/akka/amqp/FaultTolerantChannelActor.scala
deleted file mode 100644
index 057ceab257..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/FaultTolerantChannelActor.scala
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import collection.JavaConversions
-import java.lang.Throwable
-import akka.actor.Actor
-import Actor._
-import com.rabbitmq.client.{ShutdownSignalException, Channel, ShutdownListener}
-import scala.PartialFunction
-import akka.amqp.AMQP._
-
-abstract private[amqp] class FaultTolerantChannelActor(
- exchangeParameters: Option[ExchangeParameters], channelParameters: Option[ChannelParameters]) extends Actor {
- protected[amqp] var channel: Option[Channel] = None
- log.info("%s is started", toString)
-
- override def receive = channelMessageHandler orElse specificMessageHandler
-
- // to be defined in subclassing actor
- def specificMessageHandler: PartialFunction[Any, Unit]
-
- private def channelMessageHandler: PartialFunction[Any, Unit] = {
- case Start =>
- // ask the connection for a new channel
- self.supervisor.foreach {
- sup =>
- log.info("%s is requesting new channel from supervising connection", toString)
- val newChannel: Option[Option[Channel]] = (sup !! ChannelRequest).as[Option[Channel]]
- newChannel.foreach(ch => ch.foreach(c => setupChannelInternal(c)))
- }
- case ch: Channel => {
- setupChannelInternal(ch)
- }
- case ChannelShutdown(cause) => {
- closeChannel
- if (cause.isHardError) {
- // connection error
- if (cause.isInitiatedByApplication) {
- log.info("%s got normal shutdown", toString)
- } else {
- log.error(cause, "%s got hard error", toString)
- }
- } else {
- // channel error
- log.error(cause, "%s self restarting because of channel shutdown", toString)
- notifyCallback(Restarting)
- self ! Start
- }
- }
- case Failure(cause) =>
- log.error(cause, "%s self restarting because of channel failure", toString)
- closeChannel
- notifyCallback(Restarting)
- self ! Start
- }
-
- // to be defined in subclassing actor
- protected def setupChannel(ch: Channel)
-
- private def setupChannelInternal(ch: Channel) = if (channel.isEmpty) {
-
- exchangeParameters.foreach {
- params =>
- import params._
- exchangeDeclaration match {
- case PassiveDeclaration => ch.exchangeDeclarePassive(exchangeName)
- case ActiveDeclaration(durable, autoDelete, _) =>
- ch.exchangeDeclare(exchangeName, exchangeType.toString, durable, autoDelete, JavaConversions.asJavaMap(configurationArguments))
- case NoActionDeclaration => // ignore
- }
- }
- ch.addShutdownListener(new ShutdownListener {
- def shutdownCompleted(cause: ShutdownSignalException) = {
- self ! ChannelShutdown(cause)
- }
- })
- channelParameters.foreach(_.shutdownListener.foreach(sdl => ch.getConnection.addShutdownListener(sdl)))
-
- setupChannel(ch)
- channel = Some(ch)
- notifyCallback(Started)
- log.info("Channel setup for %s", toString)
- }
-
- private def closeChannel = {
- channel.foreach {
- ch =>
- if (ch.isOpen) ch.close
- notifyCallback(Stopped)
- log.info("%s channel closed", toString)
- }
- channel = None
- }
-
- private def notifyCallback(message: AMQPMessage) = {
- channelParameters.foreach(_.channelCallback.foreach(cb => if (cb.isRunning) cb ! message))
- }
-
- override def preRestart(reason: Throwable) = {
- notifyCallback(Restarting)
- closeChannel
- }
-
- override def postStop = closeChannel
-}
diff --git a/akka-amqp/src/main/scala/akka/amqp/FaultTolerantConnectionActor.scala b/akka-amqp/src/main/scala/akka/amqp/FaultTolerantConnectionActor.scala
deleted file mode 100644
index b202e84b18..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/FaultTolerantConnectionActor.scala
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import java.util.{TimerTask, Timer}
-import java.io.IOException
-import com.rabbitmq.client._
-import akka.amqp.AMQP.ConnectionParameters
-import akka.config.Supervision.{ Permanent, OneForOneStrategy }
-import akka.actor.{Exit, Actor}
-
-private[amqp] class FaultTolerantConnectionActor(connectionParameters: ConnectionParameters) extends Actor {
- import connectionParameters._
-
- self.id = "amqp-connection-%s".format(host)
- self.lifeCycle = Permanent
- self.faultHandler = OneForOneStrategy(List(classOf[Throwable]))
-
- val reconnectionTimer = new Timer("%s-timer".format(self.id))
-
- val connectionFactory: ConnectionFactory = new ConnectionFactory()
- connectionFactory.setHost(host)
- connectionFactory.setPort(port)
- connectionFactory.setUsername(username)
- connectionFactory.setPassword(password)
- connectionFactory.setVirtualHost(virtualHost)
-
- var connection: Option[Connection] = None
-
- protected def receive = {
- case Connect => connect
- case ChannelRequest => {
- connection match {
- case Some(conn) => {
- val chanel: Channel = conn.createChannel
- self.reply(Some(chanel))
- }
- case None => {
- log.warning("Unable to create new channel - no connection")
- self.reply(None)
- }
- }
- }
- case ConnectionShutdown(cause) => {
- if (cause.isHardError) {
- // connection error
- if (cause.isInitiatedByApplication) {
- log.info("ConnectionShutdown by application [%s]", self.id)
- } else {
- log.error(cause, "ConnectionShutdown is hard error - self terminating")
- self ! new Exit(self, cause)
- }
- }
- }
- }
-
- private def connect = if (connection.isEmpty || !connection.get.isOpen) {
- try {
- connection = Some(connectionFactory.newConnection)
- connection.foreach {
- conn =>
- conn.addShutdownListener(new ShutdownListener {
- def shutdownCompleted(cause: ShutdownSignalException) = {
- self ! ConnectionShutdown(cause)
- }
- })
- log.info("Successfully (re)connected to AMQP Server %s:%s [%s]", host, port, self.id)
- log.debug("Sending new channel to %d already linked actors", self.linkedActors.size)
- import scala.collection.JavaConversions._
- self.linkedActors.values.iterator.foreach(_ ! conn.createChannel)
- notifyCallback(Connected)
- }
- } catch {
- case e: Exception =>
- connection = None
- log.info("Trying to connect to AMQP server in %d milliseconds [%s]"
- , connectionParameters.initReconnectDelay, self.id)
- reconnectionTimer.schedule(new TimerTask() {
- override def run = {
- notifyCallback(Reconnecting)
- self ! Connect
- }
- }, connectionParameters.initReconnectDelay)
- }
- }
-
- private def disconnect = {
- try {
- connection.foreach(_.close)
- log.debug("Disconnected AMQP connection at %s:%s [%s]", host, port, self.id)
- notifyCallback(Disconnected)
- } catch {
- case e: IOException => log.error("Could not close AMQP connection %s:%s [%s]", host, port, self.id)
- case _ => ()
- }
- connection = None
- }
-
- private def notifyCallback(message: AMQPMessage) = {
- connectionCallback.foreach(cb => if (cb.isRunning) cb ! message)
- }
-
- override def postStop = {
- reconnectionTimer.cancel
- // make sure postStop is called on all linked actors so they can do channel cleanup before connection is killed
- self.shutdownLinkedActors
- disconnect
- }
-
- override def preRestart(reason: Throwable) = disconnect
-
- override def postRestart(reason: Throwable) = {
- notifyCallback(Reconnecting)
- connect
- }
-}
diff --git a/akka-amqp/src/main/scala/akka/amqp/ProducerActor.scala b/akka-amqp/src/main/scala/akka/amqp/ProducerActor.scala
deleted file mode 100644
index 8aabd26649..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/ProducerActor.scala
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import com.rabbitmq.client._
-
-import akka.amqp.AMQP.ProducerParameters
-
-private[amqp] class ProducerActor(producerParameters: ProducerParameters)
- extends FaultTolerantChannelActor(
- producerParameters.exchangeParameters, producerParameters.channelParameters) {
-
- import producerParameters._
-
- val exchangeName = exchangeParameters.flatMap(params => Some(params.exchangeName))
-
- producerId.foreach(id => self.id = id)
-
- def specificMessageHandler = {
-
- case message@Message(payload, routingKey, mandatory, immediate, properties) if channel.isDefined => {
- log.debug("Sending message [%s]", message)
- channel.foreach(_.basicPublish(exchangeName.getOrElse(""), routingKey, mandatory, immediate, properties.getOrElse(null), payload))
- }
- case message@Message(payload, routingKey, mandatory, immediate, properties) => {
- log.warning("Unable to send message [%s]", message)
- // FIXME: If channel is not available, messages should be queued back into the actor mailbox and actor should only react on 'Start'
- }
- }
-
- protected def setupChannel(ch: Channel) {
- returnListener match {
- case Some(listener) => ch.setReturnListener(listener)
- case None => ch.setReturnListener(new ReturnListener() {
- def handleBasicReturn(
- replyCode: Int,
- replyText: String,
- exchange: String,
- routingKey: String,
- properties: com.rabbitmq.client.AMQP.BasicProperties,
- body: Array[Byte]) = {
- throw new MessageNotDeliveredException(
- "Could not deliver message [" + body +
- "] with reply code [" + replyCode +
- "] with reply text [" + replyText +
- "] and routing key [" + routingKey +
- "] to exchange [" + exchange + "]",
- replyCode, replyText, exchange, routingKey, properties, body)
- }
- })
- }
- }
-
- override def toString =
- "AMQP.Poducer[id= "+ self.id +
- ", exchangeParameters=" + exchangeParameters + "]"
-}
-
diff --git a/akka-amqp/src/main/scala/akka/amqp/rpc/RPC.scala b/akka-amqp/src/main/scala/akka/amqp/rpc/RPC.scala
deleted file mode 100644
index 8ce746735a..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/rpc/RPC.scala
+++ /dev/null
@@ -1,324 +0,0 @@
-package akka.amqp.rpc
-
-import akka.amqp.AMQP._
-import com.google.protobuf.Message
-import akka.actor.{Actor, ActorRef}
-import Actor._
-import akka.amqp._
-import reflect.Manifest
-import akka.japi
-
-object RPC {
-
- // Needed for Java API usage
- def newRpcClient[O, I](connection: ActorRef,
- exchangeName: String,
- routingKey: String,
- serializer: RpcClientSerializer[O, I]): RpcClient[O,I] = {
- newRpcClient(connection, exchangeName, serializer, Some(routingKey), None)
- }
-
- // Needed for Java API usage
- def newRpcClient[O, I](connection: ActorRef,
- exchangeName: String,
- routingKey: String,
- serializer: RpcClientSerializer[O, I],
- channelParameters: ChannelParameters): RpcClient[O,I] = {
- newRpcClient(connection, exchangeName, serializer, Some(routingKey), Some(channelParameters))
- }
-
- def newRpcClient[O, I](connection: ActorRef,
- exchangeName: String,
- serializer: RpcClientSerializer[O, I],
- routingKey: Option[String] = None,
- channelParameters: Option[ChannelParameters] = None): RpcClient[O,I] = {
-
- val rKey = routingKey.getOrElse("%s.request".format(exchangeName))
-
- val rpcActor: ActorRef = actorOf(new RpcClientActor[O, I](
- ExchangeParameters(exchangeName, exchangeDeclaration = PassiveDeclaration), rKey, serializer, channelParameters))
- connection.startLink(rpcActor)
- rpcActor ! Start
- rpcActor
- new RpcClient(rpcActor)
- }
-
- // Needed for Java API usage
- def newRpcServer[I, O](connection: ActorRef,
- exchangeName: String,
- serializer: RpcServerSerializer[I, O],
- requestHandler: japi.Function[I,O],
- routingKey: String): RpcServerHandle = {
- newRpcServer(connection, exchangeName, serializer, requestHandler.apply _, Some(routingKey))
- }
-
- // Needed for Java API usage
- def newRpcServer[I, O](connection: ActorRef,
- exchangeName: String,
- serializer: RpcServerSerializer[I, O],
- requestHandler: Function[I,O],
- routingKey: String,
- queueName: String): RpcServerHandle = {
- newRpcServer(connection, exchangeName, serializer, requestHandler.apply _, Some(routingKey), Some(queueName))
- }
-
- // Needed for Java API usage
- def newRpcServer[I, O](connection: ActorRef,
- exchangeName: String,
- serializer: RpcServerSerializer[I, O],
- requestHandler: japi.Function[I,O],
- routingKey: String,
- channelParameters: ChannelParameters): RpcServerHandle = {
- newRpcServer(connection, exchangeName, serializer, requestHandler.apply _, Some(routingKey), None, Some(channelParameters))
- }
-
- // Needed for Java API usage
- def newRpcServer[I, O](connection: ActorRef,
- exchangeName: String,
- serializer: RpcServerSerializer[I, O],
- requestHandler: japi.Function[I,O],
- routingKey: String,
- queueName: String,
- channelParameters: ChannelParameters): RpcServerHandle = {
- newRpcServer(connection, exchangeName, serializer, requestHandler.apply _, Some(routingKey), Some(queueName), Some(channelParameters))
- }
-
- def newRpcServer[I, O](connection: ActorRef,
- exchangeName: String,
- serializer: RpcServerSerializer[I, O],
- requestHandler: I => O,
- routingKey: Option[String] = None,
- queueName: Option[String] = None,
- channelParameters: Option[ChannelParameters] = None,
- poolSize: Int = 1): RpcServerHandle = {
-
- val rKey = routingKey.getOrElse("%s.request".format(exchangeName))
- val qName = queueName.getOrElse("%s.in".format(rKey))
-
- val producer = newProducer(connection, ProducerParameters(channelParameters = channelParameters))
-
- val consumers = (1 to poolSize).map {
- num =>
- val rpcServer = actorOf(new RpcServerActor[I, O](producer, serializer, requestHandler))
- newConsumer(connection, ConsumerParameters(rKey, rpcServer,
- exchangeParameters = Some(ExchangeParameters(exchangeName)), channelParameters = channelParameters,
- selfAcknowledging = false, queueName = Some(qName)))
- }
- RpcServerHandle(producer, consumers)
- }
-
- case class RpcServerHandle(producer: ActorRef, consumers: Seq[ActorRef]) {
- def stop = {
- consumers.foreach(_.stop)
- producer.stop
- }
- }
-
- case class RpcClientSerializer[O, I](toBinary: ToBinary[O], fromBinary: FromBinary[I])
-
- case class RpcServerSerializer[I, O](fromBinary: FromBinary[I], toBinary: ToBinary[O])
-
-
- /**
- * RPC convenience
- */
- class RpcClient[O, I](client: ActorRef){
-
- // Needed for Java API usage
- def call(request: O): Option[I] = {
- call(request, 5000)
- }
-
- def call(request: O, timeout: Long = 5000): Option[I] = {
- (client.!!(request, timeout)).as[I]
- }
-
- // Needed for Java API usage
- def callAsync(request: O, responseHandler: japi.Procedure[I]): Unit = {
- callAsync(request, 5000, responseHandler)
- }
-
- // Needed for Java API usage
- def callAsync(request: O, timeout: Long, responseHandler: japi.Procedure[I]): Unit = {
- callAsync(request, timeout){
- case Some(response) => responseHandler.apply(response)
- }
- }
-
- def callAsync(request: O, timeout: Long = 5000)(responseHandler: PartialFunction[Option[I],Unit]) = {
- spawn {
- val result = call(request, timeout)
- responseHandler.apply(result)
- }
- }
- def stop = client.stop
- }
-
-
- // Needed for Java API usage
- def newProtobufRpcServer[I <: Message, O <: Message](
- connection: ActorRef,
- exchangeName: String,
- requestHandler: japi.Function[I,O],
- resultClazz: Class[I]): RpcServerHandle = {
-
- implicit val manifest = Manifest.classType[I](resultClazz)
- newProtobufRpcServer(connection, exchangeName, requestHandler.apply _)
- }
-
- // Needed for Java API usage
- def newProtobufRpcServer[I <: Message, O <: Message](
- connection: ActorRef,
- exchangeName: String,
- requestHandler: japi.Function[I,O],
- routingKey: String,
- resultClazz: Class[I]): RpcServerHandle = {
-
- implicit val manifest = Manifest.classType[I](resultClazz)
- newProtobufRpcServer(connection, exchangeName, requestHandler.apply _, Some(routingKey))
- }
-
- // Needed for Java API usage
- def newProtobufRpcServer[I <: Message, O <: Message](
- connection: ActorRef,
- exchangeName: String,
- requestHandler: japi.Function[I,O],
- routingKey: String,
- queueName: String,
- resultClazz: Class[I]): RpcServerHandle = {
-
- implicit val manifest = Manifest.classType[I](resultClazz)
- newProtobufRpcServer(connection, exchangeName, requestHandler.apply _, Some(routingKey), Some(queueName))
- }
-
- def newProtobufRpcServer[I <: Message, O <: Message](
- connection: ActorRef,
- exchangeName: String,
- requestHandler: I => O,
- routingKey: Option[String] = None,
- queueName: Option[String] = None)(implicit manifest: Manifest[I]): RpcServerHandle = {
-
- val serializer = new RpcServerSerializer[I, O](
- new FromBinary[I] {
- def fromBinary(bytes: Array[Byte]): I = {
- createProtobufFromBytes[I](bytes)
- }
- }, new ToBinary[O] {
- def toBinary(t: O) = t.toByteArray
- })
-
- newRpcServer(connection, exchangeName, serializer, requestHandler, routingKey, queueName)
- }
-
- // Needed for Java API usage
- def newProtobufRpcClient[O <: Message, I <: Message](
- connection: ActorRef,
- exchangeName: String,
- resultClazz: Class[I]): RpcClient[O, I] = {
-
- implicit val manifest = Manifest.classType[I](resultClazz)
- newProtobufRpcClient(connection, exchangeName, None)
- }
-
- // Needed for Java API usage
- def newProtobufRpcClient[O <: Message, I <: Message](
- connection: ActorRef,
- exchangeName: String,
- routingKey: String,
- resultClazz: Class[I]): RpcClient[O, I] = {
-
- implicit val manifest = Manifest.classType[I](resultClazz)
- newProtobufRpcClient(connection, exchangeName, Some(routingKey))
- }
-
- def newProtobufRpcClient[O <: Message, I <: Message](
- connection: ActorRef,
- exchangeName: String,
- routingKey: Option[String] = None)(implicit manifest: Manifest[I]): RpcClient[O, I] = {
-
-
- val serializer = new RpcClientSerializer[O, I](
- new ToBinary[O] {
- def toBinary(t: O) = t.toByteArray
- }, new FromBinary[I] {
- def fromBinary(bytes: Array[Byte]): I = {
- createProtobufFromBytes[I](bytes)
- }
- })
-
- newRpcClient(connection, exchangeName, serializer, routingKey)
- }
-
- // Needed for Java API usage
- def newStringRpcServer(connection: ActorRef,
- exchangeName: String,
- requestHandler: japi.Function[String,String]): RpcServerHandle = {
- newStringRpcServer(connection, exchangeName, requestHandler.apply _)
- }
-
- // Needed for Java API usage
- def newStringRpcServer(connection: ActorRef,
- exchangeName: String,
- requestHandler: japi.Function[String,String],
- routingKey: String): RpcServerHandle = {
- newStringRpcServer(connection, exchangeName, requestHandler.apply _, Some(routingKey))
- }
-
- // Needed for Java API usage
- def newStringRpcServer(connection: ActorRef,
- exchangeName: String,
- requestHandler: japi.Function[String,String],
- routingKey: String,
- queueName: String): RpcServerHandle = {
- newStringRpcServer(connection, exchangeName, requestHandler.apply _, Some(routingKey), Some(queueName))
- }
-
- def newStringRpcServer(connection: ActorRef,
- exchangeName: String,
- requestHandler: String => String,
- routingKey: Option[String] = None,
- queueName: Option[String] = None): RpcServerHandle = {
-
- val serializer = new RpcServerSerializer[String, String](
- new FromBinary[String] {
- def fromBinary(bytes: Array[Byte]): String = {
- new String(bytes)
- }
- }, new ToBinary[String] {
- def toBinary(t: String) = t.getBytes
- })
-
- newRpcServer(connection, exchangeName, serializer, requestHandler, routingKey, queueName)
- }
-
- // Needed for Java API usage
- def newStringRpcClient(connection: ActorRef,
- exchange: String): RpcClient[String, String] = {
- newStringRpcClient(connection, exchange, None)
- }
-
- // Needed for Java API usage
- def newStringRpcClient(connection: ActorRef,
- exchange: String,
- routingKey: String): RpcClient[String, String] = {
- newStringRpcClient(connection, exchange, Some(routingKey))
- }
-
- def newStringRpcClient(connection: ActorRef,
- exchange: String,
- routingKey: Option[String] = None): RpcClient[String, String] = {
-
-
- val serializer = new RpcClientSerializer[String, String](
- new ToBinary[String] {
- def toBinary(t: String) = t.getBytes
- }, new FromBinary[String] {
- def fromBinary(bytes: Array[Byte]): String = {
- new String(bytes)
- }
- })
-
- newRpcClient(connection, exchange, serializer, routingKey)
- }
-}
-
diff --git a/akka-amqp/src/main/scala/akka/amqp/rpc/RpcClientActor.scala b/akka-amqp/src/main/scala/akka/amqp/rpc/RpcClientActor.scala
deleted file mode 100644
index cae8587fb1..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/rpc/RpcClientActor.scala
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import com.rabbitmq.client.{Channel, RpcClient}
-import rpc.RPC.RpcClientSerializer
-import akka.amqp.AMQP.{ChannelParameters, ExchangeParameters}
-
-class RpcClientActor[I,O](
- exchangeParameters: ExchangeParameters,
- routingKey: String,
- serializer: RpcClientSerializer[I,O],
- channelParameters: Option[ChannelParameters] = None)
- extends FaultTolerantChannelActor(Some(exchangeParameters), channelParameters) {
-
- import exchangeParameters._
-
- var rpcClient: Option[RpcClient] = None
-
- log.info("%s started", this)
-
- def specificMessageHandler = {
- case payload: I => {
- rpcClient match {
- case Some(client) =>
- val response: Array[Byte] = client.primitiveCall(serializer.toBinary.toBinary(payload))
- self.reply(serializer.fromBinary.fromBinary(response))
- case None => error("%s has no client to send messages with".format(this))
- }
- }
- }
-
- protected def setupChannel(ch: Channel) = rpcClient = Some(new RpcClient(ch, exchangeName, routingKey))
-
- override def preRestart(reason: Throwable) = {
- rpcClient = None
- super.preRestart(reason)
- }
-
-
- override def postStop = {
- rpcClient.foreach(rpc => rpc.close)
- super.postStop
- }
-
- override def toString = "AMQP.RpcClient[exchange=" +exchangeName + ", routingKey=" + routingKey+ "]"
-}
diff --git a/akka-amqp/src/main/scala/akka/amqp/rpc/RpcServerActor.scala b/akka-amqp/src/main/scala/akka/amqp/rpc/RpcServerActor.scala
deleted file mode 100644
index 2459cde290..0000000000
--- a/akka-amqp/src/main/scala/akka/amqp/rpc/RpcServerActor.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp
-
-import rpc.RPC.RpcServerSerializer
-import akka.actor.{ActorRef, Actor}
-import com.rabbitmq.client.AMQP.BasicProperties
-
-class RpcServerActor[I,O](
- producer: ActorRef,
- serializer: RpcServerSerializer[I,O],
- requestHandler: I => O) extends Actor {
-
- log.info("%s started", this)
-
- protected def receive = {
- case Delivery(payload, _, tag, _, props, sender) => {
-
- log.debug("%s handling delivery with tag %d", this, tag)
- val request = serializer.fromBinary.fromBinary(payload)
- val response: Array[Byte] = serializer.toBinary.toBinary(requestHandler(request))
-
- log.debug("%s sending reply to %s", this, props.getReplyTo)
- val replyProps = new BasicProperties
- replyProps.setCorrelationId(props.getCorrelationId)
- producer ! new Message(response, props.getReplyTo, properties = Some(replyProps))
-
- sender.foreach(_ ! Acknowledge(tag))
- }
- case Acknowledged(tag) => log.debug("%s acknowledged delivery with tag %d", this, tag)
- }
-
- override def toString = "AMQP.RpcServer[]"
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConnectionRecoveryTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPConnectionRecoveryTestIntegration.scala
deleted file mode 100644
index 64f6c99040..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConnectionRecoveryTestIntegration.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import java.util.concurrent.TimeUnit
-import akka.actor.{Actor, ActorRef}
-import org.multiverse.api.latches.StandardLatch
-import com.rabbitmq.client.ShutdownSignalException
-import akka.amqp._
-import akka.amqp.AMQP.ConnectionParameters
-import org.scalatest.matchers.MustMatchers
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-
-class AMQPConnectionRecoveryTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def connectionAndRecovery = AMQPTest.withCleanEndState {
-
- val connectedLatch = new StandardLatch
- val reconnectingLatch = new StandardLatch
- val reconnectedLatch = new StandardLatch
- val disconnectedLatch = new StandardLatch
-
- val connectionCallback: ActorRef = Actor.actorOf( new Actor {
- def receive = {
- case Connected =>
- if (!connectedLatch.isOpen) {
- connectedLatch.open
- } else {
- reconnectedLatch.open
- }
- case Reconnecting => reconnectingLatch.open
- case Disconnected => disconnectedLatch.open
- }
- }).start
-
- val connection = AMQP.newConnection(ConnectionParameters(initReconnectDelay = 50, connectionCallback = Some(connectionCallback)))
- try {
- connectedLatch.tryAwait(2, TimeUnit.SECONDS) must be(true)
-
- connection ! new ConnectionShutdown(new ShutdownSignalException(true, false, "TestException", "TestRef"))
- reconnectingLatch.tryAwait(2, TimeUnit.SECONDS) must be(true)
- reconnectedLatch.tryAwait(2, TimeUnit.SECONDS) must be(true)
-
- } finally {
- AMQP.shutdownAll
- disconnectedLatch.tryAwait(2, TimeUnit.SECONDS) must be(true)
- }
- }
-
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerChannelRecoveryTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerChannelRecoveryTestIntegration.scala
deleted file mode 100644
index eace56114f..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerChannelRecoveryTestIntegration.scala
+++ /dev/null
@@ -1,65 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import org.multiverse.api.latches.StandardLatch
-import com.rabbitmq.client.ShutdownSignalException
-import akka.amqp._
-import org.scalatest.matchers.MustMatchers
-import java.util.concurrent.TimeUnit
-import org.junit.Test
-import akka.amqp.AMQP._
-import org.scalatest.junit.JUnitSuite
-import akka.actor.Actor._
-import akka.actor.{Actor, ActorRef}
-
-class AMQPConsumerChannelRecoveryTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerChannelRecovery = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection(ConnectionParameters(initReconnectDelay = 50))
- try {
- val producer = AMQP.newProducer(connection, ProducerParameters(
- Some(ExchangeParameters("text_exchange"))))
-
- val consumerStartedLatch = new StandardLatch
- val consumerRestartedLatch = new StandardLatch
- val consumerChannelCallback: ActorRef = actorOf( new Actor {
- def receive = {
- case Started => {
- if (!consumerStartedLatch.isOpen) {
- consumerStartedLatch.open
- } else {
- consumerRestartedLatch.open
- }
- }
- case Restarting => ()
- case Stopped => ()
- }
- }).start
-
- val payloadLatch = new StandardLatch
- val consumerExchangeParameters = ExchangeParameters("text_exchange")
- val consumerChannelParameters = ChannelParameters(channelCallback = Some(consumerChannelCallback))
- val consumer = AMQP.newConsumer(connection, ConsumerParameters("non.interesting.routing.key", actorOf( new Actor {
- def receive = { case Delivery(payload, _, _, _, _, _) => payloadLatch.open }
- }),
- exchangeParameters = Some(consumerExchangeParameters), channelParameters = Some(consumerChannelParameters)))
- consumerStartedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
-
- val listenerLatch = new StandardLatch
-
- consumer ! new ChannelShutdown(new ShutdownSignalException(false, false, "TestException", "TestRef"))
-
- consumerRestartedLatch.tryAwait(4, TimeUnit.SECONDS) must be (true)
-
- producer ! Message("some_payload".getBytes, "non.interesting.routing.key")
- payloadLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- } finally {
- connection.stop
- }
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerConnectionRecoveryTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerConnectionRecoveryTestIntegration.scala
deleted file mode 100644
index 52769db007..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerConnectionRecoveryTestIntegration.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import org.multiverse.api.latches.StandardLatch
-import com.rabbitmq.client.ShutdownSignalException
-import akka.amqp._
-import org.scalatest.matchers.MustMatchers
-import java.util.concurrent.TimeUnit
-import org.junit.Test
-import akka.amqp.AMQP._
-import org.scalatest.junit.JUnitSuite
-import akka.actor.{Actor, ActorRef}
-import Actor._
-
-class AMQPConsumerConnectionRecoveryTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerConnectionRecovery = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection(ConnectionParameters(initReconnectDelay = 50))
- try {
- val producerStartedLatch = new StandardLatch
- val producerRestartedLatch = new StandardLatch
- val producerChannelCallback: ActorRef = actorOf( new Actor {
- def receive = {
- case Started => {
- if (!producerStartedLatch.isOpen) {
- producerStartedLatch.open
- } else {
- producerRestartedLatch.open
- }
- }
- case Restarting => ()
- case Stopped => ()
- }
- }).start
-
- val channelParameters = ChannelParameters(channelCallback = Some(producerChannelCallback))
- val producer = AMQP.newProducer(connection, ProducerParameters(
- Some(ExchangeParameters("text_exchange")), channelParameters = Some(channelParameters)))
- producerStartedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
-
-
- val consumerStartedLatch = new StandardLatch
- val consumerRestartedLatch = new StandardLatch
- val consumerChannelCallback: ActorRef = actorOf( new Actor {
- def receive = {
- case Started => {
- if (!consumerStartedLatch.isOpen) {
- consumerStartedLatch.open
- } else {
- consumerRestartedLatch.open
- }
- }
- case Restarting => ()
- case Stopped => ()
- }
- }).start
-
-
- val payloadLatch = new StandardLatch
- val consumerExchangeParameters = ExchangeParameters("text_exchange")
- val consumerChannelParameters = ChannelParameters(channelCallback = Some(consumerChannelCallback))
- val consumer = AMQP.newConsumer(connection, ConsumerParameters("non.interesting.routing.key", actorOf( new Actor {
- def receive = { case Delivery(payload, _, _, _, _, _) => payloadLatch.open }
- }), exchangeParameters = Some(consumerExchangeParameters), channelParameters = Some(consumerChannelParameters)))
-
- consumerStartedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
-
- val listenerLatch = new StandardLatch
-
- connection ! new ConnectionShutdown(new ShutdownSignalException(true, false, "TestException", "TestRef"))
-
- producerRestartedLatch.tryAwait(4, TimeUnit.SECONDS) must be (true)
- consumerRestartedLatch.tryAwait(4, TimeUnit.SECONDS) must be (true)
-
- producer ! Message("some_payload".getBytes, "non.interesting.routing.key")
- payloadLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- } finally {
- connection.stop
- }
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerManualAcknowledgeTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerManualAcknowledgeTestIntegration.scala
deleted file mode 100644
index 3f3bf0539b..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerManualAcknowledgeTestIntegration.scala
+++ /dev/null
@@ -1,65 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import akka.actor.Actor._
-import org.scalatest.matchers.MustMatchers
-import akka.amqp._
-import org.junit.Test
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-import org.multiverse.api.latches.StandardLatch
-import org.scalatest.junit.JUnitSuite
-import akka.amqp.AMQP._
-import akka.actor.{Actor, ActorRef}
-
-class AMQPConsumerManualAcknowledgeTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessageManualAcknowledge = AMQPTest.withCleanEndState {
- val connection = AMQP.newConnection()
- try {
- val countDown = new CountDownLatch(2)
- val channelCallback = actorOf( new Actor {
- def receive = {
- case Started => countDown.countDown
- case Restarting => ()
- case Stopped => ()
- }
- }).start
- val exchangeParameters = ExchangeParameters("text_exchange")
- val channelParameters = ChannelParameters(channelCallback = Some(channelCallback))
-
- val failLatch = new StandardLatch
- val acknowledgeLatch = new StandardLatch
- var deliveryTagCheck: Long = -1
- val consumer:ActorRef = AMQP.newConsumer(connection, ConsumerParameters("manual.ack.this", actorOf( new Actor {
- def receive = {
- case Delivery(payload, _, deliveryTag, _, _, sender) => {
- if (!failLatch.isOpen) {
- failLatch.open
- error("Make it fail!")
- } else {
- deliveryTagCheck = deliveryTag
- sender.foreach(_ ! Acknowledge(deliveryTag))
- }
- }
- case Acknowledged(deliveryTag) => if (deliveryTagCheck == deliveryTag) acknowledgeLatch.open
- }
- }), queueName = Some("self.ack.queue"), exchangeParameters = Some(exchangeParameters),
- selfAcknowledging = false, channelParameters = Some(channelParameters),
- queueDeclaration = ActiveDeclaration(autoDelete = false)))
-
- val producer = AMQP.newProducer(connection,
- ProducerParameters(Some(exchangeParameters), channelParameters = Some(channelParameters)))
-
- countDown.await(2, TimeUnit.SECONDS) must be (true)
- producer ! Message("some_payload".getBytes, "manual.ack.this")
-
- acknowledgeLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- } finally {
- connection.stop
- }
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerManualRejectTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerManualRejectTestIntegration.scala
deleted file mode 100644
index 4ba4c27971..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerManualRejectTestIntegration.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import akka.actor.Actor._
-import org.scalatest.matchers.MustMatchers
-import akka.amqp._
-import org.junit.Test
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-import akka.amqp.AMQP.{ExchangeParameters, ConsumerParameters, ChannelParameters, ProducerParameters}
-import org.multiverse.api.latches.StandardLatch
-import org.scalatest.junit.JUnitSuite
-import akka.actor.{Actor, ActorRef}
-
-class AMQPConsumerManualRejectTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessageManualAcknowledge = AMQPTest.withCleanEndState {
- val connection = AMQP.newConnection()
- try {
- val countDown = new CountDownLatch(2)
- val restartingLatch = new StandardLatch
- val channelCallback = actorOf(new Actor {
- def receive = {
- case Started => countDown.countDown
- case Restarting => restartingLatch.open
- case Stopped => ()
- }
- }).start
- val exchangeParameters = ExchangeParameters("text_exchange")
- val channelParameters = ChannelParameters(channelCallback = Some(channelCallback))
-
- val rejectedLatch = new StandardLatch
- val consumer:ActorRef = AMQP.newConsumer(connection, ConsumerParameters("manual.reject.this", actorOf( new Actor {
- def receive = {
- case Delivery(payload, _, deliveryTag, _, _, sender) => sender.foreach(_ ! Reject(deliveryTag))
- case Rejected(deliveryTag) => rejectedLatch.open
- }
- }), queueName = Some("self.reject.queue"), exchangeParameters = Some(exchangeParameters),
- selfAcknowledging = false, channelParameters = Some(channelParameters)))
-
- val producer = AMQP.newProducer(connection,
- ProducerParameters(Some(exchangeParameters), channelParameters = Some(channelParameters)))
-
- countDown.await(2, TimeUnit.SECONDS) must be (true)
- producer ! Message("some_payload".getBytes, "manual.reject.this")
-
- rejectedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- restartingLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- } finally {
- connection.stop
- }
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerMessageTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerMessageTestIntegration.scala
deleted file mode 100644
index 0a9613d21f..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerMessageTestIntegration.scala
+++ /dev/null
@@ -1,46 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import akka.amqp._
-import org.multiverse.api.latches.StandardLatch
-import akka.actor.Actor._
-import org.scalatest.matchers.MustMatchers
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-import akka.amqp.AMQP.{ExchangeParameters, ConsumerParameters, ChannelParameters, ProducerParameters}
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-import akka.actor.Actor
-
-class AMQPConsumerMessageTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessage = AMQPTest.withCleanEndState {
- val connection = AMQP.newConnection()
- val countDown = new CountDownLatch(2)
- val channelCallback = actorOf(new Actor {
- def receive = {
- case Started => countDown.countDown
- case Restarting => ()
- case Stopped => ()
- }
- }).start
-
- val exchangeParameters = ExchangeParameters("text_exchange")
- val channelParameters = ChannelParameters(channelCallback = Some(channelCallback))
-
- val payloadLatch = new StandardLatch
- val consumer = AMQP.newConsumer(connection, ConsumerParameters("non.interesting.routing.key", actorOf(new Actor {
- def receive = { case Delivery(payload, _, _, _, _, _) => payloadLatch.open }
- }), exchangeParameters = Some(exchangeParameters), channelParameters = Some(channelParameters)))
-
- val producer = AMQP.newProducer(connection,
- ProducerParameters(Some(exchangeParameters), channelParameters = Some(channelParameters)))
-
- countDown.await(2, TimeUnit.SECONDS) must be (true)
- producer ! Message("some_payload".getBytes, "non.interesting.routing.key")
- payloadLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerPrivateQueueTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerPrivateQueueTestIntegration.scala
deleted file mode 100644
index 6b03b6ded8..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPConsumerPrivateQueueTestIntegration.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import akka.amqp._
-import org.multiverse.api.latches.StandardLatch
-import akka.actor.Actor._
-import org.scalatest.matchers.MustMatchers
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-import akka.amqp.AMQP.{ConsumerParameters, ChannelParameters, ProducerParameters}
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-import akka.actor.Actor
-
-class AMQPConsumerPrivateQueueTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessage = AMQPTest.withCleanEndState {
- val connection = AMQP.newConnection()
- val countDown = new CountDownLatch(2)
- val channelCallback = actorOf(new Actor {
- def receive = {
- case Started => countDown.countDown
- case Restarting => ()
- case Stopped => ()
- }
- }).start
-
- val channelParameters = ChannelParameters(channelCallback = Some(channelCallback))
-
- val payloadLatch = new StandardLatch
- val consumer = AMQP.newConsumer(connection, ConsumerParameters("my.private.routing.key", actorOf(new Actor {
- def receive = { case Delivery(payload, _, _, _, _, _) => payloadLatch.open }
- }), channelParameters = Some(channelParameters)))
-
- val producer = AMQP.newProducer(connection,
- ProducerParameters(channelParameters = Some(channelParameters)))
-
- countDown.await(2, TimeUnit.SECONDS) must be (true)
- producer ! Message("some_payload".getBytes, "my.private.routing.key")
- payloadLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- }
-}
\ No newline at end of file
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerChannelRecoveryTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerChannelRecoveryTestIntegration.scala
deleted file mode 100644
index 4b64f946e0..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerChannelRecoveryTestIntegration.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import java.util.concurrent.TimeUnit
-import akka.actor.{Actor, ActorRef}
-import org.multiverse.api.latches.StandardLatch
-import com.rabbitmq.client.ShutdownSignalException
-import akka.amqp._
-import org.scalatest.matchers.MustMatchers
-import akka.amqp.AMQP.{ExchangeParameters, ChannelParameters, ProducerParameters, ConnectionParameters}
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-
-class AMQPProducerChannelRecoveryTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def producerChannelRecovery = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection(ConnectionParameters(initReconnectDelay = 50))
-
- try {
- val startedLatch = new StandardLatch
- val restartingLatch = new StandardLatch
- val restartedLatch = new StandardLatch
-
- val producerCallback: ActorRef = Actor.actorOf( new Actor {
- def receive = {
- case Started => {
- if (!startedLatch.isOpen) {
- startedLatch.open
- } else {
- restartedLatch.open
- }
- }
- case Restarting => restartingLatch.open
- case Stopped => ()
- }
- }).start
-
- val channelParameters = ChannelParameters(channelCallback = Some(producerCallback))
- val producerParameters = ProducerParameters(
- Some(ExchangeParameters("text_exchange")), channelParameters = Some(channelParameters))
-
- val producer = AMQP.newProducer(connection, producerParameters)
- startedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
-
- producer ! new ChannelShutdown(new ShutdownSignalException(false, false, "TestException", "TestRef"))
- restartingLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- restartedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- } finally {
- connection.stop
- }
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerConnectionRecoveryTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerConnectionRecoveryTestIntegration.scala
deleted file mode 100644
index 00ac02e1c4..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerConnectionRecoveryTestIntegration.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import java.util.concurrent.TimeUnit
-import akka.actor.{Actor, ActorRef}
-import org.multiverse.api.latches.StandardLatch
-import com.rabbitmq.client.ShutdownSignalException
-import akka.amqp._
-import org.scalatest.matchers.MustMatchers
-import akka.amqp.AMQP.{ExchangeParameters, ChannelParameters, ProducerParameters, ConnectionParameters}
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-
-class AMQPProducerConnectionRecoveryTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def producerConnectionRecovery = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection(ConnectionParameters(initReconnectDelay = 50))
- try {
- val startedLatch = new StandardLatch
- val restartingLatch = new StandardLatch
- val restartedLatch = new StandardLatch
-
- val producerCallback: ActorRef = Actor.actorOf(new Actor{
- def receive = {
- case Started => {
- if (!startedLatch.isOpen) {
- startedLatch.open
- } else {
- restartedLatch.open
- }
- }
- case Restarting => restartingLatch.open
- case Stopped => ()
- }
- }).start
-
- val channelParameters = ChannelParameters(channelCallback = Some(producerCallback))
- val producerParameters = ProducerParameters(
- Some(ExchangeParameters("text_exchange")), channelParameters = Some(channelParameters))
-
- val producer = AMQP.newProducer(connection, producerParameters)
- startedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
-
- connection ! new ConnectionShutdown(new ShutdownSignalException(true, false, "TestException", "TestRef"))
- restartingLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- restartedLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- } finally {
- connection.stop
- }
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerMessageTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerMessageTestIntegration.scala
deleted file mode 100644
index 037af3e179..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProducerMessageTestIntegration.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import java.util.concurrent.TimeUnit
-import akka.actor.ActorRef
-import org.multiverse.api.latches.StandardLatch
-import akka.amqp._
-import com.rabbitmq.client.ReturnListener
-import com.rabbitmq.client.AMQP.BasicProperties
-import java.lang.String
-import org.scalatest.matchers.MustMatchers
-import akka.amqp.AMQP.{ExchangeParameters, ProducerParameters}
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-
-class AMQPProducerMessageTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def producerMessage = AMQPTest.withCleanEndState {
-
- val connection: ActorRef = AMQP.newConnection()
- try {
- val returnLatch = new StandardLatch
- val returnListener = new ReturnListener {
- def handleBasicReturn(replyCode: Int, replyText: String, exchange: String, routingKey: String, properties: BasicProperties, body: Array[Byte]) = {
- returnLatch.open
- }
- }
- val producerParameters = ProducerParameters(
- Some(ExchangeParameters("text_exchange")), returnListener = Some(returnListener))
-
- val producer = AMQP.newProducer(connection, producerParameters)
-
- producer ! new Message("some_payload".getBytes, "non.interesing.routing.key", mandatory = true)
- returnLatch.tryAwait(2, TimeUnit.SECONDS) must be(true)
- } finally {
- connection.stop
- }
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProtobufProducerConsumerTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPProtobufProducerConsumerTestIntegration.scala
deleted file mode 100644
index 668db09c78..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPProtobufProducerConsumerTestIntegration.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-import org.scalatest.matchers.MustMatchers
-import org.scalatest.junit.JUnitSuite
-import akka.amqp.AMQP
-import org.junit.Test
-import org.multiverse.api.latches.StandardLatch
-import java.util.concurrent.TimeUnit
-import akka.amqp.rpc.RPC
-import akka.remote.protocol.RemoteProtocol.AddressProtocol
-
-class AMQPProtobufProducerConsumerTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessage = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection()
-
- val responseLatch = new StandardLatch
-
- RPC.newProtobufRpcServer(connection, "protoexchange", requestHandler)
-
- val request = AddressProtocol.newBuilder.setHostname("testhost").setPort(4321).build
-
- def responseHandler(response: AddressProtocol) = {
- assert(response.getHostname == request.getHostname.reverse)
- responseLatch.open
- }
- AMQP.newProtobufConsumer(connection, responseHandler _, None, Some("proto.reply.key"))
-
- val producer = AMQP.newProtobufProducer[AddressProtocol](connection, Some("protoexchange"))
- producer.send(request, Some("proto.reply.key"))
-
- responseLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- }
-
- def requestHandler(request: AddressProtocol): AddressProtocol = {
- AddressProtocol.newBuilder.setHostname(request.getHostname.reverse).setPort(request.getPort).build
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcClientServerTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcClientServerTestIntegration.scala
deleted file mode 100644
index 8ada12c423..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcClientServerTestIntegration.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-import akka.amqp._
-import rpc.RPC
-import rpc.RPC.{RpcClientSerializer, RpcServerSerializer}
-import akka.actor.Actor._
-import org.scalatest.matchers.MustMatchers
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-import akka.amqp.AMQP._
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-import akka.actor.Actor
-
-class AMQPRpcClientServerTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessage = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection()
-
- val countDown = new CountDownLatch(3)
- val channelCallback = actorOf( new Actor {
- def receive = {
- case Started => countDown.countDown
- case Restarting => ()
- case Stopped => ()
- }
- }).start
-
- val exchangeName = "text_topic_exchange"
- val channelParameters = ChannelParameters(channelCallback
- = Some(channelCallback))
-
- val rpcServerSerializer = new RpcServerSerializer[String, Int](
- new FromBinary[String] {
- def fromBinary(bytes: Array[Byte]) = new String(bytes)
- }, new ToBinary[Int] {
- def toBinary(t: Int) = Array(t.toByte)
- })
-
- def requestHandler(request: String) = 3
-
- val rpcServer = RPC.newRpcServer[String, Int](connection, exchangeName, rpcServerSerializer,
- requestHandler _, Some("rpc.routing"), channelParameters = Some(channelParameters))
-
- val rpcClientSerializer = new RpcClientSerializer[String, Int](
- new ToBinary[String] {
- def toBinary(t: String) = t.getBytes
- }, new FromBinary[Int] {
- def fromBinary(bytes: Array[Byte]) = bytes.head.toInt
- })
-
- val rpcClient = RPC.newRpcClient[String, Int](connection, exchangeName, rpcClientSerializer, Some("rpc.routing"),
- channelParameters = Some(channelParameters))
-
- countDown.await(2, TimeUnit.SECONDS) must be(true)
- val response = rpcClient.call("some_payload")
- response must be(Some(3))
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcProtobufTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcProtobufTestIntegration.scala
deleted file mode 100644
index dddc2f8432..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcProtobufTestIntegration.scala
+++ /dev/null
@@ -1,49 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-import org.scalatest.matchers.MustMatchers
-import org.scalatest.junit.JUnitSuite
-import akka.amqp.AMQP
-import akka.remote.protocol.RemoteProtocol.AddressProtocol
-import org.junit.Test
-import akka.amqp.rpc.RPC
-import org.multiverse.api.latches.StandardLatch
-import java.util.concurrent.TimeUnit
-
-class AMQPRpcProtobufTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessage = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection()
-
- RPC.newProtobufRpcServer(connection, "protoservice", requestHandler)
-
- val protobufClient = RPC.newProtobufRpcClient[AddressProtocol, AddressProtocol](connection, "protoservice")
-
- val request = AddressProtocol.newBuilder.setHostname("testhost").setPort(4321).build
-
- protobufClient.call(request) match {
- case Some(response) => assert(response.getHostname == request.getHostname.reverse)
- case None => fail("no response")
- }
-
- val aSyncLatch = new StandardLatch
- protobufClient.callAsync(request) {
- case Some(response) => {
- assert(response.getHostname == request.getHostname.reverse)
- aSyncLatch.open
- }
- case None => fail("no response")
- }
-
- aSyncLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
-
- }
-
- def requestHandler(request: AddressProtocol): AddressProtocol = {
- AddressProtocol.newBuilder.setHostname(request.getHostname.reverse).setPort(request.getPort).build
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcStringTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcStringTestIntegration.scala
deleted file mode 100644
index 1610757ab5..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPRpcStringTestIntegration.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-import org.scalatest.matchers.MustMatchers
-import org.scalatest.junit.JUnitSuite
-import akka.amqp.AMQP
-import org.junit.Test
-import akka.amqp.rpc.RPC
-import org.multiverse.api.latches.StandardLatch
-import java.util.concurrent.TimeUnit
-
-class AMQPRpcStringTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessage = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection()
-
- RPC.newStringRpcServer(connection, "stringservice", requestHandler _)
-
- val protobufClient = RPC.newStringRpcClient(connection, "stringservice")
-
- val request = "teststring"
-
- protobufClient.call(request) match {
- case Some(response) => assert(response == request.reverse)
- case None => fail("no response")
- }
-
- val aSyncLatch = new StandardLatch
- protobufClient.callAsync(request) {
- case Some(response) => {
- assert(response == request.reverse)
- aSyncLatch.open
- }
- case None => fail("no response")
- }
-
- aSyncLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- }
-
- def requestHandler(request: String): String= {
- request.reverse
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPStringProducerConsumerTestIntegration.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPStringProducerConsumerTestIntegration.scala
deleted file mode 100644
index 972fd0917d..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPStringProducerConsumerTestIntegration.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-package akka.amqp.test
-
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-import org.scalatest.matchers.MustMatchers
-import org.scalatest.junit.JUnitSuite
-import akka.amqp.AMQP
-import org.junit.Test
-import org.multiverse.api.latches.StandardLatch
-import java.util.concurrent.TimeUnit
-import akka.amqp.rpc.RPC
-
-class AMQPStringProducerConsumerTestIntegration extends JUnitSuite with MustMatchers {
-
- @Test
- def consumerMessage = AMQPTest.withCleanEndState {
-
- val connection = AMQP.newConnection()
-
- val responseLatch = new StandardLatch
-
- RPC.newStringRpcServer(connection, "stringexchange", requestHandler _)
-
- val request = "somemessage"
-
- def responseHandler(response: String) = {
-
- assert(response == request.reverse)
- responseLatch.open
- }
- AMQP.newStringConsumer(connection, responseHandler _, None, Some("string.reply.key"))
-
- val producer = AMQP.newStringProducer(connection, Some("stringexchange"))
- producer.send(request, Some("string.reply.key"))
-
- responseLatch.tryAwait(2, TimeUnit.SECONDS) must be (true)
- }
-
- def requestHandler(request: String): String= {
- println("###### Reverse")
- request.reverse
- }
-}
diff --git a/akka-amqp/src/test/scala/akka/amqp/test/AMQPTest.scala b/akka-amqp/src/test/scala/akka/amqp/test/AMQPTest.scala
deleted file mode 100644
index b9415c929a..0000000000
--- a/akka-amqp/src/test/scala/akka/amqp/test/AMQPTest.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.amqp.test
-
-import akka.amqp.AMQP
-
-object AMQPTest {
-
- def withCleanEndState(action: => Unit) {
- try {
- try {
- action
- } finally {
- AMQP.shutdownAll
- }
- } catch {
- case e => println(e)
- }
- }
-}
diff --git a/akka-camel/src/main/java/akka/camel/consume.java b/akka-camel/src/main/java/akka/camel/consume.java
deleted file mode 100644
index ebcc2efd29..0000000000
--- a/akka-camel/src/main/java/akka/camel/consume.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.camel;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation used by implementations of {@link akka.actor.TypedActor}
- * (on method-level) to define consumer endpoints.
- *
- * @author Martin Krasser
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface consume {
-
- /**
- * Consumer endpoint URI
- */
- public abstract String value();
-
- /**
- * Route definition handler class for customizing route to annotated method.
- * The handler class must have a default constructor.
- */
- public abstract Class extends RouteDefinitionHandler> routeDefinitionHandler()
- default RouteDefinitionIdentity.class;
-
-}
diff --git a/akka-camel/src/main/resources/META-INF/services/org/apache/camel/component/actor b/akka-camel/src/main/resources/META-INF/services/org/apache/camel/component/actor
deleted file mode 100644
index 386928c5a8..0000000000
--- a/akka-camel/src/main/resources/META-INF/services/org/apache/camel/component/actor
+++ /dev/null
@@ -1 +0,0 @@
-class=akka.camel.component.ActorComponent
\ No newline at end of file
diff --git a/akka-camel/src/main/resources/META-INF/services/org/apache/camel/component/typed-actor b/akka-camel/src/main/resources/META-INF/services/org/apache/camel/component/typed-actor
deleted file mode 100644
index 02efe457e6..0000000000
--- a/akka-camel/src/main/resources/META-INF/services/org/apache/camel/component/typed-actor
+++ /dev/null
@@ -1 +0,0 @@
-class=akka.camel.component.TypedActorComponent
\ No newline at end of file
diff --git a/akka-camel/src/main/scala/akka/CamelContextLifecycle.scala b/akka-camel/src/main/scala/akka/CamelContextLifecycle.scala
deleted file mode 100644
index 93375131d2..0000000000
--- a/akka-camel/src/main/scala/akka/CamelContextLifecycle.scala
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.camel
-
-import java.util.Map
-
-import org.apache.camel.{ProducerTemplate, CamelContext}
-import org.apache.camel.impl.DefaultCamelContext
-
-import akka.camel.component.TypedActorComponent
-import akka.japi.{Option => JOption}
-import akka.util.Logging
-
-/**
- * Manages the lifecycle of a CamelContext. Allowed transitions are
- * init -> start -> stop -> init -> ... etc.
- *
- * @author Martin Krasser
- */
-trait CamelContextLifecycle extends Logging {
- // TODO: enforce correct state transitions
- // valid: init -> start -> stop -> init ...
-
- private var _context: Option[CamelContext] = None
- private var _template: Option[ProducerTemplate] = None
-
- private var _initialized = false
- private var _started = false
-
- /**
- * Camel component for accessing typed actors.
- */
- private[camel] var typedActorComponent: TypedActorComponent = _
-
- /**
- * Registry in which typed actors are TEMPORARILY registered during
- * creation of Camel routes to these actors.
- */
- private[camel] var typedActorRegistry: Map[String, AnyRef] = _
-
- /**
- * Returns Some(CamelContext) (containing the current CamelContext)
- * if CamelContextLifecycle has been initialized, otherwise None.
- */
- def context: Option[CamelContext] = _context
-
- /**
- * Returns Some(ProducerTemplate) (containing the current ProducerTemplate)
- * if CamelContextLifecycle has been initialized, otherwise None.
- */
- def template: Option[ProducerTemplate] = _template
-
- /**
- * Returns Some(CamelContext) (containing the current CamelContext)
- * if CamelContextLifecycle has been initialized, otherwise None.
- *
- * Java API.
- */
- def getContext: JOption[CamelContext] = context
-
- /**
- * Returns Some(ProducerTemplate) (containing the current ProducerTemplate)
- * if CamelContextLifecycle has been initialized, otherwise None.
- *
- * Java API.
- */
- def getTemplate: JOption[ProducerTemplate] = template
-
- /**
- * Returns the current CamelContext if this CamelContextLifecycle
- * has been initialized, otherwise throws an IllegalStateException.
- */
- def mandatoryContext =
- if (context.isDefined) context.get
- else throw new IllegalStateException("no current CamelContext")
-
- /**
- * Returns the current ProducerTemplate if this CamelContextLifecycle
- * has been initialized, otherwise throws an IllegalStateException.
- */
- def mandatoryTemplate =
- if (template.isDefined) template.get
- else throw new IllegalStateException("no current ProducerTemplate")
-
- /**
- * Returns the current CamelContext if this CamelContextLifecycle
- * has been initialized, otherwise throws an IllegalStateException.
- *
- * Java API.
- */
- def getMandatoryContext = mandatoryContext
-
- /**
- * Returns the current ProducerTemplate if this CamelContextLifecycle
- * has been initialized, otherwise throws an IllegalStateException.
- *
- * Java API.
- */
- def getMandatoryTemplate = mandatoryTemplate
-
- def initialized = _initialized
- def started = _started
-
- /**
- * Starts the CamelContext and an associated ProducerTemplate.
- */
- def start = {
- for {
- c <- context
- t <- template
- } {
- c.start
- t.start
- _started = true
- log.info("Camel context started")
- }
- }
-
- /**
- * Stops the CamelContext and the associated ProducerTemplate.
- */
- def stop = {
- for {
- t <- template
- c <- context
- } {
- t.stop
- c.stop
- _started = false
- _initialized = false
- log.info("Camel context stopped")
- }
- }
-
- /**
- * Initializes this lifecycle object with the a DefaultCamelContext.
- */
- def init(): Unit = init(new DefaultCamelContext)
-
- /**
- * Initializes this lifecycle object with the given CamelContext. For the passed
- * CamelContext, stream-caching is enabled. If applications want to disable stream-
- * caching they can do so after this method returned and prior to calling start.
- * This method also registers a new TypedActorComponent at the passes CamelContext
- * under a name defined by TypedActorComponent.InternalSchema.
- */
- def init(context: CamelContext) {
- this.typedActorComponent = new TypedActorComponent
- this.typedActorRegistry = typedActorComponent.typedActorRegistry
-
- context.setStreamCaching(true)
- context.addComponent(TypedActorComponent.InternalSchema, typedActorComponent)
-
- this._context = Some(context)
- this._template = Some(context.createProducerTemplate)
-
- _initialized = true
- log.info("Camel context initialized")
- }
-}
-
-/**
- * Manages a global CamelContext and an associated ProducerTemplate.
- */
-object CamelContextManager extends CamelContextLifecycle {
-
- // -----------------------------------------------------
- // The inherited getters aren't statically accessible
- // from Java. Therefore, they are redefined here.
- // TODO: investigate if this is a Scala bug.
- // -----------------------------------------------------
-
- /**
- * see CamelContextLifecycle.getContext
- *
- * Java API.
- */
- override def getMandatoryTemplate = super.getMandatoryTemplate
-}
diff --git a/akka-camel/src/main/scala/akka/CamelService.scala b/akka-camel/src/main/scala/akka/CamelService.scala
deleted file mode 100644
index da71701ae1..0000000000
--- a/akka-camel/src/main/scala/akka/CamelService.scala
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.camel
-
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
-
-import org.apache.camel.CamelContext
-
-import akka.actor.Actor._
-import akka.actor.{AspectInitRegistry, ActorRegistry}
-import akka.config.Config._
-import akka.japi.{SideEffect, Option => JOption}
-import akka.util.{Logging, Bootable}
-
-/**
- * Publishes (untyped) consumer actors and typed consumer actors via Camel endpoints. Actors
- * are published (asynchronously) when they are started and unpublished (asynchronously) when
- * they are stopped. The CamelService is notified about actor start- and stop-events by
- * registering listeners at ActorRegistry and AspectInitRegistry.
- *
- * @author Martin Krasser
- */
-trait CamelService extends Bootable with Logging {
- private[camel] val consumerPublisher = actorOf[ConsumerPublisher]
- private[camel] val publishRequestor = actorOf[PublishRequestor]
-
- private val serviceEnabled = config.getList("akka.enabled-modules").exists(_ == "camel")
-
- /**
- * Starts this CamelService unless akka.camel.service is set to false.
- */
- abstract override def onLoad = {
- if (serviceEnabled) registerPublishRequestor
- super.onLoad
- if (serviceEnabled) start
- }
-
- /**
- * Stops this CamelService unless akka.camel.service is set to false.
- */
- abstract override def onUnload = {
- if (serviceEnabled) stop
- super.onUnload
- }
-
- @deprecated("use start() instead")
- def load = start
-
- @deprecated("use stop() instead")
- def unload = stop
-
- /**
- * Starts this CamelService. Any started actor that is a consumer actor will be (asynchronously)
- * published as Camel endpoint. Consumer actors that are started after this method returned will
- * be published as well. Actor publishing is done asynchronously. A started (loaded) CamelService
- * also publishes @consume annotated methods of typed actors that have been created
- * with TypedActor.newInstance(..) (and TypedActor.newRemoteInstance(..)
- * on a remote node).
- */
- def start: CamelService = {
- if (!publishRequestorRegistered) registerPublishRequestor
-
- // Only init and start if not already done by application
- if (!CamelContextManager.initialized) CamelContextManager.init
- if (!CamelContextManager.started) CamelContextManager.start
-
- // start actor that exposes consumer actors and typed actors via Camel endpoints
- consumerPublisher.start
-
- // init publishRequestor so that buffered and future events are delivered to consumerPublisher
- publishRequestor ! PublishRequestorInit(consumerPublisher)
-
- // Register this instance as current CamelService and return it
- CamelServiceManager.register(this)
- CamelServiceManager.mandatoryService
- }
-
- /**
- * Stops this CamelService. All published consumer actors and typed consumer actor methods will be
- * unpublished asynchronously.
- */
- def stop = {
- // Unregister this instance as current CamelService
- CamelServiceManager.unregister(this)
-
- // Remove related listeners from registry
- unregisterPublishRequestor
-
- // Stop related services
- consumerPublisher.stop
- CamelContextManager.stop
- }
-
- /**
- * Waits for an expected number (count) of endpoints to be activated
- * during execution of f. The wait-timeout is by default 10 seconds.
- * Other timeout values can be set via the timeout and timeUnit
- * parameters.
- */
- def awaitEndpointActivation(count: Int, timeout: Long = 10, timeUnit: TimeUnit = TimeUnit.SECONDS)(f: => Unit): Boolean = {
- val activation = expectEndpointActivationCount(count)
- f; activation.await(timeout, timeUnit)
- }
-
- /**
- * Waits for an expected number (count) of endpoints to be de-activated
- * during execution of f. The wait-timeout is by default 10 seconds.
- * Other timeout values can be set via the timeout and timeUnit
- * parameters.
- */
- def awaitEndpointDeactivation(count: Int, timeout: Long = 10, timeUnit: TimeUnit = TimeUnit.SECONDS)(f: => Unit): Boolean = {
- val activation = expectEndpointDeactivationCount(count)
- f; activation.await(timeout, timeUnit)
- }
-
- /**
- * Waits for an expected number (count) of endpoints to be activated
- * during execution of p. The wait timeout is 10 seconds.
- *
- * Java API
- */
- def awaitEndpointActivation(count: Int, p: SideEffect): Boolean = {
- awaitEndpointActivation(count, 10, TimeUnit.SECONDS, p)
- }
-
- /**
- * Waits for an expected number (count) of endpoints to be activated
- * during execution of p. Timeout values can be set via the
- * timeout and timeUnit parameters.
- *
- * Java API
- */
- def awaitEndpointActivation(count: Int, timeout: Long, timeUnit: TimeUnit, p: SideEffect): Boolean = {
- awaitEndpointActivation(count, timeout, timeUnit) { p.apply }
- }
-
- /**
- * Waits for an expected number (count) of endpoints to be de-activated
- * during execution of p. The wait timeout is 10 seconds.
- *
- * Java API
- */
- def awaitEndpointDeactivation(count: Int, p: SideEffect): Boolean = {
- awaitEndpointDeactivation(count, 10, TimeUnit.SECONDS, p)
- }
-
- /**
- * Waits for an expected number (count) of endpoints to be de-activated
- * during execution of p. Timeout values can be set via the
- * timeout and timeUnit parameters.
- *
- * Java API
- */
- def awaitEndpointDeactivation(count: Int, timeout: Long, timeUnit: TimeUnit, p: SideEffect): Boolean = {
- awaitEndpointDeactivation(count, timeout, timeUnit) { p.apply }
- }
-
- /**
- * Sets an expectation on the number of upcoming endpoint activations and returns
- * a CountDownLatch that can be used to wait for the activations to occur. Endpoint
- * activations that occurred in the past are not considered.
- */
- private def expectEndpointActivationCount(count: Int): CountDownLatch =
- (consumerPublisher !! SetExpectedRegistrationCount(count)).as[CountDownLatch].get
-
- /**
- * Sets an expectation on the number of upcoming endpoint de-activations and returns
- * a CountDownLatch that can be used to wait for the de-activations to occur. Endpoint
- * de-activations that occurred in the past are not considered.
- */
- private def expectEndpointDeactivationCount(count: Int): CountDownLatch =
- (consumerPublisher !! SetExpectedUnregistrationCount(count)).as[CountDownLatch].get
-
- private[camel] def publishRequestorRegistered: Boolean = {
- ActorRegistry.hasListener(publishRequestor) ||
- AspectInitRegistry.hasListener(publishRequestor)
- }
-
- private[camel] def registerPublishRequestor: Unit = {
- ActorRegistry.addListener(publishRequestor)
- AspectInitRegistry.addListener(publishRequestor)
- }
-
- private[camel] def unregisterPublishRequestor: Unit = {
- ActorRegistry.removeListener(publishRequestor)
- AspectInitRegistry.removeListener(publishRequestor)
- }
-}
-
-/**
- * Manages a global CamelService (the 'current' CamelService).
- *
- * @author Martin Krasser
- */
-object CamelServiceManager {
-
- /**
- * The current (optional) CamelService. Is defined when a CamelService has been started.
- */
- private var _current: Option[CamelService] = None
-
- /**
- * Starts a new CamelService and makes it the current CamelService.
- *
- * @see CamelService#start
- * @see CamelService#onLoad
- */
- def startCamelService = CamelServiceFactory.createCamelService.start
-
- /**
- * Stops the current CamelService.
- *
- * @see CamelService#stop
- * @see CamelService#onUnload
- */
- def stopCamelService = for (s <- service) s.stop
-
- /**
- * Returns Some(CamelService) if this CamelService
- * has been started, None otherwise.
- */
- def service = _current
-
- /**
- * Returns the current CamelService if CamelService
- * has been started, otherwise throws an IllegalStateException.
- *
- * Java API
- */
- def getService: JOption[CamelService] = CamelServiceManager.service
-
- /**
- * Returns Some(CamelService) (containing the current CamelService)
- * if this CamelServicehas been started, None otherwise.
- */
- def mandatoryService =
- if (_current.isDefined) _current.get
- else throw new IllegalStateException("co current CamelService")
-
- /**
- * Returns Some(CamelService) (containing the current CamelService)
- * if this CamelServicehas been started, None otherwise.
- *
- * Java API
- */
- def getMandatoryService = mandatoryService
-
- private[camel] def register(service: CamelService) =
- if (_current.isDefined) throw new IllegalStateException("current CamelService already registered")
- else _current = Some(service)
-
- private[camel] def unregister(service: CamelService) =
- if (_current == Some(service)) _current = None
- else throw new IllegalStateException("only current CamelService can be unregistered")
-}
-
-/**
- * @author Martin Krasser
- */
-object CamelServiceFactory {
- /**
- * Creates a new CamelService instance.
- */
- def createCamelService: CamelService = new CamelService { }
-
- /**
- * Creates a new CamelService instance and initializes it with the given CamelContext.
- */
- def createCamelService(camelContext: CamelContext): CamelService = {
- CamelContextManager.init(camelContext)
- createCamelService
- }
-}
diff --git a/akka-camel/src/main/scala/akka/Consumer.scala b/akka-camel/src/main/scala/akka/Consumer.scala
deleted file mode 100644
index a6323c3bae..0000000000
--- a/akka-camel/src/main/scala/akka/Consumer.scala
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.camel
-
-import java.net.InetSocketAddress
-
-import org.apache.camel.{Exchange, Processor}
-import org.apache.camel.model.{RouteDefinition, ProcessorDefinition}
-
-import akka.actor._
-import akka.japi.{Function => JFunction}
-
-/**
- * Mixed in by Actor implementations that consume message from Camel endpoints.
- *
- * @author Martin Krasser
- */
-trait Consumer { self: Actor =>
- import RouteDefinitionHandler._
-
- /**
- * The default route definition handler is the identity function
- */
- private[camel] var routeDefinitionHandler: RouteDefinitionHandler = identity
-
- /**
- * Returns the Camel endpoint URI to consume messages from.
- */
- def endpointUri: String
-
- /**
- * Determines whether two-way communications between an endpoint and this consumer actor
- * should be done in blocking or non-blocking mode (default is non-blocking). This method
- * doesn't have any effect on one-way communications (they'll never block).
- */
- def blocking = false
-
- /**
- * Sets the route definition handler for creating a custom route to this consumer instance.
- */
- def onRouteDefinition(h: RouteDefinition => ProcessorDefinition[_]): Unit = onRouteDefinition(from(h))
-
- /**
- * Sets the route definition handler for creating a custom route to this consumer instance.
- *
- * Java API.
- */
- def onRouteDefinition(h: RouteDefinitionHandler): Unit = routeDefinitionHandler = h
-}
-
-/**
- * Java-friendly Consumer.
- *
- * @see UntypedConsumerActor
- * @see RemoteUntypedConsumerActor
- *
- * @author Martin Krasser
- */
-trait UntypedConsumer extends Consumer { self: UntypedActor =>
- final override def endpointUri = getEndpointUri
- final override def blocking = isBlocking
-
- /**
- * Returns the Camel endpoint URI to consume messages from.
- */
- def getEndpointUri(): String
-
- /**
- * Determines whether two-way communications between an endpoint and this consumer actor
- * should be done in blocking or non-blocking mode (default is non-blocking). This method
- * doesn't have any effect on one-way communications (they'll never block).
- */
- def isBlocking() = super.blocking
-}
-
-/**
- * Subclass this abstract class to create an MDB-style untyped consumer actor. This
- * class is meant to be used from Java.
- */
-abstract class UntypedConsumerActor extends UntypedActor with UntypedConsumer
-
-/**
- * Subclass this abstract class to create an MDB-style remote untyped consumer
- * actor. This class is meant to be used from Java.
- */
-abstract class RemoteUntypedConsumerActor(address: InetSocketAddress) extends RemoteUntypedActor(address) with UntypedConsumer {
- def this(host: String, port: Int) = this(new InetSocketAddress(host, port))
-}
-
-/**
- * A callback handler for route definitions to consumer actors.
- *
- * @author Martin Krasser
- */
-trait RouteDefinitionHandler {
- def onRouteDefinition(rd: RouteDefinition): ProcessorDefinition[_]
-}
-
-/**
- * The identity route definition handler.
- *
- * @author Martin Krasser
- *
- */
-class RouteDefinitionIdentity extends RouteDefinitionHandler {
- def onRouteDefinition(rd: RouteDefinition) = rd
-}
-
-/**
- * @author Martin Krasser
- */
-object RouteDefinitionHandler {
- /**
- * Returns the identity route definition handler
- */
- val identity = new RouteDefinitionIdentity
-
- /**
- * Created a route definition handler from the given function.
- */
- def from(f: RouteDefinition => ProcessorDefinition[_]) = new RouteDefinitionHandler {
- def onRouteDefinition(rd: RouteDefinition) = f(rd)
- }
-}
-
-/**
- * @author Martin Krasser
- */
-private[camel] object Consumer {
- /**
- * Applies a function f to actorRef if actorRef
- * references a consumer actor. A valid reference to a consumer actor is a local actor
- * reference with a target actor that implements the Consumer trait. The
- * target Consumer object is passed as argument to f. This
- * method returns None if actorRef is not a valid reference
- * to a consumer actor, Some consumer actor otherwise.
- */
- def forConsumer[T](actorRef: ActorRef)(f: Consumer => T): Option[T] = {
- if (!actorRef.actor.isInstanceOf[Consumer]) None
- else if (actorRef.remoteAddress.isDefined) None
- else Some(f(actorRef.actor.asInstanceOf[Consumer]))
- }
-}
diff --git a/akka-camel/src/main/scala/akka/ConsumerPublisher.scala b/akka-camel/src/main/scala/akka/ConsumerPublisher.scala
deleted file mode 100644
index 39c4e0bb2f..0000000000
--- a/akka-camel/src/main/scala/akka/ConsumerPublisher.scala
+++ /dev/null
@@ -1,351 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.camel
-
-import collection.mutable.ListBuffer
-
-import java.io.InputStream
-import java.lang.reflect.Method
-import java.util.concurrent.CountDownLatch
-
-import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.model.{ProcessorDefinition, RouteDefinition}
-
-import akka.actor._
-import akka.camel.component.TypedActorComponent
-import akka.util.Logging
-
-/**
- * @author Martin Krasser
- */
-private[camel] object ConsumerPublisher extends Logging {
- /**
- * Creates a route to the registered consumer actor.
- */
- def handleConsumerActorRegistered(event: ConsumerActorRegistered) {
- CamelContextManager.mandatoryContext.addRoutes(new ConsumerActorRouteBuilder(event))
- log.info("published actor %s at endpoint %s" format (event.actorRef, event.endpointUri))
- }
-
- /**
- * Stops the route to the already un-registered consumer actor.
- */
- def handleConsumerActorUnregistered(event: ConsumerActorUnregistered) {
- CamelContextManager.mandatoryContext.stopRoute(event.uuid)
- log.info("unpublished actor %s from endpoint %s" format (event.actorRef, event.endpointUri))
- }
-
- /**
- * Creates a route to an typed actor method.
- */
- def handleConsumerMethodRegistered(event: ConsumerMethodRegistered) {
- CamelContextManager.typedActorRegistry.put(event.methodUuid, event.typedActor)
- CamelContextManager.mandatoryContext.addRoutes(new ConsumerMethodRouteBuilder(event))
- log.info("published method %s of %s at endpoint %s" format (event.methodName, event.typedActor, event.endpointUri))
- }
-
- /**
- * Stops the route to the already un-registered consumer actor method.
- */
- def handleConsumerMethodUnregistered(event: ConsumerMethodUnregistered) {
- CamelContextManager.typedActorRegistry.remove(event.methodUuid)
- CamelContextManager.mandatoryContext.stopRoute(event.methodUuid)
- log.info("unpublished method %s of %s from endpoint %s" format (event.methodName, event.typedActor, event.endpointUri))
- }
-}
-
-/**
- * Actor that publishes consumer actors and typed actor methods at Camel endpoints.
- * The Camel context used for publishing is obtained via CamelContextManager.context.
- * This actor accepts messages of type
- * akka.camel.ConsumerActorRegistered,
- * akka.camel.ConsumerActorUnregistered,
- * akka.camel.ConsumerMethodRegistered and
- * akka.camel.ConsumerMethodUnregistered.
- *
- * @author Martin Krasser
- */
-private[camel] class ConsumerPublisher extends Actor {
- import ConsumerPublisher._
-
- @volatile private var registrationLatch = new CountDownLatch(0)
- @volatile private var unregistrationLatch = new CountDownLatch(0)
-
- protected def receive = {
- case r: ConsumerActorRegistered => {
- handleConsumerActorRegistered(r)
- registrationLatch.countDown
- }
- case u: ConsumerActorUnregistered => {
- handleConsumerActorUnregistered(u)
- unregistrationLatch.countDown
- }
- case mr: ConsumerMethodRegistered => {
- handleConsumerMethodRegistered(mr)
- registrationLatch.countDown
- }
- case mu: ConsumerMethodUnregistered => {
- handleConsumerMethodUnregistered(mu)
- unregistrationLatch.countDown
- }
- case SetExpectedRegistrationCount(num) => {
- registrationLatch = new CountDownLatch(num)
- self.reply(registrationLatch)
- }
- case SetExpectedUnregistrationCount(num) => {
- unregistrationLatch = new CountDownLatch(num)
- self.reply(unregistrationLatch)
- }
- case _ => { /* ignore */}
- }
-}
-
-private[camel] case class SetExpectedRegistrationCount(num: Int)
-private[camel] case class SetExpectedUnregistrationCount(num: Int)
-
-/**
- * Abstract route to a target which is either an actor or an typed actor method.
- *
- * @param endpointUri endpoint URI of the consumer actor or typed actor method.
- * @param id actor identifier or typed actor identifier (registry key).
- *
- * @author Martin Krasser
- */
-private[camel] abstract class ConsumerRouteBuilder(endpointUri: String, id: String) extends RouteBuilder {
- // TODO: make conversions configurable
- private val bodyConversions = Map(
- "file" -> classOf[InputStream]
- )
-
- def configure = {
- val schema = endpointUri take endpointUri.indexOf(":") // e.g. "http" from "http://whatever/..."
- val cnvopt = bodyConversions.get(schema)
-
- onRouteDefinition(startRouteDefinition(cnvopt)).to(targetUri)
- }
-
- protected def routeDefinitionHandler: RouteDefinitionHandler
- protected def targetUri: String
-
- private def onRouteDefinition(rd: RouteDefinition) = routeDefinitionHandler.onRouteDefinition(rd)
- private def startRouteDefinition(bodyConversion: Option[Class[_]]): RouteDefinition = bodyConversion match {
- case Some(clazz) => from(endpointUri).routeId(id).convertBodyTo(clazz)
- case None => from(endpointUri).routeId(id)
- }
-}
-
-/**
- * Defines the route to a (untyped) consumer actor.
- *
- * @author Martin Krasser
- */
-private[camel] class ConsumerActorRouteBuilder(event: ConsumerActorRegistered) extends ConsumerRouteBuilder(event.endpointUri, event.uuid) {
- protected def routeDefinitionHandler: RouteDefinitionHandler = event.routeDefinitionHandler
- protected def targetUri = "actor:uuid:%s?blocking=%s" format (event.uuid, event.blocking)
-}
-
-/**
- * Defines the route to a typed actor method.
- *
- * @author Martin Krasser
- */
-private[camel] class ConsumerMethodRouteBuilder(event: ConsumerMethodRegistered) extends ConsumerRouteBuilder(event.endpointUri, event.methodUuid) {
- protected def routeDefinitionHandler: RouteDefinitionHandler = event.routeDefinitionHandler
- protected def targetUri = "%s:%s?method=%s" format (TypedActorComponent.InternalSchema, event.methodUuid, event.methodName)
-}
-
-/**
- * A registration listener that triggers publication of consumer actors and typed actor
- * methods as well as un-publication of consumer actors and typed actor methods. This actor
- * needs to be initialized with a PublishRequestorInit command message for
- * obtaining a reference to a publisher actor. Before initialization it buffers
- * all outbound messages and delivers them to the publisher when receiving a
- * PublishRequestorInit message. After initialization, outbound messages are
- * delivered directly without buffering.
- *
- * @see PublishRequestorInit
- *
- * @author Martin Krasser
- */
-private[camel] class PublishRequestor extends Actor {
- private val events = ListBuffer[ConsumerEvent]()
- private var publisher: Option[ActorRef] = None
-
- protected def receive = {
- case ActorRegistered(actor) =>
- for (event <- ConsumerActorRegistered.forConsumer(actor)) deliverCurrentEvent(event)
- case ActorUnregistered(actor) =>
- for (event <- ConsumerActorUnregistered.forConsumer(actor)) deliverCurrentEvent(event)
- case AspectInitRegistered(proxy, init) =>
- for (event <- ConsumerMethodRegistered.forConsumer(proxy, init)) deliverCurrentEvent(event)
- case AspectInitUnregistered(proxy, init) =>
- for (event <- ConsumerMethodUnregistered.forConsumer(proxy, init)) deliverCurrentEvent(event)
- case PublishRequestorInit(pub) => {
- publisher = Some(pub)
- deliverBufferedEvents
- }
- case _ => { /* ignore */ }
- }
-
- private def deliverCurrentEvent(event: ConsumerEvent) = {
- publisher match {
- case Some(pub) => pub ! event
- case None => events += event
- }
- }
-
- private def deliverBufferedEvents = {
- for (event <- events) deliverCurrentEvent(event)
- events.clear
- }
-}
-
-/**
- * Command message to initialize a PublishRequestor to use consumerPublisher
- * for publishing actors or typed actor methods.
- */
-private[camel] case class PublishRequestorInit(consumerPublisher: ActorRef)
-
-/**
- * A consumer (un)registration event.
- */
-private[camel] sealed trait ConsumerEvent
-
-/**
- * A consumer actor (un)registration event.
- */
-private[camel] trait ConsumerActorEvent extends ConsumerEvent {
- val actorRef: ActorRef
- val actor: Consumer
-
- val uuid = actorRef.uuid.toString
- val endpointUri = actor.endpointUri
- val blocking = actor.blocking
- val routeDefinitionHandler = actor.routeDefinitionHandler
-}
-
-/**
- * A consumer method (un)registration event.
- */
-private[camel] trait ConsumerMethodEvent extends ConsumerEvent {
- val typedActor: AnyRef
- val init: AspectInit
- val method: Method
-
- val uuid = init.actorRef.uuid.toString
- val methodName = method.getName
- val methodUuid = "%s_%s" format (uuid, methodName)
-
- lazy val routeDefinitionHandler = consumeAnnotation.routeDefinitionHandler.newInstance
- lazy val consumeAnnotation = method.getAnnotation(classOf[consume])
- lazy val endpointUri = consumeAnnotation.value
-}
-
-/**
- * Event indicating that a consumer actor has been registered at the actor registry.
- */
-private[camel] case class ConsumerActorRegistered(actorRef: ActorRef, actor: Consumer) extends ConsumerActorEvent
-
-/**
- * Event indicating that a consumer actor has been unregistered from the actor registry.
- */
-private[camel] case class ConsumerActorUnregistered(actorRef: ActorRef, actor: Consumer) extends ConsumerActorEvent
-
-/**
- * Event indicating that an typed actor proxy has been created for a typed actor. For each @consume
- * annotated typed actor method a separate instance of this class is created.
- */
-private[camel] case class ConsumerMethodRegistered(typedActor: AnyRef, init: AspectInit, method: Method) extends ConsumerMethodEvent
-
-/**
- * Event indicating that an typed actor has been stopped. For each @consume
- * annotated typed object method a separate instance of this class is created.
- */
-private[camel] case class ConsumerMethodUnregistered(typedActor: AnyRef, init: AspectInit, method: Method) extends ConsumerMethodEvent
-
-/**
- * @author Martin Krasser
- */
-private[camel] object ConsumerActorRegistered {
- /**
- * Creates an ConsumerActorRegistered event message for a consumer actor or None if
- * actorRef is not a consumer actor.
- */
- def forConsumer(actorRef: ActorRef): Option[ConsumerActorRegistered] = {
- Consumer.forConsumer[ConsumerActorRegistered](actorRef) {
- actor => ConsumerActorRegistered(actorRef, actor)
- }
- }
-}
-
-/**
- * @author Martin Krasser
- */
-private[camel] object ConsumerActorUnregistered {
- /**
- * Creates an ConsumerActorUnregistered event message for a consumer actor or None if
- * actorRef is not a consumer actor.
- */
- def forConsumer(actorRef: ActorRef): Option[ConsumerActorUnregistered] = {
- Consumer.forConsumer[ConsumerActorUnregistered](actorRef) {
- actor => ConsumerActorUnregistered(actorRef, actor)
- }
- }
-}
-
-/**
- * @author Martin Krasser
- */
-private[camel] object ConsumerMethod {
- /**
- * Applies a function f to each consumer method of TypedActor and
- * returns the function results as a list. A consumer method is one that is annotated with
- * @consume. If typedActor is a proxy for a remote typed actor
- * f is never called and Nil is returned.
- */
- def forConsumer[T](typedActor: AnyRef, init: AspectInit)(f: Method => T): List[T] = {
- if (init.remoteAddress.isDefined) Nil // let remote node publish typed actor methods on endpoints
- else {
- // TODO: support consumer annotation inheritance
- // - visit overridden methods in superclasses
- // - visit implemented method declarations in interfaces
- val intfClass = typedActor.getClass
- val implClass = init.targetInstance.getClass
- (for (m <- intfClass.getMethods.toList; if (m.isAnnotationPresent(classOf[consume]))) yield f(m)) ++
- (for (m <- implClass.getMethods.toList; if (m.isAnnotationPresent(classOf[consume]))) yield f(m))
- }
- }
-}
-
-/**
- * @author Martin Krasser
- */
-private[camel] object ConsumerMethodRegistered {
- /**
- * Creates a list of ConsumerMethodRegistered event messages for a typed actor or an empty
- * list if the typed actor is a proxy for a remote typed actor or the typed actor doesn't
- * have any @consume annotated methods.
- */
- def forConsumer(typedActor: AnyRef, init: AspectInit): List[ConsumerMethodRegistered] = {
- ConsumerMethod.forConsumer(typedActor, init) {
- m => ConsumerMethodRegistered(typedActor, init, m)
- }
- }
-}
-
-/**
- * @author Martin Krasser
- */
-private[camel] object ConsumerMethodUnregistered {
- /**
- * Creates a list of ConsumerMethodUnregistered event messages for a typed actor or an empty
- * list if the typed actor is a proxy for a remote typed actor or the typed actor doesn't
- * have any @consume annotated methods.
- */
- def forConsumer(typedActor: AnyRef, init: AspectInit): List[ConsumerMethodUnregistered] = {
- ConsumerMethod.forConsumer(typedActor, init) {
- m => ConsumerMethodUnregistered(typedActor, init, m)
- }
- }
-}
diff --git a/akka-camel/src/main/scala/akka/Message.scala b/akka-camel/src/main/scala/akka/Message.scala
deleted file mode 100644
index aa1fcbd083..0000000000
--- a/akka-camel/src/main/scala/akka/Message.scala
+++ /dev/null
@@ -1,380 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.camel
-
-import java.util.{Map => JMap, Set => JSet}
-
-import scala.collection.JavaConversions._
-
-import org.apache.camel.{Exchange, Message => CamelMessage}
-import org.apache.camel.util.ExchangeHelper
-
-import akka.japi.{Function => JFunction}
-
-/**
- * An immutable representation of a Camel message.
- *
- * @author Martin Krasser
- */
-case class Message(val body: Any, val headers: Map[String, Any] = Map.empty) {
-
- /**
- * Creates a Message with given body and empty headers map.
- */
- def this(body: Any) = this(body, Map.empty[String, Any])
-
- /**
- * Creates a Message with given body and headers map. A copy of the headers map is made.
- *
- * Java API
- */
- def this(body: Any, headers: JMap[String, Any]) = this(body, headers.toMap)
-
- /**
- * Returns the body of the message converted to the type T. Conversion is done
- * using Camel's type converter. The type converter is obtained from the CamelContext managed
- * by CamelContextManager. Applications have to ensure proper initialization of
- * CamelContextManager.
- *
- * @see CamelContextManager.
- */
- def bodyAs[T](implicit m: Manifest[T]): T = getBodyAs(m.erasure.asInstanceOf[Class[T]])
-
- /**
- * Returns the body of the message converted to the type as given by the clazz
- * parameter. Conversion is done using Camel's type converter. The type converter is obtained
- * from the CamelContext managed by CamelContextManager. Applications have to ensure proper
- * initialization of CamelContextManager.
- *
- * Java API
- *
- * @see CamelContextManager.
- */
- def getBodyAs[T](clazz: Class[T]): T =
- CamelContextManager.mandatoryContext.getTypeConverter.mandatoryConvertTo[T](clazz, body)
-
- /**
- * Returns those headers from this message whose name is contained in names.
- */
- def headers(names: Set[String]): Map[String, Any] = headers.filter(names contains _._1)
-
- /**
- * Returns those headers from this message whose name is contained in names.
- * The returned headers map is backed up by an immutable headers map. Any attempt to modify
- * the returned map will throw an exception.
- *
- * Java API
- */
- def getHeaders(names: JSet[String]): JMap[String, Any] = headers.filter(names contains _._1)
-
- /**
- * Returns all headers from this message. The returned headers map is backed up by this
- * message's immutable headers map. Any attempt to modify the returned map will throw an
- * exception.
- *
- * Java API
- */
- def getHeaders: JMap[String, Any] = headers
-
- /**
- * Returns the header with given name. Throws NoSuchElementException
- * if the header doesn't exist.
- */
- def header(name: String): Any = headers(name)
-
- /**
- * Returns the header with given name. Throws NoSuchElementException
- * if the header doesn't exist.
- *
- * Java API
- */
- def getHeader(name: String): Any = header(name)
-
- /**
- * Returns the header with given name converted to type T. Throws
- * NoSuchElementException if the header doesn't exist.
- */
- def headerAs[T](name: String)(implicit m: Manifest[T]): T =
- getHeaderAs(name, m.erasure.asInstanceOf[Class[T]])
-
- /**
- * Returns the header with given name converted to type as given by the clazz
- * parameter. Throws NoSuchElementException if the header doesn't exist.
- *
- * Java API
- */
- def getHeaderAs[T](name: String, clazz: Class[T]): T =
- CamelContextManager.mandatoryContext.getTypeConverter.mandatoryConvertTo[T](clazz, header(name))
-
- /**
- * Creates a Message with a transformed body using a transformer function.
- */
- def transformBody[A](transformer: A => Any): Message = setBody(transformer(body.asInstanceOf[A]))
-
- /**
- * Creates a Message with a transformed body using a transformer function.
- *
- * Java API
- */
- def transformBody[A](transformer: JFunction[A, Any]): Message = setBody(transformer(body.asInstanceOf[A]))
-
- /**
- * Creates a Message with current body converted to type T.
- */
- def setBodyAs[T](implicit m: Manifest[T]): Message = setBodyAs(m.erasure.asInstanceOf[Class[T]])
-
- /**
- * Creates a Message with current body converted to type clazz.
- *
- * Java API
- */
- def setBodyAs[T](clazz: Class[T]): Message = setBody(getBodyAs(clazz))
-
- /**
- * Creates a Message with a given body.
- */
- def setBody(body: Any) = new Message(body, this.headers)
-
- /**
- * Creates a new Message with given headers.
- */
- def setHeaders(headers: Map[String, Any]): Message = copy(this.body, headers)
-
- /**
- * Creates a new Message with given headers. A copy of the headers map is made.
- *
- * Java API
- */
- def setHeaders(headers: JMap[String, Any]): Message = setHeaders(headers.toMap)
-
- /**
- * Creates a new Message with given headers added to the current headers.
- */
- def addHeaders(headers: Map[String, Any]): Message = copy(this.body, this.headers ++ headers)
-
- /**
- * Creates a new Message with given headers added to the current headers.
- * A copy of the headers map is made.
- *
- * Java API
- */
- def addHeaders(headers: JMap[String, Any]): Message = addHeaders(headers.toMap)
-
- /**
- * Creates a new Message with the given header added to the current headers.
- */
- def addHeader(header: (String, Any)): Message = copy(this.body, this.headers + header)
-
- /**
- * Creates a new Message with the given header, represented by name and
- * value added to the existing headers.
- *
- * Java API
- */
- def addHeader(name: String, value: Any): Message = addHeader((name, value))
-
- /**
- * Creates a new Message where the header with given headerName is removed from
- * the existing headers.
- */
- def removeHeader(headerName: String) = copy(this.body, this.headers - headerName)
-}
-
-/**
- * Companion object of Message class.
- *
- * @author Martin Krasser
- */
-object Message {
-
- /**
- * Message header to correlate request with response messages. Applications that send
- * messages to a Producer actor may want to set this header on the request message
- * so that it can be correlated with an asynchronous response. Messages send to Consumer
- * actors have this header already set.
- */
- val MessageExchangeId = "MessageExchangeId".intern
-
- /**
- * Creates a new Message with body as message body and an empty header map.
- */
- //def apply(body: Any) = new Message(body)
-
- /**
- * Creates a canonical form of the given message msg. If msg of type
- * Message then msg is returned, otherwise msg is set as body of a
- * newly created Message object.
- */
- def canonicalize(msg: Any) = msg match {
- case mobj: Message => mobj
- case body => new Message(body)
- }
-}
-
-/**
- * An immutable representation of a failed Camel exchange. It contains the failure cause
- * obtained from Exchange.getException and the headers from either the Exchange.getIn
- * message or Exchange.getOut message, depending on the exchange pattern.
- *
- * @author Martin Krasser
- */
-case class Failure(val cause: Exception, val headers: Map[String, Any] = Map.empty) {
-
- /**
- * Creates a Failure with cause body and empty headers map.
- */
- def this(cause: Exception) = this(cause, Map.empty[String, Any])
-
- /**
- * Creates a Failure with given cause and headers map. A copy of the headers map is made.
- *
- * Java API
- */
- def this(cause: Exception, headers: JMap[String, Any]) = this(cause, headers.toMap)
-
- /**
- * Returns the cause of this Failure.
- *
- * Java API.
- */
- def getCause = cause
-
- /**
- * Returns all headers from this failure message. The returned headers map is backed up by
- * this message's immutable headers map. Any attempt to modify the returned map will throw
- * an exception.
- *
- * Java API
- */
- def getHeaders: JMap[String, Any] = headers
-}
-
-/**
- * Adapter for converting an org.apache.camel.Exchange to and from Message and Failure objects.
- *
- * @author Martin Krasser
- */
-class CamelExchangeAdapter(exchange: Exchange) {
- import CamelMessageConversion.toMessageAdapter
-
- /**
- * Sets Exchange.getIn from the given Message object.
- */
- def fromRequestMessage(msg: Message): Exchange = { requestMessage.fromMessage(msg); exchange }
-
- /**
- * Depending on the exchange pattern, sets Exchange.getIn or Exchange.getOut from the given
- * Message object. If the exchange is out-capable then the Exchange.getOut is set, otherwise
- * Exchange.getIn.
- */
- def fromResponseMessage(msg: Message): Exchange = { responseMessage.fromMessage(msg); exchange }
-
- /**
- * Sets Exchange.getException from the given Failure message. Headers of the Failure message
- * are ignored.
- */
- def fromFailureMessage(msg: Failure): Exchange = { exchange.setException(msg.cause); exchange }
-
- /**
- * Creates a Message object from Exchange.getIn.
- */
- def toRequestMessage: Message = toRequestMessage(Map.empty)
-
- /**
- * Depending on the exchange pattern, creates a Message object from Exchange.getIn or Exchange.getOut.
- * If the exchange is out-capable then the Exchange.getOut is set, otherwise Exchange.getIn.
- */
- def toResponseMessage: Message = toResponseMessage(Map.empty)
-
- /**
- * Creates a Failure object from the adapted Exchange.
- *
- * @see Failure
- */
- def toFailureMessage: Failure = toFailureMessage(Map.empty)
-
- /**
- * Creates a Message object from Exchange.getIn.
- *
- * @param headers additional headers to set on the created Message in addition to those
- * in the Camel message.
- */
- def toRequestMessage(headers: Map[String, Any]): Message = requestMessage.toMessage(headers)
-
- /**
- * Depending on the exchange pattern, creates a Message object from Exchange.getIn or Exchange.getOut.
- * If the exchange is out-capable then the Exchange.getOut is set, otherwise Exchange.getIn.
- *
- * @param headers additional headers to set on the created Message in addition to those
- * in the Camel message.
- */
- def toResponseMessage(headers: Map[String, Any]): Message = responseMessage.toMessage(headers)
-
- /**
- * Creates a Failure object from the adapted Exchange.
- *
- * @param headers additional headers to set on the created Message in addition to those
- * in the Camel message.
- *
- * @see Failure
- */
- def toFailureMessage(headers: Map[String, Any]): Failure =
- Failure(exchange.getException, headers ++ responseMessage.toMessage.headers)
-
- private def requestMessage = exchange.getIn
-
- private def responseMessage = ExchangeHelper.getResultMessage(exchange)
-
-}
-
-/**
- * Adapter for converting an org.apache.camel.Message to and from Message objects.
- *
- * @author Martin Krasser
- */
-class CamelMessageAdapter(val cm: CamelMessage) {
- /**
- * Set the adapted Camel message from the given Message object.
- */
- def fromMessage(m: Message): CamelMessage = {
- cm.setBody(m.body)
- for (h <- m.headers) cm.getHeaders.put(h._1, h._2.asInstanceOf[AnyRef])
- cm
- }
-
- /**
- * Creates a new Message object from the adapted Camel message.
- */
- def toMessage: Message = toMessage(Map.empty)
-
- /**
- * Creates a new Message object from the adapted Camel message.
- *
- * @param headers additional headers to set on the created Message in addition to those
- * in the Camel message.
- */
- def toMessage(headers: Map[String, Any]): Message = Message(cm.getBody, cmHeaders(headers, cm))
-
- private def cmHeaders(headers: Map[String, Any], cm: CamelMessage) = headers ++ cm.getHeaders
-}
-
-/**
- * Defines conversion methods to CamelExchangeAdapter and CamelMessageAdapter.
- * Imported by applications that implicitly want to use conversion methods of
- * CamelExchangeAdapter and CamelMessageAdapter.
- */
-object CamelMessageConversion {
-
- /**
- * Creates an CamelExchangeAdapter for the given Camel exchange.
- */
- implicit def toExchangeAdapter(ce: Exchange): CamelExchangeAdapter =
- new CamelExchangeAdapter(ce)
-
- /**
- * Creates an CamelMessageAdapter for the given Camel message.
- */
- implicit def toMessageAdapter(cm: CamelMessage): CamelMessageAdapter =
- new CamelMessageAdapter(cm)
-}
diff --git a/akka-camel/src/main/scala/akka/Producer.scala b/akka-camel/src/main/scala/akka/Producer.scala
deleted file mode 100644
index ae23ae8c4e..0000000000
--- a/akka-camel/src/main/scala/akka/Producer.scala
+++ /dev/null
@@ -1,256 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.camel
-
-import CamelMessageConversion.toExchangeAdapter
-
-import org.apache.camel._
-import org.apache.camel.processor.SendProcessor
-
-import akka.actor.{Actor, ActorRef, UntypedActor}
-
-/**
- * Support trait for producing messages to Camel endpoints.
- *
- * @author Martin Krasser
- */
-trait ProducerSupport { this: Actor =>
-
- /**
- * Message headers to copy by default from request message to response-message.
- */
- private val headersToCopyDefault = Set(Message.MessageExchangeId)
-
- /**
- * Endpoint object resolved from the current CamelContext with
- * endpointUri.
- */
- private lazy val endpoint = CamelContextManager.mandatoryContext.getEndpoint(endpointUri)
-
- /**
- * SendProcessor for producing messages to endpoint.
- */
- private lazy val processor = createSendProcessor
-
- /**
- * If set to false (default), this producer expects a response message from the Camel endpoint.
- * If set to true, this producer initiates an in-only message exchange with the Camel endpoint
- * (fire and forget).
- */
- def oneway: Boolean = false
-
- /**
- * Returns the Camel endpoint URI to produce messages to.
- */
- def endpointUri: String
-
- /**
- * Returns the names of message headers to copy from a request message to a response message.
- * By default only the Message.MessageExchangeId is copied. Applications may override this to
- * define an application-specific set of message headers to copy.
- */
- def headersToCopy: Set[String] = headersToCopyDefault
-
- /**
- * Default implementation of Actor.postStop for freeing resources needed
- * to actually send messages to endpointUri.
- */
- override def postStop {
- processor.stop
- }
-
- /**
- * Initiates a message exchange of given pattern with the endpoint specified by
- * endpointUri. The in-message of the initiated exchange is the canonical form
- * of msg. After sending the in-message, the processing result (response) is passed
- * as argument to receiveAfterProduce. If the response is received synchronously from
- * the endpoint then receiveAfterProduce is called synchronously as well. If the
- * response is received asynchronously, the receiveAfterProduce is called
- * asynchronously. This is done by wrapping the response, adding it to this producers
- * mailbox, unwrapping it and calling receiveAfterProduce. The original
- * sender and senderFuture are thereby preserved.
- *
- * @see Message#canonicalize(Any)
- *
- * @param msg message to produce
- * @param pattern exchange pattern
- */
- protected def produce(msg: Any, pattern: ExchangePattern): Unit = {
- val cmsg = Message.canonicalize(msg)
- val exchange = createExchange(pattern).fromRequestMessage(cmsg)
- processor.process(exchange, new AsyncCallback {
- val producer = self
- // Need copies of sender and senderFuture references here
- // since the callback could be done later by another thread.
- val sender = self.sender
- val senderFuture = self.senderFuture
-
- def done(doneSync: Boolean): Unit = {
- (doneSync, exchange.isFailed) match {
- case (true, true) => dispatchSync(exchange.toFailureMessage(cmsg.headers(headersToCopy)))
- case (true, false) => dispatchSync(exchange.toResponseMessage(cmsg.headers(headersToCopy)))
- case (false, true) => dispatchAsync(FailureResult(exchange.toFailureMessage(cmsg.headers(headersToCopy))))
- case (false, false) => dispatchAsync(MessageResult(exchange.toResponseMessage(cmsg.headers(headersToCopy))))
- }
- }
-
- private def dispatchSync(result: Any) =
- receiveAfterProduce(result)
-
- private def dispatchAsync(result: Any) = {
- if (senderFuture.isDefined)
- producer.postMessageToMailboxAndCreateFutureResultWithTimeout(result, producer.timeout, sender, senderFuture)
- else
- producer.postMessageToMailbox(result, sender)
- }
- })
- }
-
- /**
- * Produces msg to the endpoint specified by endpointUri. Before the message is
- * actually sent it is pre-processed by calling receiveBeforeProduce. If oneway
- * is true, an in-only message exchange is initiated, otherwise an in-out message exchange.
- *
- * @see Producer#produce(Any, ExchangePattern)
- */
- protected def produce: Receive = {
- case res: MessageResult => receiveAfterProduce(res.message)
- case res: FailureResult => receiveAfterProduce(res.failure)
- case msg => {
- if (oneway)
- produce(receiveBeforeProduce(msg), ExchangePattern.InOnly)
- else
- produce(receiveBeforeProduce(msg), ExchangePattern.InOut)
- }
- }
-
- /**
- * Called before the message is sent to the endpoint specified by endpointUri. The original
- * message is passed as argument. By default, this method simply returns the argument but may be overridden
- * by subtraits or subclasses.
- */
- protected def receiveBeforeProduce: PartialFunction[Any, Any] = {
- case msg => msg
- }
-
- /**
- * Called after a response was received from the endpoint specified by endpointUri. The
- * response is passed as argument. By default, this method sends the response back to the original sender
- * if oneway is false. If oneway is true, nothing is
- * done. This method may be overridden by subtraits or subclasses (e.g. to forward responses to another
- * actor).
- */
- protected def receiveAfterProduce: Receive = {
- case msg => if (!oneway) self.reply(msg)
- }
-
- /**
- * Creates a new Exchange of given pattern from the endpoint specified by
- * endpointUri.
- */
- private def createExchange(pattern: ExchangePattern): Exchange = endpoint.createExchange(pattern)
-
- /**
- * Creates a new SendProcessor for endpoint.
- */
- private def createSendProcessor = {
- val sendProcessor = new SendProcessor(endpoint)
- sendProcessor.start
- sendProcessor
- }
-}
-
-/**
- * Mixed in by Actor implementations to produce messages to Camel endpoints.
- */
-trait Producer extends ProducerSupport { this: Actor =>
-
- /**
- * Default implementation of Actor.receive. Any messages received by this actors
- * will be produced to the endpoint specified by endpointUri.
- */
- protected def receive = produce
-}
-
-/**
- * Java-friendly ProducerSupport.
- *
- * @see UntypedProducerActor
- *
- * @author Martin Krasser
- */
-trait UntypedProducer extends ProducerSupport { this: UntypedActor =>
- final override def endpointUri = getEndpointUri
- final override def oneway = isOneway
-
- final override def receiveBeforeProduce = {
- case msg => onReceiveBeforeProduce(msg)
- }
-
- final override def receiveAfterProduce = {
- case msg => onReceiveAfterProduce(msg)
- }
-
- /**
- * Default implementation of UntypedActor.onReceive
- */
- def onReceive(message: Any) = produce(message)
-
- /**
- * Returns the Camel endpoint URI to produce messages to.
- */
- def getEndpointUri(): String
-
- /**
- * If set to false (default), this producer expects a response message from the Camel endpoint.
- * If set to true, this producer communicates with the Camel endpoint with an in-only message
- * exchange pattern (fire and forget).
- */
- def isOneway() = super.oneway
-
- /**
- * Called before the message is sent to the endpoint specified by getEndpointUri. The original
- * message is passed as argument. By default, this method simply returns the argument but may be overridden
- * by subclasses.
- */
- @throws(classOf[Exception])
- def onReceiveBeforeProduce(message: Any): Any = super.receiveBeforeProduce(message)
-
- /**
- * Called after a response was received from the endpoint specified by endpointUri. The
- * response is passed as argument. By default, this method sends the response back to the original sender
- * if oneway is false. If oneway is true, nothing is
- * done. This method may be overridden by subclasses (e.g. to forward responses to another actor).
- */
- @throws(classOf[Exception])
- def onReceiveAfterProduce(message: Any): Unit = super.receiveAfterProduce(message)
-}
-
-/**
- * Subclass this abstract class to create an untyped producer actor. This class is meant to be used from Java.
- *
- * @author Martin Krasser
- */
-abstract class UntypedProducerActor extends UntypedActor with UntypedProducer
-
-/**
- * @author Martin Krasser
- */
-private[camel] case class MessageResult(message: Message)
-
-/**
- * @author Martin Krasser
- */
-private[camel] case class FailureResult(failure: Failure)
-
-/**
- * A one-way producer.
- *
- * @author Martin Krasser
- */
-trait Oneway extends Producer { this: Actor =>
- override def oneway = true
-}
-
diff --git a/akka-camel/src/main/scala/akka/component/ActorComponent.scala b/akka-camel/src/main/scala/akka/component/ActorComponent.scala
deleted file mode 100644
index e84a894ee3..0000000000
--- a/akka-camel/src/main/scala/akka/component/ActorComponent.scala
+++ /dev/null
@@ -1,305 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.camel.component
-
-import java.net.InetSocketAddress
-import java.util.{Map => JMap}
-import java.util.concurrent.TimeoutException
-import java.util.concurrent.atomic.AtomicReference
-
-import org.apache.camel._
-import org.apache.camel.impl.{DefaultProducer, DefaultEndpoint, DefaultComponent}
-
-import akka.actor._
-import akka.camel.{Failure, Message}
-import akka.camel.CamelMessageConversion.toExchangeAdapter
-import akka.dispatch.{CompletableFuture, MessageInvocation, MessageDispatcher}
-
-import scala.reflect.BeanProperty
-
-/**
- * @author Martin Krasser
- */
-object ActorComponent {
- /**
- * Name of the message header containing the actor id or uuid.
- */
- val ActorIdentifier = "CamelActorIdentifier"
-}
-
-/**
- * Camel component for sending messages to and receiving replies from (untyped) actors.
- *
- * @see akka.camel.component.ActorEndpoint
- * @see akka.camel.component.ActorProducer
- *
- * @author Martin Krasser
- */
-class ActorComponent extends DefaultComponent {
- def createEndpoint(uri: String, remaining: String, parameters: JMap[String, Object]): ActorEndpoint = {
- val (idType, idValue) = parsePath(remaining)
- new ActorEndpoint(uri, this, idType, idValue)
- }
-
- private def parsePath(remaining: String): Tuple2[String, Option[String]] = remaining match {
- case null | "" => throw new IllegalArgumentException("invalid path: [%s] - should be or id: or uuid:" format remaining)
- case id if id startsWith "id:" => ("id", parseIdentifier(id substring 3))
- case uuid if uuid startsWith "uuid:" => ("uuid", parseIdentifier(uuid substring 5))
- case id => ("id", parseIdentifier(id))
- }
-
- private def parseIdentifier(identifier: String): Option[String] =
- if (identifier.length > 0) Some(identifier) else None
-}
-
-/**
- * Camel endpoint for sending messages to and receiving replies from (untyped) actors. Actors
- * are referenced using actor endpoint URIs of the following format:
- * actor:,
- * actor:id:[] and
- * actor:uuid:[],
- * where refers to ActorRef.id and
- * refers to the String-representation od ActorRef.uuid. In URIs that contain
- * id: or uuid:, an actor identifier (id or uuid) is optional. In this
- * case, the in-message of an exchange produced to this endpoint must contain a message header
- * with name CamelActorIdentifier and a value that is the target actor's identifier.
- * If the URI contains an actor identifier, a message with a CamelActorIdentifier
- * header overrides the identifier in the endpoint URI.
- *
- * @see akka.camel.component.ActorComponent
- * @see akka.camel.component.ActorProducer
-
- * @author Martin Krasser
- */
-class ActorEndpoint(uri: String,
- comp: ActorComponent,
- val idType: String,
- val idValue: Option[String]) extends DefaultEndpoint(uri, comp) {
-
- /**
- * Whether to block caller thread during two-way message exchanges with (untyped) actors. This is
- * set via the blocking=true|false endpoint URI parameter. Default value is
- * false.
- */
- @BeanProperty var blocking: Boolean = false
-
- /**
- * @throws UnsupportedOperationException
- */
- def createConsumer(processor: Processor): Consumer =
- throw new UnsupportedOperationException("actor consumer not supported yet")
-
- /**
- * Creates a new ActorProducer instance initialized with this endpoint.
- */
- def createProducer: ActorProducer = new ActorProducer(this)
-
- /**
- * Returns true.
- */
- def isSingleton: Boolean = true
-}
-
-/**
- * Sends the in-message of an exchange to an (untyped) actor, identified by an
- * actor endpoint URI or by a CamelActorIdentifier message header.
- *
- *
If the exchange pattern is out-capable and blocking is set to
- * true then the producer waits for a reply, using the !! operator.
- *
If the exchange pattern is out-capable and blocking is set to
- * false then the producer sends the message using the ! operator, together
- * with a callback handler. The callback handler is an ActorRef that can be
- * used by the receiving actor to asynchronously reply to the route that is sending the
- * message.
- *
If the exchange pattern is in-only then the producer sends the message using the
- * ! operator.
- *
- *
- * @see akka.camel.component.ActorComponent
- * @see akka.camel.component.ActorEndpoint
- *
- * @author Martin Krasser
- */
-class ActorProducer(val ep: ActorEndpoint) extends DefaultProducer(ep) with AsyncProcessor {
- import ActorProducer._
-
- private lazy val uuid = uuidFrom(ep.idValue.getOrElse(throw new ActorIdentifierNotSetException))
-
- def process(exchange: Exchange) =
- if (exchange.getPattern.isOutCapable) sendSync(exchange) else sendAsync(exchange)
-
- def process(exchange: Exchange, callback: AsyncCallback): Boolean = {
- (exchange.getPattern.isOutCapable, ep.blocking) match {
- case (true, true) => {
- sendSync(exchange)
- callback.done(true)
- true
- }
- case (true, false) => {
- sendAsync(exchange, Some(AsyncCallbackAdapter(exchange, callback)))
- false
- }
- case (false, _) => {
- sendAsync(exchange)
- callback.done(true)
- true
- }
- }
- }
-
- private def sendSync(exchange: Exchange) = {
- val actor = target(exchange)
- val result: Any = actor !! requestFor(exchange)
-
- result match {
- case Some(msg: Failure) => exchange.fromFailureMessage(msg)
- case Some(msg) => exchange.fromResponseMessage(Message.canonicalize(msg))
- case None => throw new TimeoutException("timeout (%d ms) while waiting response from %s"
- format (actor.timeout, ep.getEndpointUri))
- }
- }
-
- private def sendAsync(exchange: Exchange, sender: Option[ActorRef] = None) =
- target(exchange).!(requestFor(exchange))(sender)
-
- private def target(exchange: Exchange) =
- targetOption(exchange) getOrElse (throw new ActorNotRegisteredException(ep.getEndpointUri))
-
- private def targetOption(exchange: Exchange): Option[ActorRef] = ep.idType match {
- case "id" => targetById(targetId(exchange))
- case "uuid" => targetByUuid(targetUuid(exchange))
- }
-
- private def targetId(exchange: Exchange) = exchange.getIn.getHeader(ActorComponent.ActorIdentifier) match {
- case id: String => id
- case null => ep.idValue.getOrElse(throw new ActorIdentifierNotSetException)
- }
-
- private def targetUuid(exchange: Exchange) = exchange.getIn.getHeader(ActorComponent.ActorIdentifier) match {
- case uuid: Uuid => uuid
- case uuid: String => uuidFrom(uuid)
- case null => uuid
- }
-
- private def targetById(id: String) = ActorRegistry.actorsFor(id) match {
- case actors if actors.length == 0 => None
- case actors => Some(actors(0))
- }
-
- private def targetByUuid(uuid: Uuid) = ActorRegistry.actorFor(uuid)
-}
-
-/**
- * @author Martin Krasser
- */
-private[camel] object ActorProducer {
- def requestFor(exchange: Exchange) =
- exchange.toRequestMessage(Map(Message.MessageExchangeId -> exchange.getExchangeId))
-}
-
-/**
- * Thrown to indicate that an actor referenced by an endpoint URI cannot be
- * found in the ActorRegistry.
- *
- * @author Martin Krasser
- */
-class ActorNotRegisteredException(uri: String) extends RuntimeException {
- override def getMessage = "%s not registered" format uri
-}
-
-/**
- * Thrown to indicate that no actor identifier has been set.
- *
- * @author Martin Krasser
- */
-class ActorIdentifierNotSetException extends RuntimeException {
- override def getMessage = "actor identifier not set"
-}
-
-/**
- * @author Martin Krasser
- */
-private[akka] object AsyncCallbackAdapter {
- /**
- * Creates and starts an AsyncCallbackAdapter.
- *
- * @param exchange message exchange to write results to.
- * @param callback callback object to generate completion notifications.
- */
- def apply(exchange: Exchange, callback: AsyncCallback) =
- new AsyncCallbackAdapter(exchange, callback).start
-}
-
-/**
- * Adapts an ActorRef to a Camel AsyncCallback. Used by receiving actors to reply
- * asynchronously to Camel routes with ActorRef.reply.
- *
- * Please note that this adapter can only be used locally at the moment which should not
- * be a problem is most situations since Camel endpoints are only activated for local actor references,
- * never for remote references.
- *
- * @author Martin Krasser
- */
-private[akka] class AsyncCallbackAdapter(exchange: Exchange, callback: AsyncCallback) extends ActorRef with ScalaActorRef {
-
- def start = {
- _status = ActorRefInternals.RUNNING
- this
- }
-
- def stop() = {
- _status = ActorRefInternals.SHUTDOWN
- }
-
- /**
- * Populates the initial exchange with the reply message and uses the
- * callback handler to notify Camel about the asynchronous completion of the message
- * exchange.
- *
- * @param message reply message
- * @param sender ignored
- */
- protected[akka] def postMessageToMailbox(message: Any, senderOption: Option[ActorRef]) = {
- message match {
- case msg: Failure => exchange.fromFailureMessage(msg)
- case msg => exchange.fromResponseMessage(Message.canonicalize(msg))
- }
- callback.done(false)
- }
-
- def actorClass: Class[_ <: Actor] = unsupported
- def actorClassName = unsupported
- def dispatcher_=(md: MessageDispatcher): Unit = unsupported
- def dispatcher: MessageDispatcher = unsupported
- def makeRemote(hostname: String, port: Int): Unit = unsupported
- def makeRemote(address: InetSocketAddress): Unit = unsupported
- def homeAddress_=(address: InetSocketAddress): Unit = unsupported
- def remoteAddress: Option[InetSocketAddress] = unsupported
- def link(actorRef: ActorRef): Unit = unsupported
- def unlink(actorRef: ActorRef): Unit = unsupported
- def startLink(actorRef: ActorRef): Unit = unsupported
- def startLinkRemote(actorRef: ActorRef, hostname: String, port: Int): Unit = unsupported
- def spawn(clazz: Class[_ <: Actor]): ActorRef = unsupported
- def spawnRemote(clazz: Class[_ <: Actor], hostname: String, port: Int): ActorRef = unsupported
- def spawnLink(clazz: Class[_ <: Actor]): ActorRef = unsupported
- def spawnLinkRemote(clazz: Class[_ <: Actor], hostname: String, port: Int): ActorRef = unsupported
- def shutdownLinkedActors: Unit = unsupported
- def supervisor: Option[ActorRef] = unsupported
- protected[akka] def postMessageToMailboxAndCreateFutureResultWithTimeout[T](message: Any, timeout: Long, senderOption: Option[ActorRef], senderFuture: Option[CompletableFuture[T]]) = unsupported
- protected[akka] def mailbox: AnyRef = unsupported
- protected[akka] def mailbox_=(msg: AnyRef):AnyRef = unsupported
- protected[akka] def restart(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Unit = unsupported
- protected[akka] def restartLinkedActors(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Unit = unsupported
- protected[akka] def handleTrapExit(dead: ActorRef, reason: Throwable): Unit = unsupported
- protected[akka] def linkedActors: JMap[Uuid, ActorRef] = unsupported
- protected[akka] def linkedActorsAsList: List[ActorRef] = unsupported
- protected[akka] def invoke(messageHandle: MessageInvocation): Unit = unsupported
- protected[akka] def remoteAddress_=(addr: Option[InetSocketAddress]): Unit = unsupported
- protected[akka] def registerSupervisorAsRemoteActor = unsupported
- protected[akka] def supervisor_=(sup: Option[ActorRef]): Unit = unsupported
- protected[akka] def actorInstance: AtomicReference[Actor] = unsupported
-
- private def unsupported = throw new UnsupportedOperationException("Not supported for %s" format classOf[AsyncCallbackAdapter].getName)
-}
diff --git a/akka-camel/src/main/scala/akka/component/TypedActorComponent.scala b/akka-camel/src/main/scala/akka/component/TypedActorComponent.scala
deleted file mode 100644
index f4a7f1b099..0000000000
--- a/akka-camel/src/main/scala/akka/component/TypedActorComponent.scala
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.camel.component
-
-import java.util.Map
-import java.util.concurrent.ConcurrentHashMap
-import org.apache.camel.CamelContext
-import org.apache.camel.component.bean._
-
-/**
- * @author Martin Krasser
- */
-object TypedActorComponent {
- /**
- * Default schema name for typed actor endpoint URIs.
- */
- val InternalSchema = "typed-actor-internal"
-}
-
-/**
- * Camel component for exchanging messages with typed actors. This component
- * tries to obtain the typed actor from its typedActorRegistry
- * first. If it's not there it tries to obtain it from the CamelContext's registry.
- *
- * @see org.apache.camel.component.bean.BeanComponent
- *
- * @author Martin Krasser
- */
-class TypedActorComponent extends BeanComponent {
- val typedActorRegistry = new ConcurrentHashMap[String, AnyRef]
-
- /**
- * Creates an org.apache.camel.component.bean.BeanEndpoint with a custom
- * bean holder that uses typedActorRegistry for getting access to typed
- * actors (beans).
- *
- * @see akka.camel.component.TypedActorHolder
- */
- override def createEndpoint(uri: String, remaining: String, parameters: Map[String, AnyRef]) = {
- val endpoint = new BeanEndpoint(uri, this)
- endpoint.setBeanName(remaining)
- endpoint.setBeanHolder(createBeanHolder(remaining))
- setProperties(endpoint.getProcessor, parameters)
- endpoint
- }
-
- private def createBeanHolder(beanName: String) =
- new TypedActorHolder(typedActorRegistry, getCamelContext, beanName).createCacheHolder
-}
-
-/**
- * org.apache.camel.component.bean.BeanHolder implementation that uses a custom
- * registry for getting access to typed actors.
- *
- * @author Martin Krasser
- */
-class TypedActorHolder(typedActorRegistry: Map[String, AnyRef], context: CamelContext, name: String)
- extends RegistryBean(context, name) {
-
- /**
- * Returns an akka.camel.component.TypedActorInfo instance.
- */
- override def getBeanInfo: BeanInfo =
- new TypedActorInfo(getContext, getBean.getClass, getParameterMappingStrategy)
-
- /**
- * Obtains a typed actor from typedActorRegistry. If the typed actor cannot
- * be found then this method tries to obtain the actor from the CamelContext's registry.
- *
- * @return a typed actor or null.
- */
- override def getBean: AnyRef = {
- val bean = typedActorRegistry.get(getName)
- if (bean eq null) super.getBean else bean
- }
-}
-
-/**
- * Typed actor meta information.
- *
- * @author Martin Krasser
- */
-class TypedActorInfo(context: CamelContext, clazz: Class[_], strategy: ParameterMappingStrategy)
- extends BeanInfo(context, clazz, strategy) {
-
- /**
- * Introspects AspectWerkz proxy classes.
- *
- * @param clazz AspectWerkz proxy class.
- */
- protected override def introspect(clazz: Class[_]): Unit = {
-
- // TODO: fix target class detection in BeanInfo.introspect(Class)
- // Camel assumes that classes containing a '$$' in the class name
- // are classes generated with CGLIB. This conflicts with proxies
- // created from interfaces with AspectWerkz. Once the fix is in
- // place this method can be removed.
-
- for (method <- clazz.getDeclaredMethods) {
- if (isValidMethod(clazz, method)) {
- introspect(clazz, method)
- }
- }
- val superclass = clazz.getSuperclass
- if ((superclass ne null) && !superclass.equals(classOf[AnyRef])) {
- introspect(superclass)
- }
- }
-}
diff --git a/akka-camel/src/test/java/akka/camel/ConsumerJavaTestBase.java b/akka-camel/src/test/java/akka/camel/ConsumerJavaTestBase.java
deleted file mode 100644
index c34ce0cc2e..0000000000
--- a/akka-camel/src/test/java/akka/camel/ConsumerJavaTestBase.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package akka.camel;
-
-import akka.actor.ActorRegistry;
-import akka.actor.TypedActor;
-import akka.actor.UntypedActor;
-import akka.japi.SideEffect;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static akka.camel.CamelContextManager.*;
-import static akka.camel.CamelServiceManager.*;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Martin Krasser
- */
-public class ConsumerJavaTestBase {
-
- private SampleErrorHandlingTypedConsumer consumer;
-
- @BeforeClass
- public static void setUpBeforeClass() {
- startCamelService();
- }
-
- @AfterClass
- public static void tearDownAfterClass() {
- stopCamelService();
- ActorRegistry.shutdownAll();
- }
-
- @Test
- public void shouldHandleExceptionThrownByActorAndGenerateCustomResponse() {
- getMandatoryService().awaitEndpointActivation(1, new SideEffect() {
- public void apply() {
- UntypedActor.actorOf(SampleErrorHandlingConsumer.class).start();
- }
- });
- String result = getMandatoryTemplate().requestBody("direct:error-handler-test-java", "hello", String.class);
- assertEquals("error: hello", result);
- }
-
- @Test
- public void shouldHandleExceptionThrownByTypedActorAndGenerateCustomResponse() {
- getMandatoryService().awaitEndpointActivation(1, new SideEffect() {
- public void apply() {
- consumer = TypedActor.newInstance(
- SampleErrorHandlingTypedConsumer.class,
- SampleErrorHandlingTypedConsumerImpl.class);
- }
- });
- String result = getMandatoryTemplate().requestBody("direct:error-handler-test-java-typed", "hello", String.class);
- assertEquals("error: hello", result);
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/MessageJavaTestBase.java b/akka-camel/src/test/java/akka/camel/MessageJavaTestBase.java
deleted file mode 100644
index 38e0b95692..0000000000
--- a/akka-camel/src/test/java/akka/camel/MessageJavaTestBase.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package akka.camel;
-
-import org.apache.camel.NoTypeConversionAvailableException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import akka.camel.CamelContextManager;
-import akka.camel.Message;
-import akka.japi.Function;
-
-import java.io.InputStream;
-import java.util.*;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Martin Krasser
- */
-public class MessageJavaTestBase {
-
- @BeforeClass
- public static void setUpBeforeClass() {
- CamelContextManager.init();
- }
-
- @Test public void shouldConvertDoubleBodyToString() {
- assertEquals("1.4", new Message("1.4").getBodyAs(String.class));
- }
-
- @Test(expected=NoTypeConversionAvailableException.class)
- public void shouldThrowExceptionWhenConvertingDoubleBodyToInputStream() {
- new Message(1.4).getBodyAs(InputStream.class);
- }
-
- @Test public void shouldReturnDoubleHeader() {
- Message message = new Message("test" , createMap("test", 1.4));
- assertEquals(1.4, message.getHeader("test"));
- }
-
- @Test public void shouldConvertDoubleHeaderToString() {
- Message message = new Message("test" , createMap("test", 1.4));
- assertEquals("1.4", message.getHeaderAs("test", String.class));
- }
-
- @Test public void shouldReturnSubsetOfHeaders() {
- Message message = new Message("test" , createMap("A", "1", "B", "2"));
- assertEquals(createMap("B", "2"), message.getHeaders(createSet("B")));
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void shouldReturnSubsetOfHeadersUnmodifiable() {
- Message message = new Message("test" , createMap("A", "1", "B", "2"));
- message.getHeaders(createSet("B")).put("x", "y");
- }
-
- @Test public void shouldReturnAllHeaders() {
- Message message = new Message("test" , createMap("A", "1", "B", "2"));
- assertEquals(createMap("A", "1", "B", "2"), message.getHeaders());
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void shouldReturnAllHeadersUnmodifiable() {
- Message message = new Message("test" , createMap("A", "1", "B", "2"));
- message.getHeaders().put("x", "y");
- }
-
- @Test public void shouldTransformBodyAndPreserveHeaders() {
- assertEquals(
- new Message("ab", createMap("A", "1")),
- new Message("a" , createMap("A", "1")).transformBody((Function)new TestTransformer()));
- }
-
- @Test public void shouldConvertBodyAndPreserveHeaders() {
- assertEquals(
- new Message("1.4", createMap("A", "1")),
- new Message(1.4 , createMap("A", "1")).setBodyAs(String.class));
- }
-
- @Test public void shouldSetBodyAndPreserveHeaders() {
- assertEquals(
- new Message("test2" , createMap("A", "1")),
- new Message("test1" , createMap("A", "1")).setBody("test2"));
- }
-
- @Test public void shouldSetHeadersAndPreserveBody() {
- assertEquals(
- new Message("test1" , createMap("C", "3")),
- new Message("test1" , createMap("A", "1")).setHeaders(createMap("C", "3")));
- }
-
- @Test public void shouldAddHeaderAndPreserveBodyAndHeaders() {
- assertEquals(
- new Message("test1" , createMap("A", "1", "B", "2")),
- new Message("test1" , createMap("A", "1")).addHeader("B", "2"));
- }
-
- @Test public void shouldAddHeadersAndPreserveBodyAndHeaders() {
- assertEquals(
- new Message("test1" , createMap("A", "1", "B", "2")),
- new Message("test1" , createMap("A", "1")).addHeaders(createMap("B", "2")));
- }
-
- @Test public void shouldRemoveHeadersAndPreserveBodyAndRemainingHeaders() {
- assertEquals(
- new Message("test1" , createMap("A", "1")),
- new Message("test1" , createMap("A", "1", "B", "2")).removeHeader("B"));
- }
-
- private static Set createSet(String... entries) {
- HashSet set = new HashSet();
- set.addAll(Arrays.asList(entries));
- return set;
- }
-
- private static Map createMap(Object... pairs) {
- HashMap map = new HashMap();
- for (int i = 0; i < pairs.length; i += 2) {
- map.put((String)pairs[i], pairs[i+1]);
- }
- return map;
- }
-
- private static class TestTransformer implements Function {
- public String apply(String param) {
- return param + "b";
- }
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleErrorHandlingConsumer.java b/akka-camel/src/test/java/akka/camel/SampleErrorHandlingConsumer.java
deleted file mode 100644
index 4e35d4e6ab..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleErrorHandlingConsumer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package akka.camel;
-
-import org.apache.camel.builder.Builder;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.RouteDefinition;
-
-/**
- * @author Martin Krasser
- */
-public class SampleErrorHandlingConsumer extends UntypedConsumerActor {
-
- public String getEndpointUri() {
- return "direct:error-handler-test-java";
- }
-
- public boolean isBlocking() {
- return true;
- }
-
- public void preStart() {
- onRouteDefinition(new RouteDefinitionHandler() {
- public ProcessorDefinition> onRouteDefinition(RouteDefinition rd) {
- return rd.onException(Exception.class).handled(true).transform(Builder.exceptionMessage()).end();
- }
- });
- }
-
- public void onReceive(Object message) throws Exception {
- Message msg = (Message)message;
- String body = msg.getBodyAs(String.class);
- throw new Exception(String.format("error: %s", body));
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleErrorHandlingTypedConsumer.java b/akka-camel/src/test/java/akka/camel/SampleErrorHandlingTypedConsumer.java
deleted file mode 100644
index d8a8c79440..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleErrorHandlingTypedConsumer.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package akka.camel;
-
-/**
- * @author Martin Krasser
- */
-public interface SampleErrorHandlingTypedConsumer {
-
- @consume(value="direct:error-handler-test-java-typed", routeDefinitionHandler=SampleRouteDefinitionHandler.class)
- String willFail(String s);
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleErrorHandlingTypedConsumerImpl.java b/akka-camel/src/test/java/akka/camel/SampleErrorHandlingTypedConsumerImpl.java
deleted file mode 100644
index cfa42a7521..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleErrorHandlingTypedConsumerImpl.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package akka.camel;
-
-import akka.actor.TypedActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleErrorHandlingTypedConsumerImpl extends TypedActor implements SampleErrorHandlingTypedConsumer {
-
- public String willFail(String s) {
- throw new RuntimeException(String.format("error: %s", s));
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleRemoteTypedConsumer.java b/akka-camel/src/test/java/akka/camel/SampleRemoteTypedConsumer.java
deleted file mode 100644
index 41a3c3f057..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleRemoteTypedConsumer.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package akka.camel;
-
-import akka.camel.consume;
-
-/**
- * @author Martin Krasser
- */
-public interface SampleRemoteTypedConsumer {
-
- @consume("direct:remote-typed-consumer")
- public String foo(String s);
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleRemoteTypedConsumerImpl.java b/akka-camel/src/test/java/akka/camel/SampleRemoteTypedConsumerImpl.java
deleted file mode 100644
index d7fb463b44..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleRemoteTypedConsumerImpl.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package akka.camel;
-
-import akka.actor.TypedActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleRemoteTypedConsumerImpl extends TypedActor implements SampleRemoteTypedConsumer {
-
- public String foo(String s) {
- return String.format("remote typed actor: %s", s);
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleRemoteUntypedConsumer.java b/akka-camel/src/test/java/akka/camel/SampleRemoteUntypedConsumer.java
deleted file mode 100644
index 85ccb2638b..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleRemoteUntypedConsumer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package akka.camel;
-
-import akka.camel.RemoteUntypedConsumerActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleRemoteUntypedConsumer extends RemoteUntypedConsumerActor {
-
- public SampleRemoteUntypedConsumer() {
- this("localhost", 7774);
- }
-
- public SampleRemoteUntypedConsumer(String host, int port) {
- super(host, port);
- }
-
- public String getEndpointUri() {
- return "direct:remote-untyped-consumer";
- }
-
- public void onReceive(Object message) {
- Message msg = (Message)message;
- String body = msg.getBodyAs(String.class);
- String header = msg.getHeaderAs("test", String.class);
- getContext().replySafe(String.format("%s %s", body, header));
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleRouteDefinitionHandler.java b/akka-camel/src/test/java/akka/camel/SampleRouteDefinitionHandler.java
deleted file mode 100644
index f1a99aa7d4..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleRouteDefinitionHandler.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package akka.camel;
-
-import org.apache.camel.builder.Builder;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.RouteDefinition;
-
-/**
- * @author Martin Krasser
- */
-public class SampleRouteDefinitionHandler implements RouteDefinitionHandler {
- public ProcessorDefinition> onRouteDefinition(RouteDefinition rd) {
- return rd.onException(Exception.class).handled(true).transform(Builder.exceptionMessage()).end();
- }
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleTypedActor.java b/akka-camel/src/test/java/akka/camel/SampleTypedActor.java
deleted file mode 100644
index 798d07a66c..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleTypedActor.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package akka.camel;
-
-/**
- * @author Martin Krasser
- */
-public interface SampleTypedActor {
-
- public String foo(String s);
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleTypedActorImpl.java b/akka-camel/src/test/java/akka/camel/SampleTypedActorImpl.java
deleted file mode 100644
index 773e3ec3ec..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleTypedActorImpl.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package akka.camel;
-
-import akka.actor.TypedActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleTypedActorImpl extends TypedActor implements SampleTypedActor {
-
- public String foo(String s) {
- return String.format("foo: %s", s);
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleTypedConsumer.java b/akka-camel/src/test/java/akka/camel/SampleTypedConsumer.java
deleted file mode 100644
index 26283d8e61..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleTypedConsumer.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package akka.camel;
-
-import org.apache.camel.Body;
-import org.apache.camel.Header;
-
-import akka.camel.consume;
-
-/**
- * @author Martin Krasser
- */
-public interface SampleTypedConsumer {
-
- public String m1(String b, String h);
- public String m2(@Body String b, @Header("test") String h);
- public String m3(@Body String b, @Header("test") String h);
-
- @consume("direct:m4")
- public String m4(@Body String b, @Header("test") String h);
- public void m5(@Body String b, @Header("test") String h);
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleTypedConsumerImpl.java b/akka-camel/src/test/java/akka/camel/SampleTypedConsumerImpl.java
deleted file mode 100644
index 3bbe7a9442..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleTypedConsumerImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package akka.camel;
-
-import akka.actor.TypedActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleTypedConsumerImpl extends TypedActor implements SampleTypedConsumer {
-
- public String m1(String b, String h) {
- return "m1: " + b + " " + h;
- }
-
- @consume("direct:m2")
- public String m2(String b, String h) {
- return "m2: " + b + " " + h;
- }
-
- @consume("direct:m3")
- public String m3(String b, String h) {
- return "m3: " + b + " " + h;
- }
-
- public String m4(String b, String h) {
- return "m4: " + b + " " + h;
- }
-
- public void m5(String b, String h) {
- }
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleTypedSingleConsumer.java b/akka-camel/src/test/java/akka/camel/SampleTypedSingleConsumer.java
deleted file mode 100644
index ff0b7bc715..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleTypedSingleConsumer.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package akka.camel;
-
-import akka.camel.consume;
-
-/**
- * @author Martin Krasser
- */
-public interface SampleTypedSingleConsumer {
-
- @consume("direct:foo")
- public void foo(String b);
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleTypedSingleConsumerImpl.java b/akka-camel/src/test/java/akka/camel/SampleTypedSingleConsumerImpl.java
deleted file mode 100644
index 27fbfdaa0d..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleTypedSingleConsumerImpl.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package akka.camel;
-
-import akka.actor.TypedActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleTypedSingleConsumerImpl extends TypedActor implements SampleTypedSingleConsumer {
-
- public void foo(String b) {
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleUntypedActor.java b/akka-camel/src/test/java/akka/camel/SampleUntypedActor.java
deleted file mode 100644
index 56614a6b80..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleUntypedActor.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package akka.camel;
-
-import akka.actor.UntypedActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleUntypedActor extends UntypedActor {
- public void onReceive(Object message) {
- logger().debug("Yay! I haz a message!");
- }
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleUntypedConsumer.java b/akka-camel/src/test/java/akka/camel/SampleUntypedConsumer.java
deleted file mode 100644
index 99300836c1..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleUntypedConsumer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package akka.camel;
-
-import akka.camel.UntypedConsumerActor;
-
-/**
- * @author Martin Krasser
- */
-public class SampleUntypedConsumer extends UntypedConsumerActor {
-
- public String getEndpointUri() {
- return "direct:test-untyped-consumer";
- }
-
- public void onReceive(Object message) {
- Message msg = (Message)message;
- String body = msg.getBodyAs(String.class);
- String header = msg.getHeaderAs("test", String.class);
- getContext().replySafe(String.format("%s %s", body, header));
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleUntypedConsumerBlocking.java b/akka-camel/src/test/java/akka/camel/SampleUntypedConsumerBlocking.java
deleted file mode 100644
index b5b22a04ae..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleUntypedConsumerBlocking.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package akka.camel;
-
-/**
- * @author Martin Krasser
- */
-public class SampleUntypedConsumerBlocking extends UntypedConsumerActor {
-
- public String getEndpointUri() {
- return "direct:test-untyped-consumer-blocking";
- }
-
- public boolean isBlocking() {
- return true;
- }
-
- public void onReceive(Object message) {
- Message msg = (Message)message;
- String body = msg.getBodyAs(String.class);
- String header = msg.getHeaderAs("test", String.class);
- getContext().replySafe(String.format("%s %s", body, header));
- }
-
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleUntypedForwardingProducer.java b/akka-camel/src/test/java/akka/camel/SampleUntypedForwardingProducer.java
deleted file mode 100644
index 3161c0f2d8..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleUntypedForwardingProducer.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package akka.camel;
-
-/**
- * @author Martin Krasser
- */
-public class SampleUntypedForwardingProducer extends UntypedProducerActor {
-
- public String getEndpointUri() {
- return "direct:producer-test-1";
- }
-
- @Override
- public void onReceiveAfterProduce(Object message) {
- Message msg = (Message)message;
- String body = msg.getBodyAs(String.class);
- CamelContextManager.getMandatoryTemplate().sendBody("direct:forward-test-1", body);
- }
-}
diff --git a/akka-camel/src/test/java/akka/camel/SampleUntypedReplyingProducer.java b/akka-camel/src/test/java/akka/camel/SampleUntypedReplyingProducer.java
deleted file mode 100644
index 09b7b86502..0000000000
--- a/akka-camel/src/test/java/akka/camel/SampleUntypedReplyingProducer.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package akka.camel;
-
-/**
- * @author Martin Krasser
- */
-public class SampleUntypedReplyingProducer extends UntypedProducerActor {
-
- public String getEndpointUri() {
- return "direct:producer-test-1";
- }
-
-}
diff --git a/akka-camel/src/test/scala/akka/CamelContextLifecycleTest.scala b/akka-camel/src/test/scala/akka/CamelContextLifecycleTest.scala
deleted file mode 100644
index 910373738f..0000000000
--- a/akka-camel/src/test/scala/akka/CamelContextLifecycleTest.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-package akka.camel
-
-import org.apache.camel.impl.{DefaultProducerTemplate, DefaultCamelContext}
-import org.junit.Test
-import org.scalatest.junit.JUnitSuite
-
-class CamelContextLifecycleTest extends JUnitSuite with CamelContextLifecycle {
- @Test def shouldManageCustomCamelContext {
- assert(context === None)
- assert(template === None)
-
- intercept[IllegalStateException] { mandatoryContext }
- intercept[IllegalStateException] { mandatoryTemplate }
-
- val ctx = new TestCamelContext
- assert(ctx.isStreamCaching === false)
-
- init(ctx)
-
- assert(mandatoryContext.isStreamCaching === true)
- assert(!mandatoryContext.asInstanceOf[TestCamelContext].isStarted)
- assert(mandatoryTemplate.asInstanceOf[DefaultProducerTemplate].isStarted)
-
- start
-
- assert(mandatoryContext.asInstanceOf[TestCamelContext].isStarted)
- assert(mandatoryTemplate.asInstanceOf[DefaultProducerTemplate].isStarted)
-
- stop
-
- assert(!mandatoryContext.asInstanceOf[TestCamelContext].isStarted)
- assert(!mandatoryTemplate.asInstanceOf[DefaultProducerTemplate].isStarted)
- }
-
- class TestCamelContext extends DefaultCamelContext
-}
diff --git a/akka-camel/src/test/scala/akka/CamelExchangeAdapterTest.scala b/akka-camel/src/test/scala/akka/CamelExchangeAdapterTest.scala
deleted file mode 100644
index 3996179b5b..0000000000
--- a/akka-camel/src/test/scala/akka/CamelExchangeAdapterTest.scala
+++ /dev/null
@@ -1,109 +0,0 @@
-package akka.camel
-
-import org.apache.camel.impl.{DefaultCamelContext, DefaultExchange}
-import org.apache.camel.ExchangePattern
-import org.junit.Test
-import org.scalatest.junit.JUnitSuite
-
-class CamelExchangeAdapterTest extends JUnitSuite {
- import CamelMessageConversion.toExchangeAdapter
-
- @Test def shouldSetInMessageFromRequestMessage = {
- val e1 = sampleInOnly.fromRequestMessage(Message("x"))
- assert(e1.getIn.getBody === "x")
- val e2 = sampleInOut.fromRequestMessage(Message("y"))
- assert(e2.getIn.getBody === "y")
- }
-
- @Test def shouldSetOutMessageFromResponseMessage = {
- val e1 = sampleInOut.fromResponseMessage(Message("y"))
- assert(e1.getOut.getBody === "y")
- }
-
- @Test def shouldSetInMessageFromResponseMessage = {
- val e1 = sampleInOnly.fromResponseMessage(Message("x"))
- assert(e1.getIn.getBody === "x")
- }
-
- @Test def shouldSetExceptionFromFailureMessage = {
- val e1 = sampleInOnly.fromFailureMessage(Failure(new Exception("test1")))
- assert(e1.getException.getMessage === "test1")
- val e2 = sampleInOut.fromFailureMessage(Failure(new Exception("test2")))
- assert(e2.getException.getMessage === "test2")
- }
-
- @Test def shouldCreateRequestMessageFromInMessage = {
- val m = sampleInOnly.toRequestMessage
- assert(m === Message("test-in", Map("key-in" -> "val-in")))
- }
-
- @Test def shouldCreateResponseMessageFromInMessage = {
- val m = sampleInOnly.toResponseMessage
- assert(m === Message("test-in", Map("key-in" -> "val-in")))
- }
-
- @Test def shouldCreateResponseMessageFromOutMessage = {
- val m = sampleInOut.toResponseMessage
- assert(m === Message("test-out", Map("key-out" -> "val-out")))
- }
-
- @Test def shouldCreateFailureMessageFromExceptionAndInMessage = {
- val e1 = sampleInOnly
- e1.setException(new Exception("test1"))
- assert(e1.toFailureMessage.cause.getMessage === "test1")
- assert(e1.toFailureMessage.headers("key-in") === "val-in")
- }
-
- @Test def shouldCreateFailureMessageFromExceptionAndOutMessage = {
- val e1 = sampleInOut
- e1.setException(new Exception("test2"))
- assert(e1.toFailureMessage.cause.getMessage === "test2")
- assert(e1.toFailureMessage.headers("key-out") === "val-out")
- }
-
- @Test def shouldCreateRequestMessageFromInMessageWithAdditionalHeader = {
- val m = sampleInOnly.toRequestMessage(Map("x" -> "y"))
- assert(m === Message("test-in", Map("key-in" -> "val-in", "x" -> "y")))
- }
-
- @Test def shouldCreateResponseMessageFromInMessageWithAdditionalHeader = {
- val m = sampleInOnly.toResponseMessage(Map("x" -> "y"))
- assert(m === Message("test-in", Map("key-in" -> "val-in", "x" -> "y")))
- }
-
- @Test def shouldCreateResponseMessageFromOutMessageWithAdditionalHeader = {
- val m = sampleInOut.toResponseMessage(Map("x" -> "y"))
- assert(m === Message("test-out", Map("key-out" -> "val-out", "x" -> "y")))
- }
-
- @Test def shouldCreateFailureMessageFromExceptionAndInMessageWithAdditionalHeader = {
- val e1 = sampleInOnly
- e1.setException(new Exception("test1"))
- assert(e1.toFailureMessage.cause.getMessage === "test1")
- val headers = e1.toFailureMessage(Map("x" -> "y")).headers
- assert(headers("key-in") === "val-in")
- assert(headers("x") === "y")
- }
-
- @Test def shouldCreateFailureMessageFromExceptionAndOutMessageWithAdditionalHeader = {
- val e1 = sampleInOut
- e1.setException(new Exception("test2"))
- assert(e1.toFailureMessage.cause.getMessage === "test2")
- val headers = e1.toFailureMessage(Map("x" -> "y")).headers
- assert(headers("key-out") === "val-out")
- assert(headers("x") === "y")
- }
-
- private def sampleInOnly = sampleExchange(ExchangePattern.InOnly)
- private def sampleInOut = sampleExchange(ExchangePattern.InOut)
-
- private def sampleExchange(pattern: ExchangePattern) = {
- val exchange = new DefaultExchange(new DefaultCamelContext)
- exchange.getIn.setBody("test-in")
- exchange.getOut.setBody("test-out")
- exchange.getIn.setHeader("key-in", "val-in")
- exchange.getOut.setHeader("key-out", "val-out")
- exchange.setPattern(pattern)
- exchange
- }
-}
diff --git a/akka-camel/src/test/scala/akka/CamelMessageAdapterTest.scala b/akka-camel/src/test/scala/akka/CamelMessageAdapterTest.scala
deleted file mode 100644
index 0c20ae1c29..0000000000
--- a/akka-camel/src/test/scala/akka/CamelMessageAdapterTest.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-package akka.camel
-
-import org.apache.camel.impl.DefaultMessage
-import org.junit.Test
-import org.scalatest.junit.JUnitSuite
-
-class CamelMessageAdapterTest extends JUnitSuite {
- import CamelMessageConversion.toMessageAdapter
-
- @Test def shouldOverwriteBodyAndAddHeader = {
- val cm = sampleMessage.fromMessage(Message("blah", Map("key" -> "baz")))
- assert(cm.getBody === "blah")
- assert(cm.getHeader("foo") === "bar")
- assert(cm.getHeader("key") === "baz")
- }
-
- @Test def shouldCreateMessageWithBodyAndHeader = {
- val m = sampleMessage.toMessage
- assert(m.body === "test")
- assert(m.headers("foo") === "bar")
- }
-
- @Test def shouldCreateMessageWithBodyAndHeaderAndCustomHeader = {
- val m = sampleMessage.toMessage(Map("key" -> "baz"))
- assert(m.body === "test")
- assert(m.headers("foo") === "bar")
- assert(m.headers("key") === "baz")
- }
-
- private[camel] def sampleMessage = {
- val message = new DefaultMessage
- message.setBody("test")
- message.setHeader("foo", "bar")
- message
- }
-
-
-}
diff --git a/akka-camel/src/test/scala/akka/CamelServiceManagerTest.scala b/akka-camel/src/test/scala/akka/CamelServiceManagerTest.scala
deleted file mode 100644
index 48ab29c6b8..0000000000
--- a/akka-camel/src/test/scala/akka/CamelServiceManagerTest.scala
+++ /dev/null
@@ -1,62 +0,0 @@
-package akka.camel
-
-import org.scalatest.{BeforeAndAfterAll, WordSpec}
-import org.scalatest.matchers.MustMatchers
-
-import akka.actor.ActorRegistry
-
-/**
- * @author Martin Krasser
- */
-class CamelServiceManagerTest extends WordSpec with BeforeAndAfterAll with MustMatchers {
-
- override def afterAll = {
- CamelServiceManager.stopCamelService
- ActorRegistry.shutdownAll
- }
-
- "A CamelServiceManager" when {
- "the startCamelService method been has been called" must {
- "have registered the started CamelService instance" in {
- val service = CamelServiceManager.startCamelService
- CamelServiceManager.mandatoryService must be theSameInstanceAs (service)
- }
- }
- "the stopCamelService method been has been called" must {
- "have unregistered the current CamelService instance" in {
- val service = CamelServiceManager.stopCamelService
- CamelServiceManager.service must be (None)
- }
- }
- }
-
- "A CamelServiceManager" when {
- val service = CamelServiceFactory.createCamelService
- "a CamelService instance has been started externally" must {
- "have registered the started CamelService instance" in {
- service.start
- CamelServiceManager.mandatoryService must be theSameInstanceAs (service)
- }
- }
- "the current CamelService instance has been stopped externally" must {
- "have unregistered the current CamelService instance" in {
- service.stop
- CamelServiceManager.service must be (None)
- }
- }
- }
-
- "A CamelServiceManager" when {
- "a CamelService has been started" must {
- "not allow further CamelService instances to be started" in {
- CamelServiceManager.startCamelService
- intercept[IllegalStateException] { CamelServiceManager.startCamelService }
- }
- }
- "a CamelService has been stopped" must {
- "only allow the current CamelService instance to be stopped" in {
- intercept[IllegalStateException] { CamelServiceFactory.createCamelService.stop }
- }
- }
- }
-}
diff --git a/akka-camel/src/test/scala/akka/ConsumerJavaTest.scala b/akka-camel/src/test/scala/akka/ConsumerJavaTest.scala
deleted file mode 100644
index 48741dda96..0000000000
--- a/akka-camel/src/test/scala/akka/ConsumerJavaTest.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package akka.camel
-
-import org.scalatest.junit.JUnitSuite
-
-class ConsumerJavaTest extends ConsumerJavaTestBase with JUnitSuite
\ No newline at end of file
diff --git a/akka-camel/src/test/scala/akka/ConsumerRegisteredTest.scala b/akka-camel/src/test/scala/akka/ConsumerRegisteredTest.scala
deleted file mode 100644
index e85c5f905c..0000000000
--- a/akka-camel/src/test/scala/akka/ConsumerRegisteredTest.scala
+++ /dev/null
@@ -1,63 +0,0 @@
-package akka.camel
-
-import org.junit.Test
-import org.scalatest.junit.JUnitSuite
-import akka.actor.{ActorRef, Actor, UntypedActor}
-
-class ConsumerRegisteredTest extends JUnitSuite {
- import ConsumerRegisteredTest._
-
- @Test def shouldCreateSomeNonBlockingPublishRequestFromConsumer = {
- val c = Actor.actorOf[ConsumerActor1]
- val event = ConsumerActorRegistered.forConsumer(c)
- assert(event === Some(ConsumerActorRegistered(c, consumerOf(c))))
- }
-
- @Test def shouldCreateSomeBlockingPublishRequestFromConsumer = {
- val c = Actor.actorOf[ConsumerActor2]
- val event = ConsumerActorRegistered.forConsumer(c)
- assert(event === Some(ConsumerActorRegistered(c, consumerOf(c))))
- }
-
- @Test def shouldCreateNoneFromConsumer = {
- val event = ConsumerActorRegistered.forConsumer(Actor.actorOf[PlainActor])
- assert(event === None)
- }
-
- @Test def shouldCreateSomeNonBlockingPublishRequestFromUntypedConsumer = {
- val uc = UntypedActor.actorOf(classOf[SampleUntypedConsumer])
- val event = ConsumerActorRegistered.forConsumer(uc)
- assert(event === Some(ConsumerActorRegistered(uc, consumerOf(uc))))
- }
-
- @Test def shouldCreateSomeBlockingPublishRequestFromUntypedConsumer = {
- val uc = UntypedActor.actorOf(classOf[SampleUntypedConsumerBlocking])
- val event = ConsumerActorRegistered.forConsumer(uc)
- assert(event === Some(ConsumerActorRegistered(uc, consumerOf(uc))))
- }
-
- @Test def shouldCreateNoneFromUntypedConsumer = {
- val a = UntypedActor.actorOf(classOf[SampleUntypedActor])
- val event = ConsumerActorRegistered.forConsumer(a)
- assert(event === None)
- }
-
- private def consumerOf(ref: ActorRef) = ref.actor.asInstanceOf[Consumer]
-}
-
-object ConsumerRegisteredTest {
- class ConsumerActor1 extends Actor with Consumer {
- def endpointUri = "mock:test1"
- protected def receive = null
- }
-
- class ConsumerActor2 extends Actor with Consumer {
- def endpointUri = "mock:test2"
- override def blocking = true
- protected def receive = null
- }
-
- class PlainActor extends Actor {
- protected def receive = null
- }
-}
diff --git a/akka-camel/src/test/scala/akka/ConsumerScalaTest.scala b/akka-camel/src/test/scala/akka/ConsumerScalaTest.scala
deleted file mode 100644
index ddbe757a3f..0000000000
--- a/akka-camel/src/test/scala/akka/ConsumerScalaTest.scala
+++ /dev/null
@@ -1,271 +0,0 @@
-package akka.camel
-
-import java.util.concurrent.{TimeoutException, CountDownLatch, TimeUnit}
-
-import org.apache.camel.CamelExecutionException
-import org.apache.camel.builder.Builder
-import org.apache.camel.model.RouteDefinition
-import org.scalatest.{BeforeAndAfterAll, WordSpec}
-import org.scalatest.matchers.MustMatchers
-
-import akka.actor.Actor._
-import akka.actor._
-
-/**
- * @author Martin Krasser
- */
-class ConsumerScalaTest extends WordSpec with BeforeAndAfterAll with MustMatchers {
- import CamelContextManager.mandatoryTemplate
- import ConsumerScalaTest._
-
- var service: CamelService = _
-
- override protected def beforeAll = {
- ActorRegistry.shutdownAll
- // create new CamelService instance
- service = CamelServiceFactory.createCamelService
- // Register publish requestor as listener
- service.registerPublishRequestor
- // register test consumer before starting the CamelService
- actorOf(new TestConsumer("direct:publish-test-1")).start
- // start consumer publisher, otherwise we cannot set message
- // count expectations in the next step (needed for testing only).
- service.consumerPublisher.start
- service.awaitEndpointActivation(1) {
- service.start
- } must be (true)
- }
-
- override protected def afterAll = {
- service.stop
- ActorRegistry.shutdownAll
- }
-
- "A responding consumer" when {
- val consumer = actorOf(new TestConsumer("direct:publish-test-2"))
- "started before starting the CamelService" must {
- "support an in-out message exchange via its endpoint" in {
- mandatoryTemplate.requestBody("direct:publish-test-1", "msg1") must equal ("received msg1")
- }
- }
- "not started" must {
- "not have an associated endpoint in the CamelContext" in {
- CamelContextManager.mandatoryContext.hasEndpoint("direct:publish-test-2") must be (null)
- }
- }
- "started" must {
- "support an in-out message exchange via its endpoint" in {
- service.awaitEndpointActivation(1) {
- consumer.start
- } must be (true)
- mandatoryTemplate.requestBody("direct:publish-test-2", "msg2") must equal ("received msg2")
- }
- "have an associated endpoint in the CamelContext" in {
- CamelContextManager.mandatoryContext.hasEndpoint("direct:publish-test-2") must not be (null)
- }
- }
- "stopped" must {
- "not support an in-out message exchange via its endpoint" in {
- service.awaitEndpointDeactivation(1) {
- consumer.stop
- } must be (true)
- intercept[CamelExecutionException] {
- mandatoryTemplate.requestBody("direct:publish-test-2", "msg2")
- }
- }
- }
- }
-
- "A responding, typed consumer" when {
- var actor: SampleTypedConsumer = null
- "started" must {
- "support in-out message exchanges via its endpoints" in {
- service.awaitEndpointActivation(3) {
- actor = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl])
- } must be (true)
- mandatoryTemplate.requestBodyAndHeader("direct:m2", "x", "test", "y") must equal ("m2: x y")
- mandatoryTemplate.requestBodyAndHeader("direct:m3", "x", "test", "y") must equal ("m3: x y")
- mandatoryTemplate.requestBodyAndHeader("direct:m4", "x", "test", "y") must equal ("m4: x y")
- }
- }
- "stopped" must {
- "not support in-out message exchanges via its endpoints" in {
- service.awaitEndpointDeactivation(3) {
- TypedActor.stop(actor)
- } must be (true)
- intercept[CamelExecutionException] {
- mandatoryTemplate.requestBodyAndHeader("direct:m2", "x", "test", "y")
- }
- intercept[CamelExecutionException] {
- mandatoryTemplate.requestBodyAndHeader("direct:m3", "x", "test", "y")
- }
- intercept[CamelExecutionException] {
- mandatoryTemplate.requestBodyAndHeader("direct:m4", "x", "test", "y")
- }
- }
- }
- }
-
- "A responding, typed consumer (Scala)" when {
- var actor: TestTypedConsumer = null
- "started" must {
- "support in-out message exchanges via its endpoints" in {
- service.awaitEndpointActivation(2) {
- actor = TypedActor.newInstance(classOf[TestTypedConsumer], classOf[TestTypedConsumerImpl])
- } must be (true)
- mandatoryTemplate.requestBody("direct:publish-test-3", "x") must equal ("foo: x")
- mandatoryTemplate.requestBody("direct:publish-test-4", "x") must equal ("bar: x")
- }
- }
- "stopped" must {
- "not support in-out message exchanges via its endpoints" in {
- service.awaitEndpointDeactivation(2) {
- TypedActor.stop(actor)
- } must be (true)
- intercept[CamelExecutionException] {
- mandatoryTemplate.requestBody("direct:publish-test-3", "x")
- }
- intercept[CamelExecutionException] {
- mandatoryTemplate.requestBody("direct:publish-test-4", "x")
- }
- }
- }
- }
-
- "A responding, untyped consumer" when {
- val consumer = UntypedActor.actorOf(classOf[SampleUntypedConsumer])
- "started" must {
- "support an in-out message exchange via its endpoint" in {
- service.awaitEndpointActivation(1) {
- consumer.start
- } must be (true)
- mandatoryTemplate.requestBodyAndHeader("direct:test-untyped-consumer", "x", "test", "y") must equal ("x y")
- }
- }
- "stopped" must {
- "not support an in-out message exchange via its endpoint" in {
- service.awaitEndpointDeactivation(1) {
- consumer.stop
- } must be (true)
- intercept[CamelExecutionException] {
- mandatoryTemplate.sendBodyAndHeader("direct:test-untyped-consumer", "blah", "test", "blub")
- }
- }
- }
- }
-
- "A non-responding, blocking consumer" when {
- "receiving an in-out message exchange" must {
- "lead to a TimeoutException" in {
- service.awaitEndpointActivation(1) {
- actorOf(new TestBlocker("direct:publish-test-5")).start
- } must be (true)
-
- try {
- mandatoryTemplate.requestBody("direct:publish-test-5", "msg3")
- fail("expected TimoutException not thrown")
- } catch {
- case e => {
- assert(e.getCause.isInstanceOf[TimeoutException])
- }
- }
- }
- }
- }
-
- "A responding, blocking consumer" when {
- "activated with a custom error handler" must {
- "handle thrown exceptions by generating a custom response" in {
- service.awaitEndpointActivation(1) {
- actorOf[ErrorHandlingConsumer].start
- } must be (true)
- mandatoryTemplate.requestBody("direct:error-handler-test", "hello") must equal ("error: hello")
-
- }
- }
- "activated with a custom redelivery handler" must {
- "handle thrown exceptions by redelivering the initial message" in {
- service.awaitEndpointActivation(1) {
- actorOf[RedeliveringConsumer].start
- } must be (true)
- mandatoryTemplate.requestBody("direct:redelivery-test", "hello") must equal ("accepted: hello")
-
- }
- }
- }
-}
-
-object ConsumerScalaTest {
- trait BlockingConsumer extends Consumer { self: Actor =>
- override def blocking = true
- }
-
- class TestConsumer(uri: String) extends Actor with Consumer {
- def endpointUri = uri
- protected def receive = {
- case msg: Message => self.reply("received %s" format msg.body)
- }
- }
-
- class TestBlocker(uri: String) extends Actor with BlockingConsumer {
- self.timeout = 1000
- def endpointUri = uri
- protected def receive = {
- case msg: Message => { /* do not reply */ }
- }
- }
-
- class ErrorHandlingConsumer extends Actor with BlockingConsumer {
- def endpointUri = "direct:error-handler-test"
-
- onRouteDefinition {rd: RouteDefinition =>
- rd.onException(classOf[Exception]).handled(true).transform(Builder.exceptionMessage).end
- }
-
- protected def receive = {
- case msg: Message => throw new Exception("error: %s" format msg.body)
- }
- }
-
- class RedeliveringConsumer extends Actor with BlockingConsumer {
- def endpointUri = "direct:redelivery-test"
-
- onRouteDefinition {rd: RouteDefinition =>
- rd.onException(classOf[Exception]).maximumRedeliveries(1).end
- }
-
- //
- // first message to this actor is not valid and will be rejected
- //
-
- var valid = false
-
- protected def receive = {
- case msg: Message => try {
- respondTo(msg)
- } finally {
- valid = true
- }
- }
-
- private def respondTo(msg: Message) =
- if (valid) self.reply("accepted: %s" format msg.body)
- else throw new Exception("rejected: %s" format msg.body)
-
- }
-
- trait TestTypedConsumer {
- @consume("direct:publish-test-3")
- def foo(s: String): String
- def bar(s: String): String
- }
-
- class TestTypedConsumerImpl extends TypedActor with TestTypedConsumer {
- def foo(s: String) = "foo: %s" format s
- @consume("direct:publish-test-4")
- def bar(s: String) = "bar: %s" format s
- }
-
-
-
-}
diff --git a/akka-camel/src/test/scala/akka/MessageJavaTest.scala b/akka-camel/src/test/scala/akka/MessageJavaTest.scala
deleted file mode 100644
index 3c95887eb4..0000000000
--- a/akka-camel/src/test/scala/akka/MessageJavaTest.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package akka.camel
-
-import org.scalatest.junit.JUnitSuite
-
-class MessageJavaTest extends MessageJavaTestBase with JUnitSuite
diff --git a/akka-camel/src/test/scala/akka/MessageScalaTest.scala b/akka-camel/src/test/scala/akka/MessageScalaTest.scala
deleted file mode 100644
index 5f43db596b..0000000000
--- a/akka-camel/src/test/scala/akka/MessageScalaTest.scala
+++ /dev/null
@@ -1,83 +0,0 @@
-package akka.camel
-
-import java.io.InputStream
-
-import org.apache.camel.NoTypeConversionAvailableException
-import org.junit.Assert._
-import org.junit.Test
-
-import org.scalatest.BeforeAndAfterAll
-import org.scalatest.junit.JUnitSuite
-
-
-class MessageScalaTest extends JUnitSuite with BeforeAndAfterAll {
- override protected def beforeAll = CamelContextManager.init
-
- @Test def shouldConvertDoubleBodyToString = {
- assertEquals("1.4", Message(1.4).bodyAs[String])
- }
-
- @Test def shouldThrowExceptionWhenConvertingDoubleBodyToInputStream {
- intercept[NoTypeConversionAvailableException] {
- Message(1.4).bodyAs[InputStream]
- }
- }
-
- @Test def shouldReturnDoubleHeader = {
- val message = Message("test" , Map("test" -> 1.4))
- assertEquals(1.4, message.header("test"))
- }
-
- @Test def shouldConvertDoubleHeaderToString = {
- val message = Message("test" , Map("test" -> 1.4))
- assertEquals("1.4", message.headerAs[String]("test"))
- }
-
- @Test def shouldReturnSubsetOfHeaders = {
- val message = Message("test" , Map("A" -> "1", "B" -> "2"))
- assertEquals(Map("B" -> "2"), message.headers(Set("B")))
- }
-
- @Test def shouldTransformBodyAndPreserveHeaders = {
- assertEquals(
- Message("ab", Map("A" -> "1")),
- Message("a" , Map("A" -> "1")).transformBody((body: String) => body + "b"))
- }
-
- @Test def shouldConvertBodyAndPreserveHeaders = {
- assertEquals(
- Message("1.4", Map("A" -> "1")),
- Message(1.4 , Map("A" -> "1")).setBodyAs[String])
- }
-
- @Test def shouldSetBodyAndPreserveHeaders = {
- assertEquals(
- Message("test2" , Map("A" -> "1")),
- Message("test1" , Map("A" -> "1")).setBody("test2"))
- }
-
- @Test def shouldSetHeadersAndPreserveBody = {
- assertEquals(
- Message("test1" , Map("C" -> "3")),
- Message("test1" , Map("A" -> "1")).setHeaders(Map("C" -> "3")))
-
- }
-
- @Test def shouldAddHeaderAndPreserveBodyAndHeaders = {
- assertEquals(
- Message("test1" , Map("A" -> "1", "B" -> "2")),
- Message("test1" , Map("A" -> "1")).addHeader("B" -> "2"))
- }
-
- @Test def shouldAddHeadersAndPreserveBodyAndHeaders = {
- assertEquals(
- Message("test1" , Map("A" -> "1", "B" -> "2")),
- Message("test1" , Map("A" -> "1")).addHeaders(Map("B" -> "2")))
- }
-
- @Test def shouldRemoveHeadersAndPreserveBodyAndRemainingHeaders = {
- assertEquals(
- Message("test1" , Map("A" -> "1")),
- Message("test1" , Map("A" -> "1", "B" -> "2")).removeHeader("B"))
- }
-}
diff --git a/akka-camel/src/test/scala/akka/ProducerFeatureTest.scala b/akka-camel/src/test/scala/akka/ProducerFeatureTest.scala
deleted file mode 100644
index 66bcbe9186..0000000000
--- a/akka-camel/src/test/scala/akka/ProducerFeatureTest.scala
+++ /dev/null
@@ -1,301 +0,0 @@
-package akka.camel
-
-import org.apache.camel.{Exchange, Processor}
-import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.component.mock.MockEndpoint
-import org.scalatest.{GivenWhenThen, BeforeAndAfterEach, BeforeAndAfterAll, FeatureSpec}
-
-import akka.actor.Actor._
-import akka.actor.{ActorRef, Actor, ActorRegistry}
-
-class ProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with BeforeAndAfterEach with GivenWhenThen {
- import ProducerFeatureTest._
-
- override protected def beforeAll = {
- ActorRegistry.shutdownAll
- CamelContextManager.init
- CamelContextManager.mandatoryContext.addRoutes(new TestRoute)
- CamelContextManager.start
- }
-
- override protected def afterAll = {
- CamelContextManager.stop
- ActorRegistry.shutdownAll
- }
-
- override protected def afterEach = {
- mockEndpoint.reset
- }
-
- feature("Produce a message to a sync Camel route") {
-
- scenario("produce message and receive normal response") {
- given("a registered two-way producer")
- val producer = actorOf(new TestProducer("direct:producer-test-2", true))
- producer.start
-
- when("a test message is sent to the producer with !!")
- val message = Message("test", Map(Message.MessageExchangeId -> "123"))
- val result = producer !! message
-
- then("a normal response should have been returned by the producer")
- val expected = Message("received TEST", Map(Message.MessageExchangeId -> "123"))
- assert(result === Some(expected))
- }
-
- scenario("produce message and receive failure response") {
- given("a registered two-way producer")
- val producer = actorOf(new TestProducer("direct:producer-test-2"))
- producer.start
-
- when("a test message causing an exception is sent to the producer with !!")
- val message = Message("fail", Map(Message.MessageExchangeId -> "123"))
- val result = (producer !! message).as[Failure]
-
- then("a failure response should have been returned by the producer")
- val expectedFailureText = result.get.cause.getMessage
- val expectedHeaders = result.get.headers
- assert(expectedFailureText === "failure")
- assert(expectedHeaders === Map(Message.MessageExchangeId -> "123"))
- }
-
- scenario("produce message oneway") {
- given("a registered one-way producer")
- val producer = actorOf(new TestProducer("direct:producer-test-1", true) with Oneway)
- producer.start
-
- when("a test message is sent to the producer with !")
- mockEndpoint.expectedBodiesReceived("TEST")
- producer ! Message("test")
-
- then("the test message should have been sent to mock:mock")
- mockEndpoint.assertIsSatisfied
- }
-
- scenario("produce message twoway without sender reference") {
- given("a registered two-way producer")
- val producer = actorOf(new TestProducer("direct:producer-test-1"))
- producer.start
-
- when("a test message is sent to the producer with !")
- mockEndpoint.expectedBodiesReceived("test")
- producer ! Message("test")
-
- then("there should be only a warning that there's no sender reference")
- mockEndpoint.assertIsSatisfied
- }
- }
-
- feature("Produce a message to an async Camel route") {
-
- scenario("produce message and receive normal response") {
- given("a registered two-way producer")
- val producer = actorOf(new TestProducer("direct:producer-test-3"))
- producer.start
-
- when("a test message is sent to the producer with !!")
- val message = Message("test", Map(Message.MessageExchangeId -> "123"))
- val result = producer !! message
-
- then("a normal response should have been returned by the producer")
- val expected = Message("received test", Map(Message.MessageExchangeId -> "123"))
- assert(result === Some(expected))
- }
-
- scenario("produce message and receive failure response") {
- given("a registered two-way producer")
- val producer = actorOf(new TestProducer("direct:producer-test-3"))
- producer.start
-
- when("a test message causing an exception is sent to the producer with !!")
- val message = Message("fail", Map(Message.MessageExchangeId -> "123"))
- val result = (producer !! message).as[Failure]
-
- then("a failure response should have been returned by the producer")
- val expectedFailureText = result.get.cause.getMessage
- val expectedHeaders = result.get.headers
- assert(expectedFailureText === "failure")
- assert(expectedHeaders === Map(Message.MessageExchangeId -> "123"))
- }
- }
-
- feature("Produce a message to a sync Camel route and then forward the response") {
-
- scenario("produce message, forward normal response to a replying target actor and receive response") {
- given("a registered two-way producer configured with a forward target")
- val target = actorOf[ReplyingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-2", target)).start
-
- when("a test message is sent to the producer with !!")
- val message = Message("test", Map(Message.MessageExchangeId -> "123"))
- val result = producer !! message
-
- then("a normal response should have been returned by the forward target")
- val expected = Message("received test", Map(Message.MessageExchangeId -> "123", "test" -> "result"))
- assert(result === Some(expected))
- }
-
- scenario("produce message, forward failure response to a replying target actor and receive response") {
- given("a registered two-way producer configured with a forward target")
- val target = actorOf[ReplyingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-2", target)).start
-
- when("a test message causing an exception is sent to the producer with !!")
- val message = Message("fail", Map(Message.MessageExchangeId -> "123"))
- val result = (producer !! message).as[Failure]
-
- then("a failure response should have been returned by the forward target")
- val expectedFailureText = result.get.cause.getMessage
- val expectedHeaders = result.get.headers
- assert(expectedFailureText === "failure")
- assert(expectedHeaders === Map(Message.MessageExchangeId -> "123", "test" -> "failure"))
- }
-
- scenario("produce message, forward normal response to a producing target actor and produce response to direct:forward-test-1") {
- given("a registered one-way producer configured with a forward target")
- val target = actorOf[ProducingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-2", target)).start
-
- when("a test message is sent to the producer with !")
- mockEndpoint.expectedBodiesReceived("received test")
- val result = producer.!(Message("test"))(Some(producer))
-
- then("a normal response should have been produced by the forward target")
- mockEndpoint.assertIsSatisfied
- }
-
- scenario("produce message, forward failure response to a producing target actor and produce response to direct:forward-test-1") {
- given("a registered one-way producer configured with a forward target")
- val target = actorOf[ProducingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-2", target)).start
-
- when("a test message causing an exception is sent to the producer with !")
- mockEndpoint.expectedMessageCount(1)
- mockEndpoint.message(0).body().isInstanceOf(classOf[Failure])
- val result = producer.!(Message("fail"))(Some(producer))
-
- then("a failure response should have been produced by the forward target")
- mockEndpoint.assertIsSatisfied
- }
- }
-
- feature("Produce a message to an async Camel route and then forward the response") {
-
- scenario("produce message, forward normal response to a replying target actor and receive response") {
- given("a registered two-way producer configured with a forward target")
- val target = actorOf[ReplyingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-3", target)).start
-
- when("a test message is sent to the producer with !!")
- val message = Message("test", Map(Message.MessageExchangeId -> "123"))
- val result = producer !! message
-
- then("a normal response should have been returned by the forward target")
- val expected = Message("received test", Map(Message.MessageExchangeId -> "123", "test" -> "result"))
- assert(result === Some(expected))
- }
-
- scenario("produce message, forward failure response to a replying target actor and receive response") {
- given("a registered two-way producer configured with a forward target")
- val target = actorOf[ReplyingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-3", target)).start
-
- when("a test message causing an exception is sent to the producer with !!")
- val message = Message("fail", Map(Message.MessageExchangeId -> "123"))
- val result = (producer !! message).as[Failure]
-
- then("a failure response should have been returned by the forward target")
- val expectedFailureText = result.get.cause.getMessage
- val expectedHeaders = result.get.headers
- assert(expectedFailureText === "failure")
- assert(expectedHeaders === Map(Message.MessageExchangeId -> "123", "test" -> "failure"))
- }
-
- scenario("produce message, forward normal response to a producing target actor and produce response to direct:forward-test-1") {
- given("a registered one-way producer configured with a forward target")
- val target = actorOf[ProducingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-3", target)).start
-
- when("a test message is sent to the producer with !")
- mockEndpoint.expectedBodiesReceived("received test")
- val result = producer.!(Message("test"))(Some(producer))
-
- then("a normal response should have been produced by the forward target")
- mockEndpoint.assertIsSatisfied
- }
-
- scenario("produce message, forward failure response to a producing target actor and produce response to direct:forward-test-1") {
- given("a registered one-way producer configured with a forward target")
- val target = actorOf[ProducingForwardTarget].start
- val producer = actorOf(new TestForwarder("direct:producer-test-3", target)).start
-
- when("a test message causing an exception is sent to the producer with !")
- mockEndpoint.expectedMessageCount(1)
- mockEndpoint.message(0).body().isInstanceOf(classOf[Failure])
- val result = producer.!(Message("fail"))(Some(producer))
-
- then("a failure response should have been produced by the forward target")
- mockEndpoint.assertIsSatisfied
- }
- }
-
- private def mockEndpoint = CamelContextManager.mandatoryContext.getEndpoint("mock:mock", classOf[MockEndpoint])
-}
-
-object ProducerFeatureTest {
- class TestProducer(uri: String, upper: Boolean = false) extends Actor with Producer {
- def endpointUri = uri
- override protected def receiveBeforeProduce = {
- case msg: Message => if (upper) msg.transformBody { body: String => body.toUpperCase } else msg
- }
- }
-
- class TestForwarder(uri: String, target: ActorRef) extends Actor with Producer {
- def endpointUri = uri
- override protected def receiveAfterProduce = {
- case msg => target forward msg
- }
- }
-
- class TestResponder extends Actor {
- protected def receive = {
- case msg: Message => msg.body match {
- case "fail" => self.reply(Failure(new Exception("failure"), msg.headers))
- case _ => self.reply(msg.transformBody { body: String => "received %s" format body })
- }
- }
- }
-
- class ReplyingForwardTarget extends Actor {
- protected def receive = {
- case msg: Message =>
- self.reply(msg.addHeader("test" -> "result"))
- case msg: Failure =>
- self.reply(Failure(msg.cause, msg.headers + ("test" -> "failure")))
- }
- }
-
- class ProducingForwardTarget extends Actor with Producer with Oneway {
- def endpointUri = "direct:forward-test-1"
- }
-
- class TestRoute extends RouteBuilder {
- val responder = actorOf[TestResponder].start
- def configure {
- from("direct:forward-test-1").to("mock:mock")
- // for one-way messaging tests
- from("direct:producer-test-1").to("mock:mock")
- // for two-way messaging tests (async)
- from("direct:producer-test-3").to("actor:uuid:%s" format responder.uuid)
- // for two-way messaging tests (sync)
- from("direct:producer-test-2").process(new Processor() {
- def process(exchange: Exchange) = {
- exchange.getIn.getBody match {
- case "fail" => throw new Exception("failure")
- case body => exchange.getOut.setBody("received %s" format body)
- }
- }
- })
- }
- }
-}
diff --git a/akka-camel/src/test/scala/akka/PublishRequestorTest.scala b/akka-camel/src/test/scala/akka/PublishRequestorTest.scala
deleted file mode 100644
index 8578abef60..0000000000
--- a/akka-camel/src/test/scala/akka/PublishRequestorTest.scala
+++ /dev/null
@@ -1,103 +0,0 @@
-package akka.camel
-
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-
-import org.junit.{Before, After, Test}
-import org.scalatest.junit.JUnitSuite
-
-import akka.actor._
-import akka.actor.Actor._
-import akka.camel.support.{SetExpectedMessageCount => SetExpectedTestMessageCount, _}
-
-class PublishRequestorTest extends JUnitSuite {
- import PublishRequestorTest._
-
- var publisher: ActorRef = _
- var requestor: ActorRef = _
- var consumer: ActorRef = _
-
- val ascendingMethodName = (r1: ConsumerMethodRegistered, r2: ConsumerMethodRegistered) =>
- r1.method.getName < r2.method.getName
-
- @Before def setUp: Unit = {
- publisher = actorOf[PublisherMock].start
- requestor = actorOf[PublishRequestor].start
- requestor ! PublishRequestorInit(publisher)
- consumer = actorOf(new Actor with Consumer {
- def endpointUri = "mock:test"
- protected def receive = null
- }).start
- }
-
- @After def tearDown = {
- AspectInitRegistry.removeListener(requestor);
- ActorRegistry.shutdownAll
- }
-
- @Test def shouldReceiveOneConsumerMethodRegisteredEvent = {
- AspectInitRegistry.addListener(requestor)
- val latch = (publisher !! SetExpectedTestMessageCount(1)).as[CountDownLatch].get
- val obj = TypedActor.newInstance(classOf[SampleTypedSingleConsumer], classOf[SampleTypedSingleConsumerImpl])
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val event = (publisher !! GetRetainedMessage).as[ConsumerMethodRegistered].get
- assert(event.endpointUri === "direct:foo")
- assert(event.typedActor === obj)
- assert(event.methodName === "foo")
- }
-
- @Test def shouldReceiveOneConsumerMethodUnregisteredEvent = {
- val obj = TypedActor.newInstance(classOf[SampleTypedSingleConsumer], classOf[SampleTypedSingleConsumerImpl])
- val latch = (publisher !! SetExpectedTestMessageCount(1)).as[CountDownLatch].get
- AspectInitRegistry.addListener(requestor)
- TypedActor.stop(obj)
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val event = (publisher !! GetRetainedMessage).as[ConsumerMethodUnregistered].get
- assert(event.endpointUri === "direct:foo")
- assert(event.typedActor === obj)
- assert(event.methodName === "foo")
- }
-
- @Test def shouldReceiveThreeConsumerMethodRegisteredEvents = {
- AspectInitRegistry.addListener(requestor)
- val latch = (publisher !! SetExpectedTestMessageCount(3)).as[CountDownLatch].get
- val obj = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl])
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val request = GetRetainedMessages(_.isInstanceOf[ConsumerMethodRegistered])
- val events = (publisher !! request).as[List[ConsumerMethodRegistered]].get
- assert(events.map(_.method.getName).sortWith(_ < _) === List("m2", "m3", "m4"))
- }
-
- @Test def shouldReceiveThreeConsumerMethodUnregisteredEvents = {
- val obj = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl])
- val latch = (publisher !! SetExpectedTestMessageCount(3)).as[CountDownLatch].get
- AspectInitRegistry.addListener(requestor)
- TypedActor.stop(obj)
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val request = GetRetainedMessages(_.isInstanceOf[ConsumerMethodUnregistered])
- val events = (publisher !! request).as[List[ConsumerMethodUnregistered]].get
- assert(events.map(_.method.getName).sortWith(_ < _) === List("m2", "m3", "m4"))
- }
-
- @Test def shouldReceiveOneConsumerRegisteredEvent = {
- val latch = (publisher !! SetExpectedTestMessageCount(1)).as[CountDownLatch].get
- requestor ! ActorRegistered(consumer)
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- assert((publisher !! GetRetainedMessage) ===
- Some(ConsumerActorRegistered(consumer, consumer.actor.asInstanceOf[Consumer])))
- }
-
- @Test def shouldReceiveOneConsumerUnregisteredEvent = {
- val latch = (publisher !! SetExpectedTestMessageCount(1)).as[CountDownLatch].get
- requestor ! ActorUnregistered(consumer)
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- assert((publisher !! GetRetainedMessage) ===
- Some(ConsumerActorUnregistered(consumer, consumer.actor.asInstanceOf[Consumer])))
- }
-}
-
-object PublishRequestorTest {
- class PublisherMock extends TestActor with Retain with Countdown {
- def handler = retain andThen countdown
- }
-}
-
diff --git a/akka-camel/src/test/scala/akka/RemoteConsumerTest.scala b/akka-camel/src/test/scala/akka/RemoteConsumerTest.scala
deleted file mode 100644
index 957080c2ec..0000000000
--- a/akka-camel/src/test/scala/akka/RemoteConsumerTest.scala
+++ /dev/null
@@ -1,101 +0,0 @@
-package akka.camel
-
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-
-import org.scalatest.{GivenWhenThen, BeforeAndAfterAll, FeatureSpec}
-
-import akka.actor._
-import akka.actor.Actor._
-import akka.remote.{RemoteClient, RemoteServer}
-
-/**
- * @author Martin Krasser
- */
-class RemoteConsumerTest extends FeatureSpec with BeforeAndAfterAll with GivenWhenThen {
- import CamelServiceManager._
- import RemoteConsumerTest._
-
- var server: RemoteServer = _
-
- override protected def beforeAll = {
- ActorRegistry.shutdownAll
-
- startCamelService
-
- server = new RemoteServer()
- server.start(host, port)
-
- Thread.sleep(1000)
- }
-
- override protected def afterAll = {
- server.shutdown
-
- stopCamelService
-
- RemoteClient.shutdownAll
- ActorRegistry.shutdownAll
-
- Thread.sleep(1000)
- }
-
- feature("Publish consumer on remote node") {
- scenario("access published remote consumer") {
- given("a client-initiated remote consumer")
- val consumer = actorOf[RemoteConsumer].start
-
- when("remote consumer publication is triggered")
- assert(mandatoryService.awaitEndpointActivation(1) {
- consumer !! "init"
- })
-
- then("the published consumer is accessible via its endpoint URI")
- val response = CamelContextManager.mandatoryTemplate.requestBody("direct:remote-consumer", "test")
- assert(response === "remote actor: test")
- }
- }
-
- feature("Publish typed consumer on remote node") {
- scenario("access published remote consumer method") {
- given("a client-initiated remote typed consumer")
- val consumer = TypedActor.newRemoteInstance(classOf[SampleRemoteTypedConsumer], classOf[SampleRemoteTypedConsumerImpl], host, port)
-
- when("remote typed consumer publication is triggered")
- assert(mandatoryService.awaitEndpointActivation(1) {
- consumer.foo("init")
- })
- then("the published method is accessible via its endpoint URI")
- val response = CamelContextManager.mandatoryTemplate.requestBody("direct:remote-typed-consumer", "test")
- assert(response === "remote typed actor: test")
- }
- }
-
- feature("Publish untyped consumer on remote node") {
- scenario("access published remote untyped consumer") {
- given("a client-initiated remote untyped consumer")
- val consumer = UntypedActor.actorOf(classOf[SampleRemoteUntypedConsumer]).start
-
- when("remote untyped consumer publication is triggered")
- assert(mandatoryService.awaitEndpointActivation(1) {
- consumer.sendRequestReply(Message("init", Map("test" -> "init")))
- })
- then("the published untyped consumer is accessible via its endpoint URI")
- val response = CamelContextManager.mandatoryTemplate.requestBodyAndHeader("direct:remote-untyped-consumer", "a", "test", "b")
- assert(response === "a b")
- }
- }
-}
-
-object RemoteConsumerTest {
- val host = "localhost"
- val port = 7774
-
- class RemoteConsumer extends RemoteActor(host, port) with Consumer {
- def endpointUri = "direct:remote-consumer"
-
- protected def receive = {
- case "init" => self.reply("done")
- case m: Message => self.reply("remote actor: %s" format m.body)
- }
- }
-}
diff --git a/akka-camel/src/test/scala/akka/UntypedProducerFeatureTest.scala b/akka-camel/src/test/scala/akka/UntypedProducerFeatureTest.scala
deleted file mode 100644
index 18930f9ab4..0000000000
--- a/akka-camel/src/test/scala/akka/UntypedProducerFeatureTest.scala
+++ /dev/null
@@ -1,98 +0,0 @@
-package akka.camel
-
-import org.apache.camel.{Exchange, Processor}
-import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.component.mock.MockEndpoint
-import org.scalatest.{GivenWhenThen, BeforeAndAfterEach, BeforeAndAfterAll, FeatureSpec}
-
-import akka.actor.UntypedActor._
-import akka.actor.ActorRegistry
-
-class UntypedProducerFeatureTest extends FeatureSpec with BeforeAndAfterAll with BeforeAndAfterEach with GivenWhenThen {
- import UntypedProducerFeatureTest._
-
- override protected def beforeAll = {
- ActorRegistry.shutdownAll
- CamelContextManager.init
- CamelContextManager.mandatoryContext.addRoutes(new TestRoute)
- CamelContextManager.start
- }
-
- override protected def afterAll = {
- CamelContextManager.stop
- ActorRegistry.shutdownAll
- }
-
- override protected def afterEach = {
- mockEndpoint.reset
- }
-
- feature("Produce a message to a sync Camel route") {
-
- scenario("produce message and receive normal response") {
- given("a registered two-way producer")
- val producer = actorOf(classOf[SampleUntypedReplyingProducer])
- producer.start
-
- when("a test message is sent to the producer with !!")
- val message = Message("test", Map(Message.MessageExchangeId -> "123"))
- val result = producer.sendRequestReply(message)
-
- then("a normal response should have been returned by the producer")
- val expected = Message("received test", Map(Message.MessageExchangeId -> "123"))
- assert(result === expected)
- }
-
- scenario("produce message and receive failure response") {
- given("a registered two-way producer")
- val producer = actorOf(classOf[SampleUntypedReplyingProducer])
- producer.start
-
- when("a test message causing an exception is sent to the producer with !!")
- val message = Message("fail", Map(Message.MessageExchangeId -> "123"))
- val result = producer.sendRequestReply(message).asInstanceOf[Failure]
-
- then("a failure response should have been returned by the producer")
- val expectedFailureText = result.cause.getMessage
- val expectedHeaders = result.headers
- assert(expectedFailureText === "failure")
- assert(expectedHeaders === Map(Message.MessageExchangeId -> "123"))
- }
-
- }
-
- feature("Produce a message to a sync Camel route and then forward the response") {
-
- scenario("produce message and send normal response to direct:forward-test-1") {
- given("a registered one-way producer configured with a forward target")
- val producer = actorOf(classOf[SampleUntypedForwardingProducer])
- producer.start
-
- when("a test message is sent to the producer with !")
- mockEndpoint.expectedBodiesReceived("received test")
- val result = producer.sendOneWay(Message("test"), producer)
-
- then("a normal response should have been sent")
- mockEndpoint.assertIsSatisfied
- }
-
- }
-
- private def mockEndpoint = CamelContextManager.mandatoryContext.getEndpoint("mock:mock", classOf[MockEndpoint])
-}
-
-object UntypedProducerFeatureTest {
- class TestRoute extends RouteBuilder {
- def configure {
- from("direct:forward-test-1").to("mock:mock")
- from("direct:producer-test-1").process(new Processor() {
- def process(exchange: Exchange) = {
- exchange.getIn.getBody match {
- case "fail" => throw new Exception("failure")
- case body => exchange.getOut.setBody("received %s" format body)
- }
- }
- })
- }
- }
-}
diff --git a/akka-camel/src/test/scala/akka/component/ActorComponentFeatureTest.scala b/akka-camel/src/test/scala/akka/component/ActorComponentFeatureTest.scala
deleted file mode 100644
index 993fe72096..0000000000
--- a/akka-camel/src/test/scala/akka/component/ActorComponentFeatureTest.scala
+++ /dev/null
@@ -1,130 +0,0 @@
-package akka.camel.component
-
-import java.util.concurrent.{TimeUnit, CountDownLatch}
-
-import org.apache.camel.RuntimeCamelException
-import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.component.mock.MockEndpoint
-import org.scalatest.{BeforeAndAfterEach, BeforeAndAfterAll, FeatureSpec}
-
-import akka.actor.Actor._
-import akka.actor.{ActorRegistry, Actor}
-import akka.camel.{Failure, Message, CamelContextManager}
-import akka.camel.support._
-
-class ActorComponentFeatureTest extends FeatureSpec with BeforeAndAfterAll with BeforeAndAfterEach {
- import ActorComponentFeatureTest._
-
- override protected def beforeAll = {
- ActorRegistry.shutdownAll
- CamelContextManager.init
- CamelContextManager.mandatoryContext.addRoutes(new TestRoute)
- CamelContextManager.start
- }
-
- override protected def afterAll = CamelContextManager.stop
-
- override protected def afterEach = {
- ActorRegistry.shutdownAll
- mockEndpoint.reset
- }
-
- feature("Communicate with an actor via an actor:uuid endpoint") {
- import CamelContextManager.mandatoryTemplate
-
- scenario("one-way communication") {
- val actor = actorOf[Tester1].start
- val latch = (actor !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- mandatoryTemplate.sendBody("actor:uuid:%s" format actor.uuid, "Martin")
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val reply = (actor !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply.body === "Martin")
- }
-
- scenario("two-way communication") {
- val actor = actorOf[Tester2].start
- assert(mandatoryTemplate.requestBody("actor:uuid:%s" format actor.uuid, "Martin") === "Hello Martin")
- }
-
- scenario("two-way communication with timeout") {
- val actor = actorOf[Tester3].start
- intercept[RuntimeCamelException] {
- mandatoryTemplate.requestBody("actor:uuid:%s?blocking=true" format actor.uuid, "Martin")
- }
- }
-
- scenario("two-way communication via a custom route with failure response") {
- mockEndpoint.expectedBodiesReceived("whatever")
- mandatoryTemplate.requestBody("direct:failure-test-1", "whatever")
- mockEndpoint.assertIsSatisfied
- }
-
- scenario("two-way communication via a custom route with exception") {
- mockEndpoint.expectedBodiesReceived("whatever")
- mandatoryTemplate.requestBody("direct:failure-test-2", "whatever")
- mockEndpoint.assertIsSatisfied
- }
- }
-
- feature("Communicate with an actor via an actor:id endpoint") {
- import CamelContextManager.mandatoryTemplate
-
- scenario("one-way communication") {
- val actor = actorOf[Tester1].start
- val latch = (actor !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- mandatoryTemplate.sendBody("actor:%s" format actor.id, "Martin")
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val reply = (actor !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply.body === "Martin")
- }
-
- scenario("two-way communication") {
- val actor = actorOf[Tester2].start
- assert(mandatoryTemplate.requestBody("actor:%s" format actor.id, "Martin") === "Hello Martin")
- }
-
- scenario("two-way communication via a custom route") {
- val actor = actorOf[CustomIdActor].start
- assert(mandatoryTemplate.requestBody("direct:custom-id-test-1", "Martin") === "Received Martin")
- assert(mandatoryTemplate.requestBody("direct:custom-id-test-2", "Martin") === "Received Martin")
- }
- }
-
- private def mockEndpoint = CamelContextManager.mandatoryContext.getEndpoint("mock:mock", classOf[MockEndpoint])
-}
-
-object ActorComponentFeatureTest {
- class CustomIdActor extends Actor {
- self.id = "custom-id"
- protected def receive = {
- case msg: Message => self.reply("Received %s" format msg.body)
- }
- }
-
- class FailWithMessage extends Actor {
- protected def receive = {
- case msg: Message => self.reply(Failure(new Exception("test")))
- }
- }
-
- class FailWithException extends Actor {
- protected def receive = {
- case msg: Message => throw new Exception("test")
- }
- }
-
- class TestRoute extends RouteBuilder {
- val failWithMessage = actorOf[FailWithMessage].start
- val failWithException = actorOf[FailWithException].start
- def configure {
- from("direct:custom-id-test-1").to("actor:custom-id")
- from("direct:custom-id-test-2").to("actor:id:custom-id")
- from("direct:failure-test-1")
- .onException(classOf[Exception]).to("mock:mock").handled(true).end
- .to("actor:uuid:%s" format failWithMessage.uuid)
- from("direct:failure-test-2")
- .onException(classOf[Exception]).to("mock:mock").handled(true).end
- .to("actor:uuid:%s?blocking=true" format failWithException.uuid)
- }
- }
-}
diff --git a/akka-camel/src/test/scala/akka/component/ActorComponentTest.scala b/akka-camel/src/test/scala/akka/component/ActorComponentTest.scala
deleted file mode 100644
index 0af9f00213..0000000000
--- a/akka-camel/src/test/scala/akka/component/ActorComponentTest.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-package akka.camel.component
-
-import org.apache.camel.{Endpoint, AsyncProcessor}
-import org.apache.camel.impl.DefaultCamelContext
-import org.junit._
-import org.scalatest.junit.JUnitSuite
-
-import akka.actor.uuidFrom
-
-class ActorComponentTest extends JUnitSuite {
- val component: ActorComponent = ActorComponentTest.actorComponent
-
- def testUUID = "93da8c80-c3fd-11df-abed-60334b120057"
-
- @Test def shouldCreateEndpointWithIdDefined = {
- val ep1: ActorEndpoint = component.createEndpoint("actor:abc").asInstanceOf[ActorEndpoint]
- val ep2: ActorEndpoint = component.createEndpoint("actor:id:abc").asInstanceOf[ActorEndpoint]
- assert(ep1.idValue === Some("abc"))
- assert(ep2.idValue === Some("abc"))
- assert(ep1.idType === "id")
- assert(ep2.idType === "id")
- assert(!ep1.blocking)
- assert(!ep2.blocking)
- }
-
- @Test def shouldCreateEndpointWithIdTemplate = {
- val ep: ActorEndpoint = component.createEndpoint("actor:id:").asInstanceOf[ActorEndpoint]
- assert(ep.idValue === None)
- assert(ep.idType === "id")
- assert(!ep.blocking)
- }
-
- @Test def shouldCreateEndpointWithIdTemplateAndBlockingSet = {
- val ep: ActorEndpoint = component.createEndpoint("actor:id:?blocking=true").asInstanceOf[ActorEndpoint]
- assert(ep.idValue === None)
- assert(ep.idType === "id")
- assert(ep.blocking)
- }
-
- @Test def shouldCreateEndpointWithUuidDefined = {
- val ep: ActorEndpoint = component.createEndpoint("actor:uuid:%s" format testUUID).asInstanceOf[ActorEndpoint]
- assert(ep.idValue === Some(testUUID))
- assert(ep.idType === "uuid")
- assert(!ep.blocking)
- }
-
- @Test def shouldCreateEndpointWithUuidTemplate = {
- val ep: ActorEndpoint = component.createEndpoint("actor:uuid:").asInstanceOf[ActorEndpoint]
- assert(ep.idValue === None)
- assert(ep.idType === "uuid")
- assert(!ep.blocking)
- }
-
- @Test def shouldCreateEndpointWithUuidTemplateandBlockingSet = {
- val ep: ActorEndpoint = component.createEndpoint("actor:uuid:?blocking=true").asInstanceOf[ActorEndpoint]
- assert(ep.idValue === None)
- assert(ep.idType === "uuid")
- assert(ep.blocking)
- }
-
- @Test def shouldCreateEndpointWithBlockingSet = {
- val ep: ActorEndpoint = component.createEndpoint("actor:uuid:%s?blocking=true" format testUUID).asInstanceOf[ActorEndpoint]
- assert(ep.idValue === Some(testUUID))
- assert(ep.idType === "uuid")
- assert(ep.blocking)
- }
-}
-
-object ActorComponentTest {
- def actorComponent = {
- val component = new ActorComponent
- component.setCamelContext(new DefaultCamelContext)
- component
- }
-
- def actorEndpoint(uri:String) = actorComponent.createEndpoint(uri)
- def actorProducer(endpoint: Endpoint) = endpoint.createProducer
- def actorAsyncProducer(endpoint: Endpoint) = endpoint.createProducer.asInstanceOf[AsyncProcessor]
-}
diff --git a/akka-camel/src/test/scala/akka/component/ActorProducerTest.scala b/akka-camel/src/test/scala/akka/component/ActorProducerTest.scala
deleted file mode 100644
index 62ccf9cb0e..0000000000
--- a/akka-camel/src/test/scala/akka/component/ActorProducerTest.scala
+++ /dev/null
@@ -1,230 +0,0 @@
-package akka.camel.component
-
-import ActorComponentTest._
-
-import java.util.concurrent.{CountDownLatch, TimeoutException, TimeUnit}
-
-import org.apache.camel.{AsyncCallback, ExchangePattern}
-
-import org.junit.{After, Test}
-import org.scalatest.junit.JUnitSuite
-import org.scalatest.BeforeAndAfterAll
-
-import akka.actor.Actor._
-import akka.actor.ActorRegistry
-import akka.camel.{Failure, Message}
-import akka.camel.support._
-
-class ActorProducerTest extends JUnitSuite with BeforeAndAfterAll {
- import ActorProducerTest._
-
- @After def tearDown = ActorRegistry.shutdownAll
-
- @Test def shouldSendMessageToActorWithSyncProcessor = {
- val actor = actorOf[Tester1].start
- val latch = (actor !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
- val exchange = endpoint.createExchange(ExchangePattern.InOnly)
- exchange.getIn.setBody("Martin")
- exchange.getIn.setHeader("k1", "v1")
- actorProducer(endpoint).process(exchange)
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val reply = (actor !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply.body === "Martin")
- assert(reply.headers === Map(Message.MessageExchangeId -> exchange.getExchangeId, "k1" -> "v1"))
- }
-
- @Test def shouldSendMessageToActorWithAsyncProcessor = {
- val actor = actorOf[Tester1].start
- val latch = (actor !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
- val exchange = endpoint.createExchange(ExchangePattern.InOnly)
- exchange.getIn.setBody("Martin")
- exchange.getIn.setHeader("k1", "v1")
- actorAsyncProducer(endpoint).process(exchange, expectSyncCompletion)
- assert(latch.await(5000, TimeUnit.MILLISECONDS))
- val reply = (actor !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply.body === "Martin")
- assert(reply.headers === Map(Message.MessageExchangeId -> exchange.getExchangeId, "k1" -> "v1"))
- }
-
- @Test def shouldSendMessageToActorAndReceiveResponseWithSyncProcessor = {
- val actor = actorOf(new Tester2 {
- override def response(msg: Message) = Message(super.response(msg), Map("k2" -> "v2"))
- }).start
- val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
- val exchange = endpoint.createExchange(ExchangePattern.InOut)
- exchange.getIn.setBody("Martin")
- exchange.getIn.setHeader("k1", "v1")
- actorProducer(endpoint).process(exchange)
- assert(exchange.getOut.getBody === "Hello Martin")
- assert(exchange.getOut.getHeader("k2") === "v2")
- }
-
- @Test def shouldSendMessageToActorAndReceiveResponseWithAsyncProcessor = {
- val actor = actorOf(new Tester2 {
- override def response(msg: Message) = Message(super.response(msg), Map("k2" -> "v2"))
- }).start
- val completion = expectAsyncCompletion
- val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
- val exchange = endpoint.createExchange(ExchangePattern.InOut)
- exchange.getIn.setBody("Martin")
- exchange.getIn.setHeader("k1", "v1")
- actorAsyncProducer(endpoint).process(exchange, completion)
- assert(completion.latch.await(5000, TimeUnit.MILLISECONDS))
- assert(exchange.getOut.getBody === "Hello Martin")
- assert(exchange.getOut.getHeader("k2") === "v2")
- }
-
- @Test def shouldSendMessageToActorAndReceiveFailureWithAsyncProcessor = {
- val actor = actorOf(new Tester2 {
- override def response(msg: Message) = Failure(new Exception("testmsg"), Map("k3" -> "v3"))
- }).start
- val completion = expectAsyncCompletion
- val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
- val exchange = endpoint.createExchange(ExchangePattern.InOut)
- exchange.getIn.setBody("Martin")
- exchange.getIn.setHeader("k1", "v1")
- actorAsyncProducer(endpoint).process(exchange, completion)
- assert(completion.latch.await(5000, TimeUnit.MILLISECONDS))
- assert(exchange.getException.getMessage === "testmsg")
- assert(exchange.getOut.getBody === null)
- assert(exchange.getOut.getHeader("k3") === null) // headers from failure message are currently ignored
- }
-
- @Test def shouldDynamicallyRouteMessageToActorWithDefaultId = {
- val actor1 = actorOf[Tester1]
- val actor2 = actorOf[Tester1]
- actor1.id = "x"
- actor2.id = "y"
- actor1.start
- actor2.start
- val latch1 = (actor1 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val latch2 = (actor2 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:id:%s" format actor1.id)
- val exchange1 = endpoint.createExchange(ExchangePattern.InOnly)
- val exchange2 = endpoint.createExchange(ExchangePattern.InOnly)
- exchange1.getIn.setBody("Test1")
- exchange2.getIn.setBody("Test2")
- exchange2.getIn.setHeader(ActorComponent.ActorIdentifier, actor2.id)
- actorProducer(endpoint).process(exchange1)
- actorProducer(endpoint).process(exchange2)
- assert(latch1.await(5, TimeUnit.SECONDS))
- assert(latch2.await(5, TimeUnit.SECONDS))
- val reply1 = (actor1 !! GetRetainedMessage).get.asInstanceOf[Message]
- val reply2 = (actor2 !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply1.body === "Test1")
- assert(reply2.body === "Test2")
- }
-
- @Test def shouldDynamicallyRouteMessageToActorWithoutDefaultId = {
- val actor1 = actorOf[Tester1]
- val actor2 = actorOf[Tester1]
- actor1.id = "x"
- actor2.id = "y"
- actor1.start
- actor2.start
- val latch1 = (actor1 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val latch2 = (actor2 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:id:")
- val exchange1 = endpoint.createExchange(ExchangePattern.InOnly)
- val exchange2 = endpoint.createExchange(ExchangePattern.InOnly)
- exchange1.getIn.setBody("Test1")
- exchange2.getIn.setBody("Test2")
- exchange1.getIn.setHeader(ActorComponent.ActorIdentifier, actor1.id)
- exchange2.getIn.setHeader(ActorComponent.ActorIdentifier, actor2.id)
- actorProducer(endpoint).process(exchange1)
- actorProducer(endpoint).process(exchange2)
- assert(latch1.await(5, TimeUnit.SECONDS))
- assert(latch2.await(5, TimeUnit.SECONDS))
- val reply1 = (actor1 !! GetRetainedMessage).get.asInstanceOf[Message]
- val reply2 = (actor2 !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply1.body === "Test1")
- assert(reply2.body === "Test2")
- }
-
- @Test def shouldDynamicallyRouteMessageToActorWithDefaultUuid = {
- val actor1 = actorOf[Tester1].start
- val actor2 = actorOf[Tester1].start
- val latch1 = (actor1 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val latch2 = (actor2 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:uuid:%s" format actor1.uuid)
- val exchange1 = endpoint.createExchange(ExchangePattern.InOnly)
- val exchange2 = endpoint.createExchange(ExchangePattern.InOnly)
- exchange1.getIn.setBody("Test1")
- exchange2.getIn.setBody("Test2")
- exchange2.getIn.setHeader(ActorComponent.ActorIdentifier, actor2.uuid.toString)
- actorProducer(endpoint).process(exchange1)
- actorProducer(endpoint).process(exchange2)
- assert(latch1.await(5, TimeUnit.SECONDS))
- assert(latch2.await(5, TimeUnit.SECONDS))
- val reply1 = (actor1 !! GetRetainedMessage).get.asInstanceOf[Message]
- val reply2 = (actor2 !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply1.body === "Test1")
- assert(reply2.body === "Test2")
- }
-
- @Test def shouldDynamicallyRouteMessageToActorWithoutDefaultUuid = {
- val actor1 = actorOf[Tester1].start
- val actor2 = actorOf[Tester1].start
- val latch1 = (actor1 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val latch2 = (actor2 !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:uuid:")
- val exchange1 = endpoint.createExchange(ExchangePattern.InOnly)
- val exchange2 = endpoint.createExchange(ExchangePattern.InOnly)
- exchange1.getIn.setBody("Test1")
- exchange2.getIn.setBody("Test2")
- exchange1.getIn.setHeader(ActorComponent.ActorIdentifier, actor1.uuid)
- exchange2.getIn.setHeader(ActorComponent.ActorIdentifier, actor2.uuid.toString)
- actorProducer(endpoint).process(exchange1)
- actorProducer(endpoint).process(exchange2)
- assert(latch1.await(5, TimeUnit.SECONDS))
- assert(latch2.await(5, TimeUnit.SECONDS))
- val reply1 = (actor1 !! GetRetainedMessage).get.asInstanceOf[Message]
- val reply2 = (actor2 !! GetRetainedMessage).get.asInstanceOf[Message]
- assert(reply1.body === "Test1")
- assert(reply2.body === "Test2")
- }
-
- @Test def shouldThrowExceptionWhenIdNotSet: Unit = {
- val actor = actorOf[Tester1].start
- val latch = (actor !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:id:")
- intercept[ActorIdentifierNotSetException] {
- actorProducer(endpoint).process(endpoint.createExchange(ExchangePattern.InOnly))
- }
- }
-
- @Test def shouldThrowExceptionWhenUuidNotSet: Unit = {
- val actor = actorOf[Tester1].start
- val latch = (actor !! SetExpectedMessageCount(1)).as[CountDownLatch].get
- val endpoint = actorEndpoint("actor:uuid:")
- intercept[ActorIdentifierNotSetException] {
- actorProducer(endpoint).process(endpoint.createExchange(ExchangePattern.InOnly))
- }
- }
-
- @Test def shouldSendMessageToActorAndTimeout(): Unit = {
- val actor = actorOf[Tester3].start
- val endpoint = actorEndpoint("actor:uuid:%s" format actor.uuid)
- val exchange = endpoint.createExchange(ExchangePattern.InOut)
- exchange.getIn.setBody("Martin")
- intercept[TimeoutException] {
- endpoint.createProducer.process(exchange)
- }
- }
-}
-
-object ActorProducerTest {
- def expectSyncCompletion = new AsyncCallback {
- def done(doneSync: Boolean) = assert(doneSync)
- }
-
- def expectAsyncCompletion = new AsyncCallback {
- val latch = new CountDownLatch(1);
- def done(doneSync: Boolean) = {
- assert(!doneSync)
- latch.countDown
- }
- }
-}
diff --git a/akka-camel/src/test/scala/akka/component/TypedActorComponentFeatureTest.scala b/akka-camel/src/test/scala/akka/component/TypedActorComponentFeatureTest.scala
deleted file mode 100644
index e6e1293a54..0000000000
--- a/akka-camel/src/test/scala/akka/component/TypedActorComponentFeatureTest.scala
+++ /dev/null
@@ -1,108 +0,0 @@
-package akka.camel.component
-
-import org.apache.camel._
-import org.apache.camel.builder.RouteBuilder
-import org.apache.camel.impl.{DefaultCamelContext, SimpleRegistry}
-import org.scalatest.{BeforeAndAfterEach, BeforeAndAfterAll, FeatureSpec}
-
-import akka.actor.{ActorRegistry, TypedActor}
-import akka.camel._
-
-/**
- * @author Martin Krasser
- */
-class TypedActorComponentFeatureTest extends FeatureSpec with BeforeAndAfterAll with BeforeAndAfterEach {
- import TypedActorComponentFeatureTest._
- import CamelContextManager.mandatoryTemplate
-
- override protected def beforeAll = {
- val typedActor = TypedActor.newInstance(classOf[SampleTypedActor], classOf[SampleTypedActorImpl]) // not a consumer
- val typedConsumer = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl])
-
- val registry = new SimpleRegistry
- // external registration
- registry.put("ta", typedActor)
-
- CamelContextManager.init(new DefaultCamelContext(registry))
- CamelContextManager.mandatoryContext.addRoutes(new CustomRouteBuilder)
- CamelContextManager.start
-
- // Internal registration
- CamelContextManager.typedActorRegistry.put("tc", typedConsumer)
- }
-
- override protected def afterAll = {
- CamelContextManager.stop
- ActorRegistry.shutdownAll
- }
-
- feature("Communicate with an internally-registered typed actor using typed-actor-internal endpoint URIs") {
- import TypedActorComponent.InternalSchema
- import ExchangePattern._
-
- scenario("two-way communication with method returning String") {
- val result1 = mandatoryTemplate.requestBodyAndHeader("%s:tc?method=m2" format InternalSchema, "x", "test", "y")
- val result2 = mandatoryTemplate.requestBodyAndHeader("%s:tc?method=m4" format InternalSchema, "x", "test", "y")
- assert(result1 === "m2: x y")
- assert(result2 === "m4: x y")
- }
-
- scenario("two-way communication with method returning void") {
- val result = mandatoryTemplate.requestBodyAndHeader("%s:tc?method=m5" format InternalSchema, "x", "test", "y")
- assert(result === "x") // returns initial body
- }
-
- scenario("one-way communication with method returning String") {
- val result = mandatoryTemplate.send("%s:tc?method=m2" format InternalSchema, InOnly, new Processor {
- def process(exchange: Exchange) = {
- exchange.getIn.setBody("x")
- exchange.getIn.setHeader("test", "y")
- }
- });
- assert(result.getPattern === InOnly)
- assert(result.getIn.getBody === "m2: x y")
- assert(result.getOut.getBody === null)
- }
-
- scenario("one-way communication with method returning void") {
- val result = mandatoryTemplate.send("%s:tc?method=m5" format InternalSchema, InOnly, new Processor {
- def process(exchange: Exchange) = {
- exchange.getIn.setBody("x")
- exchange.getIn.setHeader("test", "y")
- }
- });
- assert(result.getPattern === InOnly)
- assert(result.getIn.getBody === "x")
- assert(result.getOut.getBody === null)
- }
-
- }
-
- feature("Communicate with an internally-registered typed actor using typed-actor endpoint URIs") {
- scenario("communication not possible") {
- intercept[ResolveEndpointFailedException] {
- mandatoryTemplate.requestBodyAndHeader("typed-actor:tc?method=m2", "x", "test", "y")
- }
- }
- }
-
- feature("Communicate with an externally-registered typed actor using typed-actor endpoint URIs") {
- scenario("two-way communication with method returning String") {
- val result = mandatoryTemplate.requestBody("typed-actor:ta?method=foo", "test")
- assert(result === "foo: test")
- }
-
- scenario("two-way communication with method returning String via custom route") {
- val result = mandatoryTemplate.requestBody("direct:test", "test")
- assert(result === "foo: test")
- }
- }
-}
-
-object TypedActorComponentFeatureTest {
- class CustomRouteBuilder extends RouteBuilder {
- def configure = {
- from("direct:test").to("typed-actor:ta?method=foo")
- }
- }
-}
diff --git a/akka-camel/src/test/scala/akka/support/TestSupport.scala b/akka-camel/src/test/scala/akka/support/TestSupport.scala
deleted file mode 100644
index 4744d774f5..0000000000
--- a/akka-camel/src/test/scala/akka/support/TestSupport.scala
+++ /dev/null
@@ -1,81 +0,0 @@
-package akka.camel.support
-
-import java.util.concurrent.{TimeUnit, CountDownLatch}
-
-import collection.mutable.Buffer
-
-import akka.camel.Message
-import akka.actor.Actor
-
-import TestSupport._
-
-object TestSupport {
- type Handler = PartialFunction[Any, Any]
-}
-
-trait TestActor extends Actor {
- def receive = {
- case msg => {
- handler(msg)
- }
- }
-
- def handler: Handler
-}
-
-class Tester1 extends TestActor with Retain with Countdown {
- def handler = retain andThen countdown
-}
-
-class Tester2 extends TestActor with Respond {
- def handler = respond
-}
-
-class Tester3 extends TestActor with Noop {
- self.timeout = 1
- def handler = noop
-}
-
-trait Countdown { this: Actor =>
- var latch: CountDownLatch = new CountDownLatch(0)
- def countdown: Handler = {
- case SetExpectedMessageCount(num) => {
- latch = new CountDownLatch(num)
- self.reply(latch)
- }
- case msg => latch.countDown
- }
-}
-
-trait Respond { this: Actor =>
- def respond: Handler = {
- case msg: Message => self.reply(response(msg))
- }
-
- def response(msg: Message): Any = "Hello %s" format msg.body
-}
-
-trait Retain { this: Actor =>
- val messages = Buffer[Any]()
-
- def retain: Handler = {
- case GetRetainedMessage => self.reply(messages.last)
- case GetRetainedMessages(p) => self.reply(messages.toList.filter(p))
- case msg => {
- messages += msg
- msg
- }
- }
-}
-
-trait Noop { this: Actor =>
- def noop: Handler = {
- case msg => msg
- }
-}
-
-case class SetExpectedMessageCount(num: Int)
-case class GetRetainedMessage()
-case class GetRetainedMessages(p: Any => Boolean) {
- def this() = this(_ => true)
-}
diff --git a/akka-http/src/main/scala/DefaultAkkaLoader.scala b/akka-http/src/main/scala/DefaultAkkaLoader.scala
index b0bc3ad020..0e032f184d 100644
--- a/akka-http/src/main/scala/DefaultAkkaLoader.scala
+++ b/akka-http/src/main/scala/DefaultAkkaLoader.scala
@@ -6,16 +6,12 @@ package akka.http
import akka.config.Config
import akka.util.{Logging, Bootable}
-import akka.camel.CamelService
import akka.remote.BootableRemoteActorService
import akka.actor.BootableActorLoaderService
import akka.servlet.AkkaLoader
class DefaultAkkaLoader extends AkkaLoader {
- def boot(): Unit = boot(true,
- new EmbeddedAppServer with BootableActorLoaderService
- with BootableRemoteActorService
- with CamelService)
+ def boot(): Unit = boot(true, new EmbeddedAppServer with BootableActorLoaderService with BootableRemoteActorService)
}
diff --git a/akka-http/src/main/scala/Initializer.scala b/akka-http/src/main/scala/Initializer.scala
index a470949821..c9eb1f8f67 100644
--- a/akka-http/src/main/scala/Initializer.scala
+++ b/akka-http/src/main/scala/Initializer.scala
@@ -6,7 +6,6 @@ package akka.servlet
import akka.remote.BootableRemoteActorService
import akka.actor.BootableActorLoaderService
-import akka.camel.CamelService
import akka.config.Config
import akka.util.{Logging, Bootable}
@@ -30,5 +29,5 @@ class Initializer extends ServletContextListener {
loader.shutdown
def contextInitialized(e: ServletContextEvent): Unit =
- loader.boot(true, new BootableActorLoaderService with BootableRemoteActorService with CamelService)
+ loader.boot(true, new BootableActorLoaderService with BootableRemoteActorService)
}
diff --git a/akka-jta/src/main/scala/akka/AtomikosTransactionService.scala b/akka-jta/src/main/scala/akka/AtomikosTransactionService.scala
deleted file mode 100644
index f2af9c01bf..0000000000
--- a/akka-jta/src/main/scala/akka/AtomikosTransactionService.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.jta
-
-import javax.transaction.{TransactionManager, SystemException}
-
-import com.atomikos.icatch.jta.{J2eeTransactionManager, J2eeUserTransaction}
-import com.atomikos.icatch.config.{TSInitInfo, UserTransactionService, UserTransactionServiceImp}
-
-import akka.config.Config._
-import akka.util.Duration
-
-object AtomikosTransactionService extends AtomikosTransactionService
-
-/**
- * Atomikos implementation of the transaction service trait.
- *
- * @author Jonas Bonér
- */
-class AtomikosTransactionService extends TransactionService with TransactionProtocol {
- val JTA_TRANSACTION_TIMEOUT = Duration(config.getInt("akka.jta.timeout", 60), TIME_UNIT)
-
- private val txService: UserTransactionService = new UserTransactionServiceImp
- private val info: TSInitInfo = txService.createTSInitInfo
-
- val transactionContainer: TransactionContainer = TransactionContainer(Right(Some(
- try {
- txService.init(info)
- val tm: TransactionManager = new J2eeTransactionManager
- tm.setTransactionTimeout(JTA_TRANSACTION_TIMEOUT.toSeconds.toInt)
- tm
- } catch {
- case e => throw new SystemException(
- "Could not create a new Atomikos J2EE Transaction Manager, due to: " + e.toString)
- }
- )))
- // TODO: gracefully postStop of the TM
- //txService.postStop(false)
-}
diff --git a/akka-jta/src/main/scala/akka/JTA.scala b/akka-jta/src/main/scala/akka/JTA.scala
deleted file mode 100644
index 1f637fc17b..0000000000
--- a/akka-jta/src/main/scala/akka/JTA.scala
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.jta
-
-import javax.transaction.{TransactionManager, UserTransaction,
- Transaction => JtaTransaction, SystemException,
- Status, Synchronization, TransactionSynchronizationRegistry}
-import javax.naming.{InitialContext, Context, NamingException}
-
-import akka.config.Config._
-import akka.util.Logging
-import akka.stm.Transaction
-import akka.AkkaException
-
-class JtaConfigurationException(message: String) extends AkkaException(message)
-
-/**
- * Detects if there is a UserTransaction or TransactionManager available in the JNDI.
- *
- * @author Jonas Bonér
- */
-object TransactionContainer extends Logging {
- val AKKA_JTA_TRANSACTION_SERVICE_CLASS = "akka.jta.AtomikosTransactionService"
- val DEFAULT_USER_TRANSACTION_NAME = "java:comp/UserTransaction"
- val FALLBACK_TRANSACTION_MANAGER_NAMES = "java:comp/TransactionManager" ::
- "java:appserver/TransactionManager" ::
- "java:pm/TransactionManager" ::
- "java:/TransactionManager" :: Nil
- val DEFAULT_TRANSACTION_SYNCHRONIZATION_REGISTRY_NAME = "java:comp/TransactionSynchronizationRegistry"
-
- val JTA_PROVIDER = config.getString("akka.jta.provider", "from-jndi")
-
- private var synchronizationRegistry: Option[TransactionSynchronizationRegistry] = None
-
- def apply(tm: Either[Option[UserTransaction], Option[TransactionManager]]) = new TransactionContainer(tm)
-
- def apply(): TransactionContainer =
- JTA_PROVIDER match {
- case "from-jndi" =>
- new TransactionContainer(findUserTransaction match {
- case None => Right(findTransactionManager)
- case tm => Left(tm)
- })
- case "atomikos" =>
- try {
- Class.forName(AKKA_JTA_TRANSACTION_SERVICE_CLASS)
- .newInstance.asInstanceOf[TransactionService]
- .transactionContainer
- } catch {
- case e: ClassNotFoundException =>
- throw new JtaConfigurationException(
- "JTA provider defined as 'atomikos', but the AtomikosTransactionService classes can not be found." +
- "\n\tPlease make sure you have 'akka-jta' JAR and its dependencies on your classpath.")
- }
- case _ =>
- throw new JtaConfigurationException(
- "No UserTransaction on TransactionManager could be found in scope." +
- "\n\tEither add 'akka-jta' to the classpath or make sure there is a" +
- "\n\tTransactionManager or UserTransaction defined in the JNDI.")
-
- }
-
- def findUserTransaction: Option[UserTransaction] = {
- val located = createInitialContext.lookup(DEFAULT_USER_TRANSACTION_NAME)
- if (located eq null) None
- else {
- log.info("JTA UserTransaction detected [%s]", located)
- Some(located.asInstanceOf[UserTransaction])
- }
- }
-
- def findSynchronizationRegistry: Option[TransactionSynchronizationRegistry] = synchronized {
- if (synchronizationRegistry.isDefined) synchronizationRegistry
- else {
- val located = createInitialContext.lookup(DEFAULT_TRANSACTION_SYNCHRONIZATION_REGISTRY_NAME)
- if (located eq null) None
- else {
- log.info("JTA TransactionSynchronizationRegistry detected [%s]", located)
- synchronizationRegistry = Some(located.asInstanceOf[TransactionSynchronizationRegistry])
- synchronizationRegistry
- }
- }
- }
-
- def findTransactionManager: Option[TransactionManager] = {
- val context = createInitialContext
- val tms = for {
- name <- FALLBACK_TRANSACTION_MANAGER_NAMES
- tm = context.lookup(name)
- if tm ne null
- } yield tm
- tms match {
- case Nil => None
- case tm :: _ =>
- log.info("JTA TransactionManager detected [%s]", tm)
- Some(tm.asInstanceOf[TransactionManager])
- }
- }
-
- private def createInitialContext = new InitialContext(new java.util.Hashtable)
-}
-
-/**
- * JTA transaction container holding either a UserTransaction or a TransactionManager.
- *
- * The TransactionContainer is created using the factory val container = TransactionContainer()
- *
- * @author Jonas Bonér
- */
-class TransactionContainer private (
- val tm: Either[Option[UserTransaction], Option[TransactionManager]]) extends Logging {
-
- def registerSynchronization(sync: Synchronization) = {
- TransactionContainer.findSynchronizationRegistry match { // try to use SynchronizationRegistry in JNDI
- case Some(registry) =>
- registry.asInstanceOf[TransactionSynchronizationRegistry].registerInterposedSynchronization(sync)
- case None =>
- tm match {
- case Right(Some(txMan)) => // try to use TransactionManager
- txMan.getTransaction.registerSynchronization(sync)
- case _ =>
- log.warning("Cannot find TransactionSynchronizationRegistry in JNDI, can't register STM synchronization")
- }
- }
- }
-
- def beginWithStmSynchronization(transaction: Transaction) = {
- begin
- registerSynchronization(new StmSynchronization(this, transaction))
- }
-
- def begin = {
- TransactionContainer.log.trace("Starting JTA transaction")
- tm match {
- case Left(Some(userTx)) => userTx.begin
- case Right(Some(txMan)) => txMan.begin
- case _ => throw new JtaConfigurationException("Does not have a UserTransaction or TransactionManager in scope")
- }
- }
-
- def commit = {
- TransactionContainer.log.trace("Committing JTA transaction")
- tm match {
- case Left(Some(userTx)) => userTx.commit
- case Right(Some(txMan)) => txMan.commit
- case _ => throw new JtaConfigurationException("Does not have a UserTransaction or TransactionManager in scope")
- }
- }
-
- def rollback = {
- TransactionContainer.log.trace("Aborting JTA transaction")
- tm match {
- case Left(Some(userTx)) => userTx.rollback
- case Right(Some(txMan)) => txMan.rollback
- case _ => throw new JtaConfigurationException("Does not have a UserTransaction or TransactionManager in scope")
- }
- }
-
- def getStatus = tm match {
- case Left(Some(userTx)) => userTx.getStatus
- case Right(Some(txMan)) => txMan.getStatus
- case _ => throw new JtaConfigurationException("Does not have a UserTransaction or TransactionManager in scope")
- }
-
- def isInExistingTransaction = tm match {
- case Left(Some(userTx)) => userTx.getStatus == Status.STATUS_ACTIVE
- case Right(Some(txMan)) => txMan.getStatus == Status.STATUS_ACTIVE
- case _ => throw new JtaConfigurationException("Does not have a UserTransaction or TransactionManager in scope")
- }
-
- def isRollbackOnly = tm match {
- case Left(Some(userTx)) => userTx.getStatus == Status.STATUS_MARKED_ROLLBACK
- case Right(Some(txMan)) => txMan.getStatus == Status.STATUS_MARKED_ROLLBACK
- case _ => throw new JtaConfigurationException("Does not have a UserTransaction or TransactionManager in scope")
- }
-
- def setRollbackOnly = tm match {
- case Left(Some(userTx)) => userTx.setRollbackOnly
- case Right(Some(txMan)) => txMan.setRollbackOnly
- case _ => throw new JtaConfigurationException("Does not have a UserTransaction or TransactionManager in scope")
- }
-
- def suspend = tm match {
- case Right(Some(txMan)) => txMan.suspend
- case _ => throw new JtaConfigurationException("Does not have a TransactionManager in scope")
- }
-
- def resume(tx: JtaTransaction) = tm match {
- case Right(Some(txMan)) => txMan.resume(tx)
- case _ => throw new JtaConfigurationException("Does not have a TransactionManager in scope")
- }
-}
-
-/**
- * STM Synchronization class for synchronizing with the JTA TransactionManager.
- *
- * @author Jonas Bonér
- */
-class StmSynchronization(tc: TransactionContainer, tx: Transaction) extends Synchronization with Logging {
- def beforeCompletion = {
- val status = tc.getStatus
- if (status != Status.STATUS_ROLLEDBACK &&
- status != Status.STATUS_ROLLING_BACK &&
- status != Status.STATUS_MARKED_ROLLBACK) {
- log.debug("JTA transaction has failed, abort STM transaction")
- tx.transaction.foreach(_.abort) // abort multiverse tx
- }
- }
-
- def afterCompletion(status: Int) = {}
-}
-
-/**
- * JTA Transaction service.
- *
- * @author Jonas Bonér
- */
-trait TransactionService {
- def transactionContainer: TransactionContainer
-}
-
diff --git a/akka-jta/src/main/scala/akka/TransactionContext.scala b/akka-jta/src/main/scala/akka/TransactionContext.scala
deleted file mode 100644
index ca92e5aa75..0000000000
--- a/akka-jta/src/main/scala/akka/TransactionContext.scala
+++ /dev/null
@@ -1,238 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.jta
-
-import javax.transaction.{Transaction, Status, TransactionManager, Synchronization}
-
-import akka.util.Logging
-import akka.config.Config._
-
-/**
- * The TransactionContext object manages the transactions.
- * Can be used as higher-order functional 'atomic blocks' or monadic.
- *
- * Manages a thread-local stack of TransactionContexts.
- *
- * Example usage 1:
- *
- *
- * @author Jonas Bonér
- */
-object TransactionContext extends TransactionProtocol with Logging {
- implicit val tc = TransactionContainer()
-
- private[TransactionContext] val stack = new scala.util.DynamicVariable(new TransactionContext(tc))
-
- /**
- * This method can be used to register a Synchronization instance for participating with the JTA transaction.
- * Here is an example of how to add a JPA EntityManager integration.
- *
- * TransactionContext.registerSynchronization(new javax.transaction.Synchronization() {
- * def beforeCompletion = {
- * try {
- * val status = tm.getStatus
- * if (status != Status.STATUS_ROLLEDBACK &&
- * status != Status.STATUS_ROLLING_BACK &&
- * status != Status.STATUS_MARKED_ROLLBACK) {
- * log.debug("Flushing EntityManager...")
- * em.flush // flush EntityManager on success
- * }
- * } catch {
- * case e: javax.transaction.SystemException => throw new RuntimeException(e)
- * }
- * }
- *
- * def afterCompletion(status: Int) = {
- * val status = tm.getStatus
- * if (closeAtTxCompletion) em.close
- * if (status == Status.STATUS_ROLLEDBACK ||
- * status == Status.STATUS_ROLLING_BACK ||
- * status == Status.STATUS_MARKED_ROLLBACK) {
- * em.close
- * }
- * }
- * })
- *
- * You should also override the 'joinTransaction' and 'handleException' methods.
- * See ScalaDoc for these methods in the 'TransactionProtocol' for details.
- */
- def registerSynchronization(sync: Synchronization) = synchronization.add(sync)
-
- /**
- * Registeres a join transaction function.
- *
- * Here is an example on how to integrate with JPA EntityManager.
- *
- *
- * TransactionContext.registerJoinTransactionFun(() => {
- * val em: EntityManager = ... // get the EntityManager
- * em.joinTransaction // join JTA transaction
- * })
- *
- */
- def registerJoinTransactionFun(fn: () => Unit) = joinTransactionFuns.add(fn)
-
- /**
- * Handle exception. Can be overriden by concrete transaction service implementation.
- *
- * Here is an example on how to handle JPA exceptions.
- *
- *
- */
- def registerExceptionNotToRollbackOn(e: Class[_ <: Exception]) = exceptionsNotToRollbackOn.add(e)
-
- object Required extends TransactionMonad {
- def map[T](f: TransactionMonad => T): T = withTxRequired { f(this) }
- def flatMap[T](f: TransactionMonad => T): T = withTxRequired { f(this) }
- def foreach(f: TransactionMonad => Unit): Unit = withTxRequired { f(this) }
- }
-
- object RequiresNew extends TransactionMonad {
- def map[T](f: TransactionMonad => T): T = withTxRequiresNew { f(this) }
- def flatMap[T](f: TransactionMonad => T): T = withTxRequiresNew { f(this) }
- def foreach(f: TransactionMonad => Unit): Unit = withTxRequiresNew { f(this) }
- }
-
- object Supports extends TransactionMonad {
- def map[T](f: TransactionMonad => T): T = withTxSupports { f(this) }
- def flatMap[T](f: TransactionMonad => T): T = withTxSupports { f(this) }
- def foreach(f: TransactionMonad => Unit): Unit = withTxSupports { f(this) }
- }
-
- object Mandatory extends TransactionMonad {
- def map[T](f: TransactionMonad => T): T = withTxMandatory { f(this) }
- def flatMap[T](f: TransactionMonad => T): T = withTxMandatory { f(this) }
- def foreach(f: TransactionMonad => Unit): Unit = withTxMandatory { f(this) }
- }
-
- object Never extends TransactionMonad {
- def map[T](f: TransactionMonad => T): T = withTxNever { f(this) }
- def flatMap[T](f: TransactionMonad => T): T = withTxNever { f(this) }
- def foreach(f: TransactionMonad => Unit): Unit = withTxNever { f(this) }
- }
-
- object NoOpTransactionMonad extends TransactionMonad {
- def map[T](f: TransactionMonad => T): T = f(this)
- def flatMap[T](f: TransactionMonad => T): T = f(this)
- def foreach(f: TransactionMonad => Unit): Unit = f(this)
- override def filter(f: TransactionMonad => Boolean): TransactionMonad = this
- }
-
- private[jta] def setRollbackOnly = current.setRollbackOnly
-
- private[jta] def isRollbackOnly = current.isRollbackOnly
-
- private[jta] def getTransactionContainer: TransactionContainer = current.getTransactionContainer
-
- private[this] def current = stack.value
-
- /**
- * Continues with the invocation defined in 'body' with the brand new context define in 'newCtx', the old
- * one is put on the stack and will automatically come back in scope when the method exits.
- *
- * Suspends and resumes the current JTA transaction.
- */
- private[jta] def withNewContext[T](body: => T): T = {
- val suspendedTx: Option[Transaction] =
- if (getTransactionContainer.isInExistingTransaction) {
- log.debug("Suspending TX")
- Some(getTransactionContainer.suspend)
- } else None
- val result = stack.withValue(new TransactionContext(tc)) { body }
- if (suspendedTx.isDefined) {
- log.debug("Resuming TX")
- getTransactionContainer.resume(suspendedTx.get)
- }
- result
- }
-}
-
-/**
- * Base monad for the transaction monad implementations.
- *
- * @author Jonas Bonér
- */
-trait TransactionMonad {
-
- // -----------------------------
- // Monadic definitions
- // -----------------------------
-
- def map[T](f: TransactionMonad => T): T
- def flatMap[T](f: TransactionMonad => T): T
- def foreach(f: TransactionMonad => Unit): Unit
- def filter(f: TransactionMonad => Boolean): TransactionMonad =
- if (f(this)) this else TransactionContext.NoOpTransactionMonad
-
- // -----------------------------
- // JTA Transaction definitions
- // -----------------------------
-
- /**
- * Marks the current transaction as doomed.
- */
- def setRollbackOnly = TransactionContext.setRollbackOnly
-
- /**
- * Marks the current transaction as doomed.
- */
- def doom = TransactionContext.setRollbackOnly
-
- /**
- * Checks if the current transaction is doomed.
- */
- def isRollbackOnly = TransactionContext.isRollbackOnly
-
- /**
- * Checks that the current transaction is NOT doomed.
- */
- def isNotDoomed = !TransactionContext.isRollbackOnly
-}
-
-/**
- * Transaction context, holds the EntityManager and the TransactionManager.
- *
- * @author Jonas Bonér
- */
-class TransactionContext(val tc: TransactionContainer) {
- def registerSynchronization(sync: Synchronization) = TransactionContext.registerSynchronization(sync)
- def setRollbackOnly = tc.setRollbackOnly
- def isRollbackOnly: Boolean = tc.getStatus == Status.STATUS_MARKED_ROLLBACK
- def getTransactionContainer: TransactionContainer = tc
-}
diff --git a/akka-jta/src/main/scala/akka/TransactionProtocol.scala b/akka-jta/src/main/scala/akka/TransactionProtocol.scala
deleted file mode 100644
index 11965df9e6..0000000000
--- a/akka-jta/src/main/scala/akka/TransactionProtocol.scala
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.jta
-
-import akka.util.Logging
-
-import java.util.{List => JList}
-import java.util.concurrent.CopyOnWriteArrayList
-
-import javax.naming.{NamingException, Context, InitialContext}
-import javax.transaction.{
- Transaction,
- UserTransaction,
- TransactionManager,
- Status,
- RollbackException,
- SystemException,
- Synchronization,
- TransactionRequiredException
-}
-
-/**
- *
- * Trait that implements a JTA transaction service that obeys the transaction semantics defined
- * in the transaction attribute types for the transacted methods according to the EJB 3 draft specification.
- * The aspect handles UserTransaction, TransactionManager instance variable injection thru @javax.ejb.Inject
- * (name subject to change as per EJB 3 spec) and method transaction levels thru @javax.ejb.TransactionAttribute.
- *
- *
- *
- * This trait should be inherited to implement the getTransactionManager() method that should return a concrete
- * javax.transaction.TransactionManager implementation (from JNDI lookup etc).
- *
- * 'Required' is probably the best choice (at least initially) for an EJB method that will need to be transactional. In this case, if the method's caller is already part of a transaction, then the EJB method does not create a new transaction, but continues in the same transaction as its caller. If the caller is not in a transaction, then a new transaction is created for the EJB method. If something happens in the EJB that means that a rollback is required, then the extent of the rollback will include everything done in the EJB method, whatever the condition of the caller. If the caller was in a transaction, then everything done by the caller will be rolled back as well. Thus the 'required' attribute ensures that any work done by the EJB will be rolled back if necessary, and if the caller requires a rollback that too will be rolled back.
- *
- *
- *
RequiresNew
- * 'RequiresNew' will be appropriate if you want to ensure that the EJB method is rolled back if necessary, but you don't want the rollback to propogate back to the caller. This attribute results in the creation of a new transaction for the method, regardless of the transactional state of the caller. If the caller was operating in a transaction, then its transaction is suspended until the EJB method completes. Because a new transaction is always created, there may be a slight performance penalty if this attribute is over-used.
- *
- *
- *
Mandatory
- * With the 'mandatory' attribute, the EJB method will not even start unless its caller is in a transaction. It will throw a TransactionRequiredException instead. If the method does start, then it will become part of the transaction of the caller. So if the EJB method signals a failure, the caller will be rolled back as well as the EJB.
- *
- *
- *
Supports
- * With this attribute, the EJB method does not care about the transactional context of its caller. If the caller is part of a transaction, then the EJB method will be part of the same transaction. If the EJB method fails, the transaction will roll back. If the caller is not part of a transaction, then the EJB method will still operate, but a failure will not cause anything to roll back. 'Supports' is probably the attribute that leads to the fastest method call (as there is no transactional overhead), but it can lead to unpredicatable results. If you want a method to be isolated from transactions, that is, to have no effect on the transaction of its caller, then use 'NotSupported' instead.
- *
- *
- *
NotSupported
- * With the 'NotSupported' attribute, the EJB method will never take part in a transaction. If the caller is part of a transaction, then the caller's transaction is suspended. If the EJB method fails, there will be no effect on the caller's transaction, and no rollback will occur. Use this method if you want to ensure that the EJB method will not cause a rollback in its caller. This is appropriate if, for example, the method does something non-essential, such as logging a message. It would not be helpful if the failure of this operation caused a transaction rollback.
- *
- *
- *
Never
- * The 'NotSupported'' attribute will ensure that the EJB method is never called by a transactional caller. Any attempt to do so will result in a RemoteException being thrown. This attribute is probably less useful than `NotSupported', in that NotSupported will assure that the caller's transaction is never affected by the EJB method (just as `Never' does), but will allow a call from a transactional caller if necessary.
- *
- *
- * @author Jonas Bonér
- */
-trait TransactionProtocol extends Logging {
-
- protected val synchronization: JList[Synchronization] = new CopyOnWriteArrayList[Synchronization]
- protected val joinTransactionFuns: JList[() => Unit] = new CopyOnWriteArrayList[() => Unit]
- protected val exceptionsNotToRollbackOn: JList[Class[_ <: Exception]] = new CopyOnWriteArrayList[Class[_ <: Exception]]
-
- def joinTransaction(): Unit = {
- val it = joinTransactionFuns.iterator
- while (it.hasNext) {
- val fn = it.next
- fn()
- }
- }
-
- def handleException(tm: TransactionContainer, e: Exception) = {
- var rollback = true
- val it = joinTransactionFuns.iterator
- while (it.hasNext) {
- val exception = it.next
- if (e.getClass.isAssignableFrom(exception.getClass))
- rollback = false
- }
- if (rollback) tm.setRollbackOnly
- throw e
- }
-
- /**
- * Wraps body in a transaction with REQUIRED semantics.
- *
- * Creates a new transaction if no transaction is active in scope, else joins the outer transaction.
- */
- def withTxRequired[T](body: => T): T = {
- val tm = TransactionContext.getTransactionContainer
- if (!isInExistingTransaction(tm)) {
- tm.begin
- registerSynchronization
- try {
- joinTransaction
- body
- } catch {
- case e: Exception => handleException(tm, e)
- } finally {
- commitOrRollBack(tm)
- }
- } else body
- }
-
- /**
- * Wraps body in a transaction with REQUIRES_NEW semantics.
- *
- * Suspends existing transaction, starts a new transaction, invokes body,
- * commits or rollbacks new transaction, finally resumes previous transaction.
- */
- def withTxRequiresNew[T](body: => T): T = TransactionContext.withNewContext {
- val tm = TransactionContext.getTransactionContainer
- tm.begin
- registerSynchronization
- try {
- joinTransaction
- body
- } catch {
- case e: Exception => handleException(tm, e)
- } finally {
- commitOrRollBack(tm)
- }
- }
-
- /**
- * Wraps body in a transaction with NOT_SUPPORTED semantics.
- *
- * Suspends existing transaction, invokes body, resumes transaction.
- */
- def withTxNotSupported[T](body: => T): T = TransactionContext.withNewContext {
- body
- }
-
- /**
- * Wraps body in a transaction with SUPPORTS semantics.
- *
- * Basicalla a No-op.
- */
- def withTxSupports[T](body: => T): T = {
- // attach to current if exists else skip -> do nothing
- body
- }
-
- /**
- * Wraps body in a transaction with MANDATORY semantics.
- *
- * Throws a TransactionRequiredException if there is no transaction active in scope.
- */
- def withTxMandatory[T](body: => T): T = {
- if (!isInExistingTransaction(TransactionContext.getTransactionContainer))
- throw new TransactionRequiredException("No active TX at method with TX type set to MANDATORY")
- body
- }
-
- /**
- * Wraps body in a transaction with NEVER semantics.
- *
- * Throws a SystemException in case of an existing transaction in scope.
- */
- def withTxNever[T](body: => T): T = {
- if (isInExistingTransaction(TransactionContext.getTransactionContainer))
- throw new SystemException("Detected active TX at method with TX type set to NEVER")
- body
- }
-
- protected def commitOrRollBack(tm: TransactionContainer) = {
- if (isInExistingTransaction(tm)) {
- if (isRollbackOnly(tm)) {
- log.debug("Rolling back TX marked as ROLLBACK_ONLY")
- tm.rollback
- } else {
- log.debug("Committing TX")
- tm.commit
- }
- }
- }
-
- // ---------------------------
- // Helper methods
- // ---------------------------
-
- protected def registerSynchronization = {
- val it = synchronization.iterator
- while (it.hasNext) TransactionContext.getTransactionContainer.registerSynchronization(it.next)
- }
- /**
- * Checks if a transaction is an existing transaction.
- *
- * @param tm the transaction manager
- * @return boolean
- */
- protected def isInExistingTransaction(tm: TransactionContainer): Boolean =
- tm.getStatus != Status.STATUS_NO_TRANSACTION
-
- /**
- * Checks if current transaction is set to rollback only.
- *
- * @param tm the transaction manager
- * @return boolean
- */
- protected def isRollbackOnly(tm: TransactionContainer): Boolean =
- tm.getStatus == Status.STATUS_MARKED_ROLLBACK
-
- /**
- * A ThreadLocal variable where to store suspended TX and enable pay as you go
- * before advice - after advice data sharing in a specific case of requiresNew TX
- */
- private val suspendedTx = new ThreadLocal[Transaction] {
- override def initialValue = null
- }
-
- private def storeInThreadLocal(tx: Transaction) = suspendedTx.set(tx)
-
- private def fetchFromThreadLocal: Option[Transaction] = {
- if ((suspendedTx ne null) && (suspendedTx.get() ne null)) Some(suspendedTx.get.asInstanceOf[Transaction])
- else None
- }
-}
diff --git a/akka-jta/src/test/scala/ReflectiveAccessSpec.scala b/akka-jta/src/test/scala/ReflectiveAccessSpec.scala
deleted file mode 100644
index 76bd83e15c..0000000000
--- a/akka-jta/src/test/scala/ReflectiveAccessSpec.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.jta
-
-import org.scalatest.junit.JUnitSuite
-import org.junit.Test
-import akka.stm.ReflectiveJtaModule
-
-class ReflectiveAccessSpec extends JUnitSuite {
- @Test def ensureReflectiveAccessCanLoadTransactionContainer {
- ReflectiveJtaModule.ensureJtaEnabled
- assert(ReflectiveJtaModule.transactionContainerObjectInstance.isDefined)
- }
-}
diff --git a/akka-karaf/akka-features/src/main/resources/features.xml b/akka-karaf/akka-features/src/main/resources/features.xml
deleted file mode 100644
index ad96d7bf05..0000000000
--- a/akka-karaf/akka-features/src/main/resources/features.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- mvn:com.weiglewilczek.scala-lang-osgi/scala-library/2.8.0.RC2
- mvn:org.eclipse.scalamodules/scalamodules-core/2.0-M2
-
-
-
-
- mvn:akka.akka-wrap/dispatch-json_2.8.0.RC3_osgi/0.7.4
- mvn:org.objenesis/objenesis/1.2
- mvn:sjson.json/sjson/0.6-SNAPSHOT
-
-
-
- sjson
- mvn:akka.akka-wrap/jgroups-wrapper_2.8.0.RC3_osgi/2.9.0.GA
- mvn:org.jboss.netty/netty/3.2.0.CR1
- mvn:akka/akka-remote_2.8.0.RC3_osgi/0.9
-
-
diff --git a/akka-kernel/src/main/scala/akka/Kernel.scala b/akka-kernel/src/main/scala/akka/Kernel.scala
deleted file mode 100644
index 342078913b..0000000000
--- a/akka-kernel/src/main/scala/akka/Kernel.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.kernel
-
-import akka.http.{ EmbeddedAppServer, DefaultAkkaLoader }
-import akka.remote.BootableRemoteActorService
-
-object Main {
- def main(args: Array[String]) = Kernel.boot
-}
-
-/**
- * The Akka Kernel, is used to start And postStop Akka in standalone/kernel mode.
- *
- * @author Jonas Bonér
- */
-object Kernel extends DefaultAkkaLoader {
- //For testing purposes only
- def startRemoteService(): Unit = bundles.foreach( _ match {
- case x: BootableRemoteActorService => x.startRemoteService
- case _ =>
- })
-}
diff --git a/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraSession.scala b/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraSession.scala
deleted file mode 100644
index b8474812ab..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraSession.scala
+++ /dev/null
@@ -1,199 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.persistence.cassandra
-
-import java.io.{Flushable, Closeable}
-
-import akka.persistence.common._
-import akka.util.Logging
-import akka.util.Helpers._
-import akka.serialization.Serializer
-import akka.config.Config.config
-
-import scala.collection.mutable.Map
-
-import org.apache.cassandra.db.ColumnFamily
-import org.apache.cassandra.thrift._
-
-import org.apache.thrift.transport._
-import org.apache.thrift.protocol._
-
-/**
- * @author Jonas Bonér
- */
-trait CassandraSession extends Closeable with Flushable {
- import scala.collection.JavaConversions._
- import java.util.{Map => JMap, List => JList}
-
- val client: Cassandra.Client
- val keyspace: String
-
- val obtainedAt: Long
- val consistencyLevel: ConsistencyLevel
- val schema: JMap[String, JMap[String, String]]
-
- /**
- * Count is always the max number of results to return.
-
- So it means, starting with `start`, or the first one if start is
- empty, go until you hit `finish` or `count`, whichever comes first.
- Empty is not a legal column name so if finish is empty it is ignored
- and only count is used.
-
- We don't offer a numeric offset since that can't be supported
- efficiently with a log-structured merge disk format.
- */
-
- // ====================================
- // ====== Scala-style API names
- // ====================================
-
- def /(key: String, columnParent: ColumnParent, start: Array[Byte], end: Array[Byte], ascending: Boolean, count: Int): List[ColumnOrSuperColumn] =
- /(key, columnParent, start, end, ascending, count, consistencyLevel)
-
- def /(key: String, columnParent: ColumnParent, start: Array[Byte], end: Array[Byte], ascending: Boolean, count: Int, consistencyLevel: ConsistencyLevel): List[ColumnOrSuperColumn] = {
- val slicePredicate = new SlicePredicate
- slicePredicate.setSlice_range(new SliceRange(start, end, ascending, count))
- client.get_slice(keyspace, key, columnParent, slicePredicate, consistencyLevel).toList
- }
-
- def /(key: String, columnParent: ColumnParent, slicePredicate: SlicePredicate): List[ColumnOrSuperColumn] =
- client.get_slice(keyspace, key, columnParent, slicePredicate, consistencyLevel).toList
-
- def /(key: String, columnParent: ColumnParent, slicePredicate: SlicePredicate, consistencyLevel: ConsistencyLevel): List[ColumnOrSuperColumn] =
- client.get_slice(keyspace, key, columnParent, slicePredicate, consistencyLevel).toList
-
- def |(key: String, colPath: ColumnPath): Option[ColumnOrSuperColumn] =
- |(key, colPath, consistencyLevel)
-
- def |(key: String, colPath: ColumnPath, consistencyLevel: ConsistencyLevel): Option[ColumnOrSuperColumn] =
- client.get(keyspace, key, colPath, consistencyLevel)
-
- def |#(key: String, columnParent: ColumnParent): Int =
- |#(key, columnParent, consistencyLevel)
-
- def |#(key: String, columnParent: ColumnParent, consistencyLevel: ConsistencyLevel): Int =
- client.get_count(keyspace, key, columnParent, consistencyLevel)
-
- def ++|(key: String, colPath: ColumnPath, value: Array[Byte]): Unit =
- ++|(key, colPath, value, obtainedAt, consistencyLevel)
-
- def ++|(key: String, colPath: ColumnPath, value: Array[Byte], consistencyLevel: ConsistencyLevel): Unit =
- ++|(key, colPath, value, obtainedAt, consistencyLevel)
-
- def ++|(key: String, colPath: ColumnPath, value: Array[Byte], timestamp: Long): Unit =
- ++|(key, colPath, value, timestamp, consistencyLevel)
-
- def ++|(key: String, colPath: ColumnPath, value: Array[Byte], timestamp: Long, consistencyLevel: ConsistencyLevel) =
- client.insert(keyspace, key, colPath, value, timestamp, consistencyLevel)
-
- def ++|(key: String, batch: Map[String, List[ColumnOrSuperColumn]]): Unit =
- ++|(key, batch, consistencyLevel)
-
- def ++|(key: String, batch: Map[String, List[ColumnOrSuperColumn]], consistencyLevel: ConsistencyLevel): Unit = {
- val jmap = new java.util.HashMap[String, JList[ColumnOrSuperColumn]]
- for (entry <- batch; (key, value) = entry) jmap.put(key, new java.util.ArrayList(value))
- client.batch_insert(keyspace, key, jmap, consistencyLevel)
- }
-
- def --(key: String, columnPath: ColumnPath, timestamp: Long): Unit =
- --(key, columnPath, timestamp, consistencyLevel)
-
- def --(key: String, columnPath: ColumnPath, timestamp: Long, consistencyLevel: ConsistencyLevel): Unit =
- client.remove(keyspace, key, columnPath, timestamp, consistencyLevel)
-
- // ====================================
- // ====== Java-style API names
- // ====================================
-
- def getSlice(key: String, columnParent: ColumnParent, start: Array[Byte], end: Array[Byte], ascending: Boolean, count: Int) = / (key, columnParent, start, end, ascending, count, consistencyLevel)
-
- def getSlice(key: String, columnParent: ColumnParent, start: Array[Byte], end: Array[Byte], ascending: Boolean, count: Int, consistencyLevel: ConsistencyLevel) = / (key, columnParent, start, end, ascending, count, consistencyLevel)
-
- def getSlice(key: String, columnParent: ColumnParent, slicePredicate: SlicePredicate) = / (key, columnParent, slicePredicate)
-
- def getSlice(key: String, columnParent: ColumnParent, slicePredicate: SlicePredicate, consistencyLevel: ConsistencyLevel) = / (key, columnParent, slicePredicate, consistencyLevel)
-
-
- def get(key: String, colPath: ColumnPath) = |(key, colPath)
-
- def get(key: String, colPath: ColumnPath, consistencyLevel: ConsistencyLevel) = |(key, colPath, consistencyLevel)
-
- def getCount(key: String, columnParent: ColumnParent)= |#(key, columnParent)
-
- def getCount(key: String, columnParent: ColumnParent, consistencyLevel: ConsistencyLevel) = |#(key, columnParent, consistencyLevel)
-
-
- def insert(key: String, colPath: ColumnPath, value: Array[Byte]): Unit = ++|(key, colPath, value)
-
- def insert(key: String, colPath: ColumnPath, value: Array[Byte], consistencyLevel: ConsistencyLevel): Unit = ++|(key, colPath, value, consistencyLevel)
-
- def insert(key: String, colPath: ColumnPath, value: Array[Byte], timestamp: Long): Unit = ++|(key, colPath, value, timestamp)
-
- def insert(key: String, colPath: ColumnPath, value: Array[Byte], timestamp: Long, consistencyLevel: ConsistencyLevel) = ++|(key, colPath, value, timestamp, consistencyLevel)
-
- def insert(key: String, batch: Map[String, List[ColumnOrSuperColumn]]): Unit = ++|(key, batch)
-
- def insert(key: String, batch: Map[String, List[ColumnOrSuperColumn]], consistencyLevel: ConsistencyLevel): Unit = ++|(key, batch, consistencyLevel)
-
- def remove(key: String, columnPath: ColumnPath, timestamp: Long): Unit = --(key, columnPath, timestamp)
-
- def remove(key: String, columnPath: ColumnPath, timestamp: Long, consistencyLevel: ConsistencyLevel): Unit = --(key, columnPath, timestamp, consistencyLevel)
-
-}
-
-class CassandraSessionPool[T <: TTransport](
- space: String,
- transportPool: Pool[T],
- inputProtocol: Protocol,
- outputProtocol: Protocol,
- consistency: ConsistencyLevel) extends Closeable with Logging {
-
- def this(space: String, transportPool: Pool[T], ioProtocol: Protocol, consistency: ConsistencyLevel) =
- this (space, transportPool, ioProtocol, ioProtocol, consistency)
-
- def newSession: CassandraSession = newSession(consistency)
-
- def newSession(consistencyLevel: ConsistencyLevel): CassandraSession = {
- val socket = transportPool.borrowObject
- val cassandraClient = new Cassandra.Client(inputProtocol(socket), outputProtocol(socket))
- val cassandraSchema = cassandraClient.describe_keyspace(space)
- new CassandraSession {
- val keyspace = space
- val client = cassandraClient
- val obtainedAt = System.currentTimeMillis
- val consistencyLevel = consistency
- val schema = cassandraSchema
- log.debug("Creating %s", toString)
-
- def flush = socket.flush
- def close = transportPool.returnObject(socket)
- override def toString = "[CassandraSession]\n\tkeyspace = " + keyspace + "\n\tschema = " + schema
- }
- }
-
- def withSession[T](body: CassandraSession => T) = {
- val session = newSession(consistency)
- try {
- val result = body(session)
- session.flush
- result
- } finally {
- session.close
- }
- }
-
- def close = transportPool.close
-}
-
-sealed abstract class Protocol(val factory: TProtocolFactory) {
- def apply(transport: TTransport) = factory.getProtocol(transport)
-}
-
-object Protocol {
- object Binary extends Protocol(new TBinaryProtocol.Factory)
- object SimpleJSON extends Protocol(new TSimpleJSONProtocol.Factory)
- object JSON extends Protocol(new TJSONProtocol.Factory)
-}
diff --git a/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraStorage.scala b/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraStorage.scala
deleted file mode 100644
index 166ccbe676..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraStorage.scala
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.persistence.cassandra
-
-import akka.stm._
-import akka.persistence.common._
-import akka.actor.{newUuid}
-
-object CassandraStorage extends Storage {
- type ElementType = Array[Byte]
-
- def newMap: PersistentMap[ElementType, ElementType] = newMap(newUuid.toString)
- def newVector: PersistentVector[ElementType] = newVector(newUuid.toString)
- def newRef: PersistentRef[ElementType] = newRef(newUuid.toString)
- override def newQueue: PersistentQueue[ElementType] = newQueue(newUuid.toString)
-
- def getMap(id: String): PersistentMap[ElementType, ElementType] = newMap(id)
- def getVector(id: String): PersistentVector[ElementType] = newVector(id)
- def getRef(id: String): PersistentRef[ElementType] = newRef(id)
- override def getQueue(id: String): PersistentQueue[ElementType] = newQueue(id)
-
- def newMap(id: String): PersistentMap[ElementType, ElementType] = new CassandraPersistentMap(id)
- def newVector(id: String): PersistentVector[ElementType] = new CassandraPersistentVector(id)
- def newRef(id: String): PersistentRef[ElementType] = new CassandraPersistentRef(id)
- override def newQueue(id: String): PersistentQueue[ElementType] = new CassandraPersistentQueue(id)
-}
-
-/**
- * Implements a persistent transactional map based on the Cassandra distributed P2P key-value storage.
- *
- * @author Jonas Bonér
- */
-class CassandraPersistentMap(id: String) extends PersistentMapBinary {
- val uuid = id
- val storage = CassandraStorageBackend
-}
-
-/**
- * Implements a persistent transactional vector based on the Cassandra
- * distributed P2P key-value storage.
- *
- * @author Jonas Bonér
- */
-class CassandraPersistentVector(id: String) extends PersistentVector[Array[Byte]] {
- val uuid = id
- val storage = CassandraStorageBackend
-}
-
-class CassandraPersistentRef(id: String) extends PersistentRef[Array[Byte]] {
- val uuid = id
- val storage = CassandraStorageBackend
-}
-
-class CassandraPersistentQueue(id: String) extends PersistentQueue[Array[Byte]] {
- val uuid = id
- val storage = CassandraStorageBackend
-}
diff --git a/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraStorageBackend.scala b/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraStorageBackend.scala
deleted file mode 100644
index a835866713..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/main/scala/akka/CassandraStorageBackend.scala
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.persistence.cassandra
-
-import akka.stm._
-import akka.persistence.common._
-import akka.util.Logging
-import akka.util.Helpers._
-import akka.config.Config.config
-
-import org.apache.cassandra.thrift._
-import java.lang.String
-import collection.JavaConversions
-import collection.immutable.{TreeMap, Iterable}
-import java.util.{Map => JMap, HashMap => JHMap, List => JList, ArrayList => JAList}
-
-/**
- * @author Jonas Bonér
- */
-
-private[akka] object CassandraStorageBackend extends CommonStorageBackend {
-
- import CommonStorageBackend._
-
- type ElementType = Array[Byte]
-
- val KEYSPACE = "akka"
- val MAP_COLUMN_PARENT = new ColumnParent("map")
- val VECTOR_COLUMN_PARENT = new ColumnParent("vector")
- val REF_COLUMN_PARENT = new ColumnParent("ref")
- val QUEUE_COLUMN_PARENT = new ColumnParent("queue")
- val REF_KEY = "item".getBytes("UTF-8")
- val EMPTY_BYTE_ARRAY = new Array[Byte](0)
-
- val CASSANDRA_SERVER_HOSTNAME = config.getString("akka.persistence.cassandra.hostname", "127.0.0.1")
- val CASSANDRA_SERVER_PORT = config.getInt("akka.persistence.cassandra.port", 9160)
- val CONSISTENCY_LEVEL = {
- config.getString("akka.persistence.cassandra.consistency-level", "QUORUM") match {
- case "ZERO" => ConsistencyLevel.ZERO
- case "ONE" => ConsistencyLevel.ONE
- case "QUORUM" => ConsistencyLevel.QUORUM
- case "DCQUORUM" => ConsistencyLevel.DCQUORUM
- case "DCQUORUMSYNC" => ConsistencyLevel.DCQUORUMSYNC
- case "ALL" => ConsistencyLevel.ALL
- case "ANY" => ConsistencyLevel.ANY
- case unknown => throw new IllegalArgumentException(
- "Cassandra consistency level [" + unknown + "] is not supported." +
- "\n\tExpected one of [ZERO, ONE, QUORUM, DCQUORUM, DCQUORUMSYNC, ALL, ANY] in the akka.conf configuration file.")
- }
- }
- val IS_ASCENDING = true
-
- @volatile private[this] var isRunning = false
- private[this] val protocol: Protocol = Protocol.Binary
-
- private[this] val sessions = new CassandraSessionPool(
- KEYSPACE,
- StackPool(SocketProvider(CASSANDRA_SERVER_HOSTNAME, CASSANDRA_SERVER_PORT)),
- protocol,
- CONSISTENCY_LEVEL)
-
-
- class CassandraAccess(parent: ColumnParent) extends CommonStorageBackendAccess {
-
- def path(key: Array[Byte]): ColumnPath = {
- new ColumnPath(parent.getColumn_family).setColumn(key)
- }
-
- def delete(owner: String, key: Array[Byte]) = {
- sessions.withSession{
- session => {
- session -- (owner, path(key), System.currentTimeMillis, CONSISTENCY_LEVEL)
- }
- }
- }
-
- override def getAll(owner: String, keys: Iterable[Array[Byte]]): Map[Array[Byte], Array[Byte]] = {
- sessions.withSession{
- session => {
- var predicate = new SlicePredicate().setColumn_names(JavaConversions.asJavaList(keys.toList))
- val cols = session / (owner, parent, predicate, CONSISTENCY_LEVEL)
- var map = new TreeMap[Array[Byte], Array[Byte]]()(ordering)
- cols.foreach{
- cosc => map += cosc.getColumn.getName -> cosc.getColumn.getValue
- }
- map
- }
- }
- }
-
-
- def get(owner: String, key: Array[Byte], default: Array[Byte]) = {
- sessions.withSession{
- session => {
- try
- {
- session | (owner, path(key), CONSISTENCY_LEVEL) match {
- case Some(cosc) => cosc.getColumn.getValue
- case None => default
- }
- } catch {
- case e: NotFoundException => default
- }
- }
- }
- }
-
- def put(owner: String, key: Array[Byte], value: Array[Byte]) = {
- sessions.withSession{
- session => {
- session ++| (owner, path(key), value, System.currentTimeMillis, CONSISTENCY_LEVEL)
- }
- }
- }
-
-
- def drop() = {
- sessions.withSession{
- session => {
- val slices = session.client.get_range_slices(session.keyspace, parent,
- new SlicePredicate().setSlice_range(new SliceRange().setStart(Array.empty[Byte]).setFinish(Array.empty[Byte])),
- new KeyRange().setStart_key("").setEnd_key(""), CONSISTENCY_LEVEL)
-
- val mutations = new JHMap[String, JMap[String, JList[Mutation]]]
- JavaConversions.asScalaIterable(slices).foreach{
- keySlice: KeySlice => {
- val key = keySlice.getKey
- val keyMutations = JavaConversions.asScalaMap(mutations).getOrElse(key, {
- val km = new JHMap[String, JList[Mutation]]
- mutations.put(key, km)
- km
- })
- val amutation = new JAList[Mutation]
- val cols = new JAList[Array[Byte]]
- keyMutations.put(parent.getColumn_family, amutation)
- JavaConversions.asScalaIterable(keySlice.getColumns) foreach {
- cosc: ColumnOrSuperColumn => {
- cols.add(cosc.getColumn.getName)
- }
- }
- amutation.add(new Mutation().setDeletion(new Deletion(System.currentTimeMillis).setPredicate(new SlicePredicate().setColumn_names(cols))))
-
- }
- }
- session.client.batch_mutate(session.keyspace, mutations, CONSISTENCY_LEVEL)
- }
- }
- }
-
- }
-
- def queueAccess = new CassandraAccess(QUEUE_COLUMN_PARENT)
-
- def mapAccess = new CassandraAccess(MAP_COLUMN_PARENT)
-
- def vectorAccess = new CassandraAccess(VECTOR_COLUMN_PARENT)
-
- def refAccess = new CassandraAccess(REF_COLUMN_PARENT)
-}
diff --git a/akka-persistence/akka-persistence-cassandra/src/test/resources/log4j.properties b/akka-persistence/akka-persistence-cassandra/src/test/resources/log4j.properties
deleted file mode 100644
index 3c8738fdc3..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-log4j.rootLogger=DEBUG,R
-
-# rolling log file ("system.log
-log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.R.DatePattern='.'yyyy-MM-dd-HH
-log4j.appender.R.layout=org.apache.log4j.PatternLayout
-log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
-log4j.appender.R.File=target/logs/system.log
diff --git a/akka-persistence/akka-persistence-cassandra/src/test/resources/storage-conf.xml b/akka-persistence/akka-persistence-cassandra/src/test/resources/storage-conf.xml
deleted file mode 100644
index b01e547665..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/test/resources/storage-conf.xml
+++ /dev/null
@@ -1,337 +0,0 @@
-
-
-
-
-
-
-
- akka
-
-
- false
-
-
-
-
-
- 0.01
-
-
-
-
-
-
-
-
-
-
-
- org.apache.cassandra.dht.RandomPartitioner
-
-
-
-
-
- org.apache.cassandra.locator.EndPointSnitch
-
-
- org.apache.cassandra.locator.RackUnawareStrategy
-
-
- 1
-
-
- target/cassandra/commitlog
-
- target/cassandra/data
-
- target/cassandra/callouts
- target/cassandra/staging
-
-
-
-
- 127.0.0.1
-
-
-
-
-
-
- 5000
-
- 128
-
-
-
-
-
- localhost
-
- 7000
-
- 7001
-
-
- localhost
-
- 9160
-
- false
-
-
-
-
-
-
-
- 64
-
-
- 32
- 8
-
-
- 64
-
-
- 64
-
- 0.1
-
- 60
-
-
- 8
- 32
-
-
- periodic
-
- 10000
-
-
-
-
- 864000
-
-
- 256
-
-
diff --git a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraPersistentActorSpec.scala b/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraPersistentActorSpec.scala
deleted file mode 100644
index f0284c84d2..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraPersistentActorSpec.scala
+++ /dev/null
@@ -1,167 +0,0 @@
-package akka.persistence.cassandra
-
-import akka.actor.{Actor, ActorRef}
-import Actor._
-import akka.stm._
-
-import org.junit.Test
-import org.junit.Assert._
-import org.junit.Before
-import org.scalatest.junit.JUnitSuite
-
-case class GetMapState(key: String)
-case object GetVectorState
-case object GetVectorSize
-case object GetRefState
-
-case class SetMapState(key: String, value: String)
-case class SetVectorState(key: String)
-case class SetRefState(key: String)
-case class Success(key: String, value: String)
-case class Failure(key: String, value: String)
-
-case class SetMapStateOneWay(key: String, value: String)
-case class SetVectorStateOneWay(key: String)
-case class SetRefStateOneWay(key: String)
-case class SuccessOneWay(key: String, value: String)
-case class FailureOneWay(key: String, value: String)
-
-class CassandraPersistentActor extends Actor {
- self.timeout = 100000
-
- private val mapState = CassandraStorage.newMap
- private val vectorState = CassandraStorage.newVector
- private val refState = CassandraStorage.newRef
-
- def receive = { case message => atomic { atomicReceive(message) } }
-
- def atomicReceive: Receive = {
- case GetMapState(key) =>
- self.reply(mapState.get(key.getBytes("UTF-8")).get)
- case GetVectorSize =>
- self.reply(vectorState.length.asInstanceOf[AnyRef])
- case GetRefState =>
- self.reply(refState.get.get)
- case SetMapState(key, msg) =>
- mapState.put(key.getBytes("UTF-8"), msg.getBytes("UTF-8"))
- self.reply(msg)
- case SetVectorState(msg) =>
- vectorState.add(msg.getBytes("UTF-8"))
- self.reply(msg)
- case SetRefState(msg) =>
- refState.swap(msg.getBytes("UTF-8"))
- self.reply(msg)
- case Success(key, msg) =>
- mapState.put(key.getBytes("UTF-8"), msg.getBytes("UTF-8"))
- vectorState.add(msg.getBytes("UTF-8"))
- refState.swap(msg.getBytes("UTF-8"))
- self.reply(msg)
- case Failure(key, msg) =>
- mapState.put(key.getBytes("UTF-8"), msg.getBytes("UTF-8"))
- vectorState.add(msg.getBytes("UTF-8"))
- refState.swap(msg.getBytes("UTF-8"))
- fail
- self.reply(msg)
- }
-
- def fail = throw new RuntimeException("Expected exception; to test fault-tolerance")
-}
-
-class CassandraPersistentActorSpec extends JUnitSuite {
-
- // @Before
- // def startCassandra = EmbeddedCassandraService.start
-
- @Test
- def testMapShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
- val stateful = actorOf[CassandraPersistentActor]
- stateful.start
- stateful !! SetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "init") // set init state
- stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
- val result = (stateful !! GetMapState("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess")).as[Array[Byte]].get
- assertEquals("new state", new String(result, 0, result.length, "UTF-8"))
- }
-
- @Test
- def testMapShouldRollbackStateForStatefulServerInCaseOfFailure = {
- val stateful = actorOf[CassandraPersistentActor]
- stateful.start
- stateful !! SetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init") // set init state
- try {
- stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state") // call failing transactionrequired method
- fail("should have thrown an exception")
- } catch {case e: RuntimeException => {}}
- val result = (stateful !! GetMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure")).as[Array[Byte]].get
- assertEquals("init", new String(result, 0, result.length, "UTF-8")) // check that state is == init state
- }
-
- @Test
- def testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
- val stateful = actorOf[CassandraPersistentActor]
- stateful.start
- stateful !! SetVectorState("init") // set init state
- stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
- assertEquals(2, (stateful !! GetVectorSize).get.asInstanceOf[java.lang.Integer].intValue)
- }
-
- @Test
- def testVectorShouldRollbackStateForStatefulServerInCaseOfFailure = {
- val stateful = actorOf[CassandraPersistentActor]
- stateful.start
- stateful !! SetVectorState("init") // set init state
- try {
- stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state") // call failing transactionrequired method
- fail("should have thrown an exception")
- } catch {case e: RuntimeException => {}}
- assertEquals(1, (stateful !! GetVectorSize).get.asInstanceOf[java.lang.Integer].intValue)
- }
-
- @Test
- def testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess = {
- val stateful = actorOf[CassandraPersistentActor]
- stateful.start
- stateful !! SetRefState("init") // set init state
- stateful !! Success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state") // transactionrequired
- val result = (stateful !! GetRefState).as[Array[Byte]].get
- assertEquals("new state", new String(result, 0, result.length, "UTF-8"))
- }
-
- @Test
- def testRefShouldRollbackStateForStatefulServerInCaseOfFailure = {
- val stateful = actorOf[CassandraPersistentActor]
- stateful.start
- stateful !! SetRefState("init") // set init state
- try {
- stateful !! Failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state") // call failing transactionrequired method
- fail("should have thrown an exception")
- } catch {case e: RuntimeException => {}}
- val result = (stateful !! GetRefState).as[Array[Byte]].get
- assertEquals("init", new String(result, 0, result.length, "UTF-8")) // check that state is == init state
- }
-
-}
-
-/*
-object EmbeddedCassandraService {
- import org.apache.cassandra.thrift.CassandraDaemon
-
- System.setProperty("storage-config", "src/test/resources");
-
- val cassandra = new Runnable {
-
- val cassandraDaemon = new CassandraDaemon
- cassandraDaemon.init(null)
-
- def run = cassandraDaemon.start
-
- }
-
- // spawn cassandra in a new thread
- val t = new Thread(cassandra)
- t.setDaemon(true)
- t.start
-
- def start(): Unit = {}
-
-}
-*/
diff --git a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraStorageBackendCompatibilityTest.scala b/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraStorageBackendCompatibilityTest.scala
deleted file mode 100644
index 500dfc8977..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraStorageBackendCompatibilityTest.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-package akka.persistence.cassandra
-
-
-import org.junit.runner.RunWith
-import org.scalatest.junit.JUnitRunner
-import akka.persistence.common.{QueueStorageBackendTest, VectorStorageBackendTest, MapStorageBackendTest, RefStorageBackendTest}
-
-@RunWith(classOf[JUnitRunner])
-class CassandraRefStorageBackendTestIntegration extends RefStorageBackendTest {
- def dropRefs = {
- CassandraStorageBackend.refAccess.drop
- }
-
-
- def storage = CassandraStorageBackend
-}
-
-@RunWith(classOf[JUnitRunner])
-class CassandraMapStorageBackendTestIntegration extends MapStorageBackendTest {
- def dropMaps = {
- CassandraStorageBackend.mapAccess.drop
- }
-
-
- def storage = CassandraStorageBackend
-}
-
-@RunWith(classOf[JUnitRunner])
-class CassandraVectorStorageBackendTestIntegration extends VectorStorageBackendTest {
- def dropVectors = {
- CassandraStorageBackend.vectorAccess.drop
- }
-
-
- def storage = CassandraStorageBackend
-}
-
-@RunWith(classOf[JUnitRunner])
-class CassandraQueueStorageBackendTestIntegration extends QueueStorageBackendTest {
- def dropQueues = {
- CassandraStorageBackend.queueAccess.drop
- }
-
-
- def storage = CassandraStorageBackend
-}
-
-
-
-
-
diff --git a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraTicket343TestIntegration.scala b/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraTicket343TestIntegration.scala
deleted file mode 100644
index 7a062f9c31..0000000000
--- a/akka-persistence/akka-persistence-cassandra/src/test/scala/CassandraTicket343TestIntegration.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.persistence.cassandra
-
-
-import org.junit.runner.RunWith
-import org.scalatest.junit.JUnitRunner
-import akka.persistence.common._
-
-@RunWith(classOf[JUnitRunner])
-class CassandraTicket343TestIntegration extends Ticket343Test {
- def dropMapsAndVectors: Unit = {
- CassandraStorageBackend.vectorAccess.drop
- CassandraStorageBackend.mapAccess.drop
- }
-
- def getVector: (String) => PersistentVector[Array[Byte]] = CassandraStorage.getVector
-
- def getMap: (String) => PersistentMap[Array[Byte], Array[Byte]] = CassandraStorage.getMap
-
-}
diff --git a/akka-persistence/akka-persistence-common/src/main/scala/akka/CommonStorageBackend.scala b/akka-persistence/akka-persistence-common/src/main/scala/akka/CommonStorageBackend.scala
deleted file mode 100644
index 18020ff180..0000000000
--- a/akka-persistence/akka-persistence-common/src/main/scala/akka/CommonStorageBackend.scala
+++ /dev/null
@@ -1,741 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.persistence.common
-
-import akka.util.Logging
-import java.lang.String
-import java.nio.ByteBuffer
-import collection.Map
-import java.util.{Map => JMap}
-import akka.persistence.common.PersistentMapBinary.COrdering._
-import collection.immutable._
-import collection.mutable.ArrayBuffer
-
-
-private[akka] trait CommonStorageBackendAccess {
-
- import CommonStorageBackend._
-
- /*abstract*/
-
- def get(owner: String, key: Array[Byte], default: Array[Byte]): Array[Byte]
-
- def getAll(owner: String, keys: Iterable[Array[Byte]]): Map[Array[Byte], Array[Byte]] = {
- keys.foldLeft(new HashMap[Array[Byte], Array[Byte]]) {
- (map, key) => {
- Option(get(owner, key)) match {
- case Some(value) => map + (key -> value)
- case None => map
- }
- }
- }
- }
-
- def put(owner: String, key: Array[Byte], value: Array[Byte]): Unit
-
- def putAll(owner: String, keyValues: Iterable[(Array[Byte], Array[Byte])]): Unit = {
- keyValues.foreach{
- kv => kv match {
- case (key, value) => put(owner, key, value)
- }
- }
- }
-
- def delete(owner: String, key: Array[Byte]): Unit
-
- def deleteAll(owner: String, keys: Iterable[Array[Byte]]): Unit = {
- keys.foreach(delete(owner, _))
- }
-
- def drop(): Unit
-
- /*concrete*/
-
- def decodeMapKey(owner: String, key: Array[Byte]): Array[Byte] = key
-
- def encodeMapKey(owner: String, key: Array[Byte]): Array[Byte] = key
-
- def decodeIndexedKey(owner: String, key: Array[Byte]): Int = IntSerializer.fromBytes(key)
-
- def encodeIndexedKey(owner: String, keyint: Int): Array[Byte] = IntSerializer.toBytes(keyint)
-
- def deleteIndexed(owner: String, index: Int): Unit = delete(owner, encodeIndexedKey(owner, index))
-
- def getIndexed(owner: String, index: Int): Array[Byte] = get(owner, encodeIndexedKey(owner, index))
-
- def get(owner: String, key: Array[Byte]): Array[Byte] = get(owner, key, null)
-
- def putIndexed(owner: String, index: Int, value: Array[Byte]): Unit = put(owner, encodeIndexedKey(owner, index), value)
-
- def putAllIndexed(owner: String, values: Iterable[(Int, Array[Byte])]): Unit = {
- putAll(owner, values.map{
- iv => {
- iv match {
- case (i, value) => (encodeIndexedKey(owner, i) -> value)
- }
- }
- })
- }
-
- def getAllIndexed(owner: String, keys: Iterable[Int]): Map[Int, Array[Byte]] = {
- val byteKeys = keys.map(encodeIndexedKey(owner, _))
- getAll(owner, byteKeys).map{
- kv => kv match {
- case (key, value) => (decodeIndexedKey(owner, key) -> value)
- }
- }
- }
-
- def deleteAllIndexed(owner: String, keys: Iterable[Int]): Unit = {
- val byteKeys = keys.map(encodeIndexedKey(owner, _))
- deleteAll(owner, byteKeys)
- }
-}
-
-private[akka] trait KVStorageBackendAccess extends CommonStorageBackendAccess with Logging {
-
- import CommonStorageBackend._
- import KVStorageBackend._
-
- def put(key: Array[Byte], value: Array[Byte]): Unit
-
- def get(key: Array[Byte]): Array[Byte]
-
- def get(key: Array[Byte], default: Array[Byte]): Array[Byte]
-
- def getAll(keys: Iterable[Array[Byte]]): Map[Array[Byte], Array[Byte]]
-
- def delete(key: Array[Byte]): Unit
-
- override def decodeMapKey(owner: String, key: Array[Byte]): Array[Byte] = {
- val mapKeyLength = key.length - IntSerializer.bytesPerInt - owner.getBytes("UTF-8").length
- val mapkey = new Array[Byte](mapKeyLength)
- System.arraycopy(key, key.length - mapKeyLength, mapkey, 0, mapKeyLength)
- mapkey
- }
-
-
- override def decodeIndexedKey(owner: String, key: Array[Byte]): Int = {
- IntSerializer.fromBytes(decodeMapKey(owner,key))
- }
-
- override def put(owner: String, key: Array[Byte], value: Array[Byte]): Unit = {
- put(getKey(owner, key), value)
- }
-
- override def putIndexed(owner: String, index: Int, value: Array[Byte]): Unit = {
- put(getIndexedKey(owner, index), value)
- }
-
-
- override def get(owner: String, key: Array[Byte]): Array[Byte] = {
- get(getKey(owner, key))
- }
-
- override def getIndexed(owner: String, index: Int): Array[Byte] = {
- get(getIndexedKey(owner, index))
- }
-
-
- override def get(owner: String, key: Array[Byte], default: Array[Byte]): Array[Byte] = {
- get(getKey(owner, key), default)
- }
-
-
- override def getAll(owner: String, keys: Iterable[Array[Byte]]): Map[Array[Byte], Array[Byte]] = {
- getAll(keys.map{
- getKey(owner, _)
- })
- }
-
- override def deleteIndexed(owner: String, index: Int): Unit = {
- delete(getIndexedKey(owner, index))
- }
-
- override def delete(owner: String, key: Array[Byte]): Unit = {
- delete(getKey(owner, key))
- }
-}
-
-private[akka] object CommonStorageBackendAccess {
- implicit def stringToByteArray(st: String): Array[Byte] = {
- st.getBytes("UTF-8")
- }
-}
-
-private[akka] object CommonStorageBackend {
- val nullMapValueHeader = 0x00.byteValue
- val nullMapValue: Array[Byte] = Array(nullMapValueHeader)
- val notNullMapValueHeader: Byte = 0xff.byteValue
- val mapKeySetKeyHeader = 0x00.byteValue
- val mapKeyHeader = 0xff.byteValue
- val mapKeysIndex: Array[Byte] = new Array[Byte](1).padTo(1, mapKeySetKeyHeader)
- val mapKeysWrapperPad: Array[Byte] = new Array[Byte](1).padTo(1, mapKeyHeader)
-
- /**
- * Wrap map key prepends mapKeysWrapperPad (1-byte) to map keys so that we can
- * use a seperate 1 byte key to store the map keyset.
- *
- * This basically creates the map key used in underlying storage
- */
-
- def wrapMapKey(key: Array[Byte]): Array[Byte] = {
- val wrapped = new Array[Byte](key.length + mapKeysWrapperPad.length)
- System.arraycopy(mapKeysWrapperPad, 0, wrapped, 0, mapKeysWrapperPad.length)
- System.arraycopy(key, 0, wrapped, mapKeysWrapperPad.length, key.length)
- wrapped
- }
-
- /**
- * unwrapMapKey removes the mapKeysWrapperPad, this translates the map key used
- * in underlying storage back to a key that is understandable by the frontend
- */
-
- def unwrapMapKey(key: Array[Byte]): Array[Byte] = {
- val unwrapped = new Array[Byte](key.length - mapKeysWrapperPad.length)
- System.arraycopy(key, mapKeysWrapperPad.length, unwrapped, 0, unwrapped.length)
- unwrapped
- }
-
- def getStoredMapValue(value: Array[Byte]): Array[Byte] = {
- value match {
- case null => nullMapValue
- case value => {
- val stored = new Array[Byte](value.length + 1)
- stored(0) = notNullMapValueHeader
- System.arraycopy(value, 0, stored, 1, value.length)
- stored
- }
- }
- }
-
- def getMapValueFromStored(value: Array[Byte]): Array[Byte] = {
-
- if (value(0) == nullMapValueHeader) {
- null
- } else if (value(0) == notNullMapValueHeader) {
- val returned = new Array[Byte](value.length - 1)
- System.arraycopy(value, 1, returned, 0, value.length - 1)
- returned
- } else {
- throw new StorageException("unknown header byte on map value:" + value(0))
- }
- }
-
- object IntSerializer {
- val bytesPerInt = java.lang.Integer.SIZE / java.lang.Byte.SIZE
-
- def toBytes(i: Int) = ByteBuffer.wrap(new Array[Byte](bytesPerInt)).putInt(i).array()
-
- def fromBytes(bytes: Array[Byte]) = ByteBuffer.wrap(bytes).getInt()
-
- def toString(obj: Int) = obj.toString
-
- def fromString(str: String) = str.toInt
- }
-
- object SortedSetSerializer {
- def toBytes(set: SortedSet[Array[Byte]]): Array[Byte] = {
- val length = set.foldLeft(0) {
- (total, bytes) => {
- total + bytes.length + IntSerializer.bytesPerInt
- }
- }
- val allBytes = new Array[Byte](length)
- val written = set.foldLeft(0) {
- (total, bytes) => {
- val sizeBytes = IntSerializer.toBytes(bytes.length)
- System.arraycopy(sizeBytes, 0, allBytes, total, sizeBytes.length)
- System.arraycopy(bytes, 0, allBytes, total + sizeBytes.length, bytes.length)
- total + sizeBytes.length + bytes.length
- }
- }
- require(length == written, "Bytes Written Did not equal Calculated Length, written %d, length %d".format(written, length))
- allBytes
- }
-
- def fromBytes(bytes: Array[Byte]): SortedSet[Array[Byte]] = {
- var set = new TreeSet[Array[Byte]]
- if (bytes.length > IntSerializer.bytesPerInt) {
- var pos = 0
- while (pos < bytes.length) {
- val lengthBytes = new Array[Byte](IntSerializer.bytesPerInt)
- System.arraycopy(bytes, pos, lengthBytes, 0, IntSerializer.bytesPerInt)
- pos += IntSerializer.bytesPerInt
- val length = IntSerializer.fromBytes(lengthBytes)
- val item = new Array[Byte](length)
- System.arraycopy(bytes, pos, item, 0, length)
- set = set + item
- pos += length
- }
- }
- set
- }
-
- }
-
-}
-
-private[akka] object KVStorageBackend {
-
- import CommonStorageBackend._
-
- /**
- * Concat the ownerlenght+owner+key+ of owner so owned data will be colocated
- * Store the length of owner as first byte to work around the rare case
- * where ownerbytes1 + keybytes1 == ownerbytes2 + keybytes2 but ownerbytes1 != ownerbytes2
- */
-
- def getKey(owner: String, key: Array[Byte]): Array[Byte] = {
- val ownerBytes: Array[Byte] = owner.getBytes("UTF-8")
- val ownerLenghtBytes: Array[Byte] = IntSerializer.toBytes(owner.length)
- val theKey = new Array[Byte](ownerLenghtBytes.length + ownerBytes.length + key.length)
- System.arraycopy(ownerLenghtBytes, 0, theKey, 0, ownerLenghtBytes.length)
- System.arraycopy(ownerBytes, 0, theKey, ownerLenghtBytes.length, ownerBytes.length)
- System.arraycopy(key, 0, theKey, ownerLenghtBytes.length + ownerBytes.length, key.length)
- theKey
- }
-
- def getIndexedKey(owner: String, index: Int): Array[Byte] = {
- getKey(owner, IntSerializer.toBytes(index))
- }
-
-}
-
-private[akka] trait CommonStorageBackend extends MapStorageBackend[Array[Byte], Array[Byte]] with VectorStorageBackend[Array[Byte]] with RefStorageBackend[Array[Byte]] with QueueStorageBackend[Array[Byte]] with Logging {
-
- import CommonStorageBackend._
-
- val vectorHeadIndex = -1
- val vectorTailIndex = -2
- val queueHeadIndex = -1
- val queueTailIndex = -2
- val zero = IntSerializer.toBytes(0)
- val refItem = "refItem".getBytes("UTF-8")
-
- implicit val ordering = ArrayOrdering
-
-
- def refAccess: CommonStorageBackendAccess
-
- def vectorAccess: CommonStorageBackendAccess
-
- def mapAccess: CommonStorageBackendAccess
-
- def queueAccess: CommonStorageBackendAccess
-
-
- def getRefStorageFor(name: String): Option[Array[Byte]] = {
- val result: Array[Byte] = refAccess.get(name, refItem)
- Option(result)
- }
-
- def insertRefStorageFor(name: String, element: Array[Byte]) = {
- element match {
- case null => refAccess.delete(name, refItem)
- case _ => refAccess.put(name, refItem, element)
- }
- }
-
-
- def getMapStorageRangeFor(name: String, start: Option[Array[Byte]], finish: Option[Array[Byte]], count: Int): List[(Array[Byte], Array[Byte])] = {
- val allkeys: SortedSet[Array[Byte]] = getMapKeys(name)
- val range = allkeys.rangeImpl(start, finish).take(count)
- getKeyValues(name, range)
- }
-
- def getMapStorageFor(name: String): List[(Array[Byte], Array[Byte])] = {
- val keys = getMapKeys(name)
- getKeyValues(name, keys)
- }
-
- private def getKeyValues(name: String, keys: SortedSet[Array[Byte]]): List[(Array[Byte], Array[Byte])] = {
- val all: Map[Array[Byte], Array[Byte]] =
- mapAccess.getAll(name, keys)
-
- var returned = new TreeMap[Array[Byte], Array[Byte]]()(ordering)
- all.foreach{
- (entry) => {
- entry match {
- case (namePlusKey: Array[Byte], value: Array[Byte]) => {
- //need to fix here
- returned += mapAccess.decodeMapKey(name, unwrapMapKey(namePlusKey)) -> getMapValueFromStored(value)
- }
- }
- }
- }
- returned.toList
- }
-
- def getMapStorageSizeFor(name: String): Int = {
- val keys = getMapKeys(name)
- keys.size
- }
-
- def getMapStorageEntryFor(name: String, key: Array[Byte]): Option[Array[Byte]] = {
- val result: Array[Byte] = mapAccess.get(name, wrapMapKey(key))
- result match {
- case null => None
- case _ => Some(getMapValueFromStored(result))
- }
- }
-
- def removeMapStorageFor(name: String, key: Array[Byte]) = {
- val wrapped = wrapMapKey(key)
- var keys = getMapKeys(name)
- keys -= wrapped
- putMapKeys(name, keys)
- mapAccess.delete(name, wrapped)
- }
-
- def removeMapStorageFor(name: String) = {
- val keys = getMapKeys(name)
- keys.foreach{
- key =>
- mapAccess.delete(name, key)
- }
- mapAccess.delete(name, mapKeysIndex)
- }
-
- def insertMapStorageEntryFor(name: String, key: Array[Byte], value: Array[Byte]) = {
- val wrapped = wrapMapKey(key)
- mapAccess.put(name, wrapped, getStoredMapValue(value))
- var keys = getMapKeys(name)
- keys += wrapped
- putMapKeys(name, keys)
- }
-
- def insertMapStorageEntriesFor(name: String, entries: List[(Array[Byte], Array[Byte])]) = {
- val toInsert = entries.map{
- kv => kv match {
- case (key, value) => (wrapMapKey(key) -> getStoredMapValue(value))
- }
- }
- mapAccess.putAll(name, toInsert)
- val newKeys = toInsert.map{
- case (key, value) => {
- key
- }
- }
- var keys = getMapKeys(name)
- keys ++= newKeys
- putMapKeys(name, keys)
- }
-
- def putMapKeys(name: String, keys: SortedSet[Array[Byte]]) = {
- mapAccess.put(name, mapKeysIndex, SortedSetSerializer.toBytes(keys))
- }
-
- def getMapKeys(name: String): SortedSet[Array[Byte]] = {
- SortedSetSerializer.fromBytes(mapAccess.get(name, mapKeysIndex, Array.empty[Byte]))
- }
-
- def getVectorStorageSizeFor(name: String): Int = {
- getVectorMetadata(name).size
- }
-
- def getVectorStorageRangeFor(name: String, start: Option[Int], finish: Option[Int], count: Int): List[Array[Byte]] = {
- val mdata = getVectorMetadata(name)
-
- val st = start.getOrElse(0)
- var cnt =
- if (finish.isDefined) {
- val f = finish.get
- if (f >= st) (f - st) else count
- } else {
- count
- }
- if (cnt > (mdata.size - st)) {
- cnt = mdata.size - st
- }
-
- val indexes = mdata.getRangeIndexes(st, count)
- val result = vectorAccess.getAllIndexed(name, indexes)
- indexes.map(result.get(_).get).toList
-
- }
-
- def getVectorStorageEntryFor(name: String, index: Int): Array[Byte] = {
- val mdata = getVectorMetadata(name)
- if (mdata.size > 0 && index < mdata.size) {
- vectorAccess.getIndexed(name, mdata.getRangeIndexes(index, 1)(0))
- } else {
- throw new StorageException("In Vector:" + name + " No such Index:" + index)
- }
- }
-
- def updateVectorStorageEntryFor(name: String, index: Int, elem: Array[Byte]) = {
- val mdata = getVectorMetadata(name)
- if (mdata.size > 0 && index < mdata.size) {
- elem match {
- case null => vectorAccess.deleteIndexed(name, mdata.getRangeIndexes(index, 1)(0))
- case _ => vectorAccess.putIndexed(name, mdata.getRangeIndexes(index, 1)(0), elem)
- }
- } else {
- throw new StorageException("In Vector:" + name + " No such Index:" + index)
- }
- }
-
- def insertVectorStorageEntriesFor(name: String, elements: List[Array[Byte]]) = {
- var mdata = getVectorMetadata(name)
- var deletes: List[Int] = Nil
- var puts: List[(Int, Array[Byte])] = Nil
- elements.foreach{
- element => {
- if (mdata.canInsert) {
- element match {
- case null => deletes = mdata.head :: deletes
- case _ => puts = (mdata.head -> element) :: puts
- }
- mdata = mdata.copy(head = mdata.nextInsert)
- } else {
- throw new IllegalStateException("The vector dosent have enough capacity to insert these entries")
- }
- }
- }
-
- vectorAccess.deleteAllIndexed(name, deletes)
- vectorAccess.putAllIndexed(name, puts)
- vectorAccess.putIndexed(name, vectorHeadIndex, IntSerializer.toBytes(mdata.head))
-
- }
-
- def insertVectorStorageEntryFor(name: String, element: Array[Byte]) = {
- val mdata = getVectorMetadata(name)
- if (mdata.canInsert) {
- element match {
- case null => vectorAccess.deleteIndexed(name, mdata.head)
- case _ => vectorAccess.putIndexed(name, mdata.head, element)
- }
- vectorAccess.putIndexed(name, vectorHeadIndex, IntSerializer.toBytes(mdata.nextInsert))
- } else {
- throw new IllegalStateException("The vector %s is full".format(name))
- }
-
- }
-
-
- override def removeVectorStorageEntryFor(name: String) = {
- val mdata = getVectorMetadata(name)
- if (mdata.canRemove) {
- vectorAccess.putIndexed(name, vectorTailIndex, IntSerializer.toBytes(mdata.nextRemove))
- try
- {
- vectorAccess.deleteIndexed(name, mdata.tail)
- } catch {
- case e: Exception => log.warn("Exception while trying to clean up a popped element from the vector, this is acceptable")
- }
-
- } else {
- //blow up or not?
- }
- }
-
- def getVectorMetadata(name: String): VectorMetadata = {
- val result = vectorAccess.getAllIndexed(name, List(vectorHeadIndex, vectorTailIndex))
- val head = result.getOrElse(vectorHeadIndex, zero)
- val tail = result.getOrElse(vectorTailIndex, zero)
- val mdata = VectorMetadata(IntSerializer.fromBytes(head), IntSerializer.fromBytes(tail))
- mdata
- }
-
- def getOrDefaultToZero(map: Map[Array[Byte], Array[Byte]], key: Array[Byte]): Int = {
- map.get(key) match {
- case Some(value) => IntSerializer.fromBytes(value)
- case None => 0
- }
- }
-
-
- def remove(name: String): Boolean = {
- val mdata = getQueueMetadata(name)
- mdata.getActiveIndexes foreach {
- index =>
- queueAccess.deleteIndexed(name, index)
- }
- queueAccess.deleteIndexed(name, queueHeadIndex)
- queueAccess.deleteIndexed(name, queueTailIndex)
- true
- }
-
- def peek(name: String, start: Int, count: Int): List[Array[Byte]] = {
- val mdata = getQueueMetadata(name)
- val indexes = mdata.getPeekIndexes(start, count)
- val result = queueAccess.getAllIndexed(name, indexes)
- indexes.map(result.get(_).get).toList
- }
-
- def size(name: String): Int = {
- getQueueMetadata(name).size
- }
-
- def dequeue(name: String): Option[Array[Byte]] = {
- val mdata = getQueueMetadata(name)
- if (mdata.canDequeue) {
- try
- {
- val dequeued = queueAccess.getIndexed(name, mdata.head)
- queueAccess.putIndexed(name, queueHeadIndex, IntSerializer.toBytes(mdata.nextDequeue))
- Some(dequeued)
- } finally {
- try
- {
- queueAccess.deleteIndexed(name, mdata.head)
- } catch {
- //a failure to delete is ok, just leaves a K-V in Voldemort that will be overwritten if the queue ever wraps around
- case e: Exception => log.warn(e, "caught an exception while deleting a dequeued element, however this will not cause any inconsistency in the queue")
- }
- }
- } else {
- None
- }
- }
-
- def enqueue(name: String, item: Array[Byte]): Option[Int] = {
- val mdata = getQueueMetadata(name)
- if (mdata.canEnqueue) {
- item match {
- case null => queueAccess.deleteIndexed(name, mdata.tail)
- case _ => queueAccess.putIndexed(name, mdata.tail, item)
- }
- queueAccess.putIndexed(name, queueTailIndex, IntSerializer.toBytes(mdata.nextEnqueue))
- Some(mdata.size + 1)
- } else {
- None
- }
- }
-
- def getQueueMetadata(name: String): QueueMetadata = {
- val result = queueAccess.getAllIndexed(name, List(vectorHeadIndex, vectorTailIndex))
- val head = result.get(vectorHeadIndex).getOrElse(zero)
- val tail = result.get(vectorTailIndex).getOrElse(zero)
- QueueMetadata(IntSerializer.fromBytes(head), IntSerializer.fromBytes(tail))
- }
-
-
- //wrapper for null
-
-
- case class QueueMetadata(head: Int, tail: Int) {
- //queue is an sequence with indexes from 0 to Int.MAX_VALUE
- //wraps around when one pointer gets to max value
- //head has an element in it.
- //tail is the next slot to write to.
-
- def size = {
- if (tail >= head) {
- tail - head
- } else {
- //queue has wrapped
- (Integer.MAX_VALUE - head) + (tail + 1)
- }
- }
-
- def canEnqueue = {
- //the -1 stops the tail from catching the head on a wrap around
- size < Integer.MAX_VALUE - 1
- }
-
- def canDequeue = {
- size > 0
- }
-
- def getActiveIndexes(): IndexedSeq[Int] = {
- if (tail >= head) {
- Range(head, tail)
- } else {
- //queue has wrapped
- val headRange = Range.inclusive(head, Integer.MAX_VALUE)
- (if (tail > 0) {
- headRange ++ Range(0, tail)
- } else {
- headRange
- })
- }
- }
-
- def getPeekIndexes(start: Int, count: Int): IndexedSeq[Int] = {
- val indexes = getActiveIndexes
- if (indexes.size < start) {
- IndexedSeq.empty[Int]
- } else {
- indexes.drop(start).take(count)
- }
- }
-
- def nextEnqueue = {
- tail match {
- case Integer.MAX_VALUE => 0
- case _ => tail + 1
- }
- }
-
- def nextDequeue = {
- head match {
- case Integer.MAX_VALUE => 0
- case _ => head + 1
- }
- }
- }
-
- case class VectorMetadata(head: Int, tail: Int) {
- def size = {
- if (head >= tail) {
- head - tail
- } else {
- //queue has wrapped
- (Integer.MAX_VALUE - tail) + (head + 1)
- }
- }
-
- def canInsert = {
- //the -1 stops the tail from catching the head on a wrap around
- size < Integer.MAX_VALUE - 1
- }
-
- def canRemove = {
- size > 0
- }
-
- def getActiveIndexes(): IndexedSeq[Int] = {
- if (head >= tail) {
- Range(tail, head)
- } else {
- //queue has wrapped
- val headRange = Range.inclusive(tail, Integer.MAX_VALUE)
- (if (head > 0) {
- headRange ++ Range(0, head)
- } else {
- headRange
- })
- }
- }
-
- def getRangeIndexes(start: Int, count: Int): IndexedSeq[Int] = {
- val indexes = getActiveIndexes.reverse
- if (indexes.size < start) {
- IndexedSeq.empty[Int]
- } else {
- indexes.drop(start).take(count)
- }
- }
-
- def nextInsert = {
- head match {
- case Integer.MAX_VALUE => 0
- case _ => head + 1
- }
- }
-
- def nextRemove = {
- tail match {
- case Integer.MAX_VALUE => 0
- case _ => tail + 1
- }
- }
- }
-
-
-}
diff --git a/akka-persistence/akka-persistence-common/src/main/scala/akka/Pool.scala b/akka-persistence/akka-persistence-common/src/main/scala/akka/Pool.scala
deleted file mode 100644
index 3e205dcfe9..0000000000
--- a/akka-persistence/akka-persistence-common/src/main/scala/akka/Pool.scala
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.persistence.common
-
-import org.apache.commons.pool._
-import org.apache.commons.pool.impl._
-
-import org.apache.thrift.transport._
-
-trait Pool[T] extends java.io.Closeable {
- def borrowObject: T
- def returnObject(t: T): Unit
- def invalidateObject(t: T): Unit
- def addObject(): Unit
- def getNumIdle: Int
- def getNumActive: Int
- def clear(): Unit
- def setFactory(factory: PoolItemFactory[T]): Unit
-}
-
-trait PoolFactory[T] {
- def createPool: Pool[T]
-}
-
-trait PoolItemFactory[T] {
- def makeObject: T
- def destroyObject(t: T): Unit
- def validateObject(t: T): Boolean
- def activateObject(t: T): Unit
- def passivateObject(t: T): Unit
-}
-
-trait PoolBridge[T, OP <: ObjectPool] extends Pool[T] {
- val impl: OP
- override def borrowObject: T = impl.borrowObject.asInstanceOf[T]
- override def returnObject(t: T) = impl.returnObject(t)
- override def invalidateObject(t: T) = impl.invalidateObject(t)
- override def addObject = impl.addObject
- override def getNumIdle: Int = impl.getNumIdle
- override def getNumActive: Int = impl.getNumActive
- override def clear(): Unit = impl.clear()
- override def close(): Unit = impl.close()
- override def setFactory(factory: PoolItemFactory[T]) = impl.setFactory(toPoolableObjectFactory(factory))
-
- def toPoolableObjectFactory[T](pif: PoolItemFactory[T]) = new PoolableObjectFactory {
- def makeObject: Object = pif.makeObject.asInstanceOf[Object]
- def destroyObject(o: Object): Unit = pif.destroyObject(o.asInstanceOf[T])
- def validateObject(o: Object): Boolean = pif.validateObject(o.asInstanceOf[T])
- def activateObject(o: Object): Unit = pif.activateObject(o.asInstanceOf[T])
- def passivateObject(o: Object): Unit = pif.passivateObject(o.asInstanceOf[T])
- }
-}
-
-object StackPool {
- def apply[T](factory: PoolItemFactory[T]) = new PoolBridge[T,StackObjectPool] {
- val impl = new StackObjectPool(toPoolableObjectFactory(factory))
- }
-
- def apply[T](factory: PoolItemFactory[T], maxIdle: Int) = new PoolBridge[T,StackObjectPool] {
- val impl = new StackObjectPool(toPoolableObjectFactory(factory),maxIdle)
- }
-
- def apply[T](factory: PoolItemFactory[T], maxIdle: Int, initIdleCapacity: Int) = new PoolBridge[T,StackObjectPool] {
- val impl = new StackObjectPool(toPoolableObjectFactory(factory),maxIdle,initIdleCapacity)
- }
-}
-
-object SoftRefPool {
- def apply[T](factory: PoolItemFactory[T]) = new PoolBridge[T,SoftReferenceObjectPool] {
- val impl = new SoftReferenceObjectPool(toPoolableObjectFactory(factory))
- }
-}
-
-trait TransportFactory[T <: TTransport] extends PoolItemFactory[T] {
- def createTransport: T
- def makeObject: T = createTransport
- def destroyObject(transport: T): Unit = transport.close
- def validateObject(transport: T) = transport.isOpen
- def activateObject(transport: T): Unit = if( !transport.isOpen ) transport.open else ()
- def passivateObject(transport: T): Unit = transport.flush
-}
-
-case class SocketProvider(val host: String, val port: Int) extends TransportFactory[TSocket] {
- def createTransport = {
- val t = new TSocket(host, port)
- t.open
- t
- }
-}
diff --git a/akka-persistence/akka-persistence-common/src/main/scala/akka/Storage.scala b/akka-persistence/akka-persistence-common/src/main/scala/akka/Storage.scala
deleted file mode 100644
index de5106d610..0000000000
--- a/akka-persistence/akka-persistence-common/src/main/scala/akka/Storage.scala
+++ /dev/null
@@ -1,876 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.persistence.common
-
-import akka.stm._
-import akka.stm.TransactionManagement.transaction
-import akka.util.Logging
-import akka.japi.{Option => JOption}
-import collection.mutable.ArraySeq
-
-// FIXME move to 'stm' package + add message with more info
-class NoTransactionInScopeException extends RuntimeException
-
-class StorageException(message: String) extends RuntimeException(message)
-
-/**
- * Example Scala usage.
- *
- * New map with generated id.
- *
- * 1. Download redis from http://github.com/antirez/redis
- * 2. build using "make"
- * 3. Run server as ./redis-server
- *
- *
- * For running this sample application :-
- *
- *
- * 1. Open a shell and set AKKA_HOME to the distribution root
- * 2. cd $AKKA_HOME
- * 3. sbt console
- * 4. import sample.pubsub._
- * 5. Sub.sub("a", "b") // starts Subscription server & subscribes to channels "a" and "b"
- *
- * 6. Open up another shell similarly as the above and set AKKA_HOME
- * 7. cd $AKKA_HOME
- * 8. sbt console
- * 9. import sample.pubsub._
- * 10. Pub.publish("a", "hello") // the first shell should get the message
- * 11. Pub.publish("c", "hi") // the first shell should NOT get this message
- *
- * 12. Open up a redis-client from where you installed redis and issue a publish command
- * ./redis-cli publish a "hi there" ## the first shell should get the message
- *
- * 13. Go back to the first shell
- * 14. Sub.unsub("a") // should unsubscribe the first shell from channel "a"
- *
- * 15. Study the callback function defined below. It supports many other message formats.
- * In the second shell window do the following:
- * scala> Pub.publish("b", "+c") // will subscribe the first window to channel "c"
- * scala> Pub.publish("b", "+d") // will subscribe the first window to channel "d"
- * scala> Pub.publish("b", "-c") // will unsubscribe the first window from channel "c"
- * scala> Pub.publish("b", "exit") // will unsubscribe the first window from all channels
- *
- */
-
-object Pub {
- println("starting publishing service ..")
- val r = new RedisClient("localhost", 6379)
- val p = actorOf(new Publisher(r))
- p.start
-
- def publish(channel: String, message: String) = {
- p ! Publish(channel, message)
- }
-}
-
-object Sub {
- println("starting subscription service ..")
- val r = new RedisClient("localhost", 6379)
- val s = actorOf(new Subscriber(r))
- s.start
- s ! Register(callback)
-
- def sub(channels: String*) = {
- s ! Subscribe(channels.toArray)
- }
-
- def unsub(channels: String*) = {
- s ! Unsubscribe(channels.toArray)
- }
-
- def callback(pubsub: PubSubMessage) = pubsub match {
- case S(channel, no) => println("subscribed to " + channel + " and count = " + no)
- case U(channel, no) => println("unsubscribed from " + channel + " and count = " + no)
- case M(channel, msg) =>
- msg match {
- // exit will unsubscribe from all channels and stop subscription service
- case "exit" =>
- println("unsubscribe all ..")
- r.unsubscribe
-
- // message "+x" will subscribe to channel x
- case x if x startsWith "+" =>
- val s: Seq[Char] = x
- s match {
- case Seq('+', rest @ _*) => r.subscribe(rest.toString){ m => }
- }
-
- // message "-x" will unsubscribe from channel x
- case x if x startsWith "-" =>
- val s: Seq[Char] = x
- s match {
- case Seq('-', rest @ _*) => r.unsubscribe(rest.toString)
- }
-
- // other message receive
- case x =>
- println("received message on channel " + channel + " as : " + x)
- }
- }
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Boot.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Boot.java
deleted file mode 100644
index 530d396abb..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Boot.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-import akka.config.TypedActorConfigurator;
-import static akka.config.Supervision.*;
-
-public class Boot {
- public final static TypedActorConfigurator configurator = new TypedActorConfigurator();
- static {
- configurator.configure(
- new OneForOneStrategy(new Class[]{Exception.class}, 3, 5000),
- new SuperviseTypedActor[] {
- new SuperviseTypedActor(
- SimpleService.class,
- SimpleServiceImpl.class,
- permanent(),
- 1000),
- new SuperviseTypedActor(
- PersistentSimpleService.class,
- PersistentSimpleServiceImpl.class,
- permanent(),
- 1000)
- }).supervise();
- }
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleService.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleService.java
deleted file mode 100644
index 5ed4b65dcf..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleService.java
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-public interface PersistentSimpleService {
- public String count();
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceImpl.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceImpl.java
deleted file mode 100644
index 5d84b27d02..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-import akka.actor.TypedActor;
-import akka.stm.Atomic;
-import akka.persistence.common.PersistentMap;
-import akka.persistence.cassandra.CassandraStorage;
-
-import java.nio.ByteBuffer;
-
-public class PersistentSimpleServiceImpl extends TypedActor implements PersistentSimpleService {
- private String KEY = "COUNTER";
-
- private boolean hasStartedTicking = false;
- private final PersistentMap storage = CassandraStorage.newMap();
-
- public String count() {
- if (!hasStartedTicking) {
- new Atomic() {
- public Object atomically() {
- storage.put(KEY.getBytes(), ByteBuffer.allocate(4).putInt(0).array());
- return null;
- }
- }.execute();
- hasStartedTicking = true;
- return "Tick: 0\n";
- } else {
- int counter = new Atomic() {
- public Integer atomically() {
- byte[] bytes = (byte[])storage.get(KEY.getBytes()).get();
- int count = ByteBuffer.wrap(bytes).getInt() + 1;
- storage.put(KEY.getBytes(), ByteBuffer.allocate(4).putInt(count).array());
- return count;
- }
- }.execute();
- return "Tick: " + counter + "\n";
- }
- }
-
- @Override
- public void preRestart(Throwable cause) {
- System.out.println("Prepare for restart by supervisor");
- }
-
- @Override
- public void postRestart(Throwable cause) {
- System.out.println("Reinitialize after restart by supervisor");
- }
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceRest.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceRest.java
deleted file mode 100644
index 1a1467c250..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/PersistentSimpleServiceRest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-
-/**
- * Try service out by invoking (multiple times):
- *
- * Or browse to the URL from a web browser.
- */
-@Path("/persistentjavacount")
-public class PersistentSimpleServiceRest {
- private PersistentSimpleService service = (PersistentSimpleService) Boot.configurator.getInstance(PersistentSimpleService.class);
-
- @GET
- @Produces({"application/json"})
- public String count() {
- return service.count();
- }
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Receiver.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Receiver.java
deleted file mode 100644
index 91654e7c15..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/Receiver.java
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-public interface Receiver {
- SimpleService get();
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/ReceiverImpl.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/ReceiverImpl.java
deleted file mode 100644
index 4e00f831ab..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/ReceiverImpl.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-import akka.actor.TypedActor;
-
-public class ReceiverImpl extends TypedActor implements Receiver {
- public SimpleService get() {
- return (SimpleService) getContext().getSender();
- }
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleService.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleService.java
deleted file mode 100644
index ca8ee5e34d..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleService.java
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-public interface SimpleService {
- public String count();
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceImpl.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceImpl.java
deleted file mode 100644
index e0b95d3c92..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceImpl.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-import akka.actor.TypedActor;
-import akka.stm.Atomic;
-import akka.stm.TransactionalMap;
-
-public class SimpleServiceImpl extends TypedActor implements SimpleService {
- private String KEY = "COUNTER";
-
- private boolean hasStartedTicking = false;
- private final TransactionalMap storage = new TransactionalMap();
- private Receiver receiver = TypedActor.newInstance(Receiver.class, ReceiverImpl.class);
-
- public String count() {
- if (!hasStartedTicking) {
- new Atomic() {
- public Object atomically() {
- storage.put(KEY, 0);
- return null;
- }
- }.execute();
- hasStartedTicking = true;
- return "Tick: 0\n";
- } else {
- // Grabs the sender address and returns it
- //SimpleService sender = receiver.receive();
- int counter = new Atomic() {
- public Integer atomically() {
- int count = (Integer) storage.get(KEY).get() + 1;
- storage.put(KEY, count);
- return count;
- }
- }.execute();
- return "Tick: " + counter + "\n";
- }
- }
-
- @Override
- public void preRestart(Throwable cause) {
- System.out.println("Prepare for restart by supervisor");
- }
-
- @Override
- public void postRestart(Throwable cause) {
- System.out.println("Reinitialize after restart by supervisor");
- }
-}
diff --git a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceRest.java b/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceRest.java
deleted file mode 100644
index eba7c85f2a..0000000000
--- a/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java/SimpleServiceRest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.rest.java;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
-
-/**
- * Try service out by invoking (multiple times):
- *
- * curl http://localhost:9998/javacount
- *
- * Or browse to the URL from a web browser.
- */
-@Path("/javacount")
-public class SimpleServiceRest {
- private SimpleService service = (SimpleService) Boot.configurator.getInstance(SimpleService.class);
-
- @GET
- @Produces({"application/json"})
- public String count() {
- return service.count();
- }
-}
diff --git a/akka-samples/akka-sample-rest-scala/src/main/scala/Boot.scala b/akka-samples/akka-sample-rest-scala/src/main/scala/Boot.scala
deleted file mode 100644
index 1eeb9348a3..0000000000
--- a/akka-samples/akka-sample-rest-scala/src/main/scala/Boot.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2010 Autodesk, Inc. All rights reserved.
- * Licensed under Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- */
-
-package sample.rest.scala
-
-import akka.actor._
-import akka.actor.Actor._
-import akka.config.Supervision._
-import akka.http._
-
-
-/**
- * Starts up the base services for http (jetty)
- */
-class Boot {
- val factory = SupervisorFactory(
- SupervisorConfig(
- OneForOneStrategy(List(classOf[Exception]), 3, 100),
- //
- // in this particular case, just boot the built-in default root endpoint
- //
- Supervise(
- actorOf[RootEndpoint],
- Permanent) ::
- Supervise(
- actorOf[SimpleAkkaAsyncHttpService],
- Permanent)
- :: Nil))
- factory.newInstance.start
-}
-
diff --git a/akka-samples/akka-sample-rest-scala/src/main/scala/InterestingService.scala b/akka-samples/akka-sample-rest-scala/src/main/scala/InterestingService.scala
deleted file mode 100644
index e00a7e8120..0000000000
--- a/akka-samples/akka-sample-rest-scala/src/main/scala/InterestingService.scala
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * Copyright 2010 Autodesk, Inc. All rights reserved.
- * Licensed under Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- */
-
-package sample.mist
-
-import akka.actor._
-import akka.actor.Actor._
-import akka.http._
-import javax.servlet.http.HttpServletResponse
-
-
-
-/**
- * Define a top level service endpoint
- *
- * @author Garrick Evans
- */
-class InterestingService extends Actor with Endpoint {
- //
- // use the configurable dispatcher
- //
- self.dispatcher = Endpoint.Dispatcher
-
- final val ServiceRoot = "/interesting/"
- final val Multi = ServiceRoot + "multi/"
-
- //
- // The "multi" endpoint shows forking off multiple actions per request
- // It is triggered by POSTing to http://localhost:9998/interesting/multi/{foo}
- // Try with/without a header named "Test-Token"
- // Try with/without a form parameter named "Data"
- //
- def hookMultiActionA(uri: String): Boolean = uri startsWith Multi
- def provideMultiActionA(uri: String): ActorRef = actorOf(new ActionAActor(complete)).start
-
- def hookMultiActionB(uri: String): Boolean = uri startsWith Multi
- def provideMultiActionB(uri: String): ActorRef = actorOf(new ActionBActor(complete)).start
-
- //
- // this is where you want attach your endpoint hooks
- //
- override def preStart {
- //
- // we expect there to be one root and that it's already been started up
- // obviously there are plenty of other ways to obtaining this actor
- // the point is that we need to attach something (for starters anyway)
- // to the root
- //
- val root = ActorRegistry.actorsFor(classOf[RootEndpoint]).head
- root ! Endpoint.Attach(hookMultiActionA, provideMultiActionA)
- root ! Endpoint.Attach(hookMultiActionB, provideMultiActionB)
- }
-
- //
- // since this actor isn't doing anything else (i.e. not handling other messages)
- // just assign the receive func like so...
- // otherwise you could do something like:
- // def myrecv = {...}
- // def receive = myrecv orElse handleHttpRequest
- //
- def receive = handleHttpRequest
-
-
- //
- // this guy completes requests after other actions have occured
- //
- lazy val complete = actorOf[ActionCompleteActor].start
-}
-
-class ActionAActor(complete: ActorRef) extends Actor {
- import javax.ws.rs.core.MediaType
-
- def receive = {
- //
- // handle a post request
- //
- case post:Post => {
- //
- // the expected content type of the request
- // similar to @Consumes
- //
- if (post.request.getContentType startsWith MediaType.APPLICATION_FORM_URLENCODED) {
- //
- // the content type of the response.
- // similar to @Produces annotation
- //
- post.response.setContentType(MediaType.TEXT_HTML)
-
- //
- // get the resource name
- //
- val name = post.request.getRequestURI.substring("/interesting/multi/".length)
- val response = if (name.length % 2 == 0)
- "
Action A verified request.
"
- else
- "
Action A could not verify request.
"
-
- post.response.getWriter.write(response)
-
- //
- // notify the next actor to coordinate the response
- //
- complete ! post
- }
- else {
- post.UnsupportedMediaType("Content-Type request header missing or incorrect (was '" + post.request.getContentType + "' should be '" + MediaType.APPLICATION_FORM_URLENCODED + "')")
- }
- }
- }
-}
-
-class ActionBActor(complete:ActorRef) extends Actor {
- import javax.ws.rs.core.MediaType
-
- def receive = {
- //
- // handle a post request
- //
- case post:Post => {
- //
- // the expected content type of the request
- // similar to @Consumes
- //
- if (post.request.getContentType startsWith MediaType.APPLICATION_FORM_URLENCODED) {
- //
- // pull some headers and form params
- //
- def default(any: Any): String = ""
- val token = post.getHeaderOrElse("Test-Token", default)
- val data = post.getParameterOrElse("Data", default)
-
- val (resp, status) = (token, data) match {
- case ("", _) => ("No token provided", HttpServletResponse.SC_FORBIDDEN)
- case (_, "") => ("No data", HttpServletResponse.SC_ACCEPTED)
- case _ => ("Data accepted", HttpServletResponse.SC_OK)
- }
-
- //
- // update the response body
- //
- post.response.getWriter.write(resp)
-
- //
- // notify the next actor to coordinate the response
- //
- complete ! (post, status)
- }
- else {
- post.UnsupportedMediaType("Content-Type request header missing or incorrect (was '" + post.request.getContentType + "' should be '" + MediaType.APPLICATION_FORM_URLENCODED + "')")
- }
- }
-
- case other: RequestMethod =>
- other.NotAllowed("Invalid method for this endpoint")
- }
-}
-
-class ActionCompleteActor extends Actor
-{
- import collection.mutable.HashMap
-
- val requests = HashMap.empty[Int, Int]
-
- def receive = {
- case req: RequestMethod =>
- if (requests contains req.hashCode)
- complete(req)
- else
- requests += (req.hashCode -> 0)
-
- case t: Tuple2[RequestMethod, Int] =>
- if (requests contains t._1.hashCode)
- complete(t._1)
- else
- requests += (t._1.hashCode -> t._2)
- }
-
- def complete(req:RequestMethod) = requests.remove(req.hashCode) match {
- case Some(HttpServletResponse.SC_FORBIDDEN) => req.Forbidden("")
- case Some(HttpServletResponse.SC_ACCEPTED) => req.Accepted("")
- case Some(_) => req.OK("")
- case _ =>
- }
-}
\ No newline at end of file
diff --git a/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleAkkaAsyncHttpService.scala b/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleAkkaAsyncHttpService.scala
deleted file mode 100644
index 57aa3754b8..0000000000
--- a/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleAkkaAsyncHttpService.scala
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * Copyright 2010 Autodesk, Inc. All rights reserved.
- * Licensed under Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
- * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
- */
-
-package sample.rest.scala
-
-import akka.actor._
-import akka.actor.Actor._
-import akka.http._
-
-
-
-/**
- * Define a top level service endpoint
- * Usage: GET or POST to http://localhost:9998/simple/same or http://localhost:9998/simple/new
- *
- * @author Garrick Evans
- */
-class SimpleAkkaAsyncHttpService extends Actor with Endpoint {
- //
- // use the configurable dispatcher
- //
- self.dispatcher = Endpoint.Dispatcher
-
- final val ServiceRoot = "/simple/"
- final val ProvideSameActor = ServiceRoot + "same"
- final val ProvideNewActor = ServiceRoot + "new"
-
- //
- // there are different ways of doing this - in this case, we'll use a single hook function
- // and discriminate in the provider; alternatively we can pair hooks & providers
- //
- def hook(uri: String): Boolean = uri match {
- case ProvideSameActor | ProvideNewActor => true
- case _ => false
- }
-
- def provide(uri: String): ActorRef = uri match {
- case ProvideSameActor => same
- case _ => actorOf[BoringActor].start
- }
-
- //
- // this is where you want attach your endpoint hooks
- //
- override def preStart {
- //
- // we expect there to be one root and that it's already been started up
- // obviously there are plenty of other ways to obtaining this actor
- // the point is that we need to attach something (for starters anyway)
- // to the root
- //
- val root = ActorRegistry.actorsFor(classOf[RootEndpoint]).head
- root ! Endpoint.Attach(hook, provide)
- }
-
- //
- // since this actor isn't doing anything else (i.e. not handling other messages)
- // just assign the receive func like so...
- // otherwise you could do something like:
- // def myrecv = {...}
- // def receive = myrecv orElse handleHttpRequest
- //
- def receive = handleHttpRequest
-
- //
- // this will be our "same" actor provided with ProvideSameActor endpoint is hit
- //
- lazy val same = actorOf[BoringActor].start
-}
-
-/**
- * Define a service handler to respond to some HTTP requests
- */
-class BoringActor extends Actor {
- import java.util.Date
- import javax.ws.rs.core.MediaType
-
- var gets = 0
- var posts = 0
- var lastget: Option[Date] = None
- var lastpost: Option[Date] = None
-
- def receive = {
- //
- // handle a get request
- //
- case get: Get => {
- //
- // the content type of the response.
- // similar to @Produces annotation
- //
- get.response.setContentType(MediaType.TEXT_HTML)
-
- //
- // "work"
- //
- gets += 1
- lastget = Some(new Date)
-
- //
- // respond
- //
- val res = "
Gets: "+gets+" Posts: "+posts+"
Last Get: "+lastget.getOrElse("Never").toString+" Last Post: "+lastpost.getOrElse("Never").toString+"
"
- get.OK(res)
- }
-
- //
- // handle a post request
- //
- case post:Post => {
- //
- // the expected content type of the request
- // similar to @Consumes
- //
- if (post.request.getContentType startsWith MediaType.APPLICATION_FORM_URLENCODED) {
- //
- // the content type of the response.
- // similar to @Produces annotation
- //
- post.response.setContentType(MediaType.TEXT_HTML)
-
- //
- // "work"
- //
- posts += 1
- lastpost = Some(new Date)
-
- //
- // respond
- //
- val res = "
Gets: "+gets+" Posts: "+posts+"
Last Get: "+lastget.getOrElse("Never").toString+" Last Post: "+lastpost.getOrElse("Never").toString+"
"
- post.OK(res)
- }
- else {
- post.UnsupportedMediaType("Content-Type request header missing or incorrect (was '" + post.request.getContentType + "' should be '" + MediaType.APPLICATION_FORM_URLENCODED + "')")
- }
- }
-
- case other: RequestMethod => other.NotAllowed("Invalid method for this endpoint")
- }
-}
diff --git a/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala b/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala
deleted file mode 100644
index bee8dd5bd9..0000000000
--- a/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package sample.security
-
-import akka.actor.{SupervisorFactory, Actor}
-import akka.actor.Actor._
-import akka.config.Supervision._
-import akka.util.Logging
-import akka.security.{BasicAuthenticationActor,BasicCredentials,SpnegoAuthenticationActor,DigestAuthenticationActor, UserInfo}
-import akka.stm._
-import akka.stm.TransactionalMap
-import akka.actor.ActorRegistry.actorFor
-
-class Boot {
- val factory = SupervisorFactory(
- SupervisorConfig(
- OneForOneStrategy(List(classOf[Exception]), 3, 100),
- // Dummy implementations of all authentication actors
- // see akka.conf to enable one of these for the AkkaSecurityFilterFactory
- Supervise(
- actorOf[BasicAuthenticationService],
- Permanent) ::
-
- // Supervise(
- // actorOf[DigestAuthenticationService],
- // Permanent) ::
- // Supervise(
- // actorOf[SpnegoAuthenticationService],
- // Permanent) ::
-
- Supervise(
- actorOf[SecureTickActor],
- Permanent):: Nil))
-
- val supervisor = factory.newInstance
- supervisor.start
-}
-
-/*
- * In akka.conf you can set the FQN of any AuthenticationActor of your wish, under the property name: akka.http.authenticator
- */
-class DigestAuthenticationService extends DigestAuthenticationActor {
- //If you want to have a distributed nonce-map, you can use something like below,
- //don't forget to configure your standalone Cassandra instance
- //
- //makeTransactionRequired
- //override def mkNonceMap = Storage.newMap(CassandraStorageConfig()).asInstanceOf[scala.collection.mutable.Map[String,Long]]
-
- //Use an in-memory nonce-map as default
- override def mkNonceMap = new scala.collection.mutable.HashMap[String, Long]
-
- //Change this to whatever you want
- override def realm = "test"
-
- //Dummy method that allows you to log on with whatever username with the password "bar"
- override def userInfo(username: String): Option[UserInfo] = Some(UserInfo(username, "bar", "ninja" :: "chef" :: Nil))
-}
-
-class BasicAuthenticationService extends BasicAuthenticationActor {
-
- //Change this to whatever you want
- override def realm = "test"
-
- //Dummy method that allows you to log on with whatever username
- def verify(odc: Option[BasicCredentials]): Option[UserInfo] = odc match {
- case Some(dc) => userInfo(dc.username)
- case _ => None
- }
-
- //Dummy method that allows you to log on with whatever username with the password "bar"
- def userInfo(username: String): Option[UserInfo] = Some(UserInfo(username, "bar", "ninja" :: "chef" :: Nil))
-
-}
-
-class SpnegoAuthenticationService extends SpnegoAuthenticationActor {
- def rolesFor(user: String) = "ninja" :: "chef" :: Nil
-
-}
-
-/**
- * a REST Actor with class level paranoia settings to deny all access
- *
- * The interesting part is
- * @RolesAllowed
- * @PermitAll
- * @DenyAll
- */
-import java.lang.Integer
-import javax.annotation.security.{RolesAllowed, DenyAll, PermitAll}
-import javax.ws.rs.{GET, Path, Produces}
-
-@Path("/secureticker")
-class SecureTickService {
-
- /**
- * allow access for any user to "/secureticker/public"
- */
- @GET
- @Produces(Array("text/xml"))
- @Path("/public")
- @PermitAll
- def publicTick = tick
-
- /**
- * restrict access to "/secureticker/chef" users with "chef" role
- */
- @GET
- @Path("/chef")
- @Produces(Array("text/xml"))
- @RolesAllowed(Array("chef"))
- def chefTick = tick
-
- /**
- * access denied for any user to default Path "/secureticker/"
- */
- @GET
- @Produces(Array("text/xml"))
- @DenyAll
- def paranoiaTick = tick
-
- def tick = {
- //Fetch the first actor of type PersistentSimpleServiceActor
- //Send it the "Tick" message and expect a NdeSeq back
- val result = for{a <- actorFor[SecureTickActor]
- r <- (a !! "Tick").as[Integer]} yield r
- //Return either the resulting NodeSeq or a default one
- result match {
- case (Some(counter)) => (Tick: {counter})
- case _ => (Error in counter)
- }
- }
-}
-
-class SecureTickActor extends Actor with Logging {
- private val KEY = "COUNTER"
- private var hasStartedTicking = false
- private val storage = TransactionalMap[String, Integer]()
- def receive = {
- case "Tick" => if (hasStartedTicking) {
- val count = atomic {
- val current = storage.get(KEY).get.intValue
- val updated = current + 1
- storage.put(KEY, updated)
- updated
- }
- self.reply(new Integer(count))
- } else {
- atomic {
- storage.put(KEY, 0)
- }
- hasStartedTicking = true
- self.reply(new Integer(0))
- }
- }
-}
diff --git a/akka-samples/akka-sample-security/src/main/webapp/WEB-INF/web.xml b/akka-samples/akka-sample-security/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index d532f0e3f2..0000000000
--- a/akka-samples/akka-sample-security/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- akka-security-samples
-
-
- AkkaServlet
- akka.http.AkkaServlet
-
-
-
- AkkaServlet
- /*
-
-
-
diff --git a/akka-spring/src/main/resources/META-INF/spring.handlers b/akka-spring/src/main/resources/META-INF/spring.handlers
deleted file mode 100644
index 0812c4dd2e..0000000000
--- a/akka-spring/src/main/resources/META-INF/spring.handlers
+++ /dev/null
@@ -1 +0,0 @@
-http\://www.akkasource.org/schema/akka=akka.spring.AkkaNamespaceHandler
diff --git a/akka-spring/src/main/resources/META-INF/spring.schemas b/akka-spring/src/main/resources/META-INF/spring.schemas
deleted file mode 100644
index 37ec717596..0000000000
--- a/akka-spring/src/main/resources/META-INF/spring.schemas
+++ /dev/null
@@ -1 +0,0 @@
-http\://scalablesolutions.se/akka/akka-1.0-SNAPSHOT.xsd=akka/spring/akka-1.0-SNAPSHOT.xsd
diff --git a/akka-spring/src/main/resources/akka/spring/akka-0.10.xsd b/akka-spring/src/main/resources/akka/spring/akka-0.10.xsd
deleted file mode 100644
index e66090fe16..0000000000
--- a/akka-spring/src/main/resources/akka/spring/akka-0.10.xsd
+++ /dev/null
@@ -1,294 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the remote host.
-
-
-
-
-
-
- Port of the remote host.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the interface implemented by implementation class.
-
-
-
-
-
-
- Name of the implementation class.
-
-
-
-
-
-
- Theh default timeout for '!!' invocations.
-
-
-
-
-
-
- Set this to true if messages should have REQUIRES_NEW semantics.
-
-
-
-
-
-
- Defines the lifecycle, can be either 'permanent' or 'temporary'.
-
-
-
-
-
-
- Supported scopes are 'singleton' and 'prototype'.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the implementation class.
-
-
-
-
-
-
- The default timeout for '!!' invocations.
-
-
-
-
-
-
- Set this to true if messages should have REQUIRES_NEW semantics.
-
-
-
-
-
-
- Defines the lifecycle, can be either 'permanent' or 'temporary'.
-
-
-
-
-
-
- Supported scopes are 'singleton' and 'prototype'.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Failover scheme, can be one of 'AllForOne' or 'OneForOne'.
-
-
-
-
-
-
- Maximal number of restarts.
-
-
-
-
-
-
- Time range for maximal number of restart.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/main/resources/akka/spring/akka-1.0-SNAPSHOT.xsd b/akka-spring/src/main/resources/akka/spring/akka-1.0-SNAPSHOT.xsd
deleted file mode 100644
index 16e3bde6f3..0000000000
--- a/akka-spring/src/main/resources/akka/spring/akka-1.0-SNAPSHOT.xsd
+++ /dev/null
@@ -1,363 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the remote host.
-
-
-
-
-
-
- Port of the remote host.
-
-
-
-
-
-
- Management type for remote actors: client managed or server managed.
-
-
-
-
-
-
- Custom service name for server managed actor.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the interface implemented by implementation class.
-
-
-
-
-
-
- Name of the implementation class.
-
-
-
-
-
-
- Bean instance behind the actor
-
-
-
-
-
-
- The default timeout for '!!' invocations in milliseconds.
-
-
-
-
-
-
- Defines the lifecycle, can be either 'permanent' or 'temporary'.
-
-
-
-
-
-
- Supported scopes are 'singleton' and 'prototype'.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the implementation class.
-
-
-
-
-
-
- Bean instance behind the actor
-
-
-
-
-
-
- The default timeout for '!!' invocations in milliseconds.
-
-
-
-
-
-
- Defines the lifecycle, can be either 'permanent' or 'temporary'.
-
-
-
-
-
-
- Supported scopes are 'singleton' and 'prototype'.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Name of the remote host.
-
-
-
-
-
-
- Port of the remote host.
-
-
-
-
-
-
- Custom service name or class name for the server managed actor.
-
-
-
-
-
-
- Name of the interface the typed actor implements.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Failover scheme, can be one of 'AllForOne' or 'OneForOne'.
-
-
-
-
-
-
- Maximal number of restarts.
-
-
-
-
-
-
- Time range for maximal number of restart.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/main/scala/akka/ActorBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/ActorBeanDefinitionParser.scala
deleted file mode 100644
index 2abb1024d8..0000000000
--- a/akka-spring/src/main/scala/akka/ActorBeanDefinitionParser.scala
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser
-import org.springframework.beans.factory.xml.ParserContext
-import AkkaSpringConfigurationTags._
-import org.w3c.dom.Element
-
-
-/**
- * Parser for custom namespace configuration.
- * @author michaelkober
- */
-class TypedActorBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActorParser {
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
- */
- override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- val typedActorConf = parseActor(element)
- typedActorConf.typed = TYPED_ACTOR_TAG
- typedActorConf.setAsProperties(builder)
- }
-
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
- */
- override def getBeanClass(element: Element): Class[_] = classOf[ActorFactoryBean]
-}
-
-
-/**
- * Parser for custom namespace configuration.
- * @author michaelkober
- */
-class UntypedActorBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActorParser {
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
- */
- override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- val untypedActorConf = parseActor(element)
- untypedActorConf.typed = UNTYPED_ACTOR_TAG
- untypedActorConf.setAsProperties(builder)
- }
-
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
- */
- override def getBeanClass(element: Element): Class[_] = classOf[ActorFactoryBean]
-}
-
-
-/**
- * Parser for custom namespace configuration.
- * @author michaelkober
- */
-class ActorForBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActorForParser {
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
- */
- override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- val actorForConf = parseActorFor(element)
- actorForConf.setAsProperties(builder)
- }
-
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
- */
- override def getBeanClass(element: Element): Class[_] = classOf[ActorForFactoryBean]
-}
-
-/**
- * Parser for custom namespace configuration.
- * @author michaelkober
- */
-class ConfigBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActorParser {
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
- */
- override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- val location = element.getAttribute(LOCATION)
- builder.addPropertyValue(LOCATION, location)
- }
-
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
- */
- override def getBeanClass(element: Element): Class[_] = classOf[ConfiggyPropertyPlaceholderConfigurer]
-
- override def shouldGenerateId() = true
-}
diff --git a/akka-spring/src/main/scala/akka/ActorFactoryBean.scala b/akka-spring/src/main/scala/akka/ActorFactoryBean.scala
deleted file mode 100644
index 0d3d407475..0000000000
--- a/akka-spring/src/main/scala/akka/ActorFactoryBean.scala
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.spring
-
-import org.springframework.beans.{BeanUtils,BeansException,BeanWrapper,BeanWrapperImpl}
-import akka.remote.{RemoteClient, RemoteServer}
-import org.springframework.beans.factory.config.AbstractFactoryBean
-import org.springframework.context.{ApplicationContext,ApplicationContextAware}
-import org.springframework.util.StringUtils
-
-import akka.actor.{ActorRef, AspectInitRegistry, TypedActorConfiguration, TypedActor,Actor}
-import akka.dispatch.MessageDispatcher
-import akka.util.{Logging, Duration}
-import scala.reflect.BeanProperty
-import java.net.InetSocketAddress
-
-/**
- * Exception to use when something goes wrong during bean creation.
- *
- * @author Johan Rask
- */
-class AkkaBeansException(message: String, cause:Throwable) extends BeansException(message, cause) {
- def this(message: String) = this(message, null)
-}
-
-/**
- * Factory bean for typed and untyped actors.
- *
- * @author michaelkober
- * @author Johan Rask
- * @author Martin Krasser
- * @author Jonas Bonér
- */
-class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with Logging with ApplicationContextAware {
- import StringReflect._
- import AkkaSpringConfigurationTags._
-
- @BeanProperty var typed: String = ""
- @BeanProperty var interface: String = ""
- @BeanProperty var implementation: String = ""
- @BeanProperty var beanRef: String = null
- @BeanProperty var timeoutStr: String = ""
- @BeanProperty var host: String = ""
- @BeanProperty var port: String = ""
- @BeanProperty var serverManaged: Boolean = false
- @BeanProperty var serviceName: String = ""
- @BeanProperty var lifecycle: String = ""
- @BeanProperty var dispatcher: DispatcherProperties = _
- @BeanProperty var scope: String = VAL_SCOPE_SINGLETON
- @BeanProperty var property: PropertyEntries = _
- @BeanProperty var applicationContext: ApplicationContext = _
-
- lazy val timeout = parseTimeout
-
- private def parseTimeout() : Long = {
- var result = -1L
- try {
- result = if (!timeoutStr.isEmpty) timeoutStr.toLong else -1L
- } catch {
- case nfe: NumberFormatException =>
- log.error(nfe, "could not parse timeout %s", timeoutStr)
- throw nfe
- }
- result
- }
-
- // Holds info about if deps have been set or not. Depends on
- // if interface is specified or not. We must set deps on
- // target instance if interface is specified
- var hasSetDependecies = false
-
- override def isSingleton = scope.equals(VAL_SCOPE_SINGLETON)
-
- /*
- * @see org.springframework.beans.factory.FactoryBean#getObjectType()
- */
- def getObjectType: Class[AnyRef] = try {
- implementation.toClass
- } catch {
- // required by contract to return null
- case e: IllegalArgumentException => null
- }
-
- /*
- * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
- */
- def createInstance: AnyRef = {
- val ref = typed match {
- case TYPED_ACTOR_TAG => val typedActor = createTypedInstance()
- setProperties(AspectInitRegistry.initFor(typedActor).targetInstance)
- typedActor
- case UNTYPED_ACTOR_TAG => val untypedActor = createUntypedInstance()
- setProperties(untypedActor.actor)
- untypedActor
- case _ => throw new IllegalArgumentException("Unknown actor type")
- }
- ref
- }
-
- private[akka] def createTypedInstance() : AnyRef = {
- if ((interface eq null) || interface == "") throw new AkkaBeansException(
- "The 'interface' part of the 'akka:actor' element in the Spring config file can't be null or empty string")
- if (((implementation eq null) || implementation == "") && (beanRef eq null)) throw new AkkaBeansException(
- "Either 'implementation' or 'ref' must be specified as attribute of the 'akka:typed-actor' element in the Spring config file ")
-
- val typedActor: AnyRef = if (beanRef eq null ) {
- TypedActor.newInstance(interface.toClass, implementation.toClass, createConfig)
- }
- else
- {
- TypedActor.newInstance(interface.toClass, getBeanFactory().getBean(beanRef), createConfig)
- }
-
-
- if (isRemote && serverManaged) {
- val server = RemoteServer.getOrCreateServer(new InetSocketAddress(host, port.toInt))
- if (serviceName.isEmpty) {
- server.registerTypedActor(interface, typedActor)
- } else {
- server.registerTypedActor(serviceName, typedActor)
- }
- }
- typedActor
- }
-
- /**
- * Create an UntypedActor.
- */
- private[akka] def createUntypedInstance() : ActorRef = {
- if (((implementation eq null) || implementation == "") && (beanRef eq null)) throw new AkkaBeansException(
- "Either 'implementation' or 'ref' must be specified as attribute of the 'akka:untyped-actor' element in the Spring config file ")
- val actorRef = if (beanRef eq null )
- Actor.actorOf(implementation.toClass)
- else
- Actor.actorOf(getBeanFactory().getBean(beanRef).asInstanceOf[Actor])
-
- if (timeout > 0) {
- actorRef.setTimeout(timeout)
- }
- if (isRemote) {
- if (serverManaged) {
- val server = RemoteServer.getOrCreateServer(new InetSocketAddress(host, port.toInt))
- if (serviceName.isEmpty) {
- server.register(actorRef)
- } else {
- server.register(serviceName, actorRef)
- }
- } else {
- actorRef.makeRemote(host, port.toInt)
- }
- }
- if (hasDispatcher) {
- if (dispatcher.dispatcherType != THREAD_BASED){
- actorRef.setDispatcher(dispatcherInstance())
- } else {
- actorRef.setDispatcher(dispatcherInstance(Some(actorRef)))
- }
- }
- actorRef
- }
-
- /**
- * Stop the typed actor if it is a singleton.
- */
- override def destroyInstance(instance: AnyRef) {
- typed match {
- case TYPED_ACTOR_TAG => TypedActor.stop(instance)
- case UNTYPED_ACTOR_TAG => instance.asInstanceOf[ActorRef].stop
- }
- }
-
- private def setProperties(ref: AnyRef): AnyRef = {
- if (hasSetDependecies) return ref
- log.debug("Processing properties and dependencies for implementation class\n\t[%s]", implementation)
- val beanWrapper = new BeanWrapperImpl(ref);
- if (ref.isInstanceOf[ApplicationContextAware]) {
- log.debug("Setting application context")
- beanWrapper.setPropertyValue("applicationContext", applicationContext)
- }
- for (entry <- property.entryList) {
- val propertyDescriptor = BeanUtils.getPropertyDescriptor(ref.getClass, entry.name)
- val method = propertyDescriptor.getWriteMethod
- if (StringUtils.hasText(entry.ref)) {
- log.debug("Setting property %s with bean ref %s using method %s", entry.name, entry.ref, method.getName)
- method.invoke(ref,getBeanFactory().getBean(entry.ref))
- } else if(StringUtils.hasText(entry.value)) {
- log.debug("Setting property %s with value %s using method %s", entry.name, entry.value, method.getName)
- beanWrapper.setPropertyValue(entry.name,entry.value)
- } else throw new AkkaBeansException("Either property@ref or property@value must be set on property element")
- }
- ref
- }
-
-
- private[akka] def createConfig: TypedActorConfiguration = {
- val config = new TypedActorConfiguration().timeout(Duration(timeout, "millis"))
- if (isRemote && !serverManaged) config.makeRemote(host, port.toInt)
- if (hasDispatcher) {
- if (dispatcher.dispatcherType != THREAD_BASED) {
- config.dispatcher(dispatcherInstance())
- } else {
- config.threadBasedDispatcher()
- }
- }
- config
- }
-
- private[akka] def isRemote = (host ne null) && (!host.isEmpty)
-
- private[akka] def hasDispatcher =
- (dispatcher ne null) &&
- (dispatcher.dispatcherType ne null) &&
- (!dispatcher.dispatcherType.isEmpty)
-
- /**
- * Create dispatcher instance with dispatcher properties.
- * @param actorRef actorRef for thread based dispatcher
- * @return new dispatcher instance
- */
- private[akka] def dispatcherInstance(actorRef: Option[ActorRef] = None) : MessageDispatcher = {
- import DispatcherFactoryBean._
- if (dispatcher.dispatcherType != THREAD_BASED) {
- createNewInstance(dispatcher)
- } else {
- createNewInstance(dispatcher, actorRef)
- }
- }
-}
-
-/**
- * Factory bean for remote client actor-for.
- *
- * @author michaelkober
- */
-class ActorForFactoryBean extends AbstractFactoryBean[AnyRef] with Logging with ApplicationContextAware {
- import StringReflect._
- import AkkaSpringConfigurationTags._
-
- @BeanProperty var interface: String = ""
- @BeanProperty var host: String = ""
- @BeanProperty var port: String = ""
- @BeanProperty var serviceName: String = ""
- @BeanProperty var applicationContext: ApplicationContext = _
-
- override def isSingleton = false
-
- /*
- * @see org.springframework.beans.factory.FactoryBean#getObjectType()
- */
- def getObjectType: Class[AnyRef] = classOf[AnyRef]
-
- /*
- * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
- */
- def createInstance: AnyRef = {
- if (interface.isEmpty) {
- RemoteClient.actorFor(serviceName, host, port.toInt)
- } else {
- RemoteClient.typedActorFor(interface.toClass, serviceName, host, port.toInt)
- }
- }
-}
-
diff --git a/akka-spring/src/main/scala/akka/ActorParser.scala b/akka-spring/src/main/scala/akka/ActorParser.scala
deleted file mode 100644
index da059d2f8e..0000000000
--- a/akka-spring/src/main/scala/akka/ActorParser.scala
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.util.xml.DomUtils
-import org.w3c.dom.Element
-import scala.collection.JavaConversions._
-import akka.util.Logging
-
-/**
- * Parser trait for custom namespace configuration for typed-actor.
- * @author michaelkober
- * @author Johan Rask
- * @author Martin Krasser
- */
-trait ActorParser extends BeanParser with DispatcherParser {
- import AkkaSpringConfigurationTags._
-
- /**
- * Parses the given element and returns a TypedActorProperties.
- * @param element dom element to parse
- * @return configuration for the typed actor
- */
- def parseActor(element: Element): ActorProperties = {
- val objectProperties = new ActorProperties()
- val remoteElement = DomUtils.getChildElementByTagName(element, REMOTE_TAG);
- val dispatcherElement = DomUtils.getChildElementByTagName(element, DISPATCHER_TAG)
- val propertyEntries = DomUtils.getChildElementsByTagName(element, PROPERTYENTRY_TAG)
-
- if (remoteElement ne null) {
- objectProperties.host = mandatory(remoteElement, HOST)
- objectProperties.port = mandatory(remoteElement, PORT)
- objectProperties.serverManaged = (remoteElement.getAttribute(MANAGED_BY) ne null) && (remoteElement.getAttribute(MANAGED_BY).equals(SERVER_MANAGED))
- val serviceName = remoteElement.getAttribute(SERVICE_NAME)
- if ((serviceName ne null) && (!serviceName.isEmpty)) {
- objectProperties.serviceName = serviceName
- objectProperties.serverManaged = true
- }
- }
-
- if (dispatcherElement ne null) {
- val dispatcherProperties = parseDispatcher(dispatcherElement)
- objectProperties.dispatcher = dispatcherProperties
- }
-
- for (element <- propertyEntries) {
- val entry = new PropertyEntry
- entry.name = element.getAttribute("name");
- entry.value = element.getAttribute("value")
- entry.ref = element.getAttribute("ref")
- objectProperties.propertyEntries.add(entry)
- }
-
- objectProperties.timeoutStr = element.getAttribute(TIMEOUT)
- objectProperties.target = if (element.getAttribute(IMPLEMENTATION).isEmpty) null else element.getAttribute(IMPLEMENTATION)
- objectProperties.beanRef = if (element.getAttribute(BEANREF).isEmpty) null else element.getAttribute(BEANREF)
-
- if (objectProperties.target == null && objectProperties.beanRef == null) {
- throw new IllegalArgumentException("Mandatory attribute missing, you need to provide either implementation or ref ")
- }
-
- if (element.hasAttribute(INTERFACE)) {
- objectProperties.interface = element.getAttribute(INTERFACE)
- }
- if (element.hasAttribute(LIFECYCLE)) {
- objectProperties.lifecycle = element.getAttribute(LIFECYCLE)
- }
- if (element.hasAttribute(SCOPE)) {
- objectProperties.scope = element.getAttribute(SCOPE)
- }
-
- objectProperties
- }
-
-}
-
-/**
- * Parser trait for custom namespace configuration for RemoteClient actor-for.
- * @author michaelkober
- */
-trait ActorForParser extends BeanParser {
- import AkkaSpringConfigurationTags._
-
- /**
- * Parses the given element and returns a ActorForProperties.
- * @param element dom element to parse
- * @return configuration for the typed actor
- */
- def parseActorFor(element: Element): ActorForProperties = {
- val objectProperties = new ActorForProperties()
-
- objectProperties.host = mandatory(element, HOST)
- objectProperties.port = mandatory(element, PORT)
- objectProperties.serviceName = mandatory(element, SERVICE_NAME)
- if (element.hasAttribute(INTERFACE)) {
- objectProperties.interface = element.getAttribute(INTERFACE)
- }
- objectProperties
- }
-
-}
-
-/**
- * Base trait with utility methods for bean parsing.
- */
-trait BeanParser extends Logging {
-
- /**
- * Get a mandatory element attribute.
- * @param element the element with the mandatory attribute
- * @param attribute name of the mandatory attribute
- */
- def mandatory(element: Element, attribute: String): String = {
- if ((element.getAttribute(attribute) eq null) || (element.getAttribute(attribute).isEmpty)) {
- throw new IllegalArgumentException("Mandatory attribute missing: " + attribute)
- } else {
- element.getAttribute(attribute)
- }
- }
-
- /**
- * Get a mandatory child element.
- * @param element the parent element
- * @param childName name of the mandatory child element
- */
- def mandatoryElement(element: Element, childName: String): Element = {
- val childElement = DomUtils.getChildElementByTagName(element, childName);
- if (childElement eq null) {
- throw new IllegalArgumentException("Mandatory element missing: ''")
- } else {
- childElement
- }
- }
-
-}
-
-
-/**
- * Parser trait for custom namespace for Akka dispatcher configuration.
- * @author michaelkober
- */
-trait DispatcherParser extends BeanParser {
- import AkkaSpringConfigurationTags._
-
- /**
- * Parses the given element and returns a DispatcherProperties.
- * @param element dom element to parse
- * @return configuration for the dispatcher
- */
- def parseDispatcher(element: Element): DispatcherProperties = {
- val properties = new DispatcherProperties()
- var dispatcherElement = element
- if (hasRef(element)) {
- val ref = element.getAttribute(REF)
- dispatcherElement = element.getOwnerDocument.getElementById(ref)
- if (dispatcherElement eq null) {
- throw new IllegalArgumentException("Referenced dispatcher not found: '" + ref + "'")
- }
- }
-
- properties.dispatcherType = mandatory(dispatcherElement, TYPE)
- if (properties.dispatcherType == THREAD_BASED) {
- val allowedParentNodes = "akka:typed-actor" :: "akka:untyped-actor" :: "typed-actor" :: "untyped-actor" :: Nil
- if (!allowedParentNodes.contains(dispatcherElement.getParentNode.getNodeName)) {
- throw new IllegalArgumentException("Thread based dispatcher must be nested in 'typed-actor' or 'untyped-actor' element!")
- }
- }
-
- if (properties.dispatcherType == HAWT) { // no name for HawtDispatcher
- properties.name = dispatcherElement.getAttribute(NAME)
- if (dispatcherElement.hasAttribute(AGGREGATE)) {
- properties.aggregate = dispatcherElement.getAttribute(AGGREGATE).toBoolean
- }
- } else {
- properties.name = mandatory(dispatcherElement, NAME)
- }
-
- val threadPoolElement = DomUtils.getChildElementByTagName(dispatcherElement, THREAD_POOL_TAG);
- if (threadPoolElement ne null) {
- if (properties.dispatcherType == THREAD_BASED) {
- throw new IllegalArgumentException("Element 'thread-pool' not allowed for this dispatcher type.")
- }
- val threadPoolProperties = parseThreadPool(threadPoolElement)
- properties.threadPool = threadPoolProperties
- }
- properties
- }
-
- /**
- * Parses the given element and returns a ThreadPoolProperties.
- * @param element dom element to parse
- * @return configuration for the thread pool
- */
- def parseThreadPool(element: Element): ThreadPoolProperties = {
- val properties = new ThreadPoolProperties()
- properties.queue = element.getAttribute(QUEUE)
- if (element.hasAttribute(CAPACITY)) {
- properties.capacity = element.getAttribute(CAPACITY).toInt
- }
- if (element.hasAttribute(BOUND)) {
- properties.bound = element.getAttribute(BOUND).toInt
- }
- if (element.hasAttribute(FAIRNESS)) {
- properties.fairness = element.getAttribute(FAIRNESS).toBoolean
- }
- if (element.hasAttribute(CORE_POOL_SIZE)) {
- properties.corePoolSize = element.getAttribute(CORE_POOL_SIZE).toInt
- }
- if (element.hasAttribute(MAX_POOL_SIZE)) {
- properties.maxPoolSize = element.getAttribute(MAX_POOL_SIZE).toInt
- }
- if (element.hasAttribute(KEEP_ALIVE)) {
- properties.keepAlive = element.getAttribute(KEEP_ALIVE).toLong
- }
- if (element.hasAttribute(REJECTION_POLICY)) {
- properties.rejectionPolicy = element.getAttribute(REJECTION_POLICY)
- }
- if (element.hasAttribute(MAILBOX_CAPACITY)) {
- properties.mailboxCapacity = element.getAttribute(MAILBOX_CAPACITY).toInt
- }
- properties
- }
-
- def hasRef(element: Element): Boolean = {
- val ref = element.getAttribute(REF)
- (ref ne null) && !ref.isEmpty
- }
-
-}
-
diff --git a/akka-spring/src/main/scala/akka/ActorProperties.scala b/akka-spring/src/main/scala/akka/ActorProperties.scala
deleted file mode 100644
index d0e7c49392..0000000000
--- a/akka-spring/src/main/scala/akka/ActorProperties.scala
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.spring
-
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-import AkkaSpringConfigurationTags._
-
-/**
- * Data container for actor configuration data.
- * @author michaelkober
- * @author Martin Krasser
- */
-class ActorProperties {
- var typed: String = ""
- var target: String = ""
- var beanRef: String = ""
- var timeoutStr: String = ""
- var interface: String = ""
- var host: String = ""
- var port: String = ""
- var serverManaged: Boolean = false
- var serviceName: String = ""
- var lifecycle: String = ""
- var scope:String = VAL_SCOPE_SINGLETON
- var dispatcher: DispatcherProperties = _
- var propertyEntries = new PropertyEntries()
-
-
- /**
- * Sets the properties to the given builder.
- * @param builder bean definition builder
- */
- def setAsProperties(builder: BeanDefinitionBuilder) {
- builder.addPropertyValue("typed", typed)
- builder.addPropertyValue(HOST, host)
- builder.addPropertyValue(PORT, port)
- builder.addPropertyValue("serverManaged", serverManaged)
- builder.addPropertyValue("serviceName", serviceName)
- builder.addPropertyValue("timeoutStr", timeoutStr)
- builder.addPropertyValue(IMPLEMENTATION, target)
- builder.addPropertyValue("beanRef", beanRef)
- builder.addPropertyValue(INTERFACE, interface)
- builder.addPropertyValue(LIFECYCLE, lifecycle)
- builder.addPropertyValue(SCOPE, scope)
- builder.addPropertyValue(DISPATCHER_TAG, dispatcher)
- builder.addPropertyValue(PROPERTYENTRY_TAG,propertyEntries)
- }
-
- def timeout() : Long = {
- if (!timeoutStr.isEmpty) timeoutStr.toLong else -1L
- }
-
-}
-
-/**
- * Data container for actor configuration data.
- * @author michaelkober
- */
-class ActorForProperties {
- var interface: String = ""
- var host: String = ""
- var port: String = ""
- var serviceName: String = ""
-
- /**
- * Sets the properties to the given builder.
- * @param builder bean definition builder
- */
- def setAsProperties(builder: BeanDefinitionBuilder) {
- builder.addPropertyValue(HOST, host)
- builder.addPropertyValue(PORT, port)
- builder.addPropertyValue("serviceName", serviceName)
- builder.addPropertyValue(INTERFACE, interface)
- }
-
-}
diff --git a/akka-spring/src/main/scala/akka/AkkaNamespaceHandler.scala b/akka-spring/src/main/scala/akka/AkkaNamespaceHandler.scala
deleted file mode 100644
index 38041a3ea4..0000000000
--- a/akka-spring/src/main/scala/akka/AkkaNamespaceHandler.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.xml.NamespaceHandlerSupport
-import AkkaSpringConfigurationTags._
-
-/**
- * Custom spring namespace handler for Akka.
- * @author michaelkober
- */
-class AkkaNamespaceHandler extends NamespaceHandlerSupport {
- def init = {
- registerBeanDefinitionParser(CONFIG_TAG, new ConfigBeanDefinitionParser());
- registerBeanDefinitionParser(TYPED_ACTOR_TAG, new TypedActorBeanDefinitionParser())
- registerBeanDefinitionParser(UNTYPED_ACTOR_TAG, new UntypedActorBeanDefinitionParser())
- registerBeanDefinitionParser(SUPERVISION_TAG, new SupervisionBeanDefinitionParser())
- registerBeanDefinitionParser(DISPATCHER_TAG, new DispatcherBeanDefinitionParser())
- registerBeanDefinitionParser(CAMEL_SERVICE_TAG, new CamelServiceBeanDefinitionParser)
- registerBeanDefinitionParser(ACTOR_FOR_TAG, new ActorForBeanDefinitionParser());
- }
-}
diff --git a/akka-spring/src/main/scala/akka/AkkaSpringConfigurationTags.scala b/akka-spring/src/main/scala/akka/AkkaSpringConfigurationTags.scala
deleted file mode 100644
index 6548495070..0000000000
--- a/akka-spring/src/main/scala/akka/AkkaSpringConfigurationTags.scala
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-/**
- * XML configuration tags.
- * @author michaelkober
- * @author Martin Krasser
- */
-object AkkaSpringConfigurationTags {
-
- // --- TAGS
- //
- // top level tags
- val CONFIG_TAG = "property-placeholder"
- val TYPED_ACTOR_TAG = "typed-actor"
- val UNTYPED_ACTOR_TAG = "untyped-actor"
- val SUPERVISION_TAG = "supervision"
- val DISPATCHER_TAG = "dispatcher"
- val PROPERTYENTRY_TAG = "property"
- val CAMEL_SERVICE_TAG = "camel-service"
- val ACTOR_FOR_TAG = "actor-for"
-
- // actor sub tags
- val REMOTE_TAG = "remote"
-
- // superivision sub tags
- val TYPED_ACTORS_TAG = "typed-actors"
- val UNTYPED_ACTORS_TAG = "untyped-actors"
- val STRATEGY_TAG = "restart-strategy"
- val TRAP_EXISTS_TAG = "trap-exits"
- val TRAP_EXIT_TAG = "trap-exit"
-
- // dispatcher sub tags
- val THREAD_POOL_TAG = "thread-pool"
-
- // camel-service sub tags
- val CAMEL_CONTEXT_TAG = "camel-context"
-
- // --- ATTRIBUTES
- //
- // actor attributes
- val TIMEOUT = "timeout"
- val IMPLEMENTATION = "implementation"
- val BEANREF = "ref"
- val INTERFACE = "interface"
- val HOST = "host"
- val PORT = "port"
- val MANAGED_BY = "managed-by"
- val SERVICE_NAME = "service-name"
- val LIFECYCLE = "lifecycle"
- val SCOPE = "scope"
-
- // supervision attributes
- val FAILOVER = "failover"
- val RETRIES = "retries"
- val TIME_RANGE = "timerange"
-
- // dispatcher attributes
- val NAME = "name"
- val REF = "ref"
- val TYPE = "type"
- val AGGREGATE = "aggregate" // HawtDispatcher
-
- // thread pool attributes
- val QUEUE = "queue"
- val CAPACITY = "capacity"
- val FAIRNESS = "fairness"
- val CORE_POOL_SIZE = "core-pool-size"
- val MAX_POOL_SIZE = "max-pool-size"
- val KEEP_ALIVE = "keep-alive"
- val BOUND ="bound"
- val REJECTION_POLICY ="rejection-policy"
- val MAILBOX_CAPACITY ="mailbox-capacity"
-
- // config attribute
- val LOCATION = "location"
-
- // --- VALUES
- //
- // Lifecycle
- val VAL_LIFECYCYLE_TEMPORARY = "temporary"
- val VAL_LIFECYCYLE_PERMANENT = "permanent"
-
- val VAL_SCOPE_SINGLETON = "singleton"
- val VAL_SCOPE_PROTOTYPE = "prototype"
-
- // Failover
- val VAL_ALL_FOR_ONE = "AllForOne"
- val VAL_ONE_FOR_ONE = "OneForOne"
-
- // rejection policies
- val VAL_ABORT_POLICY = "abort-policy"
- val VAL_CALLER_RUNS_POLICY = "caller-runs-policy"
- val VAL_DISCARD_OLDEST_POLICY = "discard-oldest-policy"
- val VAL_DISCARD_POLICY = "discard-policy"
-
- // dispatcher queue types
- val VAL_BOUNDED_LINKED_BLOCKING_QUEUE = "bounded-linked-blocking-queue"
- val VAL_UNBOUNDED_LINKED_BLOCKING_QUEUE = "unbounded-linked-blocking-queue"
- val VAL_SYNCHRONOUS_QUEUE = "synchronous-queue"
- val VAL_BOUNDED_ARRAY_BLOCKING_QUEUE = "bounded-array-blocking-queue"
-
- // dispatcher types
- val EXECUTOR_BASED_EVENT_DRIVEN = "executor-based-event-driven"
- val EXECUTOR_BASED_EVENT_DRIVEN_WORK_STEALING = "executor-based-event-driven-work-stealing"
- val THREAD_BASED = "thread-based"
- val HAWT = "hawt"
-
- // managed by types
- val SERVER_MANAGED = "server"
- val CLIENT_MANAGED = "client"
-
-}
diff --git a/akka-spring/src/main/scala/akka/CamelServiceBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/CamelServiceBeanDefinitionParser.scala
deleted file mode 100644
index 4025a831a8..0000000000
--- a/akka-spring/src/main/scala/akka/CamelServiceBeanDefinitionParser.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-import org.springframework.beans.factory.xml.{ParserContext, AbstractSingleBeanDefinitionParser}
-import org.springframework.util.xml.DomUtils
-import org.w3c.dom.Element
-
-import akka.spring.AkkaSpringConfigurationTags._
-
-
-/**
- * Parser for <camel-service> elements.
- *
- * @author Martin Krasser
- */
-class CamelServiceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
- /**
- * Parses the <camel-service> element. If a nested <camel-context> element
- * is defined then the referenced context is set on the {@link CamelServiceFactoryBean}.
- */
- override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- val camelContextElement = DomUtils.getChildElementByTagName(element, CAMEL_CONTEXT_TAG);
- if (camelContextElement ne null) {
- val camelContextReference = camelContextElement.getAttribute("ref")
- builder.addPropertyReference("camelContext", camelContextReference)
- }
- }
-
- /**
- * Returns the class of {@link CamelServiceFactoryBean}
- */
- override def getBeanClass(element: Element): Class[_] = classOf[CamelServiceFactoryBean]
-
- /**
- * Returns true.
- */
- override def shouldGenerateIdAsFallback = true
-}
diff --git a/akka-spring/src/main/scala/akka/CamelServiceFactoryBean.scala b/akka-spring/src/main/scala/akka/CamelServiceFactoryBean.scala
deleted file mode 100644
index 337413f0eb..0000000000
--- a/akka-spring/src/main/scala/akka/CamelServiceFactoryBean.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.apache.camel.CamelContext
-import org.springframework.beans.factory.{DisposableBean, InitializingBean, FactoryBean}
-
-import akka.camel.{CamelContextManager, CamelService, CamelServiceFactory}
-
-/**
- * Factory bean for a {@link CamelService}.
- *
- * @author Martin Krasser
- */
-class CamelServiceFactoryBean extends FactoryBean[CamelService] with InitializingBean with DisposableBean {
- @scala.reflect.BeanProperty var camelContext: CamelContext = _
-
- var instance: CamelService = _
-
- def isSingleton = true
-
- def getObjectType = classOf[CamelService]
-
- def getObject = instance
-
- /**
- * Initializes the {@link CamelContextManager} with camelService if defined, then
- * creates and starts the {@link CamelService} singleton.
- */
- def afterPropertiesSet = {
- if (camelContext ne null) {
- CamelContextManager.init(camelContext)
- }
- instance = CamelServiceFactory.createCamelService
- instance.start
- }
-
- /**
- * Stops the {@link CamelService} singleton.
- */
- def destroy = {
- instance.stop
- }
-}
diff --git a/akka-spring/src/main/scala/akka/ConfiggyPropertyPlaceholderConfigurer.scala b/akka-spring/src/main/scala/akka/ConfiggyPropertyPlaceholderConfigurer.scala
deleted file mode 100644
index e32c331688..0000000000
--- a/akka-spring/src/main/scala/akka/ConfiggyPropertyPlaceholderConfigurer.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
-import org.springframework.core.io.Resource
-import net.lag.configgy.Configgy
-import java.util.Properties
-
-/**
- * ConfiggyPropertyPlaceholderConfigurer. Property resource configurer for configgy files.
- */
-class ConfiggyPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
-
- /**
- * Sets the akka properties as local properties, leaves the location empty.
- * @param configgyResource akka.conf
- */
- override def setLocation(configgyResource: Resource) {
- if (configgyResource eq null) throw new IllegalArgumentException("Property 'config' must be set")
- val properties = loadAkkaConfig(configgyResource)
- setProperties(properties)
- }
-
- /**
- * Load the akka.conf and transform to properties.
- */
- private def loadAkkaConfig(configgyResource: Resource) : Properties = {
- Configgy.configure(configgyResource.getFile.getPath)
- val config = Configgy.config
- val properties = new Properties()
- config.asMap.foreach {case (k, v) => properties.put(k, v); println("(k,v)=" + k + ", " + v)}
- properties
- }
-
-}
diff --git a/akka-spring/src/main/scala/akka/DispatcherBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/DispatcherBeanDefinitionParser.scala
deleted file mode 100644
index 4f2a40469f..0000000000
--- a/akka-spring/src/main/scala/akka/DispatcherBeanDefinitionParser.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.w3c.dom.Element
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-import org.springframework.beans.factory.xml.{ParserContext, AbstractSingleBeanDefinitionParser}
-
-
-/**
- * Parser for custom namespace configuration.
- * @author michaelkober
- */
-class DispatcherBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActorParser with DispatcherParser {
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
- */
- override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- val dispatcherProperties = parseDispatcher(element)
- dispatcherProperties.setAsProperties(builder)
- }
-
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
- */
- override def getBeanClass(element: Element): Class[_] = classOf[DispatcherFactoryBean]
-}
diff --git a/akka-spring/src/main/scala/akka/DispatcherFactoryBean.scala b/akka-spring/src/main/scala/akka/DispatcherFactoryBean.scala
deleted file mode 100644
index bdcfca5d33..0000000000
--- a/akka-spring/src/main/scala/akka/DispatcherFactoryBean.scala
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.config.AbstractFactoryBean
-import akka.config.Supervision._
-import AkkaSpringConfigurationTags._
-import reflect.BeanProperty
-import akka.actor.ActorRef
-import java.util.concurrent.RejectedExecutionHandler
-import java.util.concurrent.ThreadPoolExecutor.{DiscardPolicy, DiscardOldestPolicy, CallerRunsPolicy, AbortPolicy}
-import akka.dispatch._
-import akka.util.Duration
-
-/**
- * Reusable factory method for dispatchers.
- */
-object DispatcherFactoryBean {
-
- /**
- * factory method for dispatchers
- * @param properties dispatcher properties
- * @param actorRef actorRef needed for thread based dispatcher
- */
- def createNewInstance(properties: DispatcherProperties, actorRef: Option[ActorRef] = None): MessageDispatcher = {
-
- //Creates a ThreadPoolConfigDispatcherBuilder and applies the configuration to it
- def configureThreadPool(createDispatcher: => (ThreadPoolConfig) => MessageDispatcher): ThreadPoolConfigDispatcherBuilder = {
- if ((properties.threadPool ne null) && (properties.threadPool.queue ne null)) {
- import ThreadPoolConfigDispatcherBuilder.conf_?
- import properties._
- val queueDef = Some(threadPool.queue)
- val corePoolSize = if (threadPool.corePoolSize > -1) Some(threadPool.corePoolSize) else None
- val maxPoolSize = if (threadPool.maxPoolSize > -1) Some(threadPool.maxPoolSize) else None
- val keepAlive = if (threadPool.keepAlive > -1) Some(threadPool.keepAlive) else None
- val executorBounds = if (threadPool.bound > -1) Some(threadPool.bound) else None
- val flowHandler = threadPool.rejectionPolicy match {
- case null | "" => None
- case "abort-policy" => Some(new AbortPolicy())
- case "caller-runs-policy" => Some(new CallerRunsPolicy())
- case "discard-oldest-policy" => Some(new DiscardOldestPolicy())
- case "discard-policy" => Some(new DiscardPolicy())
- case x => throw new IllegalArgumentException("Unknown rejection-policy '" + x + "'")
- }
-
- //Apply the following options to the config if they are present in the cfg
- ThreadPoolConfigDispatcherBuilder(createDispatcher,ThreadPoolConfig()).configure(
- conf_?(queueDef )(definition => definition match {
- case VAL_BOUNDED_ARRAY_BLOCKING_QUEUE =>
- _.withNewThreadPoolWithArrayBlockingQueueWithCapacityAndFairness(threadPool.capacity,threadPool.fairness)
- case VAL_UNBOUNDED_LINKED_BLOCKING_QUEUE if threadPool.capacity > -1 =>
- _.withNewThreadPoolWithLinkedBlockingQueueWithCapacity(threadPool.capacity)
- case VAL_UNBOUNDED_LINKED_BLOCKING_QUEUE if threadPool.capacity <= 0 =>
- _.withNewThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity
- case VAL_BOUNDED_LINKED_BLOCKING_QUEUE =>
- _.withNewBoundedThreadPoolWithLinkedBlockingQueueWithUnboundedCapacity(threadPool.bound)
- case VAL_SYNCHRONOUS_QUEUE =>
- _.withNewThreadPoolWithSynchronousQueueWithFairness(threadPool.fairness)
- case unknown =>
- throw new IllegalArgumentException("Unknown queue type " + unknown)
- }),
- conf_?(keepAlive )(time => _.setKeepAliveTimeInMillis(time)),
- conf_?(corePoolSize )(count => _.setCorePoolSize(count)),
- conf_?(maxPoolSize )(count => _.setMaxPoolSize(count)),
- conf_?(executorBounds)(bounds => _.setExecutorBounds(bounds)),
- conf_?(flowHandler )(policy => _.setRejectionPolicy(policy)))
- }
- else
- ThreadPoolConfigDispatcherBuilder(createDispatcher,ThreadPoolConfig())
- }
-
- //Create the dispatcher
- properties.dispatcherType match {
- case EXECUTOR_BASED_EVENT_DRIVEN =>
- configureThreadPool(poolConfig => new ExecutorBasedEventDrivenDispatcher(properties.name, poolConfig)).build
- case EXECUTOR_BASED_EVENT_DRIVEN_WORK_STEALING =>
- configureThreadPool(poolConfig => new ExecutorBasedEventDrivenWorkStealingDispatcher(properties.name,Dispatchers.MAILBOX_TYPE,poolConfig)).build
- case THREAD_BASED if actorRef.isEmpty =>
- throw new IllegalArgumentException("Need an ActorRef to create a thread based dispatcher.")
- case THREAD_BASED if actorRef.isDefined =>
- Dispatchers.newThreadBasedDispatcher(actorRef.get)
- case HAWT =>
- Dispatchers.newHawtDispatcher(properties.aggregate)
- case unknown =>
- throw new IllegalArgumentException("Unknown dispatcher type " + unknown)
- }
- }
-}
-
-/**
- * Factory bean for supervisor configuration.
- * @author michaelkober
- */
-class DispatcherFactoryBean extends AbstractFactoryBean[MessageDispatcher] {
- @BeanProperty var properties: DispatcherProperties = _
-
- /*
- * @see org.springframework.beans.factory.FactoryBean#getObjectType()
- */
- def getObjectType: Class[MessageDispatcher] = classOf[MessageDispatcher]
-
- /*
- * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
- */
- def createInstance: MessageDispatcher = {
- import DispatcherFactoryBean._
- createNewInstance(properties)
- }
-}
diff --git a/akka-spring/src/main/scala/akka/DispatcherProperties.scala b/akka-spring/src/main/scala/akka/DispatcherProperties.scala
deleted file mode 100644
index 8dd33602df..0000000000
--- a/akka-spring/src/main/scala/akka/DispatcherProperties.scala
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-
-/**
- * Data container for dispatcher configuration data.
- * @author michaelkober
- */
-class DispatcherProperties {
- var ref: String = ""
- var dispatcherType: String = ""
- var name: String = ""
- var threadPool: ThreadPoolProperties = _
- var aggregate = true
-
- /**
- * Sets the properties to the given builder.
- * @param builder bean definition builder
- */
- def setAsProperties(builder: BeanDefinitionBuilder) {
- builder.addPropertyValue("properties", this)
- }
-
- override def toString : String = {
- "DispatcherProperties[ref=" + ref +
- ", dispatcher-type=" + dispatcherType +
- ", name=" + name +
- ", threadPool=" + threadPool + "]"
- }
-}
-
-/**
- * Data container for thread pool configuration data.
- * @author michaelkober
- */
-class ThreadPoolProperties {
- var queue = ""
- var bound = -1
- var capacity = -1
- var fairness = false
- var corePoolSize = -1
- var maxPoolSize = -1
- var keepAlive = -1L
- var rejectionPolicy = ""
- var mailboxCapacity = -1
-
- override def toString : String = {
- "ThreadPoolProperties[queue=" + queue +
- ", bound=" + bound +
- ", capacity=" + capacity +
- ", fairness=" + fairness +
- ", corePoolSize=" + corePoolSize +
- ", maxPoolSize=" + maxPoolSize +
- ", keepAlive=" + keepAlive +
- ", policy=" + rejectionPolicy +
- ", mailboxCapacity=" + mailboxCapacity + "]"
- }
-}
diff --git a/akka-spring/src/main/scala/akka/PropertyEntries.scala b/akka-spring/src/main/scala/akka/PropertyEntries.scala
deleted file mode 100644
index 9f6493bbb3..0000000000
--- a/akka-spring/src/main/scala/akka/PropertyEntries.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-
-import scala.collection.mutable._
-
-/**
- * Simple container for Properties
- * @author Johan Rask
- */
-class PropertyEntries {
- var entryList: ListBuffer[PropertyEntry] = ListBuffer[PropertyEntry]()
-
- def add(entry: PropertyEntry) = {
- entryList.append(entry)
- }
-}
-
-/**
- * Represents a property element
- * @author Johan Rask
- */
-class PropertyEntry {
- var name: String = _
- var value: String = null
- var ref: String = null
-
-
- override def toString(): String = {
- format("name = %s,value = %s, ref = %s", name, value, ref)
- }
-}
-
diff --git a/akka-spring/src/main/scala/akka/StringReflect.scala b/akka-spring/src/main/scala/akka/StringReflect.scala
deleted file mode 100644
index 2b77f8caa6..0000000000
--- a/akka-spring/src/main/scala/akka/StringReflect.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-
-package akka.spring
-
-object StringReflect {
-
- /**
- * Implicit conversion from String to StringReflect.
- */
- implicit def string2StringReflect(x: String) = new StringReflect(x)
-}
-
-/**
- * Reflection helper class.
- * @author michaelkober
- */
-class StringReflect(val self: String) {
- if ((self eq null) || self == "") throw new IllegalArgumentException("Class name can't be null or empty string [" + self + "]")
- def toClass[T <: AnyRef]: Class[T] = {
- val clazz = Class.forName(self)
- clazz.asInstanceOf[Class[T]]
- }
-}
diff --git a/akka-spring/src/main/scala/akka/SupervisionBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/SupervisionBeanDefinitionParser.scala
deleted file mode 100644
index c4753d1d5b..0000000000
--- a/akka-spring/src/main/scala/akka/SupervisionBeanDefinitionParser.scala
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import akka.util.Logging
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-import org.springframework.beans.factory.xml.{ParserContext, AbstractSingleBeanDefinitionParser}
-import akka.config.Supervision._
-import AkkaSpringConfigurationTags._
-
-
-import org.w3c.dom.Element
-import org.springframework.util.xml.DomUtils
-
-
-/**
- * Parser for custom namespace for Akka declarative supervisor configuration.
- * @author michaelkober
- */
-class SupervisionBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with ActorParser {
- /* (non-Javadoc)
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#doParse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext, org.springframework.beans.factory.support.BeanDefinitionBuilder)
- */
- override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) {
- parseSupervisor(element, builder)
- }
-
- /**
- * made accessible for testing
- */
- private[akka] def parseSupervisor(element: Element, builder: BeanDefinitionBuilder) {
- val strategyElement = mandatoryElement(element, STRATEGY_TAG)
- val typedActorsElement = DomUtils.getChildElementByTagName(element, TYPED_ACTORS_TAG)
- val untypedActorsElement = DomUtils.getChildElementByTagName(element, UNTYPED_ACTORS_TAG)
- if ((typedActorsElement eq null) && (untypedActorsElement eq null)) {
- throw new IllegalArgumentException("One of 'akka:typed-actors' or 'akka:untyped-actors' needed.")
- }
- parseRestartStrategy(strategyElement, builder)
- if (typedActorsElement ne null) {
- builder.addPropertyValue("typed", AkkaSpringConfigurationTags.TYPED_ACTOR_TAG)
- parseTypedActorList(typedActorsElement, builder)
- } else {
- builder.addPropertyValue("typed", AkkaSpringConfigurationTags.UNTYPED_ACTOR_TAG)
- parseUntypedActorList(untypedActorsElement, builder)
- }
- }
-
- private[akka] def parseRestartStrategy(element: Element, builder: BeanDefinitionBuilder) {
- val failover = mandatory(element, FAILOVER)
- val timeRange = mandatory(element, TIME_RANGE).toInt
- val retries = mandatory(element, RETRIES).toInt
- val trapExitsElement = mandatoryElement(element, TRAP_EXISTS_TAG)
- val trapExceptions = parseTrapExits(trapExitsElement)
-
- val restartStrategy = failover match {
- case "AllForOne" => new AllForOneStrategy(trapExceptions, retries, timeRange)
- case "OneForOne" => new OneForOneStrategy(trapExceptions, retries, timeRange)
- case _ => new OneForOneStrategy(trapExceptions, retries, timeRange) //Default to OneForOne
- }
- builder.addPropertyValue("restartStrategy", restartStrategy)
- }
-
- private[akka] def parseTypedActorList(element: Element, builder: BeanDefinitionBuilder) {
- val typedActors = DomUtils.getChildElementsByTagName(element, TYPED_ACTOR_TAG).toArray.toList.asInstanceOf[List[Element]]
- val actorProperties = typedActors.map(parseActor(_))
- builder.addPropertyValue("supervised", actorProperties)
- }
-
- private[akka] def parseUntypedActorList(element: Element, builder: BeanDefinitionBuilder) {
- val untypedActors = DomUtils.getChildElementsByTagName(element, UNTYPED_ACTOR_TAG).toArray.toList.asInstanceOf[List[Element]]
- val actorProperties = untypedActors.map(parseActor(_))
- builder.addPropertyValue("supervised", actorProperties)
- }
-
- private def parseTrapExits(element: Element): Array[Class[_ <: Throwable]] = {
- import StringReflect._
- val trapExits = DomUtils.getChildElementsByTagName(element, TRAP_EXIT_TAG).toArray.toList.asInstanceOf[List[Element]]
- trapExits.map(DomUtils.getTextValue(_).toClass.asInstanceOf[Class[_ <: Throwable]]).toArray
- }
-
- /*
- * @see org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser#getBeanClass(org.w3c.dom.Element)
- */
- override def getBeanClass(element: Element): Class[_] = classOf[SupervisionFactoryBean]
-}
diff --git a/akka-spring/src/main/scala/akka/SupervisionFactoryBean.scala b/akka-spring/src/main/scala/akka/SupervisionFactoryBean.scala
deleted file mode 100644
index 5e88374f18..0000000000
--- a/akka-spring/src/main/scala/akka/SupervisionFactoryBean.scala
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.springframework.beans.factory.config.AbstractFactoryBean
-import akka.config.Supervision._
-import akka.actor.{Supervisor, SupervisorFactory, Actor}
-import AkkaSpringConfigurationTags._
-import reflect.BeanProperty
-import akka.config.{TypedActorConfigurator, RemoteAddress}
-
-/**
- * Factory bean for supervisor configuration.
- * @author michaelkober
- */
-class SupervisionFactoryBean extends AbstractFactoryBean[AnyRef] {
- @BeanProperty var restartStrategy: FaultHandlingStrategy = _
- @BeanProperty var supervised: List[ActorProperties] = _
- @BeanProperty var typed: String = ""
-
- /*
- * @see org.springframework.beans.factory.FactoryBean#getObjectType()
- */
- def getObjectType: Class[AnyRef] = classOf[AnyRef]
-
- /*
- * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
- */
- def createInstance: AnyRef = typed match {
- case AkkaSpringConfigurationTags.TYPED_ACTOR_TAG => createInstanceForTypedActors
- case AkkaSpringConfigurationTags.UNTYPED_ACTOR_TAG => createInstanceForUntypedActors
- }
-
- private def createInstanceForTypedActors() : TypedActorConfigurator = {
- val configurator = new TypedActorConfigurator()
- configurator.configure(
- restartStrategy,
- supervised.map(createComponent(_)).toArray
- ).supervise
-
- }
-
- private def createInstanceForUntypedActors() : Supervisor = {
- val factory = new SupervisorFactory(
- new SupervisorConfig(
- restartStrategy,
- supervised.map(createSupervise(_))))
- factory.newInstance
- }
-
- /**
- * Create configuration for TypedActor
- */
- private[akka] def createComponent(props: ActorProperties): SuperviseTypedActor = {
- import StringReflect._
- val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) Temporary else Permanent
- val isRemote = (props.host ne null) && (!props.host.isEmpty)
- val withInterface = (props.interface ne null) && (!props.interface.isEmpty)
- if (isRemote) {
- //val remote = new RemoteAddress(props.host, props.port)
- val remote = new RemoteAddress(props.host, props.port.toInt)
- if (withInterface) {
- new SuperviseTypedActor(props.interface.toClass, props.target.toClass, lifeCycle, props.timeout, remote)
- } else {
- new SuperviseTypedActor(props.target.toClass, lifeCycle, props.timeout, remote)
- }
- } else {
- if (withInterface) {
- new SuperviseTypedActor(props.interface.toClass, props.target.toClass, lifeCycle, props.timeout)
- } else {
- new SuperviseTypedActor(props.target.toClass, lifeCycle, props.timeout)
- }
- }
- }
-
- /**
- * Create configuration for UntypedActor
- */
- private[akka] def createSupervise(props: ActorProperties): Server = {
- import StringReflect._
- val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) Temporary else Permanent
- val isRemote = (props.host ne null) && (!props.host.isEmpty)
- val actorRef = Actor.actorOf(props.target.toClass)
- if (props.timeout > 0) {
- actorRef.setTimeout(props.timeout)
- }
-
- val supervise = if (isRemote) {
- val remote = new RemoteAddress(props.host, props.port.toInt)
- Supervise(actorRef, lifeCycle, remote)
- } else {
- Supervise(actorRef, lifeCycle)
- }
- supervise
- }
-}
diff --git a/akka-spring/src/test/java/akka/spring/Pojo.java b/akka-spring/src/test/java/akka/spring/Pojo.java
deleted file mode 100644
index 618adc8cc3..0000000000
--- a/akka-spring/src/test/java/akka/spring/Pojo.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package akka.spring;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-import javax.annotation.PreDestroy;
-import javax.annotation.PostConstruct;
-
-import akka.actor.*;
-
-public class Pojo extends TypedActor implements PojoInf, ApplicationContextAware {
-
- private String stringFromVal;
- private String stringFromRef;
-
- private boolean gotApplicationContext = false;
- private boolean preStartInvoked = false;
-
- public boolean gotApplicationContext() {
- return gotApplicationContext;
- }
-
- public void setApplicationContext(ApplicationContext context) {
- gotApplicationContext = true;
- }
-
- public String getStringFromVal() {
- return stringFromVal;
- }
-
- public void setStringFromVal(String s) {
- stringFromVal = s;
- }
-
- public String getStringFromRef() {
- return stringFromRef;
- }
-
- public void setStringFromRef(String s) {
- stringFromRef = s;
- }
-
- @Override
- public void preStart() {
- preStartInvoked = true;
- }
-
- public boolean isPreStartInvoked() {
- return preStartInvoked;
- }
-}
diff --git a/akka-spring/src/test/java/akka/spring/PojoInf.java b/akka-spring/src/test/java/akka/spring/PojoInf.java
deleted file mode 100644
index f73ce35814..0000000000
--- a/akka-spring/src/test/java/akka/spring/PojoInf.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package akka.spring;
-
-import javax.annotation.PreDestroy;
-import javax.annotation.PostConstruct;
-
-public interface PojoInf {
-
- public String getStringFromVal();
- public String getStringFromRef();
- public boolean gotApplicationContext();
- public boolean isPreStartInvoked();
-
-}
diff --git a/akka-spring/src/test/java/akka/spring/SampleBean.java b/akka-spring/src/test/java/akka/spring/SampleBean.java
deleted file mode 100644
index e23672d060..0000000000
--- a/akka-spring/src/test/java/akka/spring/SampleBean.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package akka.spring;
-
-import akka.actor.*;
-
-public class SampleBean extends TypedActor implements SampleBeanIntf {
-
- private boolean down;
-
- public SampleBean() {
- down = false;
- }
-
- public boolean down() {
- return down;
- }
-
- public String foo(String s) {
- return "hello " + s;
- }
-
- @Override
- public void postStop() {
- down = true;
- }
- }
diff --git a/akka-spring/src/test/java/akka/spring/SampleBeanIntf.java b/akka-spring/src/test/java/akka/spring/SampleBeanIntf.java
deleted file mode 100644
index 365275f193..0000000000
--- a/akka-spring/src/test/java/akka/spring/SampleBeanIntf.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package akka.spring;
-
-public interface SampleBeanIntf {
- public boolean down();
- public String foo(String s);
- }
diff --git a/akka-spring/src/test/java/akka/spring/SampleRoute.java b/akka-spring/src/test/java/akka/spring/SampleRoute.java
deleted file mode 100644
index fb3565661d..0000000000
--- a/akka-spring/src/test/java/akka/spring/SampleRoute.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package akka.spring;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class SampleRoute extends RouteBuilder {
-
- @Override
- public void configure() throws Exception {
- from("direct:test").to("typed-actor:sample?method=foo");
- }
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/Bar.java b/akka-spring/src/test/java/akka/spring/foo/Bar.java
deleted file mode 100644
index 36276ff108..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/Bar.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package akka.spring.foo;
-
-import java.io.IOException;
-import akka.actor.*;
-
-public class Bar extends TypedActor implements IBar {
-
- @Override
- public String getBar() {
- return "bar";
- }
-
- public void throwsIOException() throws IOException {
- throw new IOException("some IO went wrong");
- }
-
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/Foo.java b/akka-spring/src/test/java/akka/spring/foo/Foo.java
deleted file mode 100644
index 189f146e51..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/Foo.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package akka.spring.foo;
-
-import akka.actor.*;
-
-public class Foo extends TypedActor implements IFoo{
-
- public String foo() {
- return "foo";
- }
-
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/IBar.java b/akka-spring/src/test/java/akka/spring/foo/IBar.java
deleted file mode 100644
index 803b4ab50a..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/IBar.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package akka.spring.foo;
-
-public interface IBar {
-
- String getBar();
-
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/IFoo.java b/akka-spring/src/test/java/akka/spring/foo/IFoo.java
deleted file mode 100644
index e47809f3af..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/IFoo.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package akka.spring.foo;
-
-/**
- * Created by IntelliJ IDEA.
- * User: michaelkober
- * Date: Aug 11, 2010
- * Time: 12:49:58 PM
- * To change this template use File | Settings | File Templates.
- */
-public interface IFoo {
- public String foo();
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/IMyPojo.java b/akka-spring/src/test/java/akka/spring/foo/IMyPojo.java
deleted file mode 100644
index 825d797cf2..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/IMyPojo.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package akka.spring.foo;
-
-/**
- * Created by IntelliJ IDEA.
- * User: michaelkober
- * Date: Aug 11, 2010
- * Time: 12:01:00 PM
- * To change this template use File | Settings | File Templates.
- */
-public interface IMyPojo {
- public void oneWay(String message);
-
- public String getFoo();
-
- public String longRunning();
-
-
-
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/MyPojo.java b/akka-spring/src/test/java/akka/spring/foo/MyPojo.java
deleted file mode 100644
index 54019f53d2..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/MyPojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package akka.spring.foo;
-
-import akka.actor.TypedActor;
-
-import java.util.concurrent.CountDownLatch;
-
-public class MyPojo extends TypedActor implements IMyPojo {
-
- public static CountDownLatch latch = new CountDownLatch(1);
- public static String lastOneWayMessage = null;
- private String foo = "foo";
-
-
- public MyPojo() {
- }
-
- public String getFoo() {
- return foo;
- }
-
- public void oneWay(String message) {
- lastOneWayMessage = message;
- latch.countDown();
- }
-
- public String longRunning() {
- try {
- Thread.sleep(6000);
- } catch (InterruptedException e) {
- }
- return "this took long";
- }
-
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/PingActor.java b/akka-spring/src/test/java/akka/spring/foo/PingActor.java
deleted file mode 100644
index b60441699a..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/PingActor.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package akka.spring.foo;
-
-import akka.actor.UntypedActor;
-import akka.actor.ActorRef;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-import java.util.concurrent.CountDownLatch;
-
-
-/**
- * test class
- */
-public class PingActor extends UntypedActor implements ApplicationContextAware {
-
- private String stringFromVal;
- private String stringFromRef;
- public static String lastMessage = null;
- public static CountDownLatch latch = new CountDownLatch(1);
-
-
- private boolean gotApplicationContext = false;
-
-
- public void setApplicationContext(ApplicationContext context) {
- gotApplicationContext = true;
- }
-
- public boolean gotApplicationContext() {
- return gotApplicationContext;
- }
-
- public String getStringFromVal() {
- return stringFromVal;
- }
-
- public void setStringFromVal(String s) {
- stringFromVal = s;
- }
-
- public String getStringFromRef() {
- return stringFromRef;
- }
-
- public void setStringFromRef(String s) {
- stringFromRef = s;
- }
-
- private String longRunning() {
- try {
- Thread.sleep(6000);
- } catch (InterruptedException e) {
- }
- return "this took long";
- }
-
- public void onReceive(Object message) throws Exception {
- if (message instanceof String) {
- lastMessage = (String) message;
- if (message.equals("longRunning")) {
- ActorRef pongActor = UntypedActor.actorOf(PongActor.class).start();
- pongActor.sendRequestReply("longRunning", getContext());
- }
- latch.countDown();
- } else {
- throw new IllegalArgumentException("Unknown message: " + message);
- }
- }
-
-
-}
-
diff --git a/akka-spring/src/test/java/akka/spring/foo/PongActor.java b/akka-spring/src/test/java/akka/spring/foo/PongActor.java
deleted file mode 100644
index d4f19078a6..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/PongActor.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package akka.spring.foo;
-
-import akka.actor.UntypedActor;
-
-/**
- * test class
- */
-public class PongActor extends UntypedActor {
-
- public void onReceive(Object message) throws Exception {
- if (message instanceof String) {
- System.out.println("Pongeceived String message: " + message);
- getContext().replyUnsafe(message + " from " + getContext().getUuid());
- } else {
- throw new IllegalArgumentException("Unknown message: " + message);
- }
- }
-}
diff --git a/akka-spring/src/test/java/akka/spring/foo/StatefulPojo.java b/akka-spring/src/test/java/akka/spring/foo/StatefulPojo.java
deleted file mode 100644
index 8f291d2a36..0000000000
--- a/akka-spring/src/test/java/akka/spring/foo/StatefulPojo.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package akka.spring.foo;
-
-/*
-import akka.stm.TransactionalMap;
-import akka.stm.TransactionalVector;
-import akka.stm.Ref;
-import akka.actor.*;
-import akka.stm.Atomic;
-
-public class StatefulPojo extends TypedActor {
- private TransactionalMap mapState;
- private TransactionalVector vectorState;
- private Ref refState;
- private boolean isInitialized = false;
-
- @Override
- public void preStart() {
- if(!isInitialized) {
- isInitialized = new Atomic() {
- public Boolean atomically() {
- mapState = new TransactionalMap();
- vectorState = new TransactionalVector();
- refState = new Ref();
- return true;
- }
- }.execute();
- }
- }
-
- public String getMapState(String key) {
- return (String)mapState.get(key).get();
- }
-
- public String getVectorState() {
- return (String)vectorState.last();
- }
-
- public String getRefState() {
- return (String)refState.get().get();
- }
-
- public void setMapState(String key, String msg) {
- mapState.put(key, msg);
- }
-
- public void setVectorState(String msg) {
- vectorState.add(msg);
- }
-
- public void setRefState(String msg) {
- refState.swap(msg);
- }
-
- public boolean isInitialized() {
- return isInitialized;
- }
-}
-*/
diff --git a/akka-spring/src/test/resources/akka-test.conf b/akka-spring/src/test/resources/akka-test.conf
deleted file mode 100644
index 2ade509c06..0000000000
--- a/akka-spring/src/test/resources/akka-test.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-akka {
- actor {
- timeout = 2000
- }
- remote {
- server {
- service = on
- hostname = "localhost" # The hostname or IP that clients should connect to
- port = 9995 # The port clients should connect to
- connection-timeout = 1
- }
- }
-}
diff --git a/akka-spring/src/test/resources/appContext.xml b/akka-spring/src/test/resources/appContext.xml
deleted file mode 100644
index d000bd67f3..0000000000
--- a/akka-spring/src/test/resources/appContext.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/appContextCamelServiceCustom.xml b/akka-spring/src/test/resources/appContextCamelServiceCustom.xml
deleted file mode 100644
index c567d7ca32..0000000000
--- a/akka-spring/src/test/resources/appContextCamelServiceCustom.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/appContextCamelServiceDefault.xml b/akka-spring/src/test/resources/appContextCamelServiceDefault.xml
deleted file mode 100644
index e9f23a3f3d..0000000000
--- a/akka-spring/src/test/resources/appContextCamelServiceDefault.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/dispatcher-config.xml b/akka-spring/src/test/resources/dispatcher-config.xml
deleted file mode 100644
index ffbf9dffc1..0000000000
--- a/akka-spring/src/test/resources/dispatcher-config.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- java.io.IOException
- java.lang.NullPointerException
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/failing-appContext.xml b/akka-spring/src/test/resources/failing-appContext.xml
deleted file mode 100644
index 28187fe4ef..0000000000
--- a/akka-spring/src/test/resources/failing-appContext.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/property-config.xml b/akka-spring/src/test/resources/property-config.xml
deleted file mode 100644
index b3f8adaa29..0000000000
--- a/akka-spring/src/test/resources/property-config.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/server-managed-config.xml b/akka-spring/src/test/resources/server-managed-config.xml
deleted file mode 100644
index 652ff7bbd7..0000000000
--- a/akka-spring/src/test/resources/server-managed-config.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/supervisor-config.xml b/akka-spring/src/test/resources/supervisor-config.xml
deleted file mode 100644
index 8dcdc25c56..0000000000
--- a/akka-spring/src/test/resources/supervisor-config.xml
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
-
-
-
-
- java.io.IOException
- java.lang.NullPointerException
-
-
-
-
-
-
-
-
-
-
-
-
-
- java.io.IOException
- java.lang.NullPointerException
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- java.lang.Exception
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/typed-actor-config.xml b/akka-spring/src/test/resources/typed-actor-config.xml
deleted file mode 100644
index 7b994fca28..0000000000
--- a/akka-spring/src/test/resources/typed-actor-config.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- java.io.IOException
- java.lang.NullPointerException
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/resources/untyped-actor-config.xml b/akka-spring/src/test/resources/untyped-actor-config.xml
deleted file mode 100644
index e827f4c1de..0000000000
--- a/akka-spring/src/test/resources/untyped-actor-config.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/akka-spring/src/test/scala/ActorFactoryBeanTest.scala b/akka-spring/src/test/scala/ActorFactoryBeanTest.scala
deleted file mode 100644
index e6e07ed5cd..0000000000
--- a/akka-spring/src/test/scala/ActorFactoryBeanTest.scala
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import akka.actor.{ActorRegistry, ActorRef}
-import akka.spring.foo.PingActor
-
-import org.junit.runner.RunWith
-import org.springframework.context.support.ClassPathXmlApplicationContext
-import org.scalatest.junit.JUnitRunner
-import org.scalatest.{BeforeAndAfterAll, Spec}
-import org.scalatest.matchers.ShouldMatchers
-
-/**
- * Test for TypedActorFactoryBean
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class ActorFactoryBeanTest extends Spec with ShouldMatchers with BeforeAndAfterAll {
- override protected def afterAll = ActorRegistry.shutdownAll
-
- describe("A ActorFactoryBean") {
- val bean = new ActorFactoryBean
- it("should have java getters and setters for all properties") {
- bean.setImplementation("java.lang.String")
- assert(bean.getImplementation == "java.lang.String")
- bean.setTimeoutStr("1000")
- assert(bean.getTimeoutStr === "1000")
- }
-
- it("should create a remote typed actor when a host is set") {
- bean.setHost("some.host.com");
- assert(bean.isRemote)
- }
-
- it("should create a typed actor with dispatcher if dispatcher is set") {
- val props = new DispatcherProperties()
- props.dispatcherType = "executor-based-event-driven"
- bean.setDispatcher(props);
- assert(bean.hasDispatcher)
- }
-
- it("should return the object type") {
- bean.setImplementation("java.lang.String")
- assert(bean.getObjectType == classOf[String])
- }
-
- it("should create a proxy of type PojoInf") {
- val bean = new ActorFactoryBean()
- bean.setInterface("akka.spring.PojoInf")
- bean.setImplementation("akka.spring.Pojo")
- bean.timeoutStr = "1000"
- bean.typed = AkkaSpringConfigurationTags.TYPED_ACTOR_TAG
- val entries = new PropertyEntries()
- val entry = new PropertyEntry()
- entry.name = "stringFromVal"
- entry.value = "tests rock"
- entries.add(entry)
- bean.setProperty(entries)
- assert(classOf[PojoInf].isAssignableFrom(bean.getObjectType))
-
- // Check that we have injected the dependency correctly
- val target = bean.createInstance.asInstanceOf[PojoInf]
- assert(target.getStringFromVal === entry.value)
- }
-
- it("should create an application context and verify dependency injection for typed") {
- var ctx = new ClassPathXmlApplicationContext("appContext.xml");
- val ta = ctx.getBean("typedActor").asInstanceOf[PojoInf];
- assert(ta.isPreStartInvoked)
- assert(ta.getStringFromVal === "akka rocks")
- assert(ta.getStringFromRef === "spring rocks")
- assert(ta.gotApplicationContext)
- ctx.close
- }
-
- it("should create an application context and verify dependency injection for untyped actors") {
- var ctx = new ClassPathXmlApplicationContext("appContext.xml")
- val uta = ctx.getBean("untypedActor").asInstanceOf[ActorRef]
- val ping = uta.actor.asInstanceOf[PingActor]
- assert(ping.getStringFromVal === "akka rocks")
- assert(ping.getStringFromRef === "spring rocks")
- assert(ping.gotApplicationContext)
- ctx.close
- }
-
- it("should stop the created typed actor when scope is singleton and the context is closed") {
- var ctx = new ClassPathXmlApplicationContext("appContext.xml");
- val target = ctx.getBean("untypedActor").asInstanceOf[ActorRef]
- target.start
- assert(target.isRunning)
- ctx.close
- assert(!target.isRunning)
- }
-
- it("should stop the created untyped actor when scope is singleton and the context is closed") {
- var ctx = new ClassPathXmlApplicationContext("appContext.xml");
- val target = ctx.getBean("bean-singleton").asInstanceOf[SampleBeanIntf]
- assert(!target.down)
- ctx.close
- assert(target.down)
- }
-
- it("should not stop the created typed actor when scope is prototype and the context is closed") {
- var ctx = new ClassPathXmlApplicationContext("appContext.xml");
- val target = ctx.getBean("bean-prototype").asInstanceOf[SampleBeanIntf]
- assert(!target.down)
- ctx.close
- assert(!target.down)
- }
- }
-}
diff --git a/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala b/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala
deleted file mode 100644
index d10cb60265..0000000000
--- a/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-package akka.spring
-
-import org.apache.camel.impl.{SimpleRegistry, DefaultCamelContext}
-import org.apache.camel.spring.SpringCamelContext
-import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FeatureSpec}
-import org.springframework.context.support.ClassPathXmlApplicationContext
-
-import akka.camel.CamelContextManager
-import akka.actor.{TypedActor, ActorRegistry}
-
-class CamelServiceSpringFeatureTest extends FeatureSpec with BeforeAndAfterEach with BeforeAndAfterAll {
- override protected def beforeAll = {
- ActorRegistry.shutdownAll
- }
-
- override protected def afterEach = {
- ActorRegistry.shutdownAll
- }
-
- feature("start CamelService from Spring application context") {
- import CamelContextManager._
- scenario("with a custom CamelContext and access a registered typed actor") {
- val appctx = new ClassPathXmlApplicationContext("/appContextCamelServiceCustom.xml")
- assert(mandatoryContext.isInstanceOf[SpringCamelContext])
- assert("hello sample" === mandatoryTemplate.requestBody("direct:test", "sample"))
- appctx.close
- }
-
- scenario("with a default CamelContext and access a registered typed actor") {
- val appctx = new ClassPathXmlApplicationContext("/appContextCamelServiceDefault.xml")
- // create a custom registry
- val registry = new SimpleRegistry
- registry.put("custom", TypedActor.newInstance(classOf[SampleBeanIntf], classOf[SampleBean]))
- // set custom registry in DefaultCamelContext
- assert(mandatoryContext.isInstanceOf[DefaultCamelContext])
- mandatoryContext.asInstanceOf[DefaultCamelContext].setRegistry(registry)
- // access registered typed actor
- assert("hello sample" === mandatoryTemplate.requestBody("typed-actor:custom?method=foo", "sample"))
- appctx.close
- }
- }
-}
diff --git a/akka-spring/src/test/scala/ConfiggyPropertyPlaceholderConfigurerSpec.scala b/akka-spring/src/test/scala/ConfiggyPropertyPlaceholderConfigurerSpec.scala
deleted file mode 100644
index 0c61b18952..0000000000
--- a/akka-spring/src/test/scala/ConfiggyPropertyPlaceholderConfigurerSpec.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-
-import foo.{IMyPojo, MyPojo, PingActor}
-import akka.dispatch._
-import org.scalatest.FeatureSpec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import org.springframework.beans.factory.support.DefaultListableBeanFactory
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader
-import org.springframework.context.ApplicationContext
-import org.springframework.context.support.ClassPathXmlApplicationContext
-import org.springframework.core.io.{ClassPathResource, Resource}
-import java.util.concurrent._
-import akka.actor.{UntypedActor, Actor, ActorRef}
-
-
-
-
-/**
- * Tests for spring configuration of typed actors.
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class ConfiggyPropertyPlaceholderConfigurerSpec extends FeatureSpec with ShouldMatchers {
- val EVENT_DRIVEN_PREFIX = "akka:event-driven:dispatcher:"
-
- feature("The ConfiggyPropertyPlaceholderConfigurator") {
-
- scenario("should provide the akkka config for spring") {
- val context = new ClassPathXmlApplicationContext("/property-config.xml")
- val actor1 = context.getBean("actor-1").asInstanceOf[ActorRef]
- assert(actor1.remoteAddress.get.getHostName === "localhost")
- assert(actor1.remoteAddress.get.getPort === 9995)
- assert(actor1.timeout === 2000)
- }
- }
-}
diff --git a/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala
deleted file mode 100644
index ef6c0c23cc..0000000000
--- a/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.scalatest.Spec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import ScalaDom._
-
-/**
- * Test for DispatcherBeanDefinitionParser
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class DispatcherBeanDefinitionParserTest extends Spec with ShouldMatchers {
- describe("A DispatcherBeanDefinitionParser") {
- val parser = new DispatcherBeanDefinitionParser()
-
- it("should be able to parse the dispatcher configuration") {
- // executor-based-event-driven
- val xml =
- var props = parser.parseDispatcher(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.dispatcherType === "executor-based-event-driven")
- assert(props.name === "myDispatcher")
-
- // executor-based-event-driven-work-stealing
- val xml2 =
- props = parser.parseDispatcher(dom(xml2).getDocumentElement);
- assert(props.dispatcherType === "executor-based-event-driven-work-stealing")
- }
-
- it("should be able to parse the thread pool configuration") {
- val xml =
- val props = parser.parseThreadPool(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.queue == "bounded-array-blocking-queue")
- assert(props.capacity == 100)
- assert(props.fairness)
- assert(props.corePoolSize == 6)
- assert(props.maxPoolSize == 40)
- assert(props.keepAlive == 2000L)
- assert(props.rejectionPolicy == "caller-runs-policy")
- }
-
- it("should be able to parse the dispatcher with a thread pool configuration") {
- val xml =
-
-
- val props = parser.parseDispatcher(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.dispatcherType == "executor-based-event-driven")
- assert(props.name == "myDispatcher")
- assert(props.threadPool.corePoolSize == 2)
- assert(props.threadPool.maxPoolSize == 10)
- assert(props.threadPool.keepAlive == 1000)
- assert(props.threadPool.queue == "linked-blocking-queue")
- }
-
- it("should throw IllegalArgumentException on not existing reference") {
- val xml =
- evaluating {parser.parseDispatcher(dom(xml).getDocumentElement)} should produce[IllegalArgumentException]
- }
-
- it("should throw IllegalArgumentException on missing mandatory attributes") {
- val xml =
- evaluating {parser.parseDispatcher(dom(xml).getDocumentElement)} should produce[IllegalArgumentException]
- }
-
- it("should throw IllegalArgumentException when configuring a thread based dispatcher without TypedActor or UntypedActor") {
- val xml =
- evaluating {parser.parseDispatcher(dom(xml).getDocumentElement)} should produce[IllegalArgumentException]
- }
-
- it("should be able to parse the hawt dispatcher configuration") {
- // hawt
- val xml =
- var props = parser.parseDispatcher(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.dispatcherType === "hawt")
- assert(props.aggregate === false)
- }
- }
-}
-
-
diff --git a/akka-spring/src/test/scala/DispatcherFactoryBeanTest.scala b/akka-spring/src/test/scala/DispatcherFactoryBeanTest.scala
deleted file mode 100644
index 486ec8820c..0000000000
--- a/akka-spring/src/test/scala/DispatcherFactoryBeanTest.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.scalatest.Spec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import akka.config.Supervision._
-import akka.dispatch.MessageDispatcher
-
-@RunWith(classOf[JUnitRunner])
-class DispatcherFactoryBeanTest extends Spec with ShouldMatchers {
-
- describe("A DispatcherFactoryBean") {
- val bean = new DispatcherFactoryBean
- it("should have java getters and setters for the dispatcher properties") {
- val props = new DispatcherProperties()
- bean.setProperties(props)
- assert(bean.getProperties == props)
- }
-
- it("should return the object type MessageDispatcher") {
- assert(bean.getObjectType == classOf[MessageDispatcher])
- }
- }
-}
diff --git a/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala b/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala
deleted file mode 100644
index ac90495e9b..0000000000
--- a/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-
-import foo.{IMyPojo, MyPojo, PingActor}
-import akka.dispatch._
-import org.scalatest.FeatureSpec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import org.springframework.beans.factory.support.DefaultListableBeanFactory
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader
-import org.springframework.context.ApplicationContext
-import org.springframework.context.support.ClassPathXmlApplicationContext
-import org.springframework.core.io.{ClassPathResource, Resource}
-import java.util.concurrent._
-import akka.actor.{UntypedActor, Actor, ActorRef}
-
-/**
- * Tests for spring configuration of typed actors.
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class DispatcherSpringFeatureTest extends FeatureSpec with ShouldMatchers {
- val EVENT_DRIVEN_PREFIX = "akka:event-driven:dispatcher:"
-
- feature("Spring configuration") {
-
- scenario("get a executor-event-driven-dispatcher with array-blocking-queue from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("executor-event-driven-dispatcher-1").asInstanceOf[ExecutorBasedEventDrivenDispatcher]
- assert(dispatcher.name === EVENT_DRIVEN_PREFIX + "dispatcher-1")
- val executor = getThreadPoolExecutorAndAssert(dispatcher)
- assert(executor.getCorePoolSize() === 1)
- assert(executor.getMaximumPoolSize() === 20)
- assert(executor.getKeepAliveTime(TimeUnit.MILLISECONDS) === 3000)
- assert(executor.getQueue().isInstanceOf[ArrayBlockingQueue[Runnable]]);
- assert(executor.getQueue().remainingCapacity() === 100)
- }
-
-
- scenario("get a dispatcher via ref from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val pojo = context.getBean("typed-actor-with-dispatcher-ref").asInstanceOf[IMyPojo]
- assert(pojo ne null)
- }
-
- scenario("get a executor-event-driven-dispatcher with blocking-queue with unbounded capacity from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("executor-event-driven-dispatcher-2").asInstanceOf[ExecutorBasedEventDrivenDispatcher]
- val executor = getThreadPoolExecutorAndAssert(dispatcher)
- assert(executor.getQueue().isInstanceOf[BlockingQueue[Runnable]])
- assert(executor.getQueue().remainingCapacity() === Integer.MAX_VALUE)
- assert(dispatcher.name === EVENT_DRIVEN_PREFIX + "dispatcher-2")
- }
-/*
- scenario("get a executor-event-driven-dispatcher with bounded-blocking-queue and with bounded mailbox capacity") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("executor-event-driven-dispatcher-mc").asInstanceOf[ExecutorBasedEventDrivenDispatcher]
- assert(dispatcher.name === EVENT_DRIVEN_PREFIX + "dispatcher-mc")
- val actorRef = UntypedActor.actorOf(classOf[PingActor])
- actorRef.dispatcher = dispatcher
- actorRef.start
- assert(actorRef.mailbox.isInstanceOf[BlockingQueue[MessageInvocation]])
- assert((actorRef.mailbox.asInstanceOf[BlockingQueue[MessageInvocation]]).remainingCapacity === 1000)
- }
-*/
- scenario("get a executor-event-driven-dispatcher with unbounded-linked-blocking-queue with bounded capacity from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("executor-event-driven-dispatcher-4").asInstanceOf[ExecutorBasedEventDrivenDispatcher]
- assert(dispatcher.name === EVENT_DRIVEN_PREFIX + "dispatcher-4")
- val executor = getThreadPoolExecutorAndAssert(dispatcher)
- assert(executor.getQueue().isInstanceOf[BlockingQueue[Runnable]])
- assert(executor.getQueue().remainingCapacity() === 55)
- }
-
- scenario("get a executor-event-driven-dispatcher with unbounded-linked-blocking-queue with unbounded capacity from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("executor-event-driven-dispatcher-5").asInstanceOf[ExecutorBasedEventDrivenDispatcher]
- assert(dispatcher.name === EVENT_DRIVEN_PREFIX + "dispatcher-5")
- val executor = getThreadPoolExecutorAndAssert(dispatcher)
- assert(executor.getQueue().isInstanceOf[BlockingQueue[Runnable]])
- assert(executor.getQueue().remainingCapacity() === Integer.MAX_VALUE)
- }
-
- scenario("get a executor-event-driven-dispatcher with synchronous-queue from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("executor-event-driven-dispatcher-6").asInstanceOf[ExecutorBasedEventDrivenDispatcher]
- assert(dispatcher.name === EVENT_DRIVEN_PREFIX + "dispatcher-6")
- val executor = getThreadPoolExecutorAndAssert(dispatcher)
- assert(executor.getQueue().isInstanceOf[SynchronousQueue[Runnable]])
- }
-
- scenario("get a executor-based-event-driven-work-stealing-dispatcher from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("executor-based-event-driven-work-stealing-dispatcher").asInstanceOf[ExecutorBasedEventDrivenWorkStealingDispatcher]
- assert(dispatcher ne null)
- assert(dispatcher.name === "akka:event-driven-work-stealing:dispatcher:workStealingDispatcher")
- val executor = getThreadPoolExecutorAndAssert(dispatcher)
- assert(executor.getQueue().isInstanceOf[BlockingQueue[Runnable]])
- }
-
- scenario("get a hawt-dispatcher from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val dispatcher = context.getBean("hawt-dispatcher").asInstanceOf[HawtDispatcher]
- assert(dispatcher ne null)
- assert(dispatcher.toString === "HawtDispatcher")
- assert(dispatcher.aggregate === false)
- }
-
- scenario("get a thread-based-dispatcher for typed actor from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val pojo = context.getBean("typed-actor-with-thread-based-dispatcher").asInstanceOf[IMyPojo]
- assert(pojo ne null)
- }
-
- scenario("get a thread-based-dispatcher for untyped from context") {
- val context = new ClassPathXmlApplicationContext("/dispatcher-config.xml")
- val actorRef = context.getBean("untyped-actor-with-thread-based-dispatcher").asInstanceOf[ActorRef]
- assert(actorRef.getActorClassName() === "akka.spring.foo.PingActor")
- actorRef.start()
- actorRef.sendOneWay("Hello")
- assert(actorRef.getDispatcher.isInstanceOf[ThreadBasedDispatcher])
- }
- }
-
- /**
- * get ThreadPoolExecutor via reflection and assert that dispatcher is correct type
- */
- private def getThreadPoolExecutorAndAssert(dispatcher: MessageDispatcher): ThreadPoolExecutor = {
-
- def unpackExecutorService(e: ExecutorService): ExecutorService = e match {
- case b: ExecutorServiceDelegate => unpackExecutorService(b.executor)
- case t: ThreadPoolExecutor => t
- case e => throw new IllegalStateException("Illegal executor type: " + e)
- }
-
- unpackExecutorService(dispatcher match {
- case e: ExecutorBasedEventDrivenDispatcher => e.executorService.get()
- case e: ExecutorBasedEventDrivenWorkStealingDispatcher => e.executorService.get()
- case x => throw new IllegalStateException("Illegal dispatcher type: " + x)
- }).asInstanceOf[ThreadPoolExecutor]
- }
-
-}
diff --git a/akka-spring/src/test/scala/ScalaDom.scala b/akka-spring/src/test/scala/ScalaDom.scala
deleted file mode 100644
index 9319b0c328..0000000000
--- a/akka-spring/src/test/scala/ScalaDom.scala
+++ /dev/null
@@ -1,40 +0,0 @@
-package akka.spring
-/**
- * from http://stackoverflow.com/questions/2002685/any-conversion-from-scalas-xml-to-w3c-dom
- */
-
-object ScalaDom {
- import scala.xml._
- import org.w3c.dom.{Document => JDocument, Node => JNode}
- import javax.xml.parsers.DocumentBuilderFactory
-
- def dom(n: Node): JDocument = {
-
- val doc = DocumentBuilderFactory
- .newInstance
- .newDocumentBuilder
- .getDOMImplementation
- .createDocument(null, null, null)
-
- def build(node: Node, parent: JNode): Unit = {
- val jnode: JNode = node match {
- case e: Elem => {
- val jn = doc.createElement(e.label)
- e.attributes foreach { a => jn.setAttribute(a.key, a.value.mkString) }
- jn
- }
- case a: Atom[_] => doc.createTextNode(a.text)
- case c: Comment => doc.createComment(c.commentText)
- case er: EntityRef => doc.createEntityReference(er.entityName)
- case pi: ProcInstr => doc.createProcessingInstruction(pi.target, pi.proctext)
- }
- parent.appendChild(jnode)
- node.child.map { build(_, jnode) }
- }
-
- build(n, doc)
- doc
-
- }
-}
-
diff --git a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala
deleted file mode 100644
index e5b4fc2c70..0000000000
--- a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala
+++ /dev/null
@@ -1,127 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.scalatest.Spec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import ScalaDom._
-
-import org.w3c.dom.Element
-import org.springframework.beans.factory.support.BeanDefinitionBuilder
-import akka.config.Supervision. {FaultHandlingStrategy, AllForOneStrategy}
-
-/**
- * Test for SupervisionBeanDefinitionParser
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class SupervisionBeanDefinitionParserTest extends Spec with ShouldMatchers {
- private class Parser extends SupervisionBeanDefinitionParser
-
- describe("A SupervisionBeanDefinitionParser") {
- val parser = new Parser()
- val builder = BeanDefinitionBuilder.genericBeanDefinition("foo.bar.Foo")
-
- it("should be able to parse typed actor configuration") {
- val props = parser.parseActor(createTypedActorElement);
- assert(props ne null)
- assert(props.timeout == 1000)
- assert(props.target == "foo.bar.MyPojo")
- }
-
- it("should parse the supervisor restart strategy") {
- parser.parseSupervisor(createSupervisorElement, builder);
- val strategy = builder.getBeanDefinition.getPropertyValues.getPropertyValue("restartStrategy").getValue.asInstanceOf[FaultHandlingStrategy]
- assert(strategy ne null)
- assert(strategy.isInstanceOf[AllForOneStrategy])
- expect(3) { strategy.asInstanceOf[AllForOneStrategy].maxNrOfRetries.get }
- expect(1000) { strategy.asInstanceOf[AllForOneStrategy].withinTimeRange.get }
- }
-
- it("should parse the supervised typed actors") {
- parser.parseSupervisor(createSupervisorElement, builder);
- val supervised = builder.getBeanDefinition.getPropertyValues.getPropertyValue("supervised").getValue.asInstanceOf[List[ActorProperties]]
- assert(supervised ne null)
- expect(4) { supervised.length }
- val iterator = supervised.iterator
- val prop1 = iterator.next
- val prop2 = iterator.next
- val prop3 = iterator.next
- val prop4 = iterator.next
- expect("foo.bar.Foo") { prop1.target }
- expect("foo.bar.Bar") { prop2.target }
- expect("foo.bar.MyPojo") { prop3.target }
- expect("foo.bar.MyPojo") { prop4.target }
- expect("permanent") { prop1.lifecycle }
- expect("temporary") { prop4.lifecycle }
- }
-
- it("should throw IllegalArgumentException on missing mandatory attributes") {
- evaluating { parser.parseSupervisor(createSupervisorMissingAttribute, builder) } should produce [IllegalArgumentException]
- }
-
- it("should throw IllegalArgumentException on missing mandatory elements") {
- evaluating { parser.parseSupervisor(createSupervisorMissingElement, builder) } should produce [IllegalArgumentException]
- }
- }
-
- private def createTypedActorElement : Element = {
- val xml =
- dom(xml).getDocumentElement
- }
-
- private def createSupervisorElement : Element = {
- val xml =
-
-
- java.io.IOException
- java.lang.NullPointerException
-
-
-
-
-
-
-
-
-
-
-
-
-
- dom(xml).getDocumentElement
- }
-
-
- private def createSupervisorMissingAttribute : Element = {
- val xml =
-
-
- java.io.IOException
-
-
-
-
-
-
- dom(xml).getDocumentElement
- }
-
- private def createSupervisorMissingElement : Element = {
- val xml =
-
-
-
-
-
-
-
- dom(xml).getDocumentElement
- }
-}
-
diff --git a/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala b/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala
deleted file mode 100644
index 542b8a1377..0000000000
--- a/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.scalatest.Spec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import akka.config.Supervision._
-import akka.config.TypedActorConfigurator
-
-private[akka] class Foo
-
-@RunWith(classOf[JUnitRunner])
-class SupervisionFactoryBeanTest extends Spec with ShouldMatchers {
-
- val faultHandlingStrategy = new AllForOneStrategy(List(classOf[Exception]), 3, 1000)
- val typedActors = List(createTypedActorProperties("akka.spring.Foo", "1000"))
-
- private def createTypedActorProperties(target: String, timeout: String) : ActorProperties = {
- val properties = new ActorProperties()
- properties.target = target
- properties.timeoutStr = timeout
- properties
- }
-
- describe("A SupervisionFactoryBean") {
- val bean = new SupervisionFactoryBean
- it("should have java getters and setters for all properties") {
- bean.setRestartStrategy(faultHandlingStrategy)
- assert(bean.getRestartStrategy == faultHandlingStrategy)
- bean.setSupervised(typedActors)
- assert(bean.getSupervised == typedActors)
- }
-
- it("should return the object type AnyRef") {
- assert(bean.getObjectType == classOf[AnyRef])
- }
- }
-}
diff --git a/akka-spring/src/test/scala/SupervisorSpringFeatureTest.scala b/akka-spring/src/test/scala/SupervisorSpringFeatureTest.scala
deleted file mode 100644
index 2ce629ed38..0000000000
--- a/akka-spring/src/test/scala/SupervisorSpringFeatureTest.scala
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-
-import akka.spring.foo.{IMyPojo, MyPojo, IFoo, IBar}
-import akka.dispatch._
-import akka.config.TypedActorConfigurator
-import akka.actor.Supervisor
-
-import org.scalatest.FeatureSpec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import org.springframework.beans.factory.support.DefaultListableBeanFactory
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader
-import org.springframework.context.ApplicationContext
-import org.springframework.context.support.ClassPathXmlApplicationContext
-import org.springframework.core.io.{ClassPathResource, Resource}
-import java.util.concurrent._
-
-/**
- * Tests for spring configuration of supervisor hierarchies.
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class SupervisorSpringFeatureTest extends FeatureSpec with ShouldMatchers {
-
- feature("Spring configuration") {
-
- scenario("get a supervisor for typed actors from context") {
- val context = new ClassPathXmlApplicationContext("/supervisor-config.xml")
- val myConfigurator = context.getBean("supervision1").asInstanceOf[TypedActorConfigurator]
- // get TypedActors
- val foo = myConfigurator.getInstance(classOf[IFoo])
- assert(foo ne null)
- val bar = myConfigurator.getInstance(classOf[IBar])
- assert(bar ne null)
- val pojo = myConfigurator.getInstance(classOf[IMyPojo])
- assert(pojo ne null)
- }
-
- scenario("get a supervisor for untyped actors from context") {
- val context = new ClassPathXmlApplicationContext("/supervisor-config.xml")
- val supervisor = context.getBean("supervision-untyped-actors").asInstanceOf[Supervisor]
- supervisor.children
- }
-
- scenario("get a supervisor and dispatcher from context") {
- val context = new ClassPathXmlApplicationContext("/supervisor-config.xml")
- val myConfigurator = context.getBean("supervision-with-dispatcher").asInstanceOf[TypedActorConfigurator]
- val foo = myConfigurator.getInstance(classOf[IFoo])
- assert(foo ne null)
- }
- }
-}
diff --git a/akka-spring/src/test/scala/TypedActorBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/TypedActorBeanDefinitionParserTest.scala
deleted file mode 100644
index f665784355..0000000000
--- a/akka-spring/src/test/scala/TypedActorBeanDefinitionParserTest.scala
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-import org.scalatest.Spec
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import ScalaDom._
-
-import org.w3c.dom.Element
-
-/**
- * Test for TypedActorParser
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class TypedActorBeanDefinitionParserTest extends Spec with ShouldMatchers {
- private class Parser extends ActorParser
-
- describe("A TypedActorParser") {
- val parser = new Parser()
- it("should parse the typed actor configuration") {
- val xml =
-
-
-
- val props = parser.parseActor(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.timeout === 1000)
- assert(props.target === "foo.bar.MyPojo")
- assert(props.scope === "prototype")
- assert(props.propertyEntries.entryList.size === 1)
- }
-
- it("should throw IllegalArgumentException on missing mandatory attributes") {
- val xml =
-
- evaluating { parser.parseActor(dom(xml).getDocumentElement) } should produce [IllegalArgumentException]
- }
-
- it("should parse TypedActors configuration with dispatcher") {
- val xml =
-
-
- val props = parser.parseActor(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.dispatcher.dispatcherType === "thread-based")
- }
-
- it("should parse remote TypedActors configuration") {
- val xml =
-
-
- val props = parser.parseActor(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.host === "com.some.host")
- assert(props.port === "2552")
- assert(!props.serverManaged)
- }
-
- it("should parse remote server managed TypedActors configuration") {
- val xml =
-
-
- val props = parser.parseActor(dom(xml).getDocumentElement);
- assert(props ne null)
- assert(props.host === "com.some.host")
- assert(props.port === "2552")
- assert(props.serviceName === "my-service")
- assert(props.serverManaged)
- }
- }
-}
diff --git a/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala b/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala
deleted file mode 100644
index 36ff8d9f06..0000000000
--- a/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-
-import foo.{PingActor, IMyPojo, MyPojo}
-import akka.dispatch.FutureTimeoutException
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import org.springframework.beans.factory.support.DefaultListableBeanFactory
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader
-import org.springframework.context.ApplicationContext
-import org.springframework.context.support.ClassPathXmlApplicationContext
-import org.springframework.core.io.{ClassPathResource, Resource}
-import org.scalatest.{BeforeAndAfterAll, FeatureSpec}
-import akka.remote.{RemoteClient, RemoteServer, RemoteNode}
-import java.util.concurrent.CountDownLatch
-import akka.actor.{TypedActor, RemoteTypedActorOne, Actor}
-import akka.actor.remote.RemoteTypedActorOneImpl
-
-/**
- * Tests for spring configuration of typed actors.
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class TypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with BeforeAndAfterAll {
-
- var server1: RemoteServer = null
- var server2: RemoteServer = null
-
- override def beforeAll = {
- val actor = Actor.actorOf[PingActor] // FIXME: remove this line when ticket 425 is fixed
- server1 = new RemoteServer()
- server1.start("localhost", 9990)
- server2 = new RemoteServer()
- server2.start("localhost", 9992)
-
- val typedActor = TypedActor.newInstance(classOf[RemoteTypedActorOne], classOf[RemoteTypedActorOneImpl], 1000)
- server1.registerTypedActor("typed-actor-service", typedActor)
- }
-
- // make sure the servers shutdown cleanly after the test has finished
- override def afterAll = {
- try {
- server1.shutdown
- server2.shutdown
- RemoteClient.shutdownAll
- Thread.sleep(1000)
- } catch {
- case e => ()
- }
- }
-
- def getTypedActorFromContext(config: String, id: String) : IMyPojo = {
- MyPojo.latch = new CountDownLatch(1)
- val context = new ClassPathXmlApplicationContext(config)
- val myPojo: IMyPojo = context.getBean(id).asInstanceOf[IMyPojo]
- myPojo
- }
-
- feature("parse Spring application context") {
-
- scenario("akka:typed-actor and akka:supervision and akka:dispatcher can be used as top level elements") {
- val context = new ClassPathResource("/typed-actor-config.xml")
- val beanFactory = new DefaultListableBeanFactory()
- val reader = new XmlBeanDefinitionReader(beanFactory)
- reader.loadBeanDefinitions(context)
- assert(beanFactory.containsBeanDefinition("simple-typed-actor"))
- assert(beanFactory.containsBeanDefinition("remote-typed-actor"))
- assert(beanFactory.containsBeanDefinition("supervision1"))
- assert(beanFactory.containsBeanDefinition("dispatcher1"))
- }
-
- scenario("get a typed actor") {
- val myPojo = getTypedActorFromContext("/typed-actor-config.xml", "simple-typed-actor")
- assert(myPojo.getFoo() === "foo")
- myPojo.oneWay("hello 1")
- MyPojo.latch.await
- assert(MyPojo.lastOneWayMessage === "hello 1")
- }
-
- scenario("get a typed actor of bean") {
- val myPojo = getTypedActorFromContext("/typed-actor-config.xml", "simple-typed-actor-of-bean")
- assert(myPojo.getFoo() === "foo")
- myPojo.oneWay("hello 1")
- MyPojo.latch.await
- assert(MyPojo.lastOneWayMessage === "hello 1")
- }
-
- scenario("FutureTimeoutException when timed out") {
- val myPojo = getTypedActorFromContext("/typed-actor-config.xml", "simple-typed-actor")
- evaluating {myPojo.longRunning()} should produce[FutureTimeoutException]
- }
-
- scenario("typed-actor with timeout") {
- val myPojo = getTypedActorFromContext("/typed-actor-config.xml", "simple-typed-actor-long-timeout")
- assert(myPojo.longRunning() === "this took long");
- }
-
- scenario("get a remote typed-actor") {
- val myPojo = getTypedActorFromContext("/typed-actor-config.xml", "remote-typed-actor")
- assert(myPojo.getFoo() === "foo")
- myPojo.oneWay("hello 3")
- MyPojo.latch.await
- assert(MyPojo.lastOneWayMessage === "hello 3")
- }
-
- scenario("get a client-managed-remote-typed-actor") {
- val myPojo = getTypedActorFromContext("/server-managed-config.xml", "client-managed-remote-typed-actor")
- assert(myPojo.getFoo() === "foo")
- myPojo.oneWay("hello client-managed-remote-typed-actor")
- MyPojo.latch.await
- assert(MyPojo.lastOneWayMessage === "hello client-managed-remote-typed-actor")
- }
-
- scenario("get a server-managed-remote-typed-actor") {
- val serverPojo = getTypedActorFromContext("/server-managed-config.xml", "server-managed-remote-typed-actor")
- //
- val myPojoProxy = RemoteClient.typedActorFor(classOf[IMyPojo], classOf[IMyPojo].getName, 5000L, "localhost", 9990)
- assert(myPojoProxy.getFoo() === "foo")
- myPojoProxy.oneWay("hello server-managed-remote-typed-actor")
- MyPojo.latch.await
- assert(MyPojo.lastOneWayMessage === "hello server-managed-remote-typed-actor")
- }
-
- scenario("get a server-managed-remote-typed-actor-custom-id") {
- val serverPojo = getTypedActorFromContext("/server-managed-config.xml", "server-managed-remote-typed-actor-custom-id")
- //
- val myPojoProxy = RemoteClient.typedActorFor(classOf[IMyPojo], "mypojo-service", 5000L, "localhost", 9990)
- assert(myPojoProxy.getFoo() === "foo")
- myPojoProxy.oneWay("hello server-managed-remote-typed-actor 2")
- MyPojo.latch.await
- assert(MyPojo.lastOneWayMessage === "hello server-managed-remote-typed-actor 2")
- }
-
- scenario("get a client proxy for server-managed-remote-typed-actor") {
- MyPojo.latch = new CountDownLatch(1)
- val context = new ClassPathXmlApplicationContext("/server-managed-config.xml")
- val myPojo: IMyPojo = context.getBean("server-managed-remote-typed-actor-custom-id").asInstanceOf[IMyPojo]
- // get client proxy from spring context
- val myPojoProxy = context.getBean("typed-client-1").asInstanceOf[IMyPojo]
- assert(myPojoProxy.getFoo() === "foo")
- myPojoProxy.oneWay("hello")
- MyPojo.latch.await
- }
-
-
- }
-
-}
-
diff --git a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala b/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala
deleted file mode 100644
index aded68a559..0000000000
--- a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Scalable Solutions AB
- */
-package akka.spring
-
-
-import foo.PingActor
-import akka.dispatch.ExecutorBasedEventDrivenWorkStealingDispatcher
-import org.scalatest.matchers.ShouldMatchers
-import org.scalatest.junit.JUnitRunner
-import org.junit.runner.RunWith
-import org.springframework.context.support.ClassPathXmlApplicationContext
-import akka.remote.{RemoteClient, RemoteServer}
-import org.scalatest.{BeforeAndAfterAll, FeatureSpec}
-
-import java.util.concurrent.CountDownLatch
-import akka.actor.{RemoteActorRef, ActorRegistry, Actor, ActorRef}
-
-/**
- * Tests for spring configuration of typed actors.
- * @author michaelkober
- */
-@RunWith(classOf[JUnitRunner])
-class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with BeforeAndAfterAll {
-
- var server1: RemoteServer = null
- var server2: RemoteServer = null
-
-
- override def beforeAll = {
- val actor = Actor.actorOf[PingActor] // FIXME: remove this line when ticket 425 is fixed
- server1 = new RemoteServer()
- server1.start("localhost", 9990)
- server2 = new RemoteServer()
- server2.start("localhost", 9992)
- }
-
- // make sure the servers shutdown cleanly after the test has finished
- override def afterAll = {
- try {
- server1.shutdown
- server2.shutdown
- RemoteClient.shutdownAll
- Thread.sleep(1000)
- } catch {
- case e => ()
- }
- }
-
-
- def getPingActorFromContext(config: String, id: String) : ActorRef = {
- PingActor.latch = new CountDownLatch(1)
- val context = new ClassPathXmlApplicationContext(config)
- val pingActor = context.getBean(id).asInstanceOf[ActorRef]
- assert(pingActor.getActorClassName() === "akka.spring.foo.PingActor")
- pingActor.start()
- }
-
-
- feature("parse Spring application context") {
-
- scenario("get a untyped actor") {
- val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor")
- myactor.sendOneWay("Hello")
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello")
- assert(myactor.isDefinedAt("some string message"))
- }
-
- scenario("untyped-actor of provided bean") {
- val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-of-bean")
- myactor.sendOneWay("Hello")
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello")
- assert(myactor.isDefinedAt("some string message"))
- }
-
- scenario("untyped-actor with timeout") {
- val myactor = getPingActorFromContext("/untyped-actor-config.xml", "simple-untyped-actor-long-timeout")
- assert(myactor.getTimeout() === 10000)
- myactor.sendOneWay("Hello 2")
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello 2")
- }
-
- scenario("get a remote typed-actor") {
- val myactor = getPingActorFromContext("/untyped-actor-config.xml", "remote-untyped-actor")
- myactor.sendOneWay("Hello 4")
- assert(myactor.getRemoteAddress().isDefined)
- assert(myactor.getRemoteAddress().get.getHostName() === "localhost")
- assert(myactor.getRemoteAddress().get.getPort() === 9992)
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello 4")
- }
-
- scenario("untyped-actor with custom dispatcher") {
- val myactor = getPingActorFromContext("/untyped-actor-config.xml", "untyped-actor-with-dispatcher")
- assert(myactor.getTimeout() === 1000)
- assert(myactor.getDispatcher.isInstanceOf[ExecutorBasedEventDrivenWorkStealingDispatcher])
- myactor.sendOneWay("Hello 5")
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello 5")
- }
-
- scenario("create client managed remote untyped-actor") {
- val myactor = getPingActorFromContext("/server-managed-config.xml", "client-managed-remote-untyped-actor")
- myactor.sendOneWay("Hello client managed remote untyped-actor")
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello client managed remote untyped-actor")
- assert(myactor.getRemoteAddress().isDefined)
- assert(myactor.getRemoteAddress().get.getHostName() === "localhost")
- assert(myactor.getRemoteAddress().get.getPort() === 9990)
- }
-
- scenario("create server managed remote untyped-actor") {
- val myactor = getPingActorFromContext("/server-managed-config.xml", "server-managed-remote-untyped-actor")
- val nrOfActors = ActorRegistry.actors.length
- val actorRef = RemoteClient.actorFor("akka.spring.foo.PingActor", "localhost", 9990)
- actorRef.sendOneWay("Hello server managed remote untyped-actor")
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello server managed remote untyped-actor")
- assert(ActorRegistry.actors.length === nrOfActors)
- }
-
- scenario("create server managed remote untyped-actor with custom service id") {
- val myactor = getPingActorFromContext("/server-managed-config.xml", "server-managed-remote-untyped-actor-custom-id")
- val nrOfActors = ActorRegistry.actors.length
- val actorRef = RemoteClient.actorFor("ping-service", "localhost", 9990)
- actorRef.sendOneWay("Hello server managed remote untyped-actor")
- PingActor.latch.await
- assert(PingActor.lastMessage === "Hello server managed remote untyped-actor")
- assert(ActorRegistry.actors.length === nrOfActors)
- }
-
- scenario("get client actor for server managed remote untyped-actor") {
- PingActor.latch = new CountDownLatch(1)
- val context = new ClassPathXmlApplicationContext("/server-managed-config.xml")
- val pingActor = context.getBean("server-managed-remote-untyped-actor-custom-id").asInstanceOf[ActorRef]
- assert(pingActor.getActorClassName() === "akka.spring.foo.PingActor")
- pingActor.start()
- val nrOfActors = ActorRegistry.actors.length
- // get client actor ref from spring context
- val actorRef = context.getBean("client-1").asInstanceOf[ActorRef]
- assert(actorRef.isInstanceOf[RemoteActorRef])
- actorRef.sendOneWay("Hello")
- PingActor.latch.await
- assert(ActorRegistry.actors.length === nrOfActors)
- }
-
- }
-}
-
diff --git a/config/cassandra-akka-storage-conf.xml b/config/cassandra-akka-storage-conf.xml
deleted file mode 100644
index f87d2eedf5..0000000000
--- a/config/cassandra-akka-storage-conf.xml
+++ /dev/null
@@ -1,395 +0,0 @@
-
-
-
-
-
-
-
- akka
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.cassandra.locator.RackUnawareStrategy
-
-
- 1
-
-
- org.apache.cassandra.locator.EndPointSnitch
-
-
-
-
-
- org.apache.cassandra.auth.AllowAllAuthenticator
-
-
- org.apache.cassandra.dht.RandomPartitioner
-
-
-
-
-
- cassandra/commitlog
-
- cassandra/data
-
-
-
-
-
- 127.0.0.1
-
-
-
-
-
-
- 10000
-
- 128
-
-
-
-
-
- localhost
-
- 7000
-
-
- localhost
-
- 9160
-
- false
-
-
-
-
-
-
-
- auto
-
-
- 512
-
-
- 64
-
-
- 32
- 8
-
-
- 64
-
-
- 64
-
- 256
-
- 0.3
-
- 60
-
-
- 8
- 32
-
-
- periodic
-
- 10000
-
-
-
-
- 864000
-
diff --git a/config/microkernel-server.xml b/config/microkernel-server.xml
deleted file mode 100644
index 6a5ed730ed..0000000000
--- a/config/microkernel-server.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 300000
- 2
- false
- 8443
- 20000
- 5000
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /
-
- akka.http.AkkaMistServlet
- /*
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- true
- 1000
-
-
diff --git a/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14-javadoc.jar b/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14-javadoc.jar
deleted file mode 100644
index 6ab90957c2..0000000000
Binary files a/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14-javadoc.jar and /dev/null differ
diff --git a/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14-sources.jar b/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14-sources.jar
deleted file mode 100644
index 0a97b3fa7b..0000000000
Binary files a/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14-sources.jar and /dev/null differ
diff --git a/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14.jar b/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14.jar
deleted file mode 100644
index a11205d066..0000000000
Binary files a/embedded-repo/com/amazonaws/aws-java-sdk/1.0.14/aws-java-sdk-1.0.14.jar and /dev/null differ
diff --git a/embedded-repo/com/rabbitmq/rabbitmq-client/0.9.1/rabbitmq-client-0.9.1.jar b/embedded-repo/com/rabbitmq/rabbitmq-client/0.9.1/rabbitmq-client-0.9.1.jar
deleted file mode 100644
index 776a3945a1..0000000000
Binary files a/embedded-repo/com/rabbitmq/rabbitmq-client/0.9.1/rabbitmq-client-0.9.1.jar and /dev/null differ
diff --git a/embedded-repo/com/rabbitmq/rabbitmq-client/0.9.1/rabbitmq-client-0.9.1.pom b/embedded-repo/com/rabbitmq/rabbitmq-client/0.9.1/rabbitmq-client-0.9.1.pom
deleted file mode 100644
index c78d868476..0000000000
--- a/embedded-repo/com/rabbitmq/rabbitmq-client/0.9.1/rabbitmq-client-0.9.1.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- com.rabbitmq
- rabbitmq-client
- 0.9.1
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-1.4/redisclient-2.8.0-1.4.jar b/embedded-repo/com/redis/redisclient/2.8.0-1.4/redisclient-2.8.0-1.4.jar
deleted file mode 100644
index b811e6ab92..0000000000
Binary files a/embedded-repo/com/redis/redisclient/2.8.0-1.4/redisclient-2.8.0-1.4.jar and /dev/null differ
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0.1/redisclient-2.8.0-2.0.1.jar b/embedded-repo/com/redis/redisclient/2.8.0-2.0.1/redisclient-2.8.0-2.0.1.jar
deleted file mode 100644
index 7709ef140b..0000000000
Binary files a/embedded-repo/com/redis/redisclient/2.8.0-2.0.1/redisclient-2.8.0-2.0.1.jar and /dev/null differ
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0.1/redisclient-2.8.0-2.0.1.pom b/embedded-repo/com/redis/redisclient/2.8.0-2.0.1/redisclient-2.8.0-2.0.1.pom
deleted file mode 100644
index 4010889e31..0000000000
--- a/embedded-repo/com/redis/redisclient/2.8.0-2.0.1/redisclient-2.8.0-2.0.1.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- com.redis
- redisclient
- 2.8.0-2.0.1
- jar
-
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0.2/redisclient-2.8.0-2.0.2.jar b/embedded-repo/com/redis/redisclient/2.8.0-2.0.2/redisclient-2.8.0-2.0.2.jar
deleted file mode 100644
index cbaf69ad80..0000000000
Binary files a/embedded-repo/com/redis/redisclient/2.8.0-2.0.2/redisclient-2.8.0-2.0.2.jar and /dev/null differ
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0.2/redisclient-2.8.0-2.0.2.pom b/embedded-repo/com/redis/redisclient/2.8.0-2.0.2/redisclient-2.8.0-2.0.2.pom
deleted file mode 100644
index 32e34d89a0..0000000000
--- a/embedded-repo/com/redis/redisclient/2.8.0-2.0.2/redisclient-2.8.0-2.0.2.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- com.redis
- redisclient
- 2.8.0-2.0.2
- jar
-
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0.3/redisclient-2.8.0-2.0.3.jar b/embedded-repo/com/redis/redisclient/2.8.0-2.0.3/redisclient-2.8.0-2.0.3.jar
deleted file mode 100644
index be75baa5aa..0000000000
Binary files a/embedded-repo/com/redis/redisclient/2.8.0-2.0.3/redisclient-2.8.0-2.0.3.jar and /dev/null differ
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0.3/redisclient-2.8.0-2.0.3.pom b/embedded-repo/com/redis/redisclient/2.8.0-2.0.3/redisclient-2.8.0-2.0.3.pom
deleted file mode 100644
index 7b1878f070..0000000000
--- a/embedded-repo/com/redis/redisclient/2.8.0-2.0.3/redisclient-2.8.0-2.0.3.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- com.redis
- redisclient
- 2.8.0-2.0.3
- jar
-
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0/redisclient-2.8.0-2.0.jar b/embedded-repo/com/redis/redisclient/2.8.0-2.0/redisclient-2.8.0-2.0.jar
deleted file mode 100644
index 66c18b6fbf..0000000000
Binary files a/embedded-repo/com/redis/redisclient/2.8.0-2.0/redisclient-2.8.0-2.0.jar and /dev/null differ
diff --git a/embedded-repo/com/redis/redisclient/2.8.0-2.0/redisclient-2.8.0-2.0.pom b/embedded-repo/com/redis/redisclient/2.8.0-2.0/redisclient-2.8.0-2.0.pom
deleted file mode 100644
index 12558da1c4..0000000000
--- a/embedded-repo/com/redis/redisclient/2.8.0-2.0/redisclient-2.8.0-2.0.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- com.redis
- redisclient
- 2.8.0-2.0
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/com/redis/redisclient/2.8.0.RC7-1.4/redisclient-2.8.0.RC7-1.4.jar b/embedded-repo/com/redis/redisclient/2.8.0.RC7-1.4/redisclient-2.8.0.RC7-1.4.jar
deleted file mode 100644
index d25fcfdccf..0000000000
Binary files a/embedded-repo/com/redis/redisclient/2.8.0.RC7-1.4/redisclient-2.8.0.RC7-1.4.jar and /dev/null differ
diff --git a/embedded-repo/com/trifork/riak-java-pb-client/1.0-for-akka-by-ticktock/riak-java-pb-client-1.0-for-akka-by-ticktock.jar b/embedded-repo/com/trifork/riak-java-pb-client/1.0-for-akka-by-ticktock/riak-java-pb-client-1.0-for-akka-by-ticktock.jar
deleted file mode 100644
index 053eb397c7..0000000000
Binary files a/embedded-repo/com/trifork/riak-java-pb-client/1.0-for-akka-by-ticktock/riak-java-pb-client-1.0-for-akka-by-ticktock.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar
deleted file mode 100644
index 7aa1393153..0000000000
Binary files a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar.md5 b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar.md5
deleted file mode 100644
index 46500d76fc..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-607f775c6b2ec1954fe60717875aefea
\ No newline at end of file
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar.sha1 b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar.sha1
deleted file mode 100644
index 3eb85256e2..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1-sources.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-ee377a85bf07b2afb3a98157f926ebdb47a5e88c
\ No newline at end of file
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar
deleted file mode 100644
index 7222c09136..0000000000
Binary files a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar.md5 b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar.md5
deleted file mode 100644
index be8f3065c7..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar.md5
+++ /dev/null
@@ -1 +0,0 @@
-ba1be87b58c03e8ae6f890ca87c74b5b
\ No newline at end of file
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar.sha1 b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar.sha1
deleted file mode 100644
index aa86a31839..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-aaa96009d7e151f89703b4d932fc73ebcf9bc973
\ No newline at end of file
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom
deleted file mode 100644
index e3cdbce60d..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
-
-
- 4.0.0
-
-
- org.apache.camel
- camel-parent
- 2.4.0
-
-
- camel-jetty
- bundle
- Camel :: Jetty
- Camel Jetty support
- 2.4.0.1
-
-
- org.apache.camel.component.jetty.*
-
-
-
-
-
- org.apache.camel
- camel-core
- 2.4.0
-
-
- org.apache.camel
- camel-http
- 2.4.0
-
-
- org.eclipse.jetty
- jetty-server
-
-
- org.eclipse.jetty
- jetty-security
-
-
- org.eclipse.jetty
- jetty-servlet
-
-
- org.eclipse.jetty
- jetty-servlets
- ${jetty-version}
-
-
- org.eclipse.jetty
- jetty-client
-
-
- org.eclipse.jetty
- jetty-jmx
- ${jetty-version}
-
-
-
- org.apache.camel
- camel-test
- 2.4.0
- test
-
-
- org.apache.camel
- camel-spring
- 2.4.0
- test
-
-
- javax.mail
- mail
- ${javax-mail-version}
- test
-
-
-
- org.springframework
- spring-context
- true
- test
-
-
- org.springframework
- spring-aop
- true
- test
-
-
- org.springframework
- spring-test
- true
- test
-
-
-
- junit
- junit
- test
-
-
- log4j
- log4j
- test
-
-
-
-
-
-
-
- maven-surefire-plugin
-
- pertest
-
-
-
- **/*XXXTest.*
-
-
-
-
-
-
-
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom.md5 b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom.md5
deleted file mode 100644
index 295aae7a23..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom.md5
+++ /dev/null
@@ -1 +0,0 @@
-fba57baa166195ac2b2a013c3cc6d3f1
\ No newline at end of file
diff --git a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom.sha1 b/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom.sha1
deleted file mode 100644
index 7fb0b3347f..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/2.4.0.1/camel-jetty-2.4.0.1.pom.sha1
+++ /dev/null
@@ -1 +0,0 @@
-c41ff483ac35754c1d41b1823561935849b362ed
\ No newline at end of file
diff --git a/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml b/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml
deleted file mode 100644
index ac53a45ab4..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
- org.apache.camel
- camel-jetty
- 2.4.0.1
-
-
- 2.4.0.1
-
- 20100723102939
-
-
diff --git a/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml.md5 b/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml.md5
deleted file mode 100644
index fcff48b3ce..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml.md5
+++ /dev/null
@@ -1 +0,0 @@
-34f1efbcb11f7251390994d8f81598b2
\ No newline at end of file
diff --git a/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml.sha1 b/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml.sha1
deleted file mode 100644
index 64ef58e71f..0000000000
--- a/embedded-repo/org/apache/camel/camel-jetty/maven-metadata.xml.sha1
+++ /dev/null
@@ -1 +0,0 @@
-2e1bb47c5a8c19f98b70e5e6af450861933deacc
\ No newline at end of file
diff --git a/embedded-repo/org/apache/cassandra/cassandra/0.4.1/cassandra-0.4.1.jar b/embedded-repo/org/apache/cassandra/cassandra/0.4.1/cassandra-0.4.1.jar
deleted file mode 100644
index 5c618e9cfc..0000000000
Binary files a/embedded-repo/org/apache/cassandra/cassandra/0.4.1/cassandra-0.4.1.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/cassandra/cassandra/0.4.1/cassandra-0.4.1.pom b/embedded-repo/org/apache/cassandra/cassandra/0.4.1/cassandra-0.4.1.pom
deleted file mode 100755
index 7a59483ddd..0000000000
--- a/embedded-repo/org/apache/cassandra/cassandra/0.4.1/cassandra-0.4.1.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- org.apache.cassandra
- cassandra
- 0.4.1
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/org/apache/cassandra/cassandra/0.5.0/cassandra-0.5.0.jar b/embedded-repo/org/apache/cassandra/cassandra/0.5.0/cassandra-0.5.0.jar
deleted file mode 100644
index 05bfccec95..0000000000
Binary files a/embedded-repo/org/apache/cassandra/cassandra/0.5.0/cassandra-0.5.0.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/cassandra/cassandra/0.6.1/cassandra-0.6.1.jar b/embedded-repo/org/apache/cassandra/cassandra/0.6.1/cassandra-0.6.1.jar
deleted file mode 100644
index c7c71b1750..0000000000
Binary files a/embedded-repo/org/apache/cassandra/cassandra/0.6.1/cassandra-0.6.1.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/cassandra/cassandra/0.6.1/cassandra-0.6.1.pom b/embedded-repo/org/apache/cassandra/cassandra/0.6.1/cassandra-0.6.1.pom
deleted file mode 100755
index 4969b74564..0000000000
--- a/embedded-repo/org/apache/cassandra/cassandra/0.6.1/cassandra-0.6.1.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- org.apache.cassandra
- cassandra
- 0.6.1
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/org/apache/cassandra/clhm-production/0.5.0/clhm-production-0.5.0.jar b/embedded-repo/org/apache/cassandra/clhm-production/0.5.0/clhm-production-0.5.0.jar
deleted file mode 100644
index 028f505bb9..0000000000
Binary files a/embedded-repo/org/apache/cassandra/clhm-production/0.5.0/clhm-production-0.5.0.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/cassandra/clhm-production/0.6.1/clhm-production-0.6.1.jar b/embedded-repo/org/apache/cassandra/clhm-production/0.6.1/clhm-production-0.6.1.jar
deleted file mode 100644
index 028f505bb9..0000000000
Binary files a/embedded-repo/org/apache/cassandra/clhm-production/0.6.1/clhm-production-0.6.1.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/cassandra/clhm-production/0.6.1/clhm-production-0.6.1.pom b/embedded-repo/org/apache/cassandra/clhm-production/0.6.1/clhm-production-0.6.1.pom
deleted file mode 100755
index 432c1c225d..0000000000
--- a/embedded-repo/org/apache/cassandra/clhm-production/0.6.1/clhm-production-0.6.1.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- org.apache.cassandra
- clhm-production
- 0.6.1
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/org/apache/cassandra/high-scale-lib/0.5.0/high-scale-lib-0.5.0.jar b/embedded-repo/org/apache/cassandra/high-scale-lib/0.5.0/high-scale-lib-0.5.0.jar
deleted file mode 100644
index 421a436eed..0000000000
Binary files a/embedded-repo/org/apache/cassandra/high-scale-lib/0.5.0/high-scale-lib-0.5.0.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/cassandra/high-scale-lib/0.6.1/high-scale-lib-0.6.1.jar b/embedded-repo/org/apache/cassandra/high-scale-lib/0.6.1/high-scale-lib-0.6.1.jar
deleted file mode 100644
index 421a436eed..0000000000
Binary files a/embedded-repo/org/apache/cassandra/high-scale-lib/0.6.1/high-scale-lib-0.6.1.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/cassandra/high-scale-lib/0.6.1/high-scale-lib-0.6.1.pom b/embedded-repo/org/apache/cassandra/high-scale-lib/0.6.1/high-scale-lib-0.6.1.pom
deleted file mode 100755
index c361dbef9f..0000000000
--- a/embedded-repo/org/apache/cassandra/high-scale-lib/0.6.1/high-scale-lib-0.6.1.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- org.apache.cassandra
- high-scale-lib
- 0.6.1
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/org/apache/hbase/hbase-core/0.20.6/hbase-core-0.20.6.jar b/embedded-repo/org/apache/hbase/hbase-core/0.20.6/hbase-core-0.20.6.jar
deleted file mode 100644
index e74cf9017e..0000000000
Binary files a/embedded-repo/org/apache/hbase/hbase-core/0.20.6/hbase-core-0.20.6.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/hbase/hbase-core/0.20.6/hbase-core-0.20.6.pom b/embedded-repo/org/apache/hbase/hbase-core/0.20.6/hbase-core-0.20.6.pom
deleted file mode 100644
index 19a8b54700..0000000000
--- a/embedded-repo/org/apache/hbase/hbase-core/0.20.6/hbase-core-0.20.6.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- org.apache.hbase
- hbase-core
- 0.20.6
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/org/apache/hbase/hbase-test/0.20.6/hbase-test-0.20.6.jar b/embedded-repo/org/apache/hbase/hbase-test/0.20.6/hbase-test-0.20.6.jar
deleted file mode 100644
index 34a65f908e..0000000000
Binary files a/embedded-repo/org/apache/hbase/hbase-test/0.20.6/hbase-test-0.20.6.jar and /dev/null differ
diff --git a/embedded-repo/org/apache/hbase/hbase-test/0.20.6/hbase-test-0.20.6.pom b/embedded-repo/org/apache/hbase/hbase-test/0.20.6/hbase-test-0.20.6.pom
deleted file mode 100644
index bdc80cc8b7..0000000000
--- a/embedded-repo/org/apache/hbase/hbase-test/0.20.6/hbase-test-0.20.6.pom
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 4.0.0
- org.apache.hbase
- hbase-test
- 0.20.6
- jar
-
\ No newline at end of file
diff --git a/embedded-repo/spy/memcached/2.5/memcached-2.5.jar b/embedded-repo/spy/memcached/2.5/memcached-2.5.jar
deleted file mode 100644
index 87072eaaa0..0000000000
Binary files a/embedded-repo/spy/memcached/2.5/memcached-2.5.jar and /dev/null differ
diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala
index 04cfe46324..9e150ea613 100644
--- a/project/build/AkkaProject.scala
+++ b/project/build/AkkaProject.scala
@@ -289,15 +289,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val akka_stm = project("akka-stm", "akka-stm", new AkkaStmProject(_), akka_actor)
lazy val akka_typed_actor = project("akka-typed-actor", "akka-typed-actor", new AkkaTypedActorProject(_), akka_stm)
lazy val akka_remote = project("akka-remote", "akka-remote", new AkkaRemoteProject(_), akka_typed_actor)
- lazy val akka_amqp = project("akka-amqp", "akka-amqp", new AkkaAMQPProject(_), akka_remote)
- lazy val akka_http = project("akka-http", "akka-http", new AkkaHttpProject(_), akka_remote, akka_camel)
- lazy val akka_camel = project("akka-camel", "akka-camel", new AkkaCamelProject(_), akka_remote)
- lazy val akka_persistence = project("akka-persistence", "akka-persistence", new AkkaPersistenceParentProject(_))
- lazy val akka_spring = project("akka-spring", "akka-spring", new AkkaSpringProject(_), akka_remote, akka_camel)
- lazy val akka_jta = project("akka-jta", "akka-jta", new AkkaJTAProject(_), akka_stm, akka_remote)
- lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_),
- akka_remote, akka_jta, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp)
- lazy val akka_osgi = project("akka-osgi", "akka-osgi", new AkkaOSGiParentProject(_))
+ lazy val akka_http = project("akka-http", "akka-http", new AkkaHttpProject(_), akka_remote)
lazy val akka_samples = project("akka-samples", "akka-samples", new AkkaSamplesParentProject(_))
// -------------------------------------------------------------------------------------------------------------------
@@ -475,23 +467,6 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
override def bndImportPackage = "javax.transaction;version=1.1" :: super.bndImportPackage.toList
}
- // -------------------------------------------------------------------------------------------------------------------
- // akka-amqp subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaAMQPProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val commons_io = Dependencies.commons_io
- val rabbit = Dependencies.rabbit
- val protobuf = Dependencies.protobuf
-
- // testing
- val junit = Dependencies.junit
- val multiverse = Dependencies.multiverse
- val scalatest = Dependencies.scalatest
-
- override def testOptions = createTestFilter( _.endsWith("Test") )
- }
-
// -------------------------------------------------------------------------------------------------------------------
// akka-http subproject
// -------------------------------------------------------------------------------------------------------------------
@@ -527,314 +502,6 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
override def testOptions = createTestFilter( _.endsWith("Test"))
}
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaPersistenceParentProject(info: ProjectInfo) extends ParentProject(info) {
- override def disableCrossPaths = true
-
- lazy val akka_persistence_common = project("akka-persistence-common", "akka-persistence-common",
- new AkkaPersistenceCommonProject(_), akka_remote, akka_stm)
- lazy val akka_persistence_redis = project("akka-persistence-redis", "akka-persistence-redis",
- new AkkaRedisProject(_), akka_persistence_common)
- lazy val akka_persistence_mongo = project("akka-persistence-mongo", "akka-persistence-mongo",
- new AkkaMongoProject(_), akka_persistence_common)
- lazy val akka_persistence_cassandra = project("akka-persistence-cassandra", "akka-persistence-cassandra",
- new AkkaCassandraProject(_), akka_persistence_common)
- lazy val akka_persistence_hbase = project("akka-persistence-hbase", "akka-persistence-hbase",
- new AkkaHbaseProject(_), akka_persistence_common)
- lazy val akka_persistence_voldemort = project("akka-persistence-voldemort", "akka-persistence-voldemort",
- new AkkaVoldemortProject(_), akka_persistence_common)
- lazy val akka_persistence_riak = project("akka-persistence-riak", "akka-persistence-riak",
- new AkkaRiakProject(_), akka_persistence_common)
- lazy val akka_persistence_couchdb = project("akka-persistence-couchdb", "akka-persistence-couchdb",
- new AkkaCouchDBProject(_), akka_persistence_common)
- lazy val akka_persistence_memcached= project("akka-persistence-memcached", "akka-persistence-memcached",
- new AkkaMemcachedProject(_), akka_persistence_common)
- lazy val akka_persistence_simpledb= project("akka-persistence-simpledb", "akka-persistence-simpledb",
- new AkkaSimpledbProject(_), akka_persistence_common)
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-common subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaPersistenceCommonProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val commons_pool = Dependencies.commons_pool
- val thrift = Dependencies.thrift
- val scalaj_coll = Dependencies.scalaj_coll
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-redis subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaRedisProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val commons_codec = Dependencies.commons_codec
- val redis = Dependencies.redis
-
- override def testOptions = createTestFilter( _.endsWith("Test"))
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-mongo subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaMongoProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val mongo = Dependencies.mongo
- val casbah = Dependencies.casbah
-
- override def testOptions = createTestFilter( _.endsWith("Test"))
- }
-
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-cassandra subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaCassandraProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val cassandra = Dependencies.cassandra
-
- // testing
- val cassandra_clhm = Dependencies.cassandra_clhm
- val commons_coll = Dependencies.commons_coll
- val google_coll = Dependencies.google_coll
- val high_scale = Dependencies.high_scale
-
- override def testOptions = createTestFilter( _.endsWith("Test"))
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-hbase subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaHbaseProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- override def ivyXML =
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- override def testOptions = createTestFilter( _.endsWith("Test") )
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-voldemort subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaVoldemortProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val voldemort = Dependencies.voldemort
- val voldemort_contrib = Dependencies.voldemort_contrib
- val voldemort_needs_log4j = Dependencies.voldemort_needs_log4j
-
- //testing
- val scalatest = Dependencies.scalatest
- val google_coll = Dependencies.google_coll
- val jdom = Dependencies.jdom
- val jetty = Dependencies.vold_jetty
- val velocity = Dependencies.velocity
- val dbcp = Dependencies.dbcp
- val sjson = Dependencies.sjson_test
-
- override def testOptions = createTestFilter({ s:String=> s.endsWith("Suite") || s.endsWith("Test")})
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-riak subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaRiakProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val riak_pb = Dependencies.riak_pb_client
- val protobuf = Dependencies.protobuf
- //testing
- val scalatest = Dependencies.scalatest
-
-
- override def testOptions = createTestFilter(_.endsWith("Test"))
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-persistence-couchdb subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaCouchDBProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val couch = Dependencies.commonsHttpClient
- val spec = Dependencies.specs
-
- override def testOptions = createTestFilter( _.endsWith("Test"))
- }
-
- class AkkaMemcachedProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val memcached = Dependencies.spymemcached
- val commons_codec = Dependencies.commons_codec
-
- val scalatest = Dependencies.scalatest
-
- override def testOptions = createTestFilter( _.endsWith("Test"))
- }
-
- class AkkaSimpledbProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val memcached = Dependencies.simpledb
- val commons_codec = Dependencies.commons_codec
- val http = Dependencies.commonsHttpClient
-
- val scalatest = Dependencies.scalatest
-
- override def testOptions = createTestFilter( _.endsWith("Test"))
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-kernel subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaKernelProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath)
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-spring subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaSpringProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val spring_beans = Dependencies.spring_beans
- val spring_context = Dependencies.spring_context
-
- // testing
- val camel_spring = Dependencies.camel_spring
- val junit = Dependencies.junit
- val scalatest = Dependencies.scalatest
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // akka-jta subproject
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaJTAProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
- val atomikos_transactions = Dependencies.atomikos_transactions
- val atomikos_transactions_api = Dependencies.atomikos_transactions_api
- val atomikos_transactions_jta = Dependencies.atomikos_transactions_jta
- //val jta_1_1 = Dependencies.jta_1_1
- //val atomikos_transactions_util = "com.atomikos" % "transactions-util" % "3.2.3" % "compile"
-
- //Testing
- val junit = Dependencies.junit
- val scalatest = Dependencies.scalatest
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // OSGi stuff
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaOSGiParentProject(info: ProjectInfo) extends ParentProject(info) {
- override def disableCrossPaths = true
-
- lazy val akka_osgi_dependencies_bundle = project("akka-osgi-dependencies-bundle", "akka-osgi-dependencies-bundle",
- new AkkaOSGiDependenciesBundleProject(_), akka_kernel, akka_jta) // akka_kernel does not depend on akka_jta (why?) therefore we list akka_jta here
- lazy val akka_osgi_assembly = project("akka-osgi-assembly", "akka-osgi-assembly",
- new AkkaOSGiAssemblyProject(_), akka_osgi_dependencies_bundle, akka_remote, akka_amqp, akka_http,
- akka_camel, akka_spring, akka_jta, akka_persistence.akka_persistence_common,
- akka_persistence.akka_persistence_redis, akka_persistence.akka_persistence_mongo,
- akka_persistence.akka_persistence_cassandra,akka_persistence.akka_persistence_hbase,
- akka_persistence.akka_persistence_voldemort)
- }
-
- class AkkaOSGiDependenciesBundleProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with BNDPlugin {
- override def bndClasspath = compileClasspath
- override def bndPrivatePackage = Seq("")
- override def bndImportPackage = Seq("*;resolution:=optional")
- override def bndExportPackage = Seq(
- "org.aopalliance.*;version=1.0.0",
-
- // Provided by other bundles
- "!akka.*",
- "!com.google.inject.*",
- "!javax.transaction.*",
- "!javax.ws.rs.*",
- "!javax.jms.*",
- "!javax.transaction,*",
- "!org.apache.commons.io.*",
- "!org.apache.commons.pool.*",
- "!org.codehaus.jackson.*",
- "!org.jboss.netty.*",
- "!org.springframework.*",
- "!org.apache.camel.*",
- "!org.fusesource.commons.management.*",
-
- "*;version=0.0.0")
- }
-
- class AkkaOSGiAssemblyProject(info: ProjectInfo) extends DefaultProject(info) {
- override def disableCrossPaths = true
-
- // Scala bundle
- val scala_bundle = "com.weiglewilczek.scala-lang-osgi" % "scala-library" % buildScalaVersion % "compile" intransitive
-
- // Camel bundles
- val camel_core = Dependencies.camel_core.intransitive
- val fusesource_commonman = "org.fusesource.commonman" % "commons-management" % "1.0" intransitive
-
- // Spring bundles
- val spring_beans = Dependencies.spring_beans.intransitive
- val spring_context = Dependencies.spring_context.intransitive
- val spring_aop = "org.springframework" % "spring-aop" % SPRING_VERSION % "compile" intransitive
- val spring_asm = "org.springframework" % "spring-asm" % SPRING_VERSION % "compile" intransitive
- val spring_core = "org.springframework" % "spring-core" % SPRING_VERSION % "compile" intransitive
- val spring_expression = "org.springframework" % "spring-expression" % SPRING_VERSION % "compile" intransitive
- val spring_jms = "org.springframework" % "spring-jms" % SPRING_VERSION % "compile" intransitive
- val spring_tx = "org.springframework" % "spring-tx" % SPRING_VERSION % "compile" intransitive
-
- val commons_codec = Dependencies.commons_codec.intransitive
- val commons_io = Dependencies.commons_io.intransitive
- val commons_pool = Dependencies.commons_pool.intransitive
- val guicey = Dependencies.guicey.intransitive
- val jackson = Dependencies.jackson.intransitive
- val jackson_core = Dependencies.jackson_core.intransitive
- val jsr311 = Dependencies.jsr311.intransitive
- val jta_1_1 = Dependencies.jta_1_1.intransitive
- val netty = Dependencies.netty.intransitive
- val commons_fileupload = "commons-fileupload" % "commons-fileupload" % "1.2.1" % "compile" intransitive
- val jms_1_1 = "org.apache.geronimo.specs" % "geronimo-jms_1.1_spec" % "1.1.1" % "compile" intransitive
- val joda = "joda-time" % "joda-time" % "1.6" intransitive
-
- override def packageAction =
- task {
- val libs: Seq[Path] = managedClasspath(config("compile")).get.toSeq
- val prjs: Seq[Path] = info.dependencies.toSeq.asInstanceOf[Seq[DefaultProject]] map { _.jarPath }
- val all = libs ++ prjs
- val destination = outputPath / "bundles"
- FileUtilities.copyFlat(all, destination, log)
- log info "Copied %s bundles to %s".format(all.size, destination)
- None
- }
-
- override def artifacts = Set.empty
- }
-
- // -------------------------------------------------------------------------------------------------------------------
- // Test
- // -------------------------------------------------------------------------------------------------------------------
-
- class AkkaTypedActorTestProject(info: ProjectInfo) extends DefaultProject(info) {
- // testing
- val junit = "junit" % "junit" % "4.5" % "test"
- val jmock = "org.jmock" % "jmock" % "2.4.0" % "test"
- }
-
// -------------------------------------------------------------------------------------------------------------------
// Examples
// -------------------------------------------------------------------------------------------------------------------
@@ -845,72 +512,17 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
}
class AkkaSampleChatProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath)
- class AkkaSamplePubSubProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath)
- class AkkaSampleFSMProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath)
-
- class AkkaSampleRestJavaProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath)
-
class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath)
- class AkkaSampleRestScalaProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) {
- val jsr311 = Dependencies.jsr311
- }
-
- class AkkaSampleCamelProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) {
- //Must be like this to be able to exclude the geronimo-servlet_2.4_spec which is a too old Servlet spec
- override def ivyXML =
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- override def testOptions = createTestFilter( _.endsWith("Test"))
- }
-
- class AkkaSampleSecurityProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) {
- val commons_codec = Dependencies.commons_codec
- val jsr250 = Dependencies.jsr250
- val jsr311 = Dependencies.jsr311
- }
-
- class AkkaSampleOSGiProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with BNDPlugin {
- val osgi_core = Dependencies.osgi_core
- override lazy val bndBundleActivator = Some("akka.sample.osgi.Activator")
- override lazy val bndExportPackage = Nil // Necessary because of mixing-in AkkaDefaultProject which exports all ...akka.* packages!
- }
-
class AkkaSamplesParentProject(info: ProjectInfo) extends ParentProject(info) {
override def disableCrossPaths = true
lazy val akka_sample_ants = project("akka-sample-ants", "akka-sample-ants",
new AkkaSampleAntsProject(_), akka_stm)
lazy val akka_sample_chat = project("akka-sample-chat", "akka-sample-chat",
- new AkkaSampleChatProject(_), akka_kernel)
- lazy val akka_sample_pubsub = project("akka-sample-pubsub", "akka-sample-pubsub",
- new AkkaSamplePubSubProject(_), akka_kernel)
- lazy val akka_sample_fsm = project("akka-sample-fsm", "akka-sample-fsm",
- new AkkaSampleFSMProject(_), akka_kernel)
- lazy val akka_sample_rest_java = project("akka-sample-rest-java", "akka-sample-rest-java",
- new AkkaSampleRestJavaProject(_), akka_kernel)
- lazy val akka_sample_rest_scala = project("akka-sample-rest-scala", "akka-sample-rest-scala",
- new AkkaSampleRestScalaProject(_), akka_kernel)
- lazy val akka_sample_camel = project("akka-sample-camel", "akka-sample-camel",
- new AkkaSampleCamelProject(_), akka_kernel)
- lazy val akka_sample_security = project("akka-sample-security", "akka-sample-security",
- new AkkaSampleSecurityProject(_), akka_kernel)
+ new AkkaSampleChatProject(_), akka_remote)
lazy val akka_sample_remote = project("akka-sample-remote", "akka-sample-remote",
- new AkkaSampleRemoteProject(_), akka_kernel)
- lazy val akka_sample_osgi = project("akka-sample-osgi", "akka-sample-osgi",
- new AkkaSampleOSGiProject(_), akka_remote)
+ new AkkaSampleRemoteProject(_), akka_remote)
}
// -------------------------------------------------------------------------------------------------------------------