From 2e2d1eb24214276699d396fbc4f48625bdd9797f Mon Sep 17 00:00:00 2001 From: sclasen Date: Mon, 23 May 2011 12:34:54 -0400 Subject: [PATCH] second pass, mostly compiles --- .../main/scala/akka/camel/TypedCamel.scala | 2 +- .../main/scala/akka/camel/TypedConsumer.scala | 8 +- .../akka/camel/TypedConsumerPublisher.scala | 18 +-- .../camel/component/TypedActorComponent.scala | 6 +- .../akka/camel/TypedCamelTestSupport.scala | 28 ++-- .../TypedConsumerPublishRequestorTest.scala | 26 +-- .../akka/camel/TypedConsumerScalaTest.scala | 20 +-- .../TypedActorComponentFeatureTest.scala | 10 +- .../spring/ActorBeanDefinitionParser.scala | 5 +- .../scala/akka/spring/ActorFactoryBean.scala | 150 ++++++++++-------- .../main/scala/akka/spring/ActorParser.scala | 11 +- .../scala/akka/spring/ActorProperties.scala | 8 +- .../spring/AkkaSpringConfigurationTags.scala | 6 +- .../CamelServiceBeanDefinitionParser.scala | 3 +- .../akka/spring/CamelServiceFactoryBean.scala | 7 +- ...onfiggyPropertyPlaceholderConfigurer.scala | 4 +- .../DispatcherBeanDefinitionParser.scala | 3 +- .../akka/spring/DispatcherFactoryBean.scala | 92 +++++------ .../akka/spring/DispatcherProperties.scala | 26 +-- .../scala/akka/spring/PropertyEntries.scala | 1 - .../SupervisionBeanDefinitionParser.scala | 10 +- .../akka/spring/SupervisionFactoryBean.scala | 24 +-- .../java/akka/spring/foo/StatefulPojo.java | 6 +- .../src/test/scala/ActorFactoryBeanTest.scala | 6 +- .../scala/CamelServiceSpringFeatureTest.scala | 6 +- ...ggyPropertyPlaceholderConfigurerSpec.scala | 10 +- .../DispatcherBeanDefinitionParserTest.scala | 38 ++--- .../scala/DispatcherSpringFeatureTest.scala | 20 ++- akka-spring/src/test/scala/ScalaDom.scala | 22 +-- .../SupervisionBeanDefinitionParserTest.scala | 59 ++++--- .../scala/SupervisionFactoryBeanTest.scala | 2 +- .../scala/SupervisorSpringFeatureTest.scala | 5 +- .../TypedActorBeanDefinitionParserTest.scala | 20 +-- .../scala/TypedActorSpringFeatureTest.scala | 17 +- .../scala/UntypedActorSpringFeatureTest.scala | 11 +- project/build/AkkaProject.scala | 10 +- 36 files changed, 338 insertions(+), 362 deletions(-) diff --git a/akka-camel-typed/src/main/scala/akka/camel/TypedCamel.scala b/akka-camel-typed/src/main/scala/akka/camel/TypedCamel.scala index 43acec977f..89b288d118 100644 --- a/akka-camel-typed/src/main/scala/akka/camel/TypedCamel.scala +++ b/akka-camel-typed/src/main/scala/akka/camel/TypedCamel.scala @@ -37,7 +37,7 @@ private[camel] object TypedCamel { registerPublishRequestor - for (event <- PublishRequestor.pastActorRegisteredEvents) publishRequestor ! event + for (event ← PublishRequestor.pastActorRegisteredEvents) publishRequestor ! event publishRequestor ! InitPublishRequestor(consumerPublisher.start) } diff --git a/akka-camel-typed/src/main/scala/akka/camel/TypedConsumer.scala b/akka-camel-typed/src/main/scala/akka/camel/TypedConsumer.scala index e2a4cf2e58..c315742f3a 100644 --- a/akka-camel-typed/src/main/scala/akka/camel/TypedConsumer.scala +++ b/akka-camel-typed/src/main/scala/akka/camel/TypedConsumer.scala @@ -6,7 +6,7 @@ package akka.camel import java.lang.reflect.Method -import akka.actor.{TypedActor, ActorRef} +import akka.actor.{ TypedActor, ActorRef } /** * @author Martin Krasser @@ -21,7 +21,7 @@ private[camel] object TypedConsumer { * is called with the corresponding method instance and the return value is * added to a list which is then returned by this method. */ - def withTypedConsumer[T](actorRef: ActorRef)(f: Method => T): List[T] = { + def withTypedConsumer[T](actorRef: ActorRef)(f: Method ⇒ T): List[T] = { if (!actorRef.actor.isInstanceOf[TypedActor]) Nil else if (actorRef.homeAddress.isDefined) Nil else { @@ -31,8 +31,8 @@ private[camel] object TypedConsumer { // - visit implemented method declarations in interfaces val intfClass = typedActor.proxy.getClass val implClass = typedActor.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)) + (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)) } } } diff --git a/akka-camel-typed/src/main/scala/akka/camel/TypedConsumerPublisher.scala b/akka-camel-typed/src/main/scala/akka/camel/TypedConsumerPublisher.scala index 8e7ed87100..883b98afce 100644 --- a/akka-camel-typed/src/main/scala/akka/camel/TypedConsumerPublisher.scala +++ b/akka-camel-typed/src/main/scala/akka/camel/TypedConsumerPublisher.scala @@ -19,8 +19,8 @@ import akka.camel.component.TypedActorComponent */ private[camel] class TypedConsumerPublishRequestor extends PublishRequestor { def receiveActorRegistryEvent = { - case ActorRegistered(actor) => for (event <- ConsumerMethodRegistered.eventsFor(actor)) deliverCurrentEvent(event) - case ActorUnregistered(actor) => for (event <- ConsumerMethodUnregistered.eventsFor(actor)) deliverCurrentEvent(event) + case ActorRegistered(actor) ⇒ for (event ← ConsumerMethodRegistered.eventsFor(actor)) deliverCurrentEvent(event) + case ActorUnregistered(actor) ⇒ for (event ← ConsumerMethodUnregistered.eventsFor(actor)) deliverCurrentEvent(event) } } @@ -36,15 +36,15 @@ private[camel] class TypedConsumerPublisher(activationTracker: ActorRef) extends import TypedConsumerPublisher._ def receive = { - case mr: ConsumerMethodRegistered => { + case mr: ConsumerMethodRegistered ⇒ { handleConsumerMethodRegistered(mr) activationTracker ! EndpointActivated } - case mu: ConsumerMethodUnregistered => { + case mu: ConsumerMethodUnregistered ⇒ { handleConsumerMethodUnregistered(mu) activationTracker ! EndpointDeactivated } - case _ => { /* ignore */} + case _ ⇒ { /* ignore */ } } } @@ -117,8 +117,8 @@ private[camel] object ConsumerMethodRegistered { * list if actorRef doesn't reference a typed consumer actor. */ def eventsFor(actorRef: ActorRef): List[ConsumerMethodRegistered] = { - TypedConsumer.withTypedConsumer(actorRef: ActorRef) { - m => ConsumerMethodRegistered(actorRef, m) + TypedConsumer.withTypedConsumer(actorRef: ActorRef) { m ⇒ + ConsumerMethodRegistered(actorRef, m) } } } @@ -132,8 +132,8 @@ private[camel] object ConsumerMethodUnregistered { * list if actorRef doesn't reference a typed consumer actor. */ def eventsFor(actorRef: ActorRef): List[ConsumerMethodUnregistered] = { - TypedConsumer.withTypedConsumer(actorRef) { - m => ConsumerMethodUnregistered(actorRef, m) + TypedConsumer.withTypedConsumer(actorRef) { m ⇒ + ConsumerMethodUnregistered(actorRef, m) } } } diff --git a/akka-camel-typed/src/main/scala/akka/camel/component/TypedActorComponent.scala b/akka-camel-typed/src/main/scala/akka/camel/component/TypedActorComponent.scala index 2731c4ab07..5110867fa7 100644 --- a/akka-camel-typed/src/main/scala/akka/camel/component/TypedActorComponent.scala +++ b/akka-camel-typed/src/main/scala/akka/camel/component/TypedActorComponent.scala @@ -62,7 +62,7 @@ class TypedActorComponent extends BeanComponent { * @author Martin Krasser */ class TypedActorHolder(uri: String, context: CamelContext, name: String) - extends RegistryBean(context, name) { + extends RegistryBean(context, name) { /** * Returns an akka.camel.component.TypedActorInfo instance. @@ -90,7 +90,7 @@ class TypedActorHolder(uri: String, context: CamelContext, name: String) * @author Martin Krasser */ class TypedActorInfo(context: CamelContext, clazz: Class[_], strategy: ParameterMappingStrategy) - extends BeanInfo(context, clazz, strategy) { + extends BeanInfo(context, clazz, strategy) { /** * Introspects AspectWerkz proxy classes. @@ -105,7 +105,7 @@ class TypedActorInfo(context: CamelContext, clazz: Class[_], strategy: Parameter // created from interfaces with AspectWerkz. Once the fix is in // place this method can be removed. - for (method <- clazz.getDeclaredMethods) { + for (method ← clazz.getDeclaredMethods) { if (isValidMethod(clazz, method)) { introspect(clazz, method) } diff --git a/akka-camel-typed/src/test/scala/akka/camel/TypedCamelTestSupport.scala b/akka-camel-typed/src/test/scala/akka/camel/TypedCamelTestSupport.scala index ea67772b88..f8b597ba1e 100644 --- a/akka-camel-typed/src/test/scala/akka/camel/TypedCamelTestSupport.scala +++ b/akka-camel-typed/src/test/scala/akka/camel/TypedCamelTestSupport.scala @@ -11,7 +11,7 @@ object TypedCamelTestSupport { trait TestActor extends Actor { def receive = { - case msg => { + case msg ⇒ { handler(msg) } } @@ -19,48 +19,48 @@ object TypedCamelTestSupport { def handler: Handler } - trait Countdown { this: Actor => + trait Countdown { this: Actor ⇒ var latch: CountDownLatch = new CountDownLatch(0) def countdown: Handler = { - case SetExpectedMessageCount(num) => { + case SetExpectedMessageCount(num) ⇒ { latch = new CountDownLatch(num) self.reply(latch) } - case msg => latch.countDown + case msg ⇒ latch.countDown } } - trait Respond { this: Actor => + trait Respond { this: Actor ⇒ def respond: Handler = { - case msg: Message => self.reply(response(msg)) + case msg: Message ⇒ self.reply(response(msg)) } def response(msg: Message): Any = "Hello %s" format msg.body } - trait Retain { this: Actor => + 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 => { + case GetRetainedMessage ⇒ self.reply(messages.last) + case GetRetainedMessages(p) ⇒ self.reply(messages.toList.filter(p)) + case msg ⇒ { messages += msg msg } } } - trait Noop { this: Actor => + trait Noop { this: Actor ⇒ def noop: Handler = { - case msg => msg + case msg ⇒ msg } } case class SetExpectedMessageCount(num: Int) case class GetRetainedMessage() - case class GetRetainedMessages(p: Any => Boolean) { - def this() = this(_ => true) + case class GetRetainedMessages(p: Any ⇒ Boolean) { + def this() = this(_ ⇒ true) } } diff --git a/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerPublishRequestorTest.scala b/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerPublishRequestorTest.scala index 16fd30bfe9..406c5656c1 100644 --- a/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerPublishRequestorTest.scala +++ b/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerPublishRequestorTest.scala @@ -1,13 +1,13 @@ package akka.camel -import java.util.concurrent.{CountDownLatch, TimeUnit} +import java.util.concurrent.{ CountDownLatch, TimeUnit } -import org.junit.{Before, After, Test} +import org.junit.{ Before, After, Test } import org.scalatest.junit.JUnitSuite import akka.actor._ import akka.actor.Actor._ -import akka.camel.TypedCamelTestSupport.{SetExpectedMessageCount => SetExpectedTestMessageCount, _} +import akka.camel.TypedCamelTestSupport.{ SetExpectedMessageCount ⇒ SetExpectedTestMessageCount, _ } class TypedConsumerPublishRequestorTest extends JUnitSuite { import TypedConsumerPublishRequestorTest._ @@ -16,10 +16,11 @@ class TypedConsumerPublishRequestorTest extends JUnitSuite { var requestor: ActorRef = _ var consumer: ActorRef = _ - val ascendingMethodName = (r1: ConsumerMethodRegistered, r2: ConsumerMethodRegistered) => + val ascendingMethodName = (r1: ConsumerMethodRegistered, r2: ConsumerMethodRegistered) ⇒ r1.method.getName < r2.method.getName - @Before def setUp: Unit = { + @Before + def setUp: Unit = { publisher = actorOf(new TypedConsumerPublisherMock).start requestor = actorOf(new TypedConsumerPublishRequestor).start requestor ! InitPublishRequestor(publisher) @@ -29,12 +30,14 @@ class TypedConsumerPublishRequestorTest extends JUnitSuite { }).start } - @After def tearDown = { + @After + def tearDown = { Actor.registry.removeListener(requestor); Actor.registry.shutdownAll } - @Test def shouldReceiveOneConsumerMethodRegisteredEvent = { + @Test + def shouldReceiveOneConsumerMethodRegisteredEvent = { Actor.registry.addListener(requestor) val latch = (publisher !! SetExpectedTestMessageCount(1)).as[CountDownLatch].get val obj = TypedActor.newInstance(classOf[SampleTypedSingleConsumer], classOf[SampleTypedSingleConsumerImpl]) @@ -45,7 +48,8 @@ class TypedConsumerPublishRequestorTest extends JUnitSuite { assert(event.methodName === "foo") } - @Test def shouldReceiveOneConsumerMethodUnregisteredEvent = { + @Test + def shouldReceiveOneConsumerMethodUnregisteredEvent = { val obj = TypedActor.newInstance(classOf[SampleTypedSingleConsumer], classOf[SampleTypedSingleConsumerImpl]) val latch = (publisher !! SetExpectedTestMessageCount(1)).as[CountDownLatch].get Actor.registry.addListener(requestor) @@ -57,7 +61,8 @@ class TypedConsumerPublishRequestorTest extends JUnitSuite { assert(event.methodName === "foo") } - @Test def shouldReceiveThreeConsumerMethodRegisteredEvents = { + @Test + def shouldReceiveThreeConsumerMethodRegisteredEvents = { Actor.registry.addListener(requestor) val latch = (publisher !! SetExpectedTestMessageCount(3)).as[CountDownLatch].get val obj = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl]) @@ -67,7 +72,8 @@ class TypedConsumerPublishRequestorTest extends JUnitSuite { assert(events.map(_.method.getName).sortWith(_ < _) === List("m2", "m3", "m4")) } - @Test def shouldReceiveThreeConsumerMethodUnregisteredEvents = { + @Test + def shouldReceiveThreeConsumerMethodUnregisteredEvents = { val obj = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl]) val latch = (publisher !! SetExpectedTestMessageCount(3)).as[CountDownLatch].get Actor.registry.addListener(requestor) diff --git a/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerScalaTest.scala b/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerScalaTest.scala index 5041d09f28..0cc0073e2d 100644 --- a/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerScalaTest.scala +++ b/akka-camel-typed/src/test/scala/akka/camel/TypedConsumerScalaTest.scala @@ -2,7 +2,7 @@ package akka.camel import org.apache.camel.CamelExecutionException -import org.scalatest.{BeforeAndAfterAll, WordSpec} +import org.scalatest.{ BeforeAndAfterAll, WordSpec } import org.scalatest.matchers.MustMatchers import akka.actor.Actor._ @@ -33,17 +33,17 @@ class TypedConsumerScalaTest extends WordSpec with BeforeAndAfterAll with MustMa "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") + } 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) + } must be(true) intercept[CamelExecutionException] { mandatoryTemplate.requestBodyAndHeader("direct:m2", "x", "test", "y") } @@ -63,16 +63,16 @@ class TypedConsumerScalaTest extends WordSpec with BeforeAndAfterAll with MustMa "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") + } 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) + } must be(true) intercept[CamelExecutionException] { mandatoryTemplate.requestBody("direct:publish-test-3", "x") } diff --git a/akka-camel-typed/src/test/scala/akka/camel/component/TypedActorComponentFeatureTest.scala b/akka-camel-typed/src/test/scala/akka/camel/component/TypedActorComponentFeatureTest.scala index ebbd58e66d..04d08023a3 100644 --- a/akka-camel-typed/src/test/scala/akka/camel/component/TypedActorComponentFeatureTest.scala +++ b/akka-camel-typed/src/test/scala/akka/camel/component/TypedActorComponentFeatureTest.scala @@ -2,10 +2,10 @@ 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 org.apache.camel.impl.{ DefaultCamelContext, SimpleRegistry } +import org.scalatest.{ BeforeAndAfterEach, BeforeAndAfterAll, FeatureSpec } -import akka.actor.{Actor, TypedActor} +import akka.actor.{ Actor, TypedActor } import akka.camel._ import akka.util.ReflectiveAccess.TypedActorModule @@ -19,8 +19,8 @@ class TypedActorComponentFeatureTest extends FeatureSpec with BeforeAndAfterAll var typedConsumerUuid: String = _ override protected def beforeAll = { - val typedActor = TypedActor.newInstance(classOf[SampleTypedActor], classOf[SampleTypedActorImpl]) // not a consumer - val typedConsumer = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl]) + val typedActor = TypedActor.newInstance(classOf[SampleTypedActor], classOf[SampleTypedActorImpl]) // not a consumer + val typedConsumer = TypedActor.newInstance(classOf[SampleTypedConsumer], classOf[SampleTypedConsumerImpl]) typedConsumerUuid = TypedActorModule.typedActorObjectInstance.get.actorFor(typedConsumer).get.uuid.toString diff --git a/akka-spring/src/main/scala/akka/spring/ActorBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/spring/ActorBeanDefinitionParser.scala index 2abb1024d8..de6beba97d 100644 --- a/akka-spring/src/main/scala/akka/spring/ActorBeanDefinitionParser.scala +++ b/akka-spring/src/main/scala/akka/spring/ActorBeanDefinitionParser.scala @@ -9,7 +9,6 @@ import org.springframework.beans.factory.xml.ParserContext import AkkaSpringConfigurationTags._ import org.w3c.dom.Element - /** * Parser for custom namespace configuration. * @author michaelkober @@ -30,7 +29,6 @@ class TypedActorBeanDefinitionParser extends AbstractSingleBeanDefinitionParser override def getBeanClass(element: Element): Class[_] = classOf[ActorFactoryBean] } - /** * Parser for custom namespace configuration. * @author michaelkober @@ -51,7 +49,6 @@ class UntypedActorBeanDefinitionParser extends AbstractSingleBeanDefinitionParse override def getBeanClass(element: Element): Class[_] = classOf[ActorFactoryBean] } - /** * Parser for custom namespace configuration. * @author michaelkober @@ -80,7 +77,7 @@ class ConfigBeanDefinitionParser extends AbstractSingleBeanDefinitionParser with * @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) + val location = element.getAttribute(LOCATION) builder.addPropertyValue(LOCATION, location) } diff --git a/akka-spring/src/main/scala/akka/spring/ActorFactoryBean.scala b/akka-spring/src/main/scala/akka/spring/ActorFactoryBean.scala index 26ae06fb8a..fd31ed074c 100644 --- a/akka-spring/src/main/scala/akka/spring/ActorFactoryBean.scala +++ b/akka-spring/src/main/scala/akka/spring/ActorFactoryBean.scala @@ -4,12 +4,12 @@ package akka.spring -import org.springframework.beans.{BeanUtils,BeansException,BeanWrapper,BeanWrapperImpl} +import org.springframework.beans.{ BeanUtils, BeansException, BeanWrapper, BeanWrapperImpl } import org.springframework.beans.factory.config.AbstractFactoryBean -import org.springframework.context.{ApplicationContext,ApplicationContextAware} +import org.springframework.context.{ ApplicationContext, ApplicationContextAware } import org.springframework.util.StringUtils -import akka.actor.{ActorRef, ActorRegistry, AspectInitRegistry, TypedActorConfiguration, TypedActor,Actor} +import akka.actor.{ ActorRef, ActorRegistry, AspectInitRegistry, TypedActorConfiguration, TypedActor, Actor } import akka.event.EventHandler import akka.dispatch.MessageDispatcher import akka.util.Duration @@ -23,7 +23,7 @@ import java.net.InetSocketAddress * * @author Johan Rask */ -class AkkaBeansException(message: String, cause:Throwable) extends BeansException(message, cause) { +class AkkaBeansException(message: String, cause: Throwable) extends BeansException(message, cause) { def this(message: String) = this(message, null) } @@ -38,27 +38,43 @@ class AkkaBeansException(message: String, cause:Throwable) extends BeansExceptio class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationContextAware { import StringReflect._ import AkkaSpringConfigurationTags._ - @BeanProperty var id: String = "" - @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 autostart: 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 = _ + @BeanProperty + var id: String = "" + @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 autostart: 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 = try { if (!timeoutStr.isEmpty) timeoutStr.toLong else -1L } catch { - case nfe: NumberFormatException => + case nfe: NumberFormatException ⇒ EventHandler notifyListeners EventHandler.Error(nfe, this, "could not parse timeout %s" format timeoutStr) throw nfe } @@ -77,7 +93,7 @@ class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationConte implementation.toClass } catch { // required by contract to return null - case e: IllegalArgumentException => null + case e: IllegalArgumentException ⇒ null } /* @@ -85,29 +101,31 @@ class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationConte */ def createInstance: AnyRef = { val ref = typed match { - case TYPED_ACTOR_TAG => val typedActor = createTypedInstance() + case TYPED_ACTOR_TAG ⇒ + val typedActor = createTypedInstance() setProperties(AspectInitRegistry.initFor(typedActor).targetInstance) typedActor - case UNTYPED_ACTOR_TAG => val untypedActor = createUntypedInstance() + case UNTYPED_ACTOR_TAG ⇒ + val untypedActor = createUntypedInstance() setProperties(untypedActor.actor) if (autostart) untypedActor.start untypedActor - case _ => throw new IllegalArgumentException("Unknown actor type") + case _ ⇒ throw new IllegalArgumentException("Unknown actor type") } ref } - private[akka] def createTypedInstance() : AnyRef = { + private[akka] def createTypedInstance(): AnyRef = { if (!StringUtils.hasText(interface)) throw new AkkaBeansException( - "The 'interface' part of the 'akka:actor' element in the Spring config file can't be null or empty string") + "The 'interface' part of the 'akka:actor' element in the Spring config file can't be null or empty string") if ((!StringUtils.hasText(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 ") + "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) + 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) { if (serviceName.isEmpty) { @@ -122,30 +140,30 @@ class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationConte /** * Create an UntypedActor. */ - private[akka] def createUntypedInstance() : ActorRef = { + private[akka] def createUntypedInstance(): ActorRef = { if ((!StringUtils.hasText(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 ") + "Either 'implementation' or 'ref' must be specified as attribute of the 'akka:untyped-actor' element in the Spring config file ") val actorRef = if (isRemote && !serverManaged) { //If clientManaged - if (beanRef ne null) - Actor.remote.actorOf(getBeanFactory().getBean(beanRef).asInstanceOf[Actor], host, port.toInt) - else - Actor.remote.actorOf(implementation.toClass, host, port.toInt) + if (beanRef ne null) + Actor.remote.actorOf(getBeanFactory().getBean(beanRef).asInstanceOf[Actor], host, port.toInt) + else + Actor.remote.actorOf(implementation.toClass, host, port.toInt) } else { if (beanRef ne null) - Actor.actorOf(getBeanFactory().getBean(beanRef).asInstanceOf[Actor]) - else - Actor.actorOf(implementation.toClass) + Actor.actorOf(getBeanFactory().getBean(beanRef).asInstanceOf[Actor]) + else + Actor.actorOf(implementation.toClass) } if (timeout > 0) actorRef.setTimeout(timeout) - if(StringUtils.hasText(id)) + if (StringUtils.hasText(id)) actorRef.id = id if (hasDispatcher) - actorRef.setDispatcher( dispatcherInstance( if (dispatcher.dispatcherType == THREAD_BASED) Some(actorRef) else None ) ) + actorRef.setDispatcher(dispatcherInstance(if (dispatcher.dispatcherType == THREAD_BASED) Some(actorRef) else None)) if (isRemote && serverManaged) { if (serviceName.isEmpty) @@ -157,15 +175,15 @@ class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationConte 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 + /** + * 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 @@ -173,19 +191,18 @@ class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationConte if (ref.isInstanceOf[ApplicationContextAware]) { beanWrapper.setPropertyValue("applicationContext", applicationContext) } - for (entry <- property.entryList) { + for (entry ← property.entryList) { val propertyDescriptor = BeanUtils.getPropertyDescriptor(ref.getClass, entry.name) val method = propertyDescriptor.getWriteMethod if (StringUtils.hasText(entry.ref)) { - method.invoke(ref,getBeanFactory().getBean(entry.ref)) - } else if(StringUtils.hasText(entry.value)) { - beanWrapper.setPropertyValue(entry.name,entry.value) + method.invoke(ref, getBeanFactory().getBean(entry.ref)) + } else if (StringUtils.hasText(entry.value)) { + 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) @@ -209,7 +226,7 @@ class ActorFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationConte * @param actorRef actorRef for thread based dispatcher * @return new dispatcher instance */ - private[akka] def dispatcherInstance(actorRef: Option[ActorRef] = None) : MessageDispatcher = { + private[akka] def dispatcherInstance(actorRef: Option[ActorRef] = None): MessageDispatcher = { import DispatcherFactoryBean._ if (dispatcher.dispatcherType == THREAD_BASED) { createNewInstance(dispatcher, actorRef) @@ -228,11 +245,16 @@ class ActorForFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationCo import StringReflect._ import AkkaSpringConfigurationTags._ - @BeanProperty var interface: String = "" - @BeanProperty var host: String = "" - @BeanProperty var port: String = "" - @BeanProperty var serviceName: String = "" - @BeanProperty var applicationContext: ApplicationContext = _ + @BeanProperty + var interface: String = "" + @BeanProperty + var host: String = "" + @BeanProperty + var port: String = "" + @BeanProperty + var serviceName: String = "" + @BeanProperty + var applicationContext: ApplicationContext = _ override def isSingleton = false @@ -245,8 +267,8 @@ class ActorForFactoryBean extends AbstractFactoryBean[AnyRef] with ApplicationCo * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance() */ def createInstance: AnyRef = interface match { - case null|"" => Actor.remote.actorFor(serviceName, host, port.toInt) - case iface => Actor.remote.typedActorFor(iface.toClass, serviceName, host, port.toInt) + case null | "" ⇒ Actor.remote.actorFor(serviceName, host, port.toInt) + case iface ⇒ Actor.remote.typedActorFor(iface.toClass, serviceName, host, port.toInt) } } diff --git a/akka-spring/src/main/scala/akka/spring/ActorParser.scala b/akka-spring/src/main/scala/akka/spring/ActorParser.scala index fd815b36c5..e52871963c 100644 --- a/akka-spring/src/main/scala/akka/spring/ActorParser.scala +++ b/akka-spring/src/main/scala/akka/spring/ActorParser.scala @@ -43,7 +43,7 @@ trait ActorParser extends BeanParser with DispatcherParser { objectProperties.dispatcher = dispatcherProperties } - for (element <- propertyEntries) { + for (element ← propertyEntries) { val entry = new PropertyEntry entry.name = element.getAttribute("name"); entry.value = element.getAttribute("value") @@ -56,12 +56,12 @@ trait ActorParser extends BeanParser with DispatcherParser { objectProperties.beanRef = if (element.getAttribute(BEANREF).isEmpty) null else element.getAttribute(BEANREF) objectProperties.id = element.getAttribute("id") objectProperties.autostart = element.getAttribute(AUTOSTART) match { - case null|"" => false - case other => other.toBoolean + case null | "" ⇒ false + case other ⇒ other.toBoolean } objectProperties.dependsOn = element.getAttribute(DEPENDS_ON) match { - case null|"" => Array[String]() - case other => for (dep <- other.split(",")) yield dep.trim + case null | "" ⇒ Array[String]() + case other ⇒ for (dep ← other.split(",")) yield dep.trim } if (objectProperties.target == null && objectProperties.beanRef == null) { @@ -143,7 +143,6 @@ trait BeanParser { } - /** * Parser trait for custom namespace for Akka dispatcher configuration. * @author michaelkober diff --git a/akka-spring/src/main/scala/akka/spring/ActorProperties.scala b/akka-spring/src/main/scala/akka/spring/ActorProperties.scala index 6f1a2b639d..7713b52be9 100644 --- a/akka-spring/src/main/scala/akka/spring/ActorProperties.scala +++ b/akka-spring/src/main/scala/akka/spring/ActorProperties.scala @@ -25,7 +25,7 @@ class ActorProperties { var autostart: Boolean = false var serviceName: String = "" var lifecycle: String = "" - var scope:String = VAL_SCOPE_SINGLETON + var scope: String = VAL_SCOPE_SINGLETON var dispatcher: DispatcherProperties = _ var propertyEntries = new PropertyEntries() var dependsOn: Array[String] = Array[String]() @@ -47,13 +47,13 @@ class ActorProperties { builder.addPropertyValue(LIFECYCLE, lifecycle) builder.addPropertyValue(SCOPE, scope) builder.addPropertyValue(DISPATCHER_TAG, dispatcher) - builder.addPropertyValue(PROPERTYENTRY_TAG,propertyEntries) + builder.addPropertyValue(PROPERTYENTRY_TAG, propertyEntries) builder.addPropertyValue("id", id) builder.addPropertyValue(AUTOSTART, autostart) - dependsOn foreach { dep => builder.addDependsOn(dep) } + dependsOn foreach { dep ⇒ builder.addDependsOn(dep) } } - def timeout() : Long = { + def timeout(): Long = { if (!timeoutStr.isEmpty) timeoutStr.toLong else -1L } diff --git a/akka-spring/src/main/scala/akka/spring/AkkaSpringConfigurationTags.scala b/akka-spring/src/main/scala/akka/spring/AkkaSpringConfigurationTags.scala index 6ca7bb9933..c4ee997ef2 100644 --- a/akka-spring/src/main/scala/akka/spring/AkkaSpringConfigurationTags.scala +++ b/akka-spring/src/main/scala/akka/spring/AkkaSpringConfigurationTags.scala @@ -71,9 +71,9 @@ object AkkaSpringConfigurationTags { 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" + val BOUND = "bound" + val REJECTION_POLICY = "rejection-policy" + val MAILBOX_CAPACITY = "mailbox-capacity" // config attribute val LOCATION = "location" diff --git a/akka-spring/src/main/scala/akka/spring/CamelServiceBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/spring/CamelServiceBeanDefinitionParser.scala index 4025a831a8..b07ae068f3 100644 --- a/akka-spring/src/main/scala/akka/spring/CamelServiceBeanDefinitionParser.scala +++ b/akka-spring/src/main/scala/akka/spring/CamelServiceBeanDefinitionParser.scala @@ -4,13 +4,12 @@ package akka.spring import org.springframework.beans.factory.support.BeanDefinitionBuilder -import org.springframework.beans.factory.xml.{ParserContext, AbstractSingleBeanDefinitionParser} +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. * diff --git a/akka-spring/src/main/scala/akka/spring/CamelServiceFactoryBean.scala b/akka-spring/src/main/scala/akka/spring/CamelServiceFactoryBean.scala index 337413f0eb..46f22a53bb 100644 --- a/akka-spring/src/main/scala/akka/spring/CamelServiceFactoryBean.scala +++ b/akka-spring/src/main/scala/akka/spring/CamelServiceFactoryBean.scala @@ -4,9 +4,9 @@ package akka.spring import org.apache.camel.CamelContext -import org.springframework.beans.factory.{DisposableBean, InitializingBean, FactoryBean} +import org.springframework.beans.factory.{ DisposableBean, InitializingBean, FactoryBean } -import akka.camel.{CamelContextManager, CamelService, CamelServiceFactory} +import akka.camel.{ CamelContextManager, CamelService, CamelServiceFactory } /** * Factory bean for a {@link CamelService}. @@ -14,7 +14,8 @@ import akka.camel.{CamelContextManager, CamelService, CamelServiceFactory} * @author Martin Krasser */ class CamelServiceFactoryBean extends FactoryBean[CamelService] with InitializingBean with DisposableBean { - @scala.reflect.BeanProperty var camelContext: CamelContext = _ + @scala.reflect.BeanProperty + var camelContext: CamelContext = _ var instance: CamelService = _ diff --git a/akka-spring/src/main/scala/akka/spring/ConfiggyPropertyPlaceholderConfigurer.scala b/akka-spring/src/main/scala/akka/spring/ConfiggyPropertyPlaceholderConfigurer.scala index 38bf1dc111..c06ab18781 100644 --- a/akka-spring/src/main/scala/akka/spring/ConfiggyPropertyPlaceholderConfigurer.scala +++ b/akka-spring/src/main/scala/akka/spring/ConfiggyPropertyPlaceholderConfigurer.scala @@ -26,10 +26,10 @@ class ConfiggyPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigure /** * Load the akka.conf and transform to properties. */ - private def loadAkkaConfig(configgyResource: Resource) : Properties = { + private def loadAkkaConfig(configgyResource: Resource): Properties = { val config = Configuration.fromFile(configgyResource.getFile.getPath) val properties = new Properties() - config.map.foreach {case (k, v) => properties.put(k, v.asInstanceOf[AnyRef]); println("(k,v)=" + k + ", " + v)} + config.map.foreach { case (k, v) ⇒ properties.put(k, v.asInstanceOf[AnyRef]); println("(k,v)=" + k + ", " + v) } properties } diff --git a/akka-spring/src/main/scala/akka/spring/DispatcherBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/spring/DispatcherBeanDefinitionParser.scala index 4f2a40469f..c2754e3174 100644 --- a/akka-spring/src/main/scala/akka/spring/DispatcherBeanDefinitionParser.scala +++ b/akka-spring/src/main/scala/akka/spring/DispatcherBeanDefinitionParser.scala @@ -5,8 +5,7 @@ package akka.spring import org.w3c.dom.Element import org.springframework.beans.factory.support.BeanDefinitionBuilder -import org.springframework.beans.factory.xml.{ParserContext, AbstractSingleBeanDefinitionParser} - +import org.springframework.beans.factory.xml.{ ParserContext, AbstractSingleBeanDefinitionParser } /** * Parser for custom namespace configuration. diff --git a/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala b/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala index 14c2a802df..703b713302 100644 --- a/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala +++ b/akka-spring/src/main/scala/akka/spring/DispatcherFactoryBean.scala @@ -9,7 +9,7 @@ import AkkaSpringConfigurationTags._ import reflect.BeanProperty import akka.actor.ActorRef import java.util.concurrent.RejectedExecutionHandler -import java.util.concurrent.ThreadPoolExecutor.{DiscardPolicy, DiscardOldestPolicy, CallerRunsPolicy, AbortPolicy} +import java.util.concurrent.ThreadPoolExecutor.{ DiscardPolicy, DiscardOldestPolicy, CallerRunsPolicy, AbortPolicy } import akka.dispatch._ import akka.util.Duration @@ -26,68 +26,67 @@ object DispatcherFactoryBean { def createNewInstance(properties: DispatcherProperties, actorRef: Option[ActorRef] = None): MessageDispatcher = { //Creates a ThreadPoolConfigDispatcherBuilder and applies the configuration to it - def configureThreadPool(createDispatcher: => (ThreadPoolConfig) => MessageDispatcher): ThreadPoolConfigDispatcherBuilder = { + 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 + "'") - } + 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()) + 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 => + case EXECUTOR_BASED_EVENT_DRIVEN ⇒ + configureThreadPool(poolConfig ⇒ new ExecutorBasedEventDrivenDispatcher(properties.name, poolConfig)).build - case EXECUTOR_BASED_EVENT_DRIVEN_WORK_STEALING => - configureThreadPool(poolConfig => + case EXECUTOR_BASED_EVENT_DRIVEN_WORK_STEALING ⇒ + configureThreadPool(poolConfig ⇒ new ExecutorBasedEventDrivenWorkStealingDispatcher( properties.name, Dispatchers.THROUGHPUT, Dispatchers.THROUGHPUT_DEADLINE_TIME_MILLIS, Dispatchers.MAILBOX_TYPE, poolConfig)).build - case THREAD_BASED if actorRef.isEmpty => + case THREAD_BASED if actorRef.isEmpty ⇒ throw new IllegalArgumentException("Need an ActorRef to create a thread based dispatcher.") - case THREAD_BASED if actorRef.isDefined => + case THREAD_BASED if actorRef.isDefined ⇒ Dispatchers.newThreadBasedDispatcher(actorRef.get) - case unknown => + case unknown ⇒ throw new IllegalArgumentException("Unknown dispatcher type " + unknown) } } @@ -98,7 +97,8 @@ object DispatcherFactoryBean { * @author michaelkober */ class DispatcherFactoryBean extends AbstractFactoryBean[MessageDispatcher] { - @BeanProperty var properties: DispatcherProperties = _ + @BeanProperty + var properties: DispatcherProperties = _ /* * @see org.springframework.beans.factory.FactoryBean#getObjectType() diff --git a/akka-spring/src/main/scala/akka/spring/DispatcherProperties.scala b/akka-spring/src/main/scala/akka/spring/DispatcherProperties.scala index 8dd33602df..22d18998bb 100644 --- a/akka-spring/src/main/scala/akka/spring/DispatcherProperties.scala +++ b/akka-spring/src/main/scala/akka/spring/DispatcherProperties.scala @@ -24,11 +24,11 @@ class DispatcherProperties { builder.addPropertyValue("properties", this) } - override def toString : String = { + override def toString: String = { "DispatcherProperties[ref=" + ref + - ", dispatcher-type=" + dispatcherType + - ", name=" + name + - ", threadPool=" + threadPool + "]" + ", dispatcher-type=" + dispatcherType + + ", name=" + name + + ", threadPool=" + threadPool + "]" } } @@ -47,15 +47,15 @@ class ThreadPoolProperties { var rejectionPolicy = "" var mailboxCapacity = -1 - override def toString : String = { + override def toString: String = { "ThreadPoolProperties[queue=" + queue + - ", bound=" + bound + - ", capacity=" + capacity + - ", fairness=" + fairness + - ", corePoolSize=" + corePoolSize + - ", maxPoolSize=" + maxPoolSize + - ", keepAlive=" + keepAlive + - ", policy=" + rejectionPolicy + - ", mailboxCapacity=" + mailboxCapacity + "]" + ", 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/spring/PropertyEntries.scala b/akka-spring/src/main/scala/akka/spring/PropertyEntries.scala index 9f6493bbb3..771c83872c 100644 --- a/akka-spring/src/main/scala/akka/spring/PropertyEntries.scala +++ b/akka-spring/src/main/scala/akka/spring/PropertyEntries.scala @@ -28,7 +28,6 @@ class PropertyEntry { 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/spring/SupervisionBeanDefinitionParser.scala b/akka-spring/src/main/scala/akka/spring/SupervisionBeanDefinitionParser.scala index d9672cb574..60705cddc6 100644 --- a/akka-spring/src/main/scala/akka/spring/SupervisionBeanDefinitionParser.scala +++ b/akka-spring/src/main/scala/akka/spring/SupervisionBeanDefinitionParser.scala @@ -4,15 +4,13 @@ package akka.spring import org.springframework.beans.factory.support.BeanDefinitionBuilder -import org.springframework.beans.factory.xml.{ParserContext, AbstractSingleBeanDefinitionParser} +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 @@ -53,9 +51,9 @@ class SupervisionBeanDefinitionParser extends AbstractSingleBeanDefinitionParser 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 + 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) } diff --git a/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala b/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala index dd4e500908..d138a4f98e 100644 --- a/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala +++ b/akka-spring/src/main/scala/akka/spring/SupervisionFactoryBean.scala @@ -5,19 +5,22 @@ package akka.spring import org.springframework.beans.factory.config.AbstractFactoryBean import akka.config.Supervision._ -import akka.actor.{Supervisor, SupervisorFactory, Actor, ActorRegistry} +import akka.actor.{ Supervisor, SupervisorFactory, Actor, ActorRegistry } import AkkaSpringConfigurationTags._ import reflect.BeanProperty -import akka.config.{TypedActorConfigurator, RemoteAddress} +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 = "" + @BeanProperty + var restartStrategy: FaultHandlingStrategy = _ + @BeanProperty + var supervised: List[ActorProperties] = _ + @BeanProperty + var typed: String = "" /* * @see org.springframework.beans.factory.FactoryBean#getObjectType() @@ -28,20 +31,19 @@ class SupervisionFactoryBean extends AbstractFactoryBean[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 + case AkkaSpringConfigurationTags.TYPED_ACTOR_TAG ⇒ createInstanceForTypedActors + case AkkaSpringConfigurationTags.UNTYPED_ACTOR_TAG ⇒ createInstanceForUntypedActors } - private def createInstanceForTypedActors() : TypedActorConfigurator = { + private def createInstanceForTypedActors(): TypedActorConfigurator = { val configurator = new TypedActorConfigurator() configurator.configure( restartStrategy, - supervised.map(createComponent(_)).toArray - ).supervise + supervised.map(createComponent(_)).toArray).supervise } - private def createInstanceForUntypedActors() : Supervisor = { + private def createInstanceForUntypedActors(): Supervisor = { val factory = new SupervisorFactory( new SupervisorConfig( restartStrategy, diff --git a/akka-spring/src/test/java/akka/spring/foo/StatefulPojo.java b/akka-spring/src/test/java/akka/spring/foo/StatefulPojo.java index 8f291d2a36..738d552485 100644 --- a/akka-spring/src/test/java/akka/spring/foo/StatefulPojo.java +++ b/akka-spring/src/test/java/akka/spring/foo/StatefulPojo.java @@ -1,6 +1,4 @@ -package akka.spring.foo; - -/* +package akka.spring.foo; /* import akka.stm.TransactionalMap; import akka.stm.TransactionalVector; import akka.stm.Ref; @@ -55,4 +53,4 @@ public class StatefulPojo extends TypedActor { return isInitialized; } } -*/ +*/ \ No newline at end of file diff --git a/akka-spring/src/test/scala/ActorFactoryBeanTest.scala b/akka-spring/src/test/scala/ActorFactoryBeanTest.scala index 10edb0916a..4b8f24396a 100644 --- a/akka-spring/src/test/scala/ActorFactoryBeanTest.scala +++ b/akka-spring/src/test/scala/ActorFactoryBeanTest.scala @@ -3,13 +3,13 @@ */ package akka.spring -import akka.actor.{Actor, ActorRef, ActorInitializationException} +import akka.actor.{ Actor, ActorRef, ActorInitializationException } 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.{ BeforeAndAfterAll, Spec } import org.scalatest.matchers.ShouldMatchers /** @@ -99,7 +99,7 @@ class ActorFactoryBeanTest extends Spec with ShouldMatchers with BeforeAndAfterA val target = ctx.getBean("bean-singleton").asInstanceOf[SampleBeanIntf] assert(!target.down) ctx.close - evaluating { target.down } should produce [ActorInitializationException] + evaluating { target.down } should produce[ActorInitializationException] } it("should not stop the created typed actor when scope is prototype and the context is closed") { diff --git a/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala b/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala index d58f65fe4f..7d401e855a 100644 --- a/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/CamelServiceSpringFeatureTest.scala @@ -1,12 +1,12 @@ package akka.spring -import org.apache.camel.impl.{SimpleRegistry, DefaultCamelContext} +import org.apache.camel.impl.{ SimpleRegistry, DefaultCamelContext } import org.apache.camel.spring.SpringCamelContext -import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FeatureSpec} +import org.scalatest.{ BeforeAndAfterAll, BeforeAndAfterEach, FeatureSpec } import org.springframework.context.support.ClassPathXmlApplicationContext import akka.camel.CamelContextManager -import akka.actor.{TypedActor, Actor} +import akka.actor.{ TypedActor, Actor } class CamelServiceSpringFeatureTest extends FeatureSpec with BeforeAndAfterEach with BeforeAndAfterAll { override protected def beforeAll = { diff --git a/akka-spring/src/test/scala/ConfiggyPropertyPlaceholderConfigurerSpec.scala b/akka-spring/src/test/scala/ConfiggyPropertyPlaceholderConfigurerSpec.scala index bc862dc7a2..718b39bdad 100644 --- a/akka-spring/src/test/scala/ConfiggyPropertyPlaceholderConfigurerSpec.scala +++ b/akka-spring/src/test/scala/ConfiggyPropertyPlaceholderConfigurerSpec.scala @@ -3,8 +3,7 @@ */ package akka.spring - -import foo.{IMyPojo, MyPojo, PingActor} +import foo.{ IMyPojo, MyPojo, PingActor } import akka.dispatch._ import org.scalatest.FeatureSpec import org.scalatest.matchers.ShouldMatchers @@ -14,12 +13,9 @@ 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.springframework.core.io.{ ClassPathResource, Resource } import java.util.concurrent._ -import akka.actor.{UntypedActor, Actor, ActorRef} - - - +import akka.actor.{ UntypedActor, Actor, ActorRef } /** * Tests for spring configuration of typed actors. diff --git a/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala index 1c01245aac..18eba19f10 100644 --- a/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala +++ b/akka-spring/src/test/scala/DispatcherBeanDefinitionParserTest.scala @@ -20,30 +20,20 @@ class DispatcherBeanDefinitionParserTest extends Spec with ShouldMatchers { it("should be able to parse the dispatcher configuration") { // executor-based-event-driven - val xml = + 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 = + 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 xml = val props = parser.parseThreadPool(dom(xml).getDocumentElement); assert(props ne null) assert(props.queue == "bounded-array-blocking-queue") @@ -56,15 +46,9 @@ class DispatcherBeanDefinitionParserTest extends Spec with ShouldMatchers { } it("should be able to parse the dispatcher with a thread pool configuration") { - val xml = - - + val xml = + + val props = parser.parseDispatcher(dom(xml).getDocumentElement); assert(props ne null) assert(props.dispatcherType == "executor-based-event-driven") @@ -77,20 +61,18 @@ class DispatcherBeanDefinitionParserTest extends Spec with ShouldMatchers { it("should throw IllegalArgumentException on not existing reference") { val xml = - evaluating {parser.parseDispatcher(dom(xml).getDocumentElement)} should produce[IllegalArgumentException] + 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] + 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] + evaluating { parser.parseDispatcher(dom(xml).getDocumentElement) } should produce[IllegalArgumentException] } } } - diff --git a/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala b/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala index 457ca7c9bd..06155181af 100644 --- a/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/DispatcherSpringFeatureTest.scala @@ -3,8 +3,7 @@ */ package akka.spring - -import foo.{IMyPojo, MyPojo, PingActor} +import foo.{ IMyPojo, MyPojo, PingActor } import akka.dispatch._ import org.scalatest.FeatureSpec import org.scalatest.matchers.ShouldMatchers @@ -14,9 +13,9 @@ 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.springframework.core.io.{ ClassPathResource, Resource } import java.util.concurrent._ -import akka.actor.{UntypedActor, Actor, ActorRef} +import akka.actor.{ UntypedActor, Actor, ActorRef } /** * Tests for spring configuration of typed actors. @@ -40,7 +39,6 @@ class DispatcherSpringFeatureTest extends FeatureSpec with ShouldMatchers { 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] @@ -55,7 +53,7 @@ class DispatcherSpringFeatureTest extends FeatureSpec with ShouldMatchers { 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] @@ -124,14 +122,14 @@ class DispatcherSpringFeatureTest extends FeatureSpec with ShouldMatchers { 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) + 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 x => throw new IllegalStateException("Illegal dispatcher type: " + x) + case e: ExecutorBasedEventDrivenDispatcher ⇒ 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 index 9319b0c328..a479bdf104 100644 --- a/akka-spring/src/test/scala/ScalaDom.scala +++ b/akka-spring/src/test/scala/ScalaDom.scala @@ -5,28 +5,28 @@ package akka.spring object ScalaDom { import scala.xml._ - import org.w3c.dom.{Document => JDocument, Node => JNode} + 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) + .newInstance + .newDocumentBuilder + .getDOMImplementation + .createDocument(null, null, null) def build(node: Node, parent: JNode): Unit = { val jnode: JNode = node match { - case e: Elem => { + case e: Elem ⇒ { val jn = doc.createElement(e.label) - e.attributes foreach { a => jn.setAttribute(a.key, a.value.mkString) } + 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) + 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) } diff --git a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala index e5b4fc2c70..c1c2fac1f8 100644 --- a/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala +++ b/akka-spring/src/test/scala/SupervisionBeanDefinitionParserTest.scala @@ -11,7 +11,7 @@ import ScalaDom._ import org.w3c.dom.Element import org.springframework.beans.factory.support.BeanDefinitionBuilder -import akka.config.Supervision. {FaultHandlingStrategy, AllForOneStrategy} +import akka.config.Supervision.{ FaultHandlingStrategy, AllForOneStrategy } /** * Test for SupervisionBeanDefinitionParser @@ -60,67 +60,64 @@ class SupervisionBeanDefinitionParserTest extends Spec with ShouldMatchers { } it("should throw IllegalArgumentException on missing mandatory attributes") { - evaluating { parser.parseSupervisor(createSupervisorMissingAttribute, builder) } should produce [IllegalArgumentException] + evaluating { parser.parseSupervisor(createSupervisorMissingAttribute, builder) } should produce[IllegalArgumentException] } it("should throw IllegalArgumentException on missing mandatory elements") { - evaluating { parser.parseSupervisor(createSupervisorMissingElement, builder) } should produce [IllegalArgumentException] + evaluating { parser.parseSupervisor(createSupervisorMissingElement, builder) } should produce[IllegalArgumentException] } } - private def createTypedActorElement : Element = { - val xml = + private def createTypedActorElement: Element = { + val xml = dom(xml).getDocumentElement } - private def createSupervisorElement : Element = { + private def createSupervisorElement: Element = { val xml = - java.io.IOException - java.lang.NullPointerException + java.io.IOException + java.lang.NullPointerException - - - - - - - - - - + + + + + + + + + + dom(xml).getDocumentElement } - - private def createSupervisorMissingAttribute : Element = { + private def createSupervisorMissingAttribute: Element = { val xml = - java.io.IOException + java.io.IOException - - - + + + dom(xml).getDocumentElement } - private def createSupervisorMissingElement : Element = { + 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 index 542b8a1377..3f28363011 100644 --- a/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala +++ b/akka-spring/src/test/scala/SupervisionFactoryBeanTest.scala @@ -18,7 +18,7 @@ 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 = { + private def createTypedActorProperties(target: String, timeout: String): ActorProperties = { val properties = new ActorProperties() properties.target = target properties.timeoutStr = timeout diff --git a/akka-spring/src/test/scala/SupervisorSpringFeatureTest.scala b/akka-spring/src/test/scala/SupervisorSpringFeatureTest.scala index 2ce629ed38..ec3406b5c2 100644 --- a/akka-spring/src/test/scala/SupervisorSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/SupervisorSpringFeatureTest.scala @@ -3,8 +3,7 @@ */ package akka.spring - -import akka.spring.foo.{IMyPojo, MyPojo, IFoo, IBar} +import akka.spring.foo.{ IMyPojo, MyPojo, IFoo, IBar } import akka.dispatch._ import akka.config.TypedActorConfigurator import akka.actor.Supervisor @@ -17,7 +16,7 @@ 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.springframework.core.io.{ ClassPathResource, Resource } import java.util.concurrent._ /** diff --git a/akka-spring/src/test/scala/TypedActorBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/TypedActorBeanDefinitionParserTest.scala index f665784355..01dd15214e 100644 --- a/akka-spring/src/test/scala/TypedActorBeanDefinitionParserTest.scala +++ b/akka-spring/src/test/scala/TypedActorBeanDefinitionParserTest.scala @@ -22,12 +22,9 @@ class TypedActorBeanDefinitionParserTest extends Spec with ShouldMatchers { describe("A TypedActorParser") { val parser = new Parser() it("should parse the typed actor configuration") { - val xml = - - + val xml = + + val props = parser.parseActor(dom(xml).getDocumentElement); assert(props ne null) @@ -40,12 +37,11 @@ class TypedActorBeanDefinitionParserTest extends Spec with ShouldMatchers { it("should throw IllegalArgumentException on missing mandatory attributes") { val xml = - evaluating { parser.parseActor(dom(xml).getDocumentElement) } should produce [IllegalArgumentException] + evaluating { parser.parseActor(dom(xml).getDocumentElement) } should produce[IllegalArgumentException] } it("should parse TypedActors configuration with dispatcher") { - val xml = + val xml = val props = parser.parseActor(dom(xml).getDocumentElement); @@ -54,8 +50,7 @@ class TypedActorBeanDefinitionParserTest extends Spec with ShouldMatchers { } it("should parse remote TypedActors configuration") { - val xml = + val xml = val props = parser.parseActor(dom(xml).getDocumentElement); @@ -66,8 +61,7 @@ class TypedActorBeanDefinitionParserTest extends Spec with ShouldMatchers { } it("should parse remote server managed TypedActors configuration") { - val xml = + val xml = val props = parser.parseActor(dom(xml).getDocumentElement); diff --git a/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala b/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala index c6f0b2bff9..3d5caf785e 100644 --- a/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/TypedActorSpringFeatureTest.scala @@ -3,8 +3,7 @@ */ package akka.spring - -import foo.{PingActor, IMyPojo, MyPojo} +import foo.{ PingActor, IMyPojo, MyPojo } import akka.dispatch.FutureTimeoutException import org.scalatest.matchers.ShouldMatchers import org.scalatest.junit.JUnitRunner @@ -13,16 +12,15 @@ 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 org.springframework.core.io.{ ClassPathResource, Resource } +import org.scalatest.{ BeforeAndAfterAll, FeatureSpec } import java.util.concurrent.CountDownLatch import akka.remote.netty.NettyRemoteSupport import akka.actor._ import akka.actor.Actor._ - object RemoteTypedActorLog { - import java.util.concurrent.{LinkedBlockingQueue, TimeUnit, BlockingQueue} + import java.util.concurrent.{ LinkedBlockingQueue, TimeUnit, BlockingQueue } val messageLog: BlockingQueue[String] = new LinkedBlockingQueue[String] val oneWayLog = new LinkedBlockingQueue[String] @@ -43,7 +41,7 @@ class TypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with B override def beforeAll { remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(false) //Can't run the test if we're eliminating all remote calls - remote.start("localhost",9990) + remote.start("localhost", 9990) val typedActor = TypedActor.newInstance(classOf[RemoteTypedActorOne], classOf[RemoteTypedActorOneImpl], 1000) remote.registerTypedActor("typed-actor-service", typedActor) } @@ -55,7 +53,7 @@ class TypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with B Thread.sleep(1000) } - def getTypedActorFromContext(config: String, id: String) : IMyPojo = { + 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] @@ -93,7 +91,7 @@ class TypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with B scenario("FutureTimeoutException when timed out") { val myPojo = getTypedActorFromContext("/typed-actor-config.xml", "simple-typed-actor") - evaluating {myPojo.longRunning()} should produce[FutureTimeoutException] + evaluating { myPojo.longRunning() } should produce[FutureTimeoutException] } scenario("typed-actor with timeout") { @@ -148,7 +146,6 @@ class TypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with B MyPojo.latch.await } - } } diff --git a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala b/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala index e0c066e527..5f13c81ffb 100644 --- a/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala +++ b/akka-spring/src/test/scala/UntypedActorSpringFeatureTest.scala @@ -3,7 +3,6 @@ */ package akka.spring - import foo.PingActor import akka.dispatch.ExecutorBasedEventDrivenWorkStealingDispatcher import org.scalatest.matchers.ShouldMatchers @@ -11,10 +10,10 @@ import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith import org.springframework.context.support.ClassPathXmlApplicationContext import akka.remote.netty.NettyRemoteSupport -import org.scalatest.{BeforeAndAfterAll, FeatureSpec} +import org.scalatest.{ BeforeAndAfterAll, FeatureSpec } import java.util.concurrent.CountDownLatch -import akka.actor.{RemoteActorRef, Actor, ActorRef, TypedActor} +import akka.actor.{ RemoteActorRef, Actor, ActorRef, TypedActor } import akka.actor.Actor._ /** @@ -28,7 +27,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with override def beforeAll { remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(false) //Can't run the test if we're eliminating all remote calls - remote.start("localhost",9990) + remote.start("localhost", 9990) } override def afterAll { @@ -38,8 +37,7 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with Thread.sleep(1000) } - - def getPingActorFromContext(config: String, id: String) : ActorRef = { + def getPingActorFromContext(config: String, id: String): ActorRef = { PingActor.latch = new CountDownLatch(1) val context = new ClassPathXmlApplicationContext(config) val pingActor = context.getBean(id).asInstanceOf[ActorRef] @@ -47,7 +45,6 @@ class UntypedActorSpringFeatureTest extends FeatureSpec with ShouldMatchers with pingActor.start() } - feature("parse Spring application context") { scenario("get a untyped actor") { diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index 789de9b46b..c615d69091 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -56,6 +56,7 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec lazy val glassfishModuleConfig = ModuleConfiguration("org.glassfish", GlassfishRepo) lazy val jbossModuleConfig = ModuleConfiguration("org.jboss", JBossRepo) lazy val jerseyModuleConfig = ModuleConfiguration("com.sun.jersey", JavaNetRepo) + lazy val jerseyContrModuleConfig = ModuleConfiguration("com.sun.jersey.contribs", JavaNetRepo) lazy val multiverseModuleConfig = ModuleConfiguration("org.multiverse", CodehausRepo) lazy val nettyModuleConfig = ModuleConfiguration("org.jboss.netty", JBossRepo) lazy val scalaTestModuleConfig = ModuleConfiguration("org.scalatest", ScalaToolsRelRepo) @@ -168,7 +169,7 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec lazy val akka_camel = project("akka-camel", "akka-camel", new AkkaCamelProject(_), akka_actor, akka_slf4j) lazy val akka_camel_typed = project("akka-camel-typed", "akka-camel-typed", new AkkaCamelTypedProject(_), akka_actor, akka_slf4j, akka_camel) - lazy val akka_spring = project("akka-spring", "akka-spring", new AkkaSpringProject(_), akka_remote, akka_actor) + lazy val akka_spring = project("akka-spring", "akka-spring", new AkkaSpringProject(_), akka_remote, akka_actor, akka_camel) lazy val akka_sbt_plugin = project("akka-sbt-plugin", "akka-sbt-plugin", new AkkaSbtPluginProject(_)) lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_), akka_stm, akka_remote, akka_http, akka_slf4j, akka_camel) @@ -567,12 +568,7 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec | val akkaVersion = "%s" | | - | def akkaModule(module: String) = "se.scalablesolutions.akka" %% ("akka-" + module) %% { - | if (Set(%s).contains(module)) - | akkaModulesVersion - | else - | akkaVersion - | } + | def akkaModule(module: String) = "se.scalablesolutions.akka" %% ("akka-" + module) %% akkaVersion | | val akkaActor = akkaModule("actor") |}