From e7a7d6ec907521fe47858f1864068b368471c3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Fri, 18 Jun 2010 13:30:00 +0200 Subject: [PATCH 01/18] Fix for ticket #280 - Tests fail if there is no akka.conf set --- akka-core/src/main/scala/stm/TransactionManagement.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-core/src/main/scala/stm/TransactionManagement.scala b/akka-core/src/main/scala/stm/TransactionManagement.scala index d551f7fd76..a6ec288466 100644 --- a/akka-core/src/main/scala/stm/TransactionManagement.scala +++ b/akka-core/src/main/scala/stm/TransactionManagement.scala @@ -20,7 +20,7 @@ class TransactionAwareWrapperException(val cause: Throwable, val tx: Option[Tran object TransactionManagement extends TransactionManagement { import se.scalablesolutions.akka.config.Config._ - val TRANSACTION_ENABLED = new AtomicBoolean(config.getBool("akka.stm.service", false)) + val TRANSACTION_ENABLED = new AtomicBoolean(config.getBool("akka.stm.service", true)) val FAIR_TRANSACTIONS = config.getBool("akka.stm.fair", true) val INTERRUPTIBLE = config.getBool("akka.stm.interruptible", true) val MAX_NR_OF_RETRIES = config.getInt("akka.stm.max-nr-of-retries", 1000) From 920b4d03f9c739ad885318b01bd3540894908529 Mon Sep 17 00:00:00 2001 From: Johan Rask Date: Wed, 16 Jun 2010 11:24:47 +0200 Subject: [PATCH 02/18] Added support for scope and depdenency injection on target bean --- akka-spring/akka-spring-test-java/pom.xml | 17 +- .../main/resources/META-INF/spring.schemas | 2 +- .../akka/spring/akka-0.10.xsd | 242 ++++++++++++++++++ .../se/scalablesolutions/akka/spring/akka.xsd | 14 + .../main/scala/ActiveObjectFactoryBean.scala | 53 +++- .../src/main/scala/ActiveObjectParser.scala | 18 +- .../main/scala/ActiveObjectProperties.scala | 10 +- .../src/main/scala/AkkaBeansException.scala | 14 + .../scala/AkkaSpringConfigurationTags.scala | 5 + .../src/main/scala/PropertyEntries.scala | 18 ++ .../src/main/scala/PropertyEntry.scala | 17 ++ .../main/scala/SupervisionFactoryBean.scala | 2 +- ...ActiveObjectBeanDefinitionParserTest.scala | 13 +- .../scala/ActiveObjectFactoryBeanTest.scala | 24 ++ 14 files changed, 430 insertions(+), 19 deletions(-) create mode 100644 akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd create mode 100644 akka-spring/src/main/scala/AkkaBeansException.scala create mode 100644 akka-spring/src/main/scala/PropertyEntries.scala create mode 100644 akka-spring/src/main/scala/PropertyEntry.scala diff --git a/akka-spring/akka-spring-test-java/pom.xml b/akka-spring/akka-spring-test-java/pom.xml index 11a29262ac..ff36202071 100644 --- a/akka-spring/akka-spring-test-java/pom.xml +++ b/akka-spring/akka-spring-test-java/pom.xml @@ -17,6 +17,11 @@ + + akka + Akka Repo + http://www.scalablesolutions.se/akka/repository/ + project.embedded.module Project Embedded Repository @@ -146,23 +151,23 @@ se.scalablesolutions.akka - akka-core_2.8.0.Beta1 - 0.9 + akka-core_2.8.0.RC3 + 0.9.1 se.scalablesolutions.akka akka-util_2.8.0.Beta1 - 0.9 + 0.8.1 se.scalablesolutions.akka akka-util-java_2.8.0.Beta1 - 0.9 + 0.8.1 se.scalablesolutions.akka - akka-spring_2.8.0.Beta1 - 0.9 + akka-spring_2.8.0.RC3 + 0.9.1 org.springframework diff --git a/akka-spring/src/main/resources/META-INF/spring.schemas b/akka-spring/src/main/resources/META-INF/spring.schemas index d04d65566a..27f7704018 100644 --- a/akka-spring/src/main/resources/META-INF/spring.schemas +++ b/akka-spring/src/main/resources/META-INF/spring.schemas @@ -1 +1 @@ -http\://www.akkasource.org/schema/akka=se/scalablesolutions/akka/spring/akka.xsd +http\://scalablesolutions.se/akka/akka-0.10.xsd=se/scalablesolutions/akka/spring/akka-0.10.xsd diff --git a/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd new file mode 100644 index 0000000000..c81fb12af3 --- /dev/null +++ b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the remote host. + + + + + + + Port of the remote host. + + + + + + + + + + + Pre restart callback method that is called during restart. + + + + + + + Post restart callback method that is called during restart. + + + + + + + + + + + + + + + + + + + Name of the target class. + + + + + + + default timeout for '!!' invocations + + + + + + + Set to true if messages should have REQUIRES_NEW semantics + + + + + + + Interface implemented by target class. + + + + + + + Lifecycle, permanent or temporary + + + + + + + Supported scopes are singleton and prototype + + + + + + + + + + + + + + + + + + + + + + + + + + + + Failover scheme, AllForOne or OneForOne + + + + + + + Maximal number of retries. + + + + + + + Timerange for restart. + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka.xsd b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka.xsd index 20cb966b8f..862cd06987 100644 --- a/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka.xsd +++ b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka.xsd @@ -25,6 +25,13 @@ + + + + + + + @@ -158,6 +165,13 @@ Lifecycle, permanent or temporary + + + + + Supported scopes are singleton and prototype + + diff --git a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala b/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala index 66ef87a15d..b1093a9a08 100644 --- a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala +++ b/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala @@ -4,19 +4,31 @@ package se.scalablesolutions.akka.spring +import java.beans.PropertyDescriptor + +import java.lang.reflect.Method +import org.springframework.beans.BeanWrapperImpl +import org.springframework.beans.BeanWrapper +import org.springframework.beans.BeanUtils +import org.springframework.util.ReflectionUtils +import org.springframework.util.StringUtils +import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.config.AbstractFactoryBean import se.scalablesolutions.akka.actor.ActiveObject import reflect.BeanProperty import se.scalablesolutions.akka.config.ScalaConfig.RestartCallbacks import se.scalablesolutions.akka.dispatch.MessageDispatcher - +import se.scalablesolutions.akka.util.Logging /** * Factory bean for active objects. + * * @author michaelkober + * @author Johan Rask */ -class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] { +class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] with Logging { import StringReflect._ + import AkkaSpringConfigurationTags._ @BeanProperty var target: String = "" @BeanProperty var timeout: Long = _ @@ -28,6 +40,8 @@ class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] { @BeanProperty var port: Int = _ @BeanProperty var lifecycle: String = "" @BeanProperty var dispatcher: DispatcherProperties = _ + @BeanProperty var scope:String = VAL_SCOPE_SINGLETON + @BeanProperty var property:PropertyEntries = _ /* * @see org.springframework.beans.factory.FactoryBean#getObjectType() @@ -39,11 +53,44 @@ class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] { * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance() */ def createInstance: AnyRef = { + if(scope.equals(VAL_SCOPE_SINGLETON)) { + setSingleton(true) + } else { + setSingleton(false) + } var argumentList = "" if (isRemote) argumentList += "r" if (hasInterface) argumentList += "i" if (hasDispatcher) argumentList += "d" - create(argumentList) + + setProperties( + create(argumentList)) +} + + /** + * This method manages element by injecting either + * values () and bean references () + */ + private def setProperties(ref:AnyRef) : AnyRef = { + log.debug("Processing properties and dependencies for target class %s",target) + val beanWrapper = new BeanWrapperImpl(ref); + 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 } // TODO: check if this works in 2.8 (type inferred to Nothing instead of AnyRef here) diff --git a/akka-spring/src/main/scala/ActiveObjectParser.scala b/akka-spring/src/main/scala/ActiveObjectParser.scala index dd48f8dbe1..d3b25791c6 100644 --- a/akka-spring/src/main/scala/ActiveObjectParser.scala +++ b/akka-spring/src/main/scala/ActiveObjectParser.scala @@ -5,10 +5,12 @@ package se.scalablesolutions.akka.spring import org.springframework.util.xml.DomUtils import org.w3c.dom.Element +import scala.collection.JavaConversions._ /** * Parser trait for custom namespace configuration for active-object. * @author michaelkober + * @author Johan Rask */ trait ActiveObjectParser extends BeanParser with DispatcherParser { import AkkaSpringConfigurationTags._ @@ -23,6 +25,7 @@ trait ActiveObjectParser extends BeanParser with DispatcherParser { val remoteElement = DomUtils.getChildElementByTagName(element, REMOTE_TAG); val callbacksElement = DomUtils.getChildElementByTagName(element, RESTART_CALLBACKS_TAG); val dispatcherElement = DomUtils.getChildElementByTagName(element, DISPATCHER_TAG) + val propertyEntries = DomUtils.getChildElementsByTagName(element,PROPERTYENTRY_TAG) if (remoteElement != null) { objectProperties.host = mandatory(remoteElement, HOST) @@ -42,6 +45,14 @@ trait ActiveObjectParser extends BeanParser with DispatcherParser { 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) + } + try { objectProperties.timeout = mandatory(element, TIMEOUT).toLong } catch { @@ -58,8 +69,13 @@ trait ActiveObjectParser extends BeanParser with DispatcherParser { } if (!element.getAttribute(LIFECYCLE).isEmpty) { - objectProperties.lifecyclye = element.getAttribute(LIFECYCLE) + objectProperties.lifecycle = element.getAttribute(LIFECYCLE) } + + if (!element.getAttribute(SCOPE).isEmpty) { + objectProperties.scope = element.getAttribute(SCOPE) + } + objectProperties } diff --git a/akka-spring/src/main/scala/ActiveObjectProperties.scala b/akka-spring/src/main/scala/ActiveObjectProperties.scala index e273d27a8d..ba4828e2f9 100644 --- a/akka-spring/src/main/scala/ActiveObjectProperties.scala +++ b/akka-spring/src/main/scala/ActiveObjectProperties.scala @@ -20,8 +20,10 @@ class ActiveObjectProperties { var postRestart: String = "" var host: String = "" var port: Int = _ - var lifecyclye: String = "" + var lifecycle: String = "" + var scope:String = "" var dispatcher: DispatcherProperties = _ + var propertyEntries = new PropertyEntries() /** @@ -37,8 +39,10 @@ class ActiveObjectProperties { builder.addPropertyValue(TARGET, target) builder.addPropertyValue(INTERFACE, interface) builder.addPropertyValue(TRANSACTIONAL, transactional) - builder.addPropertyValue(LIFECYCLE, lifecyclye) + builder.addPropertyValue(LIFECYCLE, lifecycle) + builder.addPropertyValue(SCOPE, scope) builder.addPropertyValue(DISPATCHER_TAG, dispatcher) - } + builder.addPropertyValue(PROPERTYENTRY_TAG,propertyEntries) +} } diff --git a/akka-spring/src/main/scala/AkkaBeansException.scala b/akka-spring/src/main/scala/AkkaBeansException.scala new file mode 100644 index 0000000000..58928cf69e --- /dev/null +++ b/akka-spring/src/main/scala/AkkaBeansException.scala @@ -0,0 +1,14 @@ +package se.scalablesolutions.akka.spring + +import org.springframework.beans.BeansException + +/** +* Exception to use when something goes wrong during bean creation +@author Johan Rask +*/ +class AkkaBeansException(errorMsg:String,t:Throwable) extends BeansException(errorMsg,t) { + + def this(errorMsg:String) = { + this(errorMsg,null) + } +} \ No newline at end of file diff --git a/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala b/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala index 8ceb1b8f6a..39cb09dd64 100644 --- a/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala +++ b/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala @@ -15,6 +15,7 @@ object AkkaSpringConfigurationTags { val ACTIVE_OBJECT_TAG = "active-object" val SUPERVISION_TAG = "supervision" val DISPATCHER_TAG = "dispatcher" + val PROPERTYENTRY_TAG = "property" // active-object sub tags val RESTART_CALLBACKS_TAG = "restart-callbacks" @@ -41,6 +42,7 @@ object AkkaSpringConfigurationTags { val PRE_RESTART = "pre" val POST_RESTART = "post" val LIFECYCLE = "lifecycle" + val SCOPE = "scope" // supervision attributes val FAILOVER = "failover" @@ -68,6 +70,9 @@ object AkkaSpringConfigurationTags { 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" diff --git a/akka-spring/src/main/scala/PropertyEntries.scala b/akka-spring/src/main/scala/PropertyEntries.scala new file mode 100644 index 0000000000..935baac4f4 --- /dev/null +++ b/akka-spring/src/main/scala/PropertyEntries.scala @@ -0,0 +1,18 @@ +package se.scalablesolutions.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) + } +} \ No newline at end of file diff --git a/akka-spring/src/main/scala/PropertyEntry.scala b/akka-spring/src/main/scala/PropertyEntry.scala new file mode 100644 index 0000000000..a01241635b --- /dev/null +++ b/akka-spring/src/main/scala/PropertyEntry.scala @@ -0,0 +1,17 @@ +package se.scalablesolutions.akka.spring + +/** +* 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) + } +} \ No newline at end of file diff --git a/akka-spring/src/main/scala/SupervisionFactoryBean.scala b/akka-spring/src/main/scala/SupervisionFactoryBean.scala index d82d329f79..d8c44c3502 100644 --- a/akka-spring/src/main/scala/SupervisionFactoryBean.scala +++ b/akka-spring/src/main/scala/SupervisionFactoryBean.scala @@ -40,7 +40,7 @@ class SupervisionFactoryBean extends AbstractFactoryBean[ActiveObjectConfigurato */ private[akka] def createComponent(props: ActiveObjectProperties): Component = { import StringReflect._ - val lifeCycle = if (!props.lifecyclye.isEmpty && props.lifecyclye.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) new LifeCycle(new Temporary()) else new LifeCycle(new Permanent()) + val lifeCycle = if (!props.lifecycle.isEmpty && props.lifecycle.equalsIgnoreCase(VAL_LIFECYCYLE_TEMPORARY)) new LifeCycle(new Temporary()) else new LifeCycle(new Permanent()) val isRemote = (props.host != null) && (!props.host.isEmpty) val withInterface = (props.interface != null) && (!props.interface.isEmpty) if (isRemote) { diff --git a/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala b/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala index e7ed68c379..23972e8f2e 100644 --- a/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala +++ b/akka-spring/src/test/scala/ActiveObjectBeanDefinitionParserTest.scala @@ -25,13 +25,18 @@ class ActiveObjectBeanDefinitionParserTest extends Spec with ShouldMatchers { val xml = + transactional="true" + scope="prototype"> + + val props = parser.parseActiveObject(dom(xml).getDocumentElement); assert(props != null) - assert(props.timeout == 1000) - assert(props.target == "foo.bar.MyPojo") + assert(props.timeout === 1000) + assert(props.target === "foo.bar.MyPojo") assert(props.transactional) + assert(props.scope === "prototype") + assert(props.propertyEntries.entryList.size === 1) } it("should throw IllegalArgumentException on missing mandatory attributes") { @@ -50,7 +55,7 @@ class ActiveObjectBeanDefinitionParserTest extends Spec with ShouldMatchers { val props = parser.parseActiveObject(dom(xml).getDocumentElement); assert(props != null) assert(props.dispatcher.dispatcherType == "thread-based") - } +} it("should parse remote ActiveObjects configuration") { val xml = Date: Mon, 21 Jun 2010 09:06:40 +0200 Subject: [PATCH 03/18] When interfaces are used, target instances are now created correctly --- .../src/main/scala/ActiveObjectFactoryBean.scala | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala b/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala index b1093a9a08..b6a51138dc 100644 --- a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala +++ b/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala @@ -110,15 +110,15 @@ class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] with Logging { if (argList == "r") { ActiveObject.newRemoteInstance(target.toClass, timeout, transactional, host, port, callbacks) } else if (argList == "ri" ) { - ActiveObject.newRemoteInstance(interface.toClass, target.toClass, timeout, transactional, host, port, callbacks) + ActiveObject.newRemoteInstance(interface.toClass, aNewInstance(target.toClass), timeout, transactional, host, port, callbacks) } else if (argList == "rd") { ActiveObject.newRemoteInstance(target.toClass, timeout, transactional, dispatcherInstance, host, port, callbacks) } else if (argList == "rid") { - ActiveObject.newRemoteInstance(interface.toClass, target.toClass, timeout, transactional, dispatcherInstance, host, port, callbacks) + ActiveObject.newRemoteInstance(interface.toClass, aNewInstance(target.toClass), timeout, transactional, dispatcherInstance, host, port, callbacks) } else if (argList == "i") { - ActiveObject.newInstance(interface.toClass, target.toClass, timeout, transactional, callbacks) + ActiveObject.newInstance(interface.toClass, aNewInstance(target.toClass), timeout, transactional, callbacks) } else if (argList == "id") { - ActiveObject.newInstance(interface.toClass, target.toClass, timeout, transactional, dispatcherInstance, callbacks) + ActiveObject.newInstance(interface.toClass, aNewInstance(target.toClass), timeout, transactional, dispatcherInstance, callbacks) } else if (argList == "d") { ActiveObject.newInstance(target.toClass, timeout, transactional, dispatcherInstance, callbacks) } else { @@ -126,6 +126,10 @@ class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] with Logging { } } + def aNewInstance[T <: AnyRef](clazz: Class[T]) : T = { + clazz.newInstance().asInstanceOf[T] + } + /** * create Option[RestartCallback] */ From cb7e26eb8b0900d91150f8a827368602f6c2a105 Mon Sep 17 00:00:00 2001 From: Johan Rask Date: Mon, 21 Jun 2010 20:49:32 +0200 Subject: [PATCH 04/18] Added missing files --- akka-spring/src/test/resources/appContext.xml | 21 +++++++++++++++++++ .../src/test/resources/failing-appContext.xml | 21 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 akka-spring/src/test/resources/appContext.xml create mode 100644 akka-spring/src/test/resources/failing-appContext.xml diff --git a/akka-spring/src/test/resources/appContext.xml b/akka-spring/src/test/resources/appContext.xml new file mode 100644 index 0000000000..3dc4d63794 --- /dev/null +++ b/akka-spring/src/test/resources/appContext.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/akka-spring/src/test/resources/failing-appContext.xml b/akka-spring/src/test/resources/failing-appContext.xml new file mode 100644 index 0000000000..3ea9f552e0 --- /dev/null +++ b/akka-spring/src/test/resources/failing-appContext.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + \ No newline at end of file From 5397e81ac53fbc23140666fbadba5baf274d968f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Mon, 21 Jun 2010 20:56:29 +0200 Subject: [PATCH 05/18] commented out failing spring test --- .../scala/ActiveObjectFactoryBeanTest.scala | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala b/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala index fb78e1b05b..e35dde5501 100644 --- a/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala +++ b/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala @@ -47,12 +47,13 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers { bean.setTarget("java.lang.String") assert(bean.getObjectType == classOf[String]) } - it("should create a proxy of type ResourceEditor") { - val bean = new ActiveObjectFactoryBean() - // we must have a java class here - bean.setTarget("org.springframework.core.io.ResourceEditor") - val entries = new PropertyEntries() - val entry = new PropertyEntry() + + it("should create a proxy of type ResourceEditor") { + val bean = new ActiveObjectFactoryBean() + // we must have a java class here + bean.setTarget("org.springframework.core.io.ResourceEditor") + val entries = new PropertyEntries() + val entry = new PropertyEntry() entry.name = "source" entry.value = "sourceBeanIsAString" entries.add(entry) @@ -60,14 +61,16 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers { assert(bean.getObjectType == classOf[ResourceEditor]) // Check that we have injected the depencency correctly - val target:ResourceEditor = bean.createInstance.asInstanceOf[ResourceEditor] - assert(target.getSource === entry.value) - } + val target:ResourceEditor = bean.createInstance.asInstanceOf[ResourceEditor] + assert(target.getSource === entry.value) + } + +/* it("should create an application context and inject a string dependency") { - var ctx = new ClassPathXmlApplicationContext("appContext.xml"); - val target:ResourceEditor = ctx.getBean("bean").asInstanceOf[ResourceEditor] - assert(target.getSource === "someString") - } - + var ctx = new ClassPathXmlApplicationContext("appContext.xml"); + val target:ResourceEditor = ctx.getBean("bean").asInstanceOf[ResourceEditor] + assert(target.getSource === "someString") + } +*/ } } From 5bb912b01c14801442fc9dfac720140f4407d2b4 Mon Sep 17 00:00:00 2001 From: Johan Rask Date: Mon, 21 Jun 2010 21:14:09 +0200 Subject: [PATCH 06/18] Removed comments from test --- akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala b/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala index e35dde5501..3543cba530 100644 --- a/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala +++ b/akka-spring/src/test/scala/ActiveObjectFactoryBeanTest.scala @@ -65,12 +65,10 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers { assert(target.getSource === entry.value) } -/* it("should create an application context and inject a string dependency") { var ctx = new ClassPathXmlApplicationContext("appContext.xml"); val target:ResourceEditor = ctx.getBean("bean").asInstanceOf[ResourceEditor] assert(target.getSource === "someString") } -*/ } } From 916cfe97c0331ebaf787e80373dbc308fb7c71ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Tue, 22 Jun 2010 07:22:47 +0200 Subject: [PATCH 07/18] Protobuf deep actor serialization working and test passing --- .../akka/remote/protocol/RemoteProtocol.java | 2321 ++++++++--------- .../src/main/protocol/RemoteProtocol.proto | 4 +- .../test/scala/SerializableActorSpec.scala | 2 +- 3 files changed, 1163 insertions(+), 1164 deletions(-) diff --git a/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java b/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java index 31234fe4a8..314f67cfa4 100644 --- a/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java +++ b/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java @@ -148,1044 +148,6 @@ public final class RemoteProtocol { // @@protoc_insertion_point(enum_scope:LifeCycleType) } - public static final class LifeCycleProtocol extends - com.google.protobuf.GeneratedMessage { - // Use LifeCycleProtocol.newBuilder() to construct. - private LifeCycleProtocol() { - initFields(); - } - private LifeCycleProtocol(boolean noInit) {} - - private static final LifeCycleProtocol defaultInstance; - public static LifeCycleProtocol getDefaultInstance() { - return defaultInstance; - } - - public LifeCycleProtocol getDefaultInstanceForType() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_LifeCycleProtocol_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_LifeCycleProtocol_fieldAccessorTable; - } - - // required .LifeCycleType lifeCycle = 1; - public static final int LIFECYCLE_FIELD_NUMBER = 1; - private boolean hasLifeCycle; - private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType lifeCycle_; - public boolean hasLifeCycle() { return hasLifeCycle; } - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType getLifeCycle() { return lifeCycle_; } - - // optional string preRestart = 2; - public static final int PRERESTART_FIELD_NUMBER = 2; - private boolean hasPreRestart; - private java.lang.String preRestart_ = ""; - public boolean hasPreRestart() { return hasPreRestart; } - public java.lang.String getPreRestart() { return preRestart_; } - - // optional string postRestart = 3; - public static final int POSTRESTART_FIELD_NUMBER = 3; - private boolean hasPostRestart; - private java.lang.String postRestart_ = ""; - public boolean hasPostRestart() { return hasPostRestart; } - public java.lang.String getPostRestart() { return postRestart_; } - - private void initFields() { - lifeCycle_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType.PERMANENT; - } - public final boolean isInitialized() { - if (!hasLifeCycle) return false; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (hasLifeCycle()) { - output.writeEnum(1, getLifeCycle().getNumber()); - } - if (hasPreRestart()) { - output.writeString(2, getPreRestart()); - } - if (hasPostRestart()) { - output.writeString(3, getPostRestart()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasLifeCycle()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(1, getLifeCycle().getNumber()); - } - if (hasPreRestart()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(2, getPreRestart()); - } - if (hasPostRestart()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(3, getPostRestart()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom(java.io.InputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input, extensionRegistry)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { - private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol result; - - // Construct using se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.newBuilder() - private Builder() {} - - private static Builder create() { - Builder builder = new Builder(); - builder.result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol(); - return builder; - } - - protected se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol internalGetResult() { - return result; - } - - public Builder clear() { - if (result == null) { - throw new IllegalStateException( - "Cannot call clear() after build()."); - } - result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol(); - return this; - } - - public Builder clone() { - return create().mergeFrom(result); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.getDescriptor(); - } - - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol getDefaultInstanceForType() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.getDefaultInstance(); - } - - public boolean isInitialized() { - return result.isInitialized(); - } - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol build() { - if (result != null && !isInitialized()) { - throw newUninitializedMessageException(result); - } - return buildPartial(); - } - - private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol buildParsed() - throws com.google.protobuf.InvalidProtocolBufferException { - if (!isInitialized()) { - throw newUninitializedMessageException( - result).asInvalidProtocolBufferException(); - } - return buildPartial(); - } - - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol buildPartial() { - if (result == null) { - throw new IllegalStateException( - "build() has already been called on this Builder."); - } - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol returnMe = result; - result = null; - return returnMe; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol) { - return mergeFrom((se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol other) { - if (other == se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.getDefaultInstance()) return this; - if (other.hasLifeCycle()) { - setLifeCycle(other.getLifeCycle()); - } - if (other.hasPreRestart()) { - setPreRestart(other.getPreRestart()); - } - if (other.hasPostRestart()) { - setPostRestart(other.getPostRestart()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); - while (true) { - int tag = input.readTag(); - switch (tag) { - case 0: - this.setUnknownFields(unknownFields.build()); - return this; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); - return this; - } - break; - } - case 8: { - int rawValue = input.readEnum(); - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType value = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(1, rawValue); - } else { - setLifeCycle(value); - } - break; - } - case 18: { - setPreRestart(input.readString()); - break; - } - case 26: { - setPostRestart(input.readString()); - break; - } - } - } - } - - - // required .LifeCycleType lifeCycle = 1; - public boolean hasLifeCycle() { - return result.hasLifeCycle(); - } - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType getLifeCycle() { - return result.getLifeCycle(); - } - public Builder setLifeCycle(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasLifeCycle = true; - result.lifeCycle_ = value; - return this; - } - public Builder clearLifeCycle() { - result.hasLifeCycle = false; - result.lifeCycle_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType.PERMANENT; - return this; - } - - // optional string preRestart = 2; - public boolean hasPreRestart() { - return result.hasPreRestart(); - } - public java.lang.String getPreRestart() { - return result.getPreRestart(); - } - public Builder setPreRestart(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasPreRestart = true; - result.preRestart_ = value; - return this; - } - public Builder clearPreRestart() { - result.hasPreRestart = false; - result.preRestart_ = getDefaultInstance().getPreRestart(); - return this; - } - - // optional string postRestart = 3; - public boolean hasPostRestart() { - return result.hasPostRestart(); - } - public java.lang.String getPostRestart() { - return result.getPostRestart(); - } - public Builder setPostRestart(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasPostRestart = true; - result.postRestart_ = value; - return this; - } - public Builder clearPostRestart() { - result.hasPostRestart = false; - result.postRestart_ = getDefaultInstance().getPostRestart(); - return this; - } - - // @@protoc_insertion_point(builder_scope:LifeCycleProtocol) - } - - static { - defaultInstance = new LifeCycleProtocol(true); - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internalForceInit(); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:LifeCycleProtocol) - } - - public static final class AddressProtocol extends - com.google.protobuf.GeneratedMessage { - // Use AddressProtocol.newBuilder() to construct. - private AddressProtocol() { - initFields(); - } - private AddressProtocol(boolean noInit) {} - - private static final AddressProtocol defaultInstance; - public static AddressProtocol getDefaultInstance() { - return defaultInstance; - } - - public AddressProtocol getDefaultInstanceForType() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_AddressProtocol_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_AddressProtocol_fieldAccessorTable; - } - - // required string hostname = 1; - public static final int HOSTNAME_FIELD_NUMBER = 1; - private boolean hasHostname; - private java.lang.String hostname_ = ""; - public boolean hasHostname() { return hasHostname; } - public java.lang.String getHostname() { return hostname_; } - - // required uint32 port = 2; - public static final int PORT_FIELD_NUMBER = 2; - private boolean hasPort; - private int port_ = 0; - public boolean hasPort() { return hasPort; } - public int getPort() { return port_; } - - private void initFields() { - } - public final boolean isInitialized() { - if (!hasHostname) return false; - if (!hasPort) return false; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (hasHostname()) { - output.writeString(1, getHostname()); - } - if (hasPort()) { - output.writeUInt32(2, getPort()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasHostname()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(1, getHostname()); - } - if (hasPort()) { - size += com.google.protobuf.CodedOutputStream - .computeUInt32Size(2, getPort()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom(java.io.InputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input, extensionRegistry)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { - private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol result; - - // Construct using se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.newBuilder() - private Builder() {} - - private static Builder create() { - Builder builder = new Builder(); - builder.result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol(); - return builder; - } - - protected se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol internalGetResult() { - return result; - } - - public Builder clear() { - if (result == null) { - throw new IllegalStateException( - "Cannot call clear() after build()."); - } - result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol(); - return this; - } - - public Builder clone() { - return create().mergeFrom(result); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.getDescriptor(); - } - - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol getDefaultInstanceForType() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.getDefaultInstance(); - } - - public boolean isInitialized() { - return result.isInitialized(); - } - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol build() { - if (result != null && !isInitialized()) { - throw newUninitializedMessageException(result); - } - return buildPartial(); - } - - private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol buildParsed() - throws com.google.protobuf.InvalidProtocolBufferException { - if (!isInitialized()) { - throw newUninitializedMessageException( - result).asInvalidProtocolBufferException(); - } - return buildPartial(); - } - - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol buildPartial() { - if (result == null) { - throw new IllegalStateException( - "build() has already been called on this Builder."); - } - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol returnMe = result; - result = null; - return returnMe; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol) { - return mergeFrom((se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol other) { - if (other == se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.getDefaultInstance()) return this; - if (other.hasHostname()) { - setHostname(other.getHostname()); - } - if (other.hasPort()) { - setPort(other.getPort()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); - while (true) { - int tag = input.readTag(); - switch (tag) { - case 0: - this.setUnknownFields(unknownFields.build()); - return this; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); - return this; - } - break; - } - case 10: { - setHostname(input.readString()); - break; - } - case 16: { - setPort(input.readUInt32()); - break; - } - } - } - } - - - // required string hostname = 1; - public boolean hasHostname() { - return result.hasHostname(); - } - public java.lang.String getHostname() { - return result.getHostname(); - } - public Builder setHostname(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasHostname = true; - result.hostname_ = value; - return this; - } - public Builder clearHostname() { - result.hasHostname = false; - result.hostname_ = getDefaultInstance().getHostname(); - return this; - } - - // required uint32 port = 2; - public boolean hasPort() { - return result.hasPort(); - } - public int getPort() { - return result.getPort(); - } - public Builder setPort(int value) { - result.hasPort = true; - result.port_ = value; - return this; - } - public Builder clearPort() { - result.hasPort = false; - result.port_ = 0; - return this; - } - - // @@protoc_insertion_point(builder_scope:AddressProtocol) - } - - static { - defaultInstance = new AddressProtocol(true); - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internalForceInit(); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:AddressProtocol) - } - - public static final class ExceptionProtocol extends - com.google.protobuf.GeneratedMessage { - // Use ExceptionProtocol.newBuilder() to construct. - private ExceptionProtocol() { - initFields(); - } - private ExceptionProtocol(boolean noInit) {} - - private static final ExceptionProtocol defaultInstance; - public static ExceptionProtocol getDefaultInstance() { - return defaultInstance; - } - - public ExceptionProtocol getDefaultInstanceForType() { - return defaultInstance; - } - - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_ExceptionProtocol_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_ExceptionProtocol_fieldAccessorTable; - } - - // required string classname = 1; - public static final int CLASSNAME_FIELD_NUMBER = 1; - private boolean hasClassname; - private java.lang.String classname_ = ""; - public boolean hasClassname() { return hasClassname; } - public java.lang.String getClassname() { return classname_; } - - // required string message = 2; - public static final int MESSAGE_FIELD_NUMBER = 2; - private boolean hasMessage; - private java.lang.String message_ = ""; - public boolean hasMessage() { return hasMessage; } - public java.lang.String getMessage() { return message_; } - - private void initFields() { - } - public final boolean isInitialized() { - if (!hasClassname) return false; - if (!hasMessage) return false; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (hasClassname()) { - output.writeString(1, getClassname()); - } - if (hasMessage()) { - output.writeString(2, getMessage()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (hasClassname()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(1, getClassname()); - } - if (hasMessage()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(2, getMessage()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return newBuilder().mergeFrom(data, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom(java.io.InputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - Builder builder = newBuilder(); - if (builder.mergeDelimitedFrom(input, extensionRegistry)) { - return builder.buildParsed(); - } else { - return null; - } - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return newBuilder().mergeFrom(input).buildParsed(); - } - public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return newBuilder().mergeFrom(input, extensionRegistry) - .buildParsed(); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder { - private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol result; - - // Construct using se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.newBuilder() - private Builder() {} - - private static Builder create() { - Builder builder = new Builder(); - builder.result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol(); - return builder; - } - - protected se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol internalGetResult() { - return result; - } - - public Builder clear() { - if (result == null) { - throw new IllegalStateException( - "Cannot call clear() after build()."); - } - result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol(); - return this; - } - - public Builder clone() { - return create().mergeFrom(result); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.getDescriptor(); - } - - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol getDefaultInstanceForType() { - return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.getDefaultInstance(); - } - - public boolean isInitialized() { - return result.isInitialized(); - } - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol build() { - if (result != null && !isInitialized()) { - throw newUninitializedMessageException(result); - } - return buildPartial(); - } - - private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol buildParsed() - throws com.google.protobuf.InvalidProtocolBufferException { - if (!isInitialized()) { - throw newUninitializedMessageException( - result).asInvalidProtocolBufferException(); - } - return buildPartial(); - } - - public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol buildPartial() { - if (result == null) { - throw new IllegalStateException( - "build() has already been called on this Builder."); - } - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol returnMe = result; - result = null; - return returnMe; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol) { - return mergeFrom((se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol other) { - if (other == se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.getDefaultInstance()) return this; - if (other.hasClassname()) { - setClassname(other.getClassname()); - } - if (other.hasMessage()) { - setMessage(other.getMessage()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder( - this.getUnknownFields()); - while (true) { - int tag = input.readTag(); - switch (tag) { - case 0: - this.setUnknownFields(unknownFields.build()); - return this; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - this.setUnknownFields(unknownFields.build()); - return this; - } - break; - } - case 10: { - setClassname(input.readString()); - break; - } - case 18: { - setMessage(input.readString()); - break; - } - } - } - } - - - // required string classname = 1; - public boolean hasClassname() { - return result.hasClassname(); - } - public java.lang.String getClassname() { - return result.getClassname(); - } - public Builder setClassname(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasClassname = true; - result.classname_ = value; - return this; - } - public Builder clearClassname() { - result.hasClassname = false; - result.classname_ = getDefaultInstance().getClassname(); - return this; - } - - // required string message = 2; - public boolean hasMessage() { - return result.hasMessage(); - } - public java.lang.String getMessage() { - return result.getMessage(); - } - public Builder setMessage(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasMessage = true; - result.message_ = value; - return this; - } - public Builder clearMessage() { - result.hasMessage = false; - result.message_ = getDefaultInstance().getMessage(); - return this; - } - - // @@protoc_insertion_point(builder_scope:ExceptionProtocol) - } - - static { - defaultInstance = new ExceptionProtocol(true); - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internalForceInit(); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:ExceptionProtocol) - } - public static final class RemoteActorRefProtocol extends com.google.protobuf.GeneratedMessage { // Use RemoteActorRefProtocol.newBuilder() to construct. @@ -1677,20 +639,20 @@ public final class RemoteProtocol { public boolean hasActorInstance() { return hasActorInstance; } public com.google.protobuf.ByteString getActorInstance() { return actorInstance_; } - // required string serializerClassname = 5; - public static final int SERIALIZERCLASSNAME_FIELD_NUMBER = 5; - private boolean hasSerializerClassname; - private java.lang.String serializerClassname_ = ""; - public boolean hasSerializerClassname() { return hasSerializerClassname; } - public java.lang.String getSerializerClassname() { return serializerClassname_; } - - // required .AddressProtocol originalAddress = 6; - public static final int ORIGINALADDRESS_FIELD_NUMBER = 6; + // required .AddressProtocol originalAddress = 5; + public static final int ORIGINALADDRESS_FIELD_NUMBER = 5; private boolean hasOriginalAddress; private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol originalAddress_; public boolean hasOriginalAddress() { return hasOriginalAddress; } public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol getOriginalAddress() { return originalAddress_; } + // optional string serializerClassname = 6; + public static final int SERIALIZERCLASSNAME_FIELD_NUMBER = 6; + private boolean hasSerializerClassname; + private java.lang.String serializerClassname_ = ""; + public boolean hasSerializerClassname() { return hasSerializerClassname; } + public java.lang.String getSerializerClassname() { return serializerClassname_; } + // optional bool isTransactor = 7; public static final int ISTRANSACTOR_FIELD_NUMBER = 7; private boolean hasIsTransactor; @@ -1736,7 +698,6 @@ public final class RemoteProtocol { if (!hasId) return false; if (!hasActorClassname) return false; if (!hasActorInstance) return false; - if (!hasSerializerClassname) return false; if (!hasOriginalAddress) return false; if (!getOriginalAddress().isInitialized()) return false; if (hasLifeCycle()) { @@ -1763,11 +724,11 @@ public final class RemoteProtocol { if (hasActorInstance()) { output.writeBytes(4, getActorInstance()); } - if (hasSerializerClassname()) { - output.writeString(5, getSerializerClassname()); - } if (hasOriginalAddress()) { - output.writeMessage(6, getOriginalAddress()); + output.writeMessage(5, getOriginalAddress()); + } + if (hasSerializerClassname()) { + output.writeString(6, getSerializerClassname()); } if (hasIsTransactor()) { output.writeBool(7, getIsTransactor()); @@ -1809,13 +770,13 @@ public final class RemoteProtocol { size += com.google.protobuf.CodedOutputStream .computeBytesSize(4, getActorInstance()); } - if (hasSerializerClassname()) { - size += com.google.protobuf.CodedOutputStream - .computeStringSize(5, getSerializerClassname()); - } if (hasOriginalAddress()) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, getOriginalAddress()); + .computeMessageSize(5, getOriginalAddress()); + } + if (hasSerializerClassname()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(6, getSerializerClassname()); } if (hasIsTransactor()) { size += com.google.protobuf.CodedOutputStream @@ -2007,12 +968,12 @@ public final class RemoteProtocol { if (other.hasActorInstance()) { setActorInstance(other.getActorInstance()); } - if (other.hasSerializerClassname()) { - setSerializerClassname(other.getSerializerClassname()); - } if (other.hasOriginalAddress()) { mergeOriginalAddress(other.getOriginalAddress()); } + if (other.hasSerializerClassname()) { + setSerializerClassname(other.getSerializerClassname()); + } if (other.hasIsTransactor()) { setIsTransactor(other.getIsTransactor()); } @@ -2070,10 +1031,6 @@ public final class RemoteProtocol { break; } case 42: { - setSerializerClassname(input.readString()); - break; - } - case 50: { se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.Builder subBuilder = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.newBuilder(); if (hasOriginalAddress()) { subBuilder.mergeFrom(getOriginalAddress()); @@ -2082,6 +1039,10 @@ public final class RemoteProtocol { setOriginalAddress(subBuilder.buildPartial()); break; } + case 50: { + setSerializerClassname(input.readString()); + break; + } case 56: { setIsTransactor(input.readBool()); break; @@ -2201,28 +1162,7 @@ public final class RemoteProtocol { return this; } - // required string serializerClassname = 5; - public boolean hasSerializerClassname() { - return result.hasSerializerClassname(); - } - public java.lang.String getSerializerClassname() { - return result.getSerializerClassname(); - } - public Builder setSerializerClassname(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasSerializerClassname = true; - result.serializerClassname_ = value; - return this; - } - public Builder clearSerializerClassname() { - result.hasSerializerClassname = false; - result.serializerClassname_ = getDefaultInstance().getSerializerClassname(); - return this; - } - - // required .AddressProtocol originalAddress = 6; + // required .AddressProtocol originalAddress = 5; public boolean hasOriginalAddress() { return result.hasOriginalAddress(); } @@ -2259,6 +1199,27 @@ public final class RemoteProtocol { return this; } + // optional string serializerClassname = 6; + public boolean hasSerializerClassname() { + return result.hasSerializerClassname(); + } + public java.lang.String getSerializerClassname() { + return result.getSerializerClassname(); + } + public Builder setSerializerClassname(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasSerializerClassname = true; + result.serializerClassname_ = value; + return this; + } + public Builder clearSerializerClassname() { + result.hasSerializerClassname = false; + result.serializerClassname_ = getDefaultInstance().getSerializerClassname(); + return this; + } + // optional bool isTransactor = 7; public boolean hasIsTransactor() { return result.hasIsTransactor(); @@ -3826,21 +2787,1044 @@ public final class RemoteProtocol { // @@protoc_insertion_point(class_scope:RemoteReplyProtocol) } - private static com.google.protobuf.Descriptors.Descriptor - internal_static_LifeCycleProtocol_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_LifeCycleProtocol_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_AddressProtocol_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_AddressProtocol_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_ExceptionProtocol_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_ExceptionProtocol_fieldAccessorTable; + public static final class LifeCycleProtocol extends + com.google.protobuf.GeneratedMessage { + // Use LifeCycleProtocol.newBuilder() to construct. + private LifeCycleProtocol() { + initFields(); + } + private LifeCycleProtocol(boolean noInit) {} + + private static final LifeCycleProtocol defaultInstance; + public static LifeCycleProtocol getDefaultInstance() { + return defaultInstance; + } + + public LifeCycleProtocol getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_LifeCycleProtocol_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_LifeCycleProtocol_fieldAccessorTable; + } + + // required .LifeCycleType lifeCycle = 1; + public static final int LIFECYCLE_FIELD_NUMBER = 1; + private boolean hasLifeCycle; + private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType lifeCycle_; + public boolean hasLifeCycle() { return hasLifeCycle; } + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType getLifeCycle() { return lifeCycle_; } + + // optional string preRestart = 2; + public static final int PRERESTART_FIELD_NUMBER = 2; + private boolean hasPreRestart; + private java.lang.String preRestart_ = ""; + public boolean hasPreRestart() { return hasPreRestart; } + public java.lang.String getPreRestart() { return preRestart_; } + + // optional string postRestart = 3; + public static final int POSTRESTART_FIELD_NUMBER = 3; + private boolean hasPostRestart; + private java.lang.String postRestart_ = ""; + public boolean hasPostRestart() { return hasPostRestart; } + public java.lang.String getPostRestart() { return postRestart_; } + + private void initFields() { + lifeCycle_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType.PERMANENT; + } + public final boolean isInitialized() { + if (!hasLifeCycle) return false; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (hasLifeCycle()) { + output.writeEnum(1, getLifeCycle().getNumber()); + } + if (hasPreRestart()) { + output.writeString(2, getPreRestart()); + } + if (hasPostRestart()) { + output.writeString(3, getPostRestart()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasLifeCycle()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, getLifeCycle().getNumber()); + } + if (hasPreRestart()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(2, getPreRestart()); + } + if (hasPostRestart()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(3, getPostRestart()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder { + private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol result; + + // Construct using se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.newBuilder() + private Builder() {} + + private static Builder create() { + Builder builder = new Builder(); + builder.result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol(); + return builder; + } + + protected se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol internalGetResult() { + return result; + } + + public Builder clear() { + if (result == null) { + throw new IllegalStateException( + "Cannot call clear() after build()."); + } + result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol(); + return this; + } + + public Builder clone() { + return create().mergeFrom(result); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.getDescriptor(); + } + + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol getDefaultInstanceForType() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.getDefaultInstance(); + } + + public boolean isInitialized() { + return result.isInitialized(); + } + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol build() { + if (result != null && !isInitialized()) { + throw newUninitializedMessageException(result); + } + return buildPartial(); + } + + private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + if (!isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return buildPartial(); + } + + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol buildPartial() { + if (result == null) { + throw new IllegalStateException( + "build() has already been called on this Builder."); + } + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol returnMe = result; + result = null; + return returnMe; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol) { + return mergeFrom((se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol other) { + if (other == se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.getDefaultInstance()) return this; + if (other.hasLifeCycle()) { + setLifeCycle(other.getLifeCycle()); + } + if (other.hasPreRestart()) { + setPreRestart(other.getPreRestart()); + } + if (other.hasPostRestart()) { + setPostRestart(other.getPostRestart()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder( + this.getUnknownFields()); + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + this.setUnknownFields(unknownFields.build()); + return this; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + this.setUnknownFields(unknownFields.build()); + return this; + } + break; + } + case 8: { + int rawValue = input.readEnum(); + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType value = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(1, rawValue); + } else { + setLifeCycle(value); + } + break; + } + case 18: { + setPreRestart(input.readString()); + break; + } + case 26: { + setPostRestart(input.readString()); + break; + } + } + } + } + + + // required .LifeCycleType lifeCycle = 1; + public boolean hasLifeCycle() { + return result.hasLifeCycle(); + } + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType getLifeCycle() { + return result.getLifeCycle(); + } + public Builder setLifeCycle(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasLifeCycle = true; + result.lifeCycle_ = value; + return this; + } + public Builder clearLifeCycle() { + result.hasLifeCycle = false; + result.lifeCycle_ = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleType.PERMANENT; + return this; + } + + // optional string preRestart = 2; + public boolean hasPreRestart() { + return result.hasPreRestart(); + } + public java.lang.String getPreRestart() { + return result.getPreRestart(); + } + public Builder setPreRestart(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasPreRestart = true; + result.preRestart_ = value; + return this; + } + public Builder clearPreRestart() { + result.hasPreRestart = false; + result.preRestart_ = getDefaultInstance().getPreRestart(); + return this; + } + + // optional string postRestart = 3; + public boolean hasPostRestart() { + return result.hasPostRestart(); + } + public java.lang.String getPostRestart() { + return result.getPostRestart(); + } + public Builder setPostRestart(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasPostRestart = true; + result.postRestart_ = value; + return this; + } + public Builder clearPostRestart() { + result.hasPostRestart = false; + result.postRestart_ = getDefaultInstance().getPostRestart(); + return this; + } + + // @@protoc_insertion_point(builder_scope:LifeCycleProtocol) + } + + static { + defaultInstance = new LifeCycleProtocol(true); + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internalForceInit(); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:LifeCycleProtocol) + } + + public static final class AddressProtocol extends + com.google.protobuf.GeneratedMessage { + // Use AddressProtocol.newBuilder() to construct. + private AddressProtocol() { + initFields(); + } + private AddressProtocol(boolean noInit) {} + + private static final AddressProtocol defaultInstance; + public static AddressProtocol getDefaultInstance() { + return defaultInstance; + } + + public AddressProtocol getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_AddressProtocol_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_AddressProtocol_fieldAccessorTable; + } + + // required string hostname = 1; + public static final int HOSTNAME_FIELD_NUMBER = 1; + private boolean hasHostname; + private java.lang.String hostname_ = ""; + public boolean hasHostname() { return hasHostname; } + public java.lang.String getHostname() { return hostname_; } + + // required uint32 port = 2; + public static final int PORT_FIELD_NUMBER = 2; + private boolean hasPort; + private int port_ = 0; + public boolean hasPort() { return hasPort; } + public int getPort() { return port_; } + + private void initFields() { + } + public final boolean isInitialized() { + if (!hasHostname) return false; + if (!hasPort) return false; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (hasHostname()) { + output.writeString(1, getHostname()); + } + if (hasPort()) { + output.writeUInt32(2, getPort()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasHostname()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(1, getHostname()); + } + if (hasPort()) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(2, getPort()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder { + private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol result; + + // Construct using se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.newBuilder() + private Builder() {} + + private static Builder create() { + Builder builder = new Builder(); + builder.result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol(); + return builder; + } + + protected se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol internalGetResult() { + return result; + } + + public Builder clear() { + if (result == null) { + throw new IllegalStateException( + "Cannot call clear() after build()."); + } + result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol(); + return this; + } + + public Builder clone() { + return create().mergeFrom(result); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.getDescriptor(); + } + + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol getDefaultInstanceForType() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.getDefaultInstance(); + } + + public boolean isInitialized() { + return result.isInitialized(); + } + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol build() { + if (result != null && !isInitialized()) { + throw newUninitializedMessageException(result); + } + return buildPartial(); + } + + private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + if (!isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return buildPartial(); + } + + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol buildPartial() { + if (result == null) { + throw new IllegalStateException( + "build() has already been called on this Builder."); + } + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol returnMe = result; + result = null; + return returnMe; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol) { + return mergeFrom((se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol other) { + if (other == se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.getDefaultInstance()) return this; + if (other.hasHostname()) { + setHostname(other.getHostname()); + } + if (other.hasPort()) { + setPort(other.getPort()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder( + this.getUnknownFields()); + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + this.setUnknownFields(unknownFields.build()); + return this; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + this.setUnknownFields(unknownFields.build()); + return this; + } + break; + } + case 10: { + setHostname(input.readString()); + break; + } + case 16: { + setPort(input.readUInt32()); + break; + } + } + } + } + + + // required string hostname = 1; + public boolean hasHostname() { + return result.hasHostname(); + } + public java.lang.String getHostname() { + return result.getHostname(); + } + public Builder setHostname(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasHostname = true; + result.hostname_ = value; + return this; + } + public Builder clearHostname() { + result.hasHostname = false; + result.hostname_ = getDefaultInstance().getHostname(); + return this; + } + + // required uint32 port = 2; + public boolean hasPort() { + return result.hasPort(); + } + public int getPort() { + return result.getPort(); + } + public Builder setPort(int value) { + result.hasPort = true; + result.port_ = value; + return this; + } + public Builder clearPort() { + result.hasPort = false; + result.port_ = 0; + return this; + } + + // @@protoc_insertion_point(builder_scope:AddressProtocol) + } + + static { + defaultInstance = new AddressProtocol(true); + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internalForceInit(); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:AddressProtocol) + } + + public static final class ExceptionProtocol extends + com.google.protobuf.GeneratedMessage { + // Use ExceptionProtocol.newBuilder() to construct. + private ExceptionProtocol() { + initFields(); + } + private ExceptionProtocol(boolean noInit) {} + + private static final ExceptionProtocol defaultInstance; + public static ExceptionProtocol getDefaultInstance() { + return defaultInstance; + } + + public ExceptionProtocol getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_ExceptionProtocol_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internal_static_ExceptionProtocol_fieldAccessorTable; + } + + // required string classname = 1; + public static final int CLASSNAME_FIELD_NUMBER = 1; + private boolean hasClassname; + private java.lang.String classname_ = ""; + public boolean hasClassname() { return hasClassname; } + public java.lang.String getClassname() { return classname_; } + + // required string message = 2; + public static final int MESSAGE_FIELD_NUMBER = 2; + private boolean hasMessage; + private java.lang.String message_ = ""; + public boolean hasMessage() { return hasMessage; } + public java.lang.String getMessage() { return message_; } + + private void initFields() { + } + public final boolean isInitialized() { + if (!hasClassname) return false; + if (!hasMessage) return false; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (hasClassname()) { + output.writeString(1, getClassname()); + } + if (hasMessage()) { + output.writeString(2, getMessage()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasClassname()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(1, getClassname()); + } + if (hasMessage()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(2, getMessage()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder { + private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol result; + + // Construct using se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.newBuilder() + private Builder() {} + + private static Builder create() { + Builder builder = new Builder(); + builder.result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol(); + return builder; + } + + protected se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol internalGetResult() { + return result; + } + + public Builder clear() { + if (result == null) { + throw new IllegalStateException( + "Cannot call clear() after build()."); + } + result = new se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol(); + return this; + } + + public Builder clone() { + return create().mergeFrom(result); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.getDescriptor(); + } + + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol getDefaultInstanceForType() { + return se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.getDefaultInstance(); + } + + public boolean isInitialized() { + return result.isInitialized(); + } + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol build() { + if (result != null && !isInitialized()) { + throw newUninitializedMessageException(result); + } + return buildPartial(); + } + + private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + if (!isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return buildPartial(); + } + + public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol buildPartial() { + if (result == null) { + throw new IllegalStateException( + "build() has already been called on this Builder."); + } + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol returnMe = result; + result = null; + return returnMe; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol) { + return mergeFrom((se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol other) { + if (other == se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.getDefaultInstance()) return this; + if (other.hasClassname()) { + setClassname(other.getClassname()); + } + if (other.hasMessage()) { + setMessage(other.getMessage()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder( + this.getUnknownFields()); + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + this.setUnknownFields(unknownFields.build()); + return this; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + this.setUnknownFields(unknownFields.build()); + return this; + } + break; + } + case 10: { + setClassname(input.readString()); + break; + } + case 18: { + setMessage(input.readString()); + break; + } + } + } + } + + + // required string classname = 1; + public boolean hasClassname() { + return result.hasClassname(); + } + public java.lang.String getClassname() { + return result.getClassname(); + } + public Builder setClassname(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasClassname = true; + result.classname_ = value; + return this; + } + public Builder clearClassname() { + result.hasClassname = false; + result.classname_ = getDefaultInstance().getClassname(); + return this; + } + + // required string message = 2; + public boolean hasMessage() { + return result.hasMessage(); + } + public java.lang.String getMessage() { + return result.getMessage(); + } + public Builder setMessage(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasMessage = true; + result.message_ = value; + return this; + } + public Builder clearMessage() { + result.hasMessage = false; + result.message_ = getDefaultInstance().getMessage(); + return this; + } + + // @@protoc_insertion_point(builder_scope:ExceptionProtocol) + } + + static { + defaultInstance = new ExceptionProtocol(true); + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.internalForceInit(); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:ExceptionProtocol) + } + private static com.google.protobuf.Descriptors.Descriptor internal_static_RemoteActorRefProtocol_descriptor; private static @@ -3861,6 +3845,21 @@ public final class RemoteProtocol { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_RemoteReplyProtocol_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_LifeCycleProtocol_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_LifeCycleProtocol_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_AddressProtocol_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_AddressProtocol_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_ExceptionProtocol_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_ExceptionProtocol_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { @@ -3870,37 +3869,37 @@ public final class RemoteProtocol { descriptor; static { java.lang.String[] descriptorData = { - "\n\024RemoteProtocol.proto\"_\n\021LifeCycleProto" + - "col\022!\n\tlifeCycle\030\001 \002(\0162\016.LifeCycleType\022\022" + - "\n\npreRestart\030\002 \001(\t\022\023\n\013postRestart\030\003 \001(\t\"" + - "1\n\017AddressProtocol\022\020\n\010hostname\030\001 \002(\t\022\014\n\004" + - "port\030\002 \002(\r\"7\n\021ExceptionProtocol\022\021\n\tclass" + - "name\030\001 \002(\t\022\017\n\007message\030\002 \002(\t\"v\n\026RemoteAct" + - "orRefProtocol\022\014\n\004uuid\030\001 \002(\t\022\026\n\016actorClas" + - "sname\030\002 \002(\t\022%\n\013homeAddress\030\003 \002(\0132\020.Addre" + - "ssProtocol\022\017\n\007timeout\030\004 \001(\004\"\276\002\n\032Serializ" + - "edActorRefProtocol\022\014\n\004uuid\030\001 \002(\t\022\n\n\002id\030\002", - " \002(\t\022\026\n\016actorClassname\030\003 \002(\t\022\025\n\ractorIns" + - "tance\030\004 \002(\014\022\033\n\023serializerClassname\030\005 \002(\t" + - "\022)\n\017originalAddress\030\006 \002(\0132\020.AddressProto" + - "col\022\024\n\014isTransactor\030\007 \001(\010\022\017\n\007timeout\030\010 \001" + - "(\004\022%\n\tlifeCycle\030\t \001(\0132\022.LifeCycleProtoco" + - "l\022+\n\nsupervisor\030\n \001(\0132\027.RemoteActorRefPr" + - "otocol\022\024\n\014hotswapStack\030\013 \001(\014\"\272\002\n\025RemoteR" + - "equestProtocol\022\n\n\002id\030\001 \002(\004\0225\n\023serializat" + - "ionScheme\030\002 \002(\0162\030.SerializationSchemeTyp" + - "e\022\017\n\007message\030\003 \002(\014\022\027\n\017messageManifest\030\004 ", - "\001(\014\022\016\n\006method\030\005 \001(\t\022\016\n\006target\030\006 \002(\t\022\014\n\004u" + - "uid\030\007 \002(\t\022\017\n\007timeout\030\010 \002(\004\022\026\n\016supervisor" + - "Uuid\030\t \001(\t\022\017\n\007isActor\030\n \002(\010\022\020\n\010isOneWay\030" + - "\013 \002(\010\022\021\n\tisEscaped\030\014 \002(\010\022\'\n\006sender\030\r \001(\013" + - "2\027.RemoteActorRefProtocol\"\350\001\n\023RemoteRepl" + - "yProtocol\022\n\n\002id\030\001 \002(\004\0225\n\023serializationSc" + - "heme\030\002 \001(\0162\030.SerializationSchemeType\022\017\n\007" + - "message\030\003 \001(\014\022\027\n\017messageManifest\030\004 \001(\014\022%" + - "\n\texception\030\005 \001(\0132\022.ExceptionProtocol\022\026\n" + - "\016supervisorUuid\030\006 \001(\t\022\017\n\007isActor\030\007 \002(\010\022\024", - "\n\014isSuccessful\030\010 \002(\010*]\n\027SerializationSch" + + "\n\024RemoteProtocol.proto\"v\n\026RemoteActorRef" + + "Protocol\022\014\n\004uuid\030\001 \002(\t\022\026\n\016actorClassname" + + "\030\002 \002(\t\022%\n\013homeAddress\030\003 \002(\0132\020.AddressPro" + + "tocol\022\017\n\007timeout\030\004 \001(\004\"\276\002\n\032SerializedAct" + + "orRefProtocol\022\014\n\004uuid\030\001 \002(\t\022\n\n\002id\030\002 \002(\t\022" + + "\026\n\016actorClassname\030\003 \002(\t\022\025\n\ractorInstance" + + "\030\004 \002(\014\022)\n\017originalAddress\030\005 \002(\0132\020.Addres" + + "sProtocol\022\033\n\023serializerClassname\030\006 \001(\t\022\024" + + "\n\014isTransactor\030\007 \001(\010\022\017\n\007timeout\030\010 \001(\004\022%\n" + + "\tlifeCycle\030\t \001(\0132\022.LifeCycleProtocol\022+\n\n", + "supervisor\030\n \001(\0132\027.RemoteActorRefProtoco" + + "l\022\024\n\014hotswapStack\030\013 \001(\014\"\272\002\n\025RemoteReques" + + "tProtocol\022\n\n\002id\030\001 \002(\004\0225\n\023serializationSc" + + "heme\030\002 \002(\0162\030.SerializationSchemeType\022\017\n\007" + + "message\030\003 \002(\014\022\027\n\017messageManifest\030\004 \001(\014\022\016" + + "\n\006method\030\005 \001(\t\022\016\n\006target\030\006 \002(\t\022\014\n\004uuid\030\007" + + " \002(\t\022\017\n\007timeout\030\010 \002(\004\022\026\n\016supervisorUuid\030" + + "\t \001(\t\022\017\n\007isActor\030\n \002(\010\022\020\n\010isOneWay\030\013 \002(\010" + + "\022\021\n\tisEscaped\030\014 \002(\010\022\'\n\006sender\030\r \001(\0132\027.Re" + + "moteActorRefProtocol\"\350\001\n\023RemoteReplyProt", + "ocol\022\n\n\002id\030\001 \002(\004\0225\n\023serializationScheme\030" + + "\002 \001(\0162\030.SerializationSchemeType\022\017\n\007messa" + + "ge\030\003 \001(\014\022\027\n\017messageManifest\030\004 \001(\014\022%\n\texc" + + "eption\030\005 \001(\0132\022.ExceptionProtocol\022\026\n\016supe" + + "rvisorUuid\030\006 \001(\t\022\017\n\007isActor\030\007 \002(\010\022\024\n\014isS" + + "uccessful\030\010 \002(\010\"_\n\021LifeCycleProtocol\022!\n\t" + + "lifeCycle\030\001 \002(\0162\016.LifeCycleType\022\022\n\npreRe" + + "start\030\002 \001(\t\022\023\n\013postRestart\030\003 \001(\t\"1\n\017Addr" + + "essProtocol\022\020\n\010hostname\030\001 \002(\t\022\014\n\004port\030\002 " + + "\002(\r\"7\n\021ExceptionProtocol\022\021\n\tclassname\030\001 ", + "\002(\t\022\017\n\007message\030\002 \002(\t*]\n\027SerializationSch" + "emeType\022\010\n\004JAVA\020\001\022\013\n\007SBINARY\020\002\022\016\n\nSCALA_" + "JSON\020\003\022\r\n\tJAVA_JSON\020\004\022\014\n\010PROTOBUF\020\005*-\n\rL" + "ifeCycleType\022\r\n\tPERMANENT\020\001\022\r\n\tTEMPORARY" + @@ -3912,32 +3911,8 @@ public final class RemoteProtocol { public com.google.protobuf.ExtensionRegistry assignDescriptors( com.google.protobuf.Descriptors.FileDescriptor root) { descriptor = root; - internal_static_LifeCycleProtocol_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_LifeCycleProtocol_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_LifeCycleProtocol_descriptor, - new java.lang.String[] { "LifeCycle", "PreRestart", "PostRestart", }, - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.class, - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.Builder.class); - internal_static_AddressProtocol_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_AddressProtocol_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_AddressProtocol_descriptor, - new java.lang.String[] { "Hostname", "Port", }, - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.class, - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.Builder.class); - internal_static_ExceptionProtocol_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_ExceptionProtocol_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_ExceptionProtocol_descriptor, - new java.lang.String[] { "Classname", "Message", }, - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.class, - se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.Builder.class); internal_static_RemoteActorRefProtocol_descriptor = - getDescriptor().getMessageTypes().get(3); + getDescriptor().getMessageTypes().get(0); internal_static_RemoteActorRefProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_RemoteActorRefProtocol_descriptor, @@ -3945,15 +3920,15 @@ public final class RemoteProtocol { se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.class, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteActorRefProtocol.Builder.class); internal_static_SerializedActorRefProtocol_descriptor = - getDescriptor().getMessageTypes().get(4); + getDescriptor().getMessageTypes().get(1); internal_static_SerializedActorRefProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_SerializedActorRefProtocol_descriptor, - new java.lang.String[] { "Uuid", "Id", "ActorClassname", "ActorInstance", "SerializerClassname", "OriginalAddress", "IsTransactor", "Timeout", "LifeCycle", "Supervisor", "HotswapStack", }, + new java.lang.String[] { "Uuid", "Id", "ActorClassname", "ActorInstance", "OriginalAddress", "SerializerClassname", "IsTransactor", "Timeout", "LifeCycle", "Supervisor", "HotswapStack", }, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.SerializedActorRefProtocol.class, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.SerializedActorRefProtocol.Builder.class); internal_static_RemoteRequestProtocol_descriptor = - getDescriptor().getMessageTypes().get(5); + getDescriptor().getMessageTypes().get(2); internal_static_RemoteRequestProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_RemoteRequestProtocol_descriptor, @@ -3961,13 +3936,37 @@ public final class RemoteProtocol { se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteRequestProtocol.class, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteRequestProtocol.Builder.class); internal_static_RemoteReplyProtocol_descriptor = - getDescriptor().getMessageTypes().get(6); + getDescriptor().getMessageTypes().get(3); internal_static_RemoteReplyProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_RemoteReplyProtocol_descriptor, new java.lang.String[] { "Id", "SerializationScheme", "Message", "MessageManifest", "Exception", "SupervisorUuid", "IsActor", "IsSuccessful", }, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteReplyProtocol.class, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.RemoteReplyProtocol.Builder.class); + internal_static_LifeCycleProtocol_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_LifeCycleProtocol_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_LifeCycleProtocol_descriptor, + new java.lang.String[] { "LifeCycle", "PreRestart", "PostRestart", }, + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.class, + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.LifeCycleProtocol.Builder.class); + internal_static_AddressProtocol_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_AddressProtocol_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_AddressProtocol_descriptor, + new java.lang.String[] { "Hostname", "Port", }, + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.class, + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.Builder.class); + internal_static_ExceptionProtocol_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_ExceptionProtocol_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_ExceptionProtocol_descriptor, + new java.lang.String[] { "Classname", "Message", }, + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.class, + se.scalablesolutions.akka.remote.protocol.RemoteProtocol.ExceptionProtocol.Builder.class); return null; } }; diff --git a/akka-core/src/main/protocol/RemoteProtocol.proto b/akka-core/src/main/protocol/RemoteProtocol.proto index e967d8b3ac..f4807fddd2 100644 --- a/akka-core/src/main/protocol/RemoteProtocol.proto +++ b/akka-core/src/main/protocol/RemoteProtocol.proto @@ -32,8 +32,8 @@ message SerializedActorRefProtocol { required string id = 2; required string actorClassname = 3; required bytes actorInstance = 4; - required string serializerClassname = 5; - required AddressProtocol originalAddress = 6; + required AddressProtocol originalAddress = 5; + optional string serializerClassname = 6; optional bool isTransactor = 7; optional uint64 timeout = 8; optional LifeCycleProtocol lifeCycle = 9; diff --git a/akka-core/src/test/scala/SerializableActorSpec.scala b/akka-core/src/test/scala/SerializableActorSpec.scala index 14b8f0dd5c..3e69a8f5f6 100644 --- a/akka-core/src/test/scala/SerializableActorSpec.scala +++ b/akka-core/src/test/scala/SerializableActorSpec.scala @@ -29,7 +29,6 @@ class SerializableActorSpec extends (actor2 !! "hello").getOrElse("_") should equal("world 2") } - /* it("should be able to serialize and deserialize a ProtobufSerializableActor") { val actor1 = actorOf[ProtobufSerializableTestActor].start (actor1 !! "hello").getOrElse("_") should equal("world 1") @@ -42,6 +41,7 @@ class SerializableActorSpec extends (actor2 !! "hello").getOrElse("_") should equal("world 3") } + /* it("should be able to serialize and deserialize a JavaJSONSerializableActor") { val actor1 = actorOf[JavaJSONSerializableTestActor].start val serializer = actor1.serializer.getOrElse(fail("Serializer not defined")) From aad718937ad405187297187dd20f001dc624ed0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Tue, 22 Jun 2010 09:15:05 +0200 Subject: [PATCH 08/18] Fixed bug with actor unregistration in ActorRegistry, now we are using a Set instead of a List and only the right instance is removed, not all as before --- .../src/main/scala/actor/ActorRegistry.scala | 46 +++++++++++++------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/akka-core/src/main/scala/actor/ActorRegistry.scala b/akka-core/src/main/scala/actor/ActorRegistry.scala index b9827fdb9c..efe1f49b7b 100644 --- a/akka-core/src/main/scala/actor/ActorRegistry.scala +++ b/akka-core/src/main/scala/actor/ActorRegistry.scala @@ -6,7 +6,10 @@ package se.scalablesolutions.akka.actor import scala.collection.mutable.ListBuffer import scala.reflect.Manifest -import java.util.concurrent.{CopyOnWriteArrayList, ConcurrentHashMap} + +import java.util.concurrent.{CopyOnWriteArraySet, ConcurrentHashMap} +import java.util.{Set=>JSet} + import se.scalablesolutions.akka.util.ListenerManagement sealed trait ActorRegistryEvent @@ -27,8 +30,8 @@ case class ActorUnregistered(actor: ActorRef) extends ActorRegistryEvent */ object ActorRegistry extends ListenerManagement { private val actorsByUUID = new ConcurrentHashMap[String, ActorRef] - private val actorsById = new ConcurrentHashMap[String, List[ActorRef]] - private val actorsByClassName = new ConcurrentHashMap[String, List[ActorRef]] + private val actorsById = new ConcurrentHashMap[String, JSet[ActorRef]] + private val actorsByClassName = new ConcurrentHashMap[String, JSet[ActorRef]] /** * Returns all actors in the system. @@ -73,16 +76,18 @@ object ActorRegistry extends ListenerManagement { * Finds all actors of the exact type specified by the class passed in as the Class argument. */ def actorsFor[T <: Actor](clazz: Class[T]): List[ActorRef] = { - if (actorsByClassName.containsKey(clazz.getName)) actorsByClassName.get(clazz.getName) - else Nil + if (actorsByClassName.containsKey(clazz.getName)) { + actorsByClassName.get(clazz.getName).toArray.toList.asInstanceOf[List[ActorRef]] + } else Nil } /** * Finds all actors that has a specific id. */ def actorsFor(id: String): List[ActorRef] = { - if (actorsById.containsKey(id)) actorsById.get(id) - else Nil + if (actorsById.containsKey(id)) { + actorsById.get(id).toArray.toList.asInstanceOf[List[ActorRef]] + } else Nil } /** @@ -103,27 +108,38 @@ object ActorRegistry extends ListenerManagement { // ID val id = actor.id if (id eq null) throw new IllegalStateException("Actor.id is null " + actor) - if (actorsById.containsKey(id)) actorsById.put(id, actor :: actorsById.get(id)) - else actorsById.put(id, actor :: Nil) + if (actorsById.containsKey(id)) actorsById.get(id).add(actor) + else { + val set = new CopyOnWriteArraySet[ActorRef] + set.add(actor) + actorsById.put(id, set) + } // Class name val className = actor.actor.getClass.getName - if (actorsByClassName.containsKey(className)) { - actorsByClassName.put(className, actor :: actorsByClassName.get(className)) - } else actorsByClassName.put(className, actor :: Nil) + if (actorsByClassName.containsKey(className)) actorsByClassName.get(className).add(actor) + else { + val set = new CopyOnWriteArraySet[ActorRef] + set.add(actor) + actorsByClassName.put(className, set) + } // notify listeners foreachListener(_ ! ActorRegistered(actor)) } /** - * FIXME: WRONG - unregisters all actors with the same id and class name, should remove the right one in each list * Unregisters an actor in the ActorRegistry. */ def unregister(actor: ActorRef) = { actorsByUUID remove actor.uuid - actorsById remove actor.id - actorsByClassName remove actor.getClass.getName + + val id = actor.id + if (actorsById.containsKey(id)) actorsById.get(id).remove(actor) + + val className = actor.getClass.getName + if (actorsByClassName.containsKey(className)) actorsByClassName.get(className).remove(actor) + // notify listeners foreachListener(_ ! ActorUnregistered(actor)) } From e3d661517e4ae23a579e2ab8076c907122e236c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Tue, 22 Jun 2010 10:02:19 +0200 Subject: [PATCH 09/18] Added test for serializing stateless actor + made mailbox accessible --- .../akka/remote/protocol/RemoteProtocol.java | 103 +++++++++--------- .../src/main/protocol/RemoteProtocol.proto | 4 +- akka-core/src/main/scala/actor/ActorRef.scala | 16 ++- .../test/scala/SerializableActorSpec.scala | 49 ++------- 4 files changed, 74 insertions(+), 98 deletions(-) diff --git a/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java b/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java index 314f67cfa4..7ba65646e3 100644 --- a/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java +++ b/akka-core/src/main/java/se/scalablesolutions/akka/remote/protocol/RemoteProtocol.java @@ -632,20 +632,20 @@ public final class RemoteProtocol { public boolean hasActorClassname() { return hasActorClassname; } public java.lang.String getActorClassname() { return actorClassname_; } - // required bytes actorInstance = 4; - public static final int ACTORINSTANCE_FIELD_NUMBER = 4; - private boolean hasActorInstance; - private com.google.protobuf.ByteString actorInstance_ = com.google.protobuf.ByteString.EMPTY; - public boolean hasActorInstance() { return hasActorInstance; } - public com.google.protobuf.ByteString getActorInstance() { return actorInstance_; } - - // required .AddressProtocol originalAddress = 5; - public static final int ORIGINALADDRESS_FIELD_NUMBER = 5; + // required .AddressProtocol originalAddress = 4; + public static final int ORIGINALADDRESS_FIELD_NUMBER = 4; private boolean hasOriginalAddress; private se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol originalAddress_; public boolean hasOriginalAddress() { return hasOriginalAddress; } public se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol getOriginalAddress() { return originalAddress_; } + // optional bytes actorInstance = 5; + public static final int ACTORINSTANCE_FIELD_NUMBER = 5; + private boolean hasActorInstance; + private com.google.protobuf.ByteString actorInstance_ = com.google.protobuf.ByteString.EMPTY; + public boolean hasActorInstance() { return hasActorInstance; } + public com.google.protobuf.ByteString getActorInstance() { return actorInstance_; } + // optional string serializerClassname = 6; public static final int SERIALIZERCLASSNAME_FIELD_NUMBER = 6; private boolean hasSerializerClassname; @@ -697,7 +697,6 @@ public final class RemoteProtocol { if (!hasUuid) return false; if (!hasId) return false; if (!hasActorClassname) return false; - if (!hasActorInstance) return false; if (!hasOriginalAddress) return false; if (!getOriginalAddress().isInitialized()) return false; if (hasLifeCycle()) { @@ -721,11 +720,11 @@ public final class RemoteProtocol { if (hasActorClassname()) { output.writeString(3, getActorClassname()); } - if (hasActorInstance()) { - output.writeBytes(4, getActorInstance()); - } if (hasOriginalAddress()) { - output.writeMessage(5, getOriginalAddress()); + output.writeMessage(4, getOriginalAddress()); + } + if (hasActorInstance()) { + output.writeBytes(5, getActorInstance()); } if (hasSerializerClassname()) { output.writeString(6, getSerializerClassname()); @@ -766,13 +765,13 @@ public final class RemoteProtocol { size += com.google.protobuf.CodedOutputStream .computeStringSize(3, getActorClassname()); } - if (hasActorInstance()) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, getActorInstance()); - } if (hasOriginalAddress()) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, getOriginalAddress()); + .computeMessageSize(4, getOriginalAddress()); + } + if (hasActorInstance()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(5, getActorInstance()); } if (hasSerializerClassname()) { size += com.google.protobuf.CodedOutputStream @@ -965,12 +964,12 @@ public final class RemoteProtocol { if (other.hasActorClassname()) { setActorClassname(other.getActorClassname()); } - if (other.hasActorInstance()) { - setActorInstance(other.getActorInstance()); - } if (other.hasOriginalAddress()) { mergeOriginalAddress(other.getOriginalAddress()); } + if (other.hasActorInstance()) { + setActorInstance(other.getActorInstance()); + } if (other.hasSerializerClassname()) { setSerializerClassname(other.getSerializerClassname()); } @@ -1027,10 +1026,6 @@ public final class RemoteProtocol { break; } case 34: { - setActorInstance(input.readBytes()); - break; - } - case 42: { se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.Builder subBuilder = se.scalablesolutions.akka.remote.protocol.RemoteProtocol.AddressProtocol.newBuilder(); if (hasOriginalAddress()) { subBuilder.mergeFrom(getOriginalAddress()); @@ -1039,6 +1034,10 @@ public final class RemoteProtocol { setOriginalAddress(subBuilder.buildPartial()); break; } + case 42: { + setActorInstance(input.readBytes()); + break; + } case 50: { setSerializerClassname(input.readString()); break; @@ -1141,28 +1140,7 @@ public final class RemoteProtocol { return this; } - // required bytes actorInstance = 4; - public boolean hasActorInstance() { - return result.hasActorInstance(); - } - public com.google.protobuf.ByteString getActorInstance() { - return result.getActorInstance(); - } - public Builder setActorInstance(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - result.hasActorInstance = true; - result.actorInstance_ = value; - return this; - } - public Builder clearActorInstance() { - result.hasActorInstance = false; - result.actorInstance_ = getDefaultInstance().getActorInstance(); - return this; - } - - // required .AddressProtocol originalAddress = 5; + // required .AddressProtocol originalAddress = 4; public boolean hasOriginalAddress() { return result.hasOriginalAddress(); } @@ -1199,6 +1177,27 @@ public final class RemoteProtocol { return this; } + // optional bytes actorInstance = 5; + public boolean hasActorInstance() { + return result.hasActorInstance(); + } + public com.google.protobuf.ByteString getActorInstance() { + return result.getActorInstance(); + } + public Builder setActorInstance(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasActorInstance = true; + result.actorInstance_ = value; + return this; + } + public Builder clearActorInstance() { + result.hasActorInstance = false; + result.actorInstance_ = getDefaultInstance().getActorInstance(); + return this; + } + // optional string serializerClassname = 6; public boolean hasSerializerClassname() { return result.hasSerializerClassname(); @@ -3874,9 +3873,9 @@ public final class RemoteProtocol { "\030\002 \002(\t\022%\n\013homeAddress\030\003 \002(\0132\020.AddressPro" + "tocol\022\017\n\007timeout\030\004 \001(\004\"\276\002\n\032SerializedAct" + "orRefProtocol\022\014\n\004uuid\030\001 \002(\t\022\n\n\002id\030\002 \002(\t\022" + - "\026\n\016actorClassname\030\003 \002(\t\022\025\n\ractorInstance" + - "\030\004 \002(\014\022)\n\017originalAddress\030\005 \002(\0132\020.Addres" + - "sProtocol\022\033\n\023serializerClassname\030\006 \001(\t\022\024" + + "\026\n\016actorClassname\030\003 \002(\t\022)\n\017originalAddre" + + "ss\030\004 \002(\0132\020.AddressProtocol\022\025\n\ractorInsta" + + "nce\030\005 \001(\014\022\033\n\023serializerClassname\030\006 \001(\t\022\024" + "\n\014isTransactor\030\007 \001(\010\022\017\n\007timeout\030\010 \001(\004\022%\n" + "\tlifeCycle\030\t \001(\0132\022.LifeCycleProtocol\022+\n\n", "supervisor\030\n \001(\0132\027.RemoteActorRefProtoco" + @@ -3924,7 +3923,7 @@ public final class RemoteProtocol { internal_static_SerializedActorRefProtocol_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_SerializedActorRefProtocol_descriptor, - new java.lang.String[] { "Uuid", "Id", "ActorClassname", "ActorInstance", "OriginalAddress", "SerializerClassname", "IsTransactor", "Timeout", "LifeCycle", "Supervisor", "HotswapStack", }, + new java.lang.String[] { "Uuid", "Id", "ActorClassname", "OriginalAddress", "ActorInstance", "SerializerClassname", "IsTransactor", "Timeout", "LifeCycle", "Supervisor", "HotswapStack", }, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.SerializedActorRefProtocol.class, se.scalablesolutions.akka.remote.protocol.RemoteProtocol.SerializedActorRefProtocol.Builder.class); internal_static_RemoteRequestProtocol_descriptor = diff --git a/akka-core/src/main/protocol/RemoteProtocol.proto b/akka-core/src/main/protocol/RemoteProtocol.proto index f4807fddd2..69c551d2e7 100644 --- a/akka-core/src/main/protocol/RemoteProtocol.proto +++ b/akka-core/src/main/protocol/RemoteProtocol.proto @@ -31,8 +31,8 @@ message SerializedActorRefProtocol { required string uuid = 1; required string id = 2; required string actorClassname = 3; - required bytes actorInstance = 4; - required AddressProtocol originalAddress = 5; + required AddressProtocol originalAddress = 4; + optional bytes actorInstance = 5; optional string serializerClassname = 6; optional bool isTransactor = 7; optional uint64 timeout = 8; diff --git a/akka-core/src/main/scala/actor/ActorRef.scala b/akka-core/src/main/scala/actor/ActorRef.scala index ed0de1072a..036faa44bf 100644 --- a/akka-core/src/main/scala/actor/ActorRef.scala +++ b/akka-core/src/main/scala/actor/ActorRef.scala @@ -726,8 +726,8 @@ sealed class LocalActorRef private[akka]( if (actorInstance.isInstanceOf[StatelessSerializableActor]) { actorInstance.asInstanceOf[Actor] } else if (actorInstance.isInstanceOf[StatefulSerializerSerializableActor]) { - __serializer - .getOrElse(throw new IllegalStateException("No serializer defined for SerializableActor [" + actorClass.getName + "]")) + __serializer.getOrElse(throw new IllegalStateException( + "No serializer defined for SerializableActor [" + actorClass.getName + "]")) .fromBinary(__actorBytes, Some(actorClass)).asInstanceOf[Actor] } else if (actorInstance.isInstanceOf[StatefulWrappedSerializableActor]) { val instance = actorInstance.asInstanceOf[StatefulWrappedSerializableActor] @@ -818,28 +818,32 @@ sealed class LocalActorRef private[akka]( } } - val originalAddress = AddressProtocol.newBuilder.setHostname(homeAddress.getHostName).setPort(homeAddress.getPort).build + val originalAddress = AddressProtocol.newBuilder + .setHostname(homeAddress.getHostName) + .setPort(homeAddress.getPort) + .build val builder = SerializedActorRefProtocol.newBuilder .setUuid(uuid) .setId(id) .setActorClassname(actorClass.getName) - .setActorInstance(ByteString.copyFrom(actor.asInstanceOf[StatefulSerializableActor].toBinary)) .setOriginalAddress(originalAddress) .setIsTransactor(isTransactor) .setTimeout(timeout) + if (actor.isInstanceOf[StatefulSerializableActor]) builder.setActorInstance( + ByteString.copyFrom(actor.asInstanceOf[StatefulSerializableActor].toBinary)) serializer.foreach(s => builder.setSerializerClassname(s.getClass.getName)) lifeCycleProtocol.foreach(builder.setLifeCycle(_)) supervisor.foreach(s => builder.setSupervisor(s.toRemoteActorRefProtocol)) // FIXME: how to serialize the hotswap PartialFunction ?? - // hotswap.foreach(builder.setHotswapStack(_)) + //hotswap.foreach(builder.setHotswapStack(_)) builder.build } /** * Returns the mailbox. */ - protected[akka] def mailbox: Deque[MessageInvocation] = _mailbox + def mailbox: Deque[MessageInvocation] = _mailbox /** * Serializes the ActorRef instance into a byte array (Array[Byte]). diff --git a/akka-core/src/test/scala/SerializableActorSpec.scala b/akka-core/src/test/scala/SerializableActorSpec.scala index 3e69a8f5f6..2db077c354 100644 --- a/akka-core/src/test/scala/SerializableActorSpec.scala +++ b/akka-core/src/test/scala/SerializableActorSpec.scala @@ -41,32 +41,16 @@ class SerializableActorSpec extends (actor2 !! "hello").getOrElse("_") should equal("world 3") } - /* - it("should be able to serialize and deserialize a JavaJSONSerializableActor") { - val actor1 = actorOf[JavaJSONSerializableTestActor].start - val serializer = actor1.serializer.getOrElse(fail("Serializer not defined")) - (actor1 !! "hello").getOrElse("_") should equal("world 1") - (actor1 !! "hello").getOrElse("_") should equal("world 2") + it("should be able to serialize and deserialize a StatelessSerializableActor") { + val actor1 = actorOf[StatelessSerializableTestActor].start + (actor1 !! "hello").getOrElse("_") should equal("world") val bytes = actor1.toBinary val actor2 = ActorRef.fromBinaryToLocalActorRef(bytes) actor2.start - (actor2 !! "hello").getOrElse("_") should equal("world 3") + (actor2 !! "hello").getOrElse("_") should equal("world") } - - it("should be able to serialize and deserialize a ScalaJSONSerializableActor") { - val actor1 = actorOf[ScalaJSONSerializableTestActor].start - val serializer = actor1.serializer.getOrElse(fail("Serializer not defined")) - (actor1 !! "hello").getOrElse("_") should equal("world 1") - - val bytes = actor1.toBinary - val actor2 = ActorRef.fromBinaryToLocalActorRef(bytes) - - actor2.start - (actor2 !! "hello").getOrElse("_") should equal("world 2") - } -*/ } } @@ -79,6 +63,13 @@ class SerializableActorSpec extends } } +class StatelessSerializableTestActor extends StatelessSerializableActor { + def receive = { + case "hello" => + self.reply("world") + } +} + class ProtobufSerializableTestActor extends ProtobufSerializableActor[ProtobufProtocol.Counter] { val clazz = classOf[ProtobufProtocol.Counter] private var count = 0 @@ -92,21 +83,3 @@ class ProtobufSerializableTestActor extends ProtobufSerializableActor[ProtobufPr self.reply("world " + count) } } - -class JavaJSONSerializableTestActor extends JavaJSONSerializableActor { - private var count = 0 - def receive = { - case "hello" => - count = count + 1 - self.reply("world " + count) - } -} - -@scala.reflect.BeanInfo class ScalaJSONSerializableTestActor extends ScalaJSONSerializableActor { - private var count = 0 - def receive = { - case "hello" => - count = count + 1 - self.reply("world " + count) - } -} \ No newline at end of file From ba7c2febd1fe94084aab888bf5e57fb2ca189745 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 22 Jun 2010 22:52:05 +0200 Subject: [PATCH 10/18] Added akka.conf values as defaults and removed lift dependency --- .../src/main/scala/AkkaCometServlet.scala | 26 +++++- akka-http/src/main/scala/Security.scala | 90 +++++++++++++++++-- .../src/main/scala/EmbeddedAppServer.scala | 6 -- project/build/AkkaProject.scala | 2 - 4 files changed, 107 insertions(+), 17 deletions(-) diff --git a/akka-http/src/main/scala/AkkaCometServlet.scala b/akka-http/src/main/scala/AkkaCometServlet.scala index b020c473f6..c5a6fb3fba 100644 --- a/akka-http/src/main/scala/AkkaCometServlet.scala +++ b/akka-http/src/main/scala/AkkaCometServlet.scala @@ -7,7 +7,7 @@ package se.scalablesolutions.akka.comet import se.scalablesolutions.akka.util.Logging import java.util.{List => JList} -import javax.servlet.ServletConfig +import javax.servlet.{ServletConfig,ServletContext} import javax.servlet.http.{HttpServletRequest, HttpServletResponse} import com.sun.jersey.spi.container.servlet.ServletContainer @@ -43,14 +43,32 @@ class AtmosphereRestServlet extends ServletContainer with AtmosphereServletProce * Used by the Akka Kernel to bootstrap REST and Comet. */ class AkkaServlet extends AtmosphereServlet with Logging { + import se.scalablesolutions.akka.config.Config.{config => c} + addInitParameter(AtmosphereServlet.DISABLE_ONSTATE_EVENT,"true") addInitParameter(AtmosphereServlet.BROADCASTER_CLASS,classOf[AkkaBroadcaster].getName) + addInitParameter("com.sun.jersey.config.property.packages",c.getList("akka.rest.resource_packages").mkString(";")) + addInitParameter("com.sun.jersey.spi.container.ResourceFilters",c.getList("akka.rest.filters").mkString(",")) - lazy val servlet = createRestServlet - - protected def createRestServlet : AtmosphereRestServlet = new AtmosphereRestServlet { + val servlet = new AtmosphereRestServlet { override def getInitParameter(key : String) = AkkaServlet.this.getInitParameter(key) + override def getInitParameterNames() = AkkaServlet.this.getInitParameterNames() } + + override def getInitParameter(key : String) = Option(super.getInitParameter(key)).getOrElse(initParams.get(key)) + + override def getInitParameterNames() = { + val names = new java.util.Vector[String]() + + val i = initParams.keySet.iterator + while(i.hasNext) names.add(i.next.toString) + + val e = super.getInitParameterNames + while(e.hasMoreElements) names.add(e.nextElement.toString) + + names.elements + } + /** * We override this to avoid Atmosphere looking for it's atmosphere.xml file * Instead we specify what semantics we want in code. diff --git a/akka-http/src/main/scala/Security.scala b/akka-http/src/main/scala/Security.scala index 284d82d98e..bbc6242bfc 100644 --- a/akka-http/src/main/scala/Security.scala +++ b/akka-http/src/main/scala/Security.scala @@ -37,10 +37,6 @@ import javax.annotation.security.{DenyAll, PermitAll, RolesAllowed} import java.security.Principal import java.util.concurrent.TimeUnit -import net.liftweb.util.{SecurityHelpers, StringHelpers, IoHelpers} - -object Enc extends SecurityHelpers with StringHelpers with IoHelpers - case object OK /** @@ -249,7 +245,7 @@ trait BasicAuthenticationActor extends AuthenticationActor[BasicCredentials] { * rest-part of the akka config */ trait DigestAuthenticationActor extends AuthenticationActor[DigestCredentials] with Logging { - import Enc._ + import LiftUtils._ private object InvalidateNonces @@ -483,3 +479,87 @@ trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] w } } + +/* +* Copyright 2006-2010 WorldWide Conferencing, LLC +* +* Licensed 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. +*/ +object LiftUtils { + import java.security.{MessageDigest,SecureRandom} + val random = new SecureRandom() + + def md5(in: Array[Byte]): Array[Byte] = (MessageDigest.getInstance("MD5")).digest(in) + + /** + * Create a random string of a given size + * @param size size of the string to create. Must be a positive or nul integer + * @return the generated string + */ + def randomString(size: Int): String = { + def addChar(pos: Int, lastRand: Int, sb: StringBuilder): StringBuilder = { + if (pos >= size) sb + else { + val randNum = if ((pos % 6) == 0) random.nextInt else lastRand + sb.append((randNum & 0x1f) match { + case n if n < 26 => ('A' + n).toChar + case n => ('0' + (n - 26)).toChar + }) + addChar(pos + 1, randNum >> 5, sb) + } + } + addChar(0, 0, new StringBuilder(size)).toString + } + +/** encode a Byte array as hexadecimal characters */ + def hexEncode(in: Array[Byte]): String = { + val sb = new StringBuilder + val len = in.length + def addDigit(in: Array[Byte], pos: Int, len: Int, sb: StringBuilder) { + if (pos < len) { + val b: Int = in(pos) + val msb = (b & 0xf0) >> 4 + val lsb = (b & 0x0f) + sb.append((if (msb < 10) ('0' + msb).asInstanceOf[Char] else ('a' + (msb - 10)).asInstanceOf[Char])) + sb.append((if (lsb < 10) ('0' + lsb).asInstanceOf[Char] else ('a' + (lsb - 10)).asInstanceOf[Char])) + addDigit(in, pos + 1, len, sb) + } + } + addDigit(in, 0, len, sb) + sb.toString + } + + + /** + * Splits a string of the form <name1=value1, name2=value2, ... > and unquotes the quoted values. + * The result is a Map[String, String] + */ + def splitNameValuePairs(props: String): Map[String, String] = { + /** + * If str is surrounded by quotes it return the content between the quotes + */ + def unquote(str: String) = { + if ((str ne null) && str.length >= 2 && str.charAt(0) == '\"' && str.charAt(str.length - 1) == '\"') + str.substring(1, str.length - 1) + else + str + } + + val list = props.split(",").toList.map(in => { + val pair = in match { case null => Nil case s => s.split("=").toList.map(_.trim).filter(_.length > 0) } + (pair(0), unquote(pair(1))) + }) + val map: Map[String, String] = Map.empty + (map /: list)((m, next) => m + (next)) + } +} diff --git a/akka-kernel/src/main/scala/EmbeddedAppServer.scala b/akka-kernel/src/main/scala/EmbeddedAppServer.scala index 8d9982c7e2..8f5495b5c1 100644 --- a/akka-kernel/src/main/scala/EmbeddedAppServer.scala +++ b/akka-kernel/src/main/scala/EmbeddedAppServer.scala @@ -61,12 +61,6 @@ trait EmbeddedAppServer extends Bootable with Logging { "org.atmosphere.container.GrizzlyCometSupport") adapter.addInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig") - adapter.addInitParameter("com.sun.jersey.config.property.packages", - config.getList("akka.rest.resource_packages").mkString(";") - ) - adapter.addInitParameter("com.sun.jersey.spi.container.ResourceFilters", - config.getList("akka.rest.filters").mkString(",") - ) if (HOME.isDefined) adapter.addRootFolder(HOME.get + "/deploy/root") log.info("REST service root path [%s] and context path [%s]", adapter.getRootFolders, adapter.getContextPath) diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index 5f1f2d1264..cb5eefc23f 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -224,8 +224,6 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { val atmo_jbossweb = "org.atmosphere" % "atmosphere-compat-jbossweb" % ATMO_VERSION % "compile" val commons_logging = "commons-logging" % "commons-logging" % "1.1.1" % "compile" val annotation = "javax.annotation" % "jsr250-api" % "1.0" % "compile" - val lift_common = "net.liftweb" % "lift-common" % LIFT_VERSION % "compile" - val lift_util = "net.liftweb" % "lift-util" % LIFT_VERSION % "compile" // testing val scalatest = "org.scalatest" % "scalatest" % SCALATEST_VERSION % "test" From 8d1a5d5b8491bc9b838f6b48c25b65d14728846c Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Wed, 23 Jun 2010 12:17:25 +1200 Subject: [PATCH 11/18] Updated sbt plugin --- akka-sbt-plugin/project/build.properties | 4 ++-- .../project/build/AkkaPluginProject.scala | 6 +++++- .../src/main/scala/AkkaProject.scala | 17 ++++++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/akka-sbt-plugin/project/build.properties b/akka-sbt-plugin/project/build.properties index 27b9049bf2..24af37f708 100644 --- a/akka-sbt-plugin/project/build.properties +++ b/akka-sbt-plugin/project/build.properties @@ -1,6 +1,6 @@ -project.name=Akka Plugin +project.name=Akka SBT Plugin project.organization=se.scalablesolutions.akka # mirrors akka version -project.version=0.9.1 +project.version=0.10 sbt.version=0.7.4 build.scala.versions=2.7.7 diff --git a/akka-sbt-plugin/project/build/AkkaPluginProject.scala b/akka-sbt-plugin/project/build/AkkaPluginProject.scala index 4c63e9d14f..976915aaf3 100644 --- a/akka-sbt-plugin/project/build/AkkaPluginProject.scala +++ b/akka-sbt-plugin/project/build/AkkaPluginProject.scala @@ -1,3 +1,7 @@ import sbt._ -class AkkaPluginProject(info: ProjectInfo) extends PluginProject(info) +class AkkaPluginProject(info: ProjectInfo) extends PluginProject(info) { + override def managedStyle = ManagedStyle.Maven + val publishTo = "Scala Tools Nexus" at "http://nexus.scala-tools.org/content/repositories/releases/" + Credentials(Path.userHome / ".ivy2" / ".scala-tools-credentials", log) +} diff --git a/akka-sbt-plugin/src/main/scala/AkkaProject.scala b/akka-sbt-plugin/src/main/scala/AkkaProject.scala index 5ec83204a2..bc0fe51f97 100644 --- a/akka-sbt-plugin/src/main/scala/AkkaProject.scala +++ b/akka-sbt-plugin/src/main/scala/AkkaProject.scala @@ -1,11 +1,12 @@ import sbt._ object AkkaRepositories { - val AkkaRepo = MavenRepository("Akka Repository", "http://scalablesolutions.se/akka/repository") - val GuiceyFruitRepo = MavenRepository("GuiceyFruit Repo", "http://guiceyfruit.googlecode.com/svn/repo/releases/") - val JBossRepo = MavenRepository("JBoss Repo", "https://repository.jboss.org/nexus/content/groups/public/") - val SunJDMKRepo = MavenRepository("Sun JDMK Repo", "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo") - val JavaNetRepo = MavenRepository("java.net Repo", "http://download.java.net/maven/2") + val AkkaRepo = MavenRepository("Akka Repository", "http://scalablesolutions.se/akka/repository") + val GuiceyFruitRepo = MavenRepository("GuiceyFruit Repo", "http://guiceyfruit.googlecode.com/svn/repo/releases/") + val JBossRepo = MavenRepository("JBoss Repo", "https://repository.jboss.org/nexus/content/groups/public/") + val SunJDMKRepo = MavenRepository("Sun JDMK Repo", "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo") + val JavaNetRepo = MavenRepository("java.net Repo", "http://download.java.net/maven/2") + val CodehausSnapshotRepo = MavenRepository("Codehaus Snapshots", "http://snapshots.repository.codehaus.org") } trait AkkaBaseProject extends BasicScalaProject { @@ -14,7 +15,8 @@ trait AkkaBaseProject extends BasicScalaProject { // Every dependency that cannot be resolved from the built-in repositories (Maven Central and Scala Tools Releases) // is resolved from a ModuleConfiguration. This will result in a significant acceleration of the update action. - val akkaModuleConfig = ModuleConfiguration("se.scalablesolutions.akka", AkkaRepo) + // for development version resolve to .ivy2/local + // val akkaModuleConfig = ModuleConfiguration("se.scalablesolutions.akka", AkkaRepo) val netLagModuleConfig = ModuleConfiguration("net.lag", AkkaRepo) val sbinaryModuleConfig = ModuleConfiguration("sbinary", AkkaRepo) val redisModuleConfig = ModuleConfiguration("com.redis", AkkaRepo) @@ -34,11 +36,12 @@ trait AkkaBaseProject extends BasicScalaProject { val jerseyModuleConfig = ModuleConfiguration("com.sun.jersey", JavaNetRepo) val jerseyContrModuleConfig = ModuleConfiguration("com.sun.jersey.contribs", JavaNetRepo) val grizzlyModuleConfig = ModuleConfiguration("com.sun.grizzly", JavaNetRepo) + val multiverseModuleConfig = ModuleConfiguration("org.multiverse", CodehausSnapshotRepo) // only while snapshot version val liftModuleConfig = ModuleConfiguration("net.liftweb", ScalaToolsSnapshots) } trait AkkaProject extends AkkaBaseProject { - val akkaVersion = "0.9.1" + val akkaVersion = "0.10" // convenience method def akkaModule(module: String) = "se.scalablesolutions.akka" %% ("akka-" + module) % akkaVersion From f5236716f4a39f16b8c925c6c31a14fa44b85895 Mon Sep 17 00:00:00 2001 From: Johan Rask Date: Wed, 23 Jun 2010 08:59:56 +0200 Subject: [PATCH 12/18] Fixed #287,Old dispatcher settings are now copied to new dispatcher on restart --- .../src/main/scala/actor/ActiveObject.scala | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/akka-core/src/main/scala/actor/ActiveObject.scala b/akka-core/src/main/scala/actor/ActiveObject.scala index 421381ccf7..215ee0f4b6 100644 --- a/akka-core/src/main/scala/actor/ActiveObject.scala +++ b/akka-core/src/main/scala/actor/ActiveObject.scala @@ -646,6 +646,7 @@ private[akka] sealed class ActiveObjectAspect { object Dispatcher { val ZERO_ITEM_CLASS_ARRAY = Array[Class[_]]() val ZERO_ITEM_OBJECT_ARRAY = Array[Object]() + var crashedActorTl:ThreadLocal[Dispatcher] = new ThreadLocal(); } /** @@ -653,7 +654,7 @@ object Dispatcher { * * @author Jonas Bonér */ -private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Option[RestartCallbacks]) extends Actor { +private[akka] class Dispatcher(transactionalRequired: Boolean, var callbacks: Option[RestartCallbacks]) extends Actor { import Dispatcher._ private[actor] var target: Option[AnyRef] = None @@ -661,13 +662,18 @@ private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Op private var postRestart: Option[Method] = None private var initTxState: Option[Method] = None private var context: Option[ActiveObjectContext] = None + private var targetClass:Class[_] = _ + + def this(transactionalRequired: Boolean) = this(transactionalRequired,None) private[actor] def initialize(targetClass: Class[_], targetInstance: AnyRef, ctx: Option[ActiveObjectContext]) = { - if (transactionalRequired || targetClass.isAnnotationPresent(Annotations.transactionrequired)) + + if (transactionalRequired || targetClass.isAnnotationPresent(Annotations.transactionrequired)) self.makeTransactionRequired self.id = targetClass.getName + this.targetClass = targetClass target = Some(targetInstance) context = ctx val methods = targetInstance.getClass.getDeclaredMethods.toList @@ -733,22 +739,43 @@ private[akka] class Dispatcher(transactionalRequired: Boolean, val callbacks: Op override def preRestart(reason: Throwable) { try { + // Since preRestart is called we know that this dispatcher + // is about to be restarted. Put the instance in a thread + // local so the new dispatcher can be initialized with the contents of the + // old. + //FIXME - This should be considered as a workaround. + crashedActorTl.set(this) if (preRestart.isDefined) preRestart.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*) } catch { case e: InvocationTargetException => throw e.getCause } } override def postRestart(reason: Throwable) { try { - if (postRestart.isDefined) postRestart.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*) + + if (postRestart.isDefined) { + postRestart.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*) + } } catch { case e: InvocationTargetException => throw e.getCause } } + override def init = { + // Get the crashed dispatcher from thread local and intitialize this actor with the + // contents of the old dispatcher + val oldActor = crashedActorTl.get(); + if(oldActor != null) { + initialize(oldActor.targetClass,oldActor.target.get,oldActor.context) + crashedActorTl.set(null) + } + } + override def initTransactionalState = { - try { + try { if (initTxState.isDefined && target.isDefined) initTxState.get.invoke(target.get, ZERO_ITEM_OBJECT_ARRAY: _*) } catch { case e: InvocationTargetException => throw e.getCause } } + + private def serializeArguments(joinPoint: JoinPoint) = { val args = joinPoint.getRtti.asInstanceOf[MethodRtti].getParameterValues var unserializable = false From 421aec4cfc1a0efc87814f7df318a84dc4d63949 Mon Sep 17 00:00:00 2001 From: Johan Rask Date: Wed, 23 Jun 2010 09:50:55 +0200 Subject: [PATCH 13/18] Added test for verifying pre/post restart invocations --- akka-active-object-test/pom.xml | 14 +++++++- .../akka/api/MiscActiveObjectTest.java | 35 ++++++++++++++++++ .../akka/api/RemoteInMemoryStateTest.java | 14 ++++---- .../akka/api/SimpleJavaPojo.java | 36 +++++++++++++++++++ 4 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/MiscActiveObjectTest.java create mode 100644 akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/SimpleJavaPojo.java diff --git a/akka-active-object-test/pom.xml b/akka-active-object-test/pom.xml index 62935a30b4..2b4183724e 100644 --- a/akka-active-object-test/pom.xml +++ b/akka-active-object-test/pom.xml @@ -40,7 +40,13 @@ se.scalablesolutions.akka akka-core_2.8.0.RC3 - 0.9 + 0.9.1 + + + org.multiverse + multiverse-alpha + + junit @@ -54,6 +60,12 @@ 2.4.0 test + + org.multiverse + multiverse-alpha + 0.6-SNAPSHOT + compile + diff --git a/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/MiscActiveObjectTest.java b/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/MiscActiveObjectTest.java new file mode 100644 index 0000000000..edc26f6695 --- /dev/null +++ b/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/MiscActiveObjectTest.java @@ -0,0 +1,35 @@ +package se.scalablesolutions.akka.api; + +import static se.scalablesolutions.akka.actor.ActiveObject.link; +import static se.scalablesolutions.akka.actor.ActiveObject.newInstance; + +import org.junit.Assert; +import org.junit.Test; + +import se.scalablesolutions.akka.config.OneForOneStrategy; +import junit.framework.TestCase; + +/** + *

Small misc tests that do not fit anywhere else and does not require a separate testcase

+ * + * @author johanrask + * + */ +public class MiscActiveObjectTest extends TestCase { + + + /** + * Verifies that both preRestart and postRestart methods are invoked when + * an actor is restarted + */ + public void testFailingPostRestartInvocation() throws InterruptedException { + SimpleJavaPojo pojo = newInstance(SimpleJavaPojo.class,500); + SimpleJavaPojo supervisor = newInstance(SimpleJavaPojo.class,500); + link(supervisor,pojo,new OneForOneStrategy(3, 2000),new Class[]{Throwable.class}); + pojo.throwException(); + Thread.sleep(500); + Assert.assertTrue(pojo.pre); + Assert.assertTrue(pojo.post); + } + +} diff --git a/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/RemoteInMemoryStateTest.java b/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/RemoteInMemoryStateTest.java index d0c22470e2..d4b4fd7687 100644 --- a/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/RemoteInMemoryStateTest.java +++ b/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/RemoteInMemoryStateTest.java @@ -38,7 +38,7 @@ public class RemoteInMemoryStateTest extends TestCase { } public void testMapShouldRollbackStateForStatefulServerInCaseOfFailure() { - InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999); + InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 10000, "localhost", 9999); stateful.init(); stateful.setMapState("testShouldRollbackStateForStatefulServerInCaseOfFailure", "init"); // set init state InMemFailer failer = ActiveObject.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getInstance(InMemFailer.class); @@ -51,7 +51,7 @@ public class RemoteInMemoryStateTest extends TestCase { } public void testVectorShouldNotRollbackStateForStatefulServerInCaseOfSuccess() { - InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999); + InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 10000, "localhost", 9999); stateful.init(); stateful.setVectorState("init"); // set init state stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired @@ -59,10 +59,10 @@ public class RemoteInMemoryStateTest extends TestCase { } public void testVectorShouldRollbackStateForStatefulServerInCaseOfFailure() { - InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999); + InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 10000, "localhost", 9999); stateful.init(); stateful.setVectorState("init"); // set init state - InMemFailer failer = ActiveObject.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getInstance(InMemFailer.class); + InMemFailer failer = ActiveObject.newRemoteInstance(InMemFailer.class, 10000, "localhost", 9999); //conf.getInstance(InMemFailer.class); try { stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method fail("should have thrown an exception"); @@ -72,7 +72,7 @@ public class RemoteInMemoryStateTest extends TestCase { } public void testRefShouldNotRollbackStateForStatefulServerInCaseOfSuccess() { - InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999); + InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 10000, "localhost", 9999); stateful.init(); stateful.setRefState("init"); // set init state stateful.success("testShouldNotRollbackStateForStatefulServerInCaseOfSuccess", "new state"); // transactionrequired @@ -80,10 +80,10 @@ public class RemoteInMemoryStateTest extends TestCase { } public void testRefShouldRollbackStateForStatefulServerInCaseOfFailure() { - InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 1000, "localhost", 9999); + InMemStateful stateful = ActiveObject.newRemoteInstance(InMemStateful.class, 10000, "localhost", 9999); stateful.init(); stateful.setRefState("init"); // set init state - InMemFailer failer = ActiveObject.newRemoteInstance(InMemFailer.class, 1000, "localhost", 9999); //conf.getInstance(InMemFailer.class); + InMemFailer failer = ActiveObject.newRemoteInstance(InMemFailer.class, 10000, "localhost", 9999); //conf.getInstance(InMemFailer.class); try { stateful.failure("testShouldRollbackStateForStatefulServerInCaseOfFailure", "new state", failer); // call failing transactionrequired method fail("should have thrown an exception"); diff --git a/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/SimpleJavaPojo.java b/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/SimpleJavaPojo.java new file mode 100644 index 0000000000..c783fd2902 --- /dev/null +++ b/akka-active-object-test/src/test/java/se/scalablesolutions/akka/api/SimpleJavaPojo.java @@ -0,0 +1,36 @@ +package se.scalablesolutions.akka.api; + +import se.scalablesolutions.akka.actor.annotation.prerestart; +import se.scalablesolutions.akka.actor.annotation.postrestart; + +public class SimpleJavaPojo { + + public boolean pre = false; + public boolean post = false; + + private String name; + + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + @prerestart + public void pre() { + System.out.println("** pre()"); + pre = true; + } + + @postrestart + public void post() { + System.out.println("** post()"); + post = true; + } + + public void throwException() { + throw new RuntimeException(); + } +} From 95d4504bbb75b8b018f3f5ae7f9eb2127e9afc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Wed, 23 Jun 2010 10:23:52 +0200 Subject: [PATCH 14/18] fixed mem-leak in Active Object + reorganized SerializableActor traits --- .../src/main/scala/actor/ActiveObject.scala | 2 ++ akka-core/src/main/scala/actor/Actor.scala | 16 +++------ akka-core/src/main/scala/actor/ActorRef.scala | 8 +++-- .../src/test/scala/ActorPatternsTest.scala | 6 ++-- akka-core/src/test/scala/StmSpec.scala | 35 ++++++++----------- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/akka-core/src/main/scala/actor/ActiveObject.scala b/akka-core/src/main/scala/actor/ActiveObject.scala index 421381ccf7..951a12a249 100644 --- a/akka-core/src/main/scala/actor/ActiveObject.scala +++ b/akka-core/src/main/scala/actor/ActiveObject.scala @@ -358,6 +358,7 @@ object ActiveObject extends Logging { val proxy = Proxy.newInstance(target, true, false) val context = injectActiveObjectContext(proxy) actorRef.actor.asInstanceOf[Dispatcher].initialize(target, proxy, context) + ActorRegistry.unregister(actorRef) // do not store the dispatcher in the ActorRegistry since it will prevent GC actorRef.timeout = timeout if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get) AspectInitRegistry.register(proxy, AspectInit(target, actorRef, remoteAddress, timeout)) @@ -370,6 +371,7 @@ object ActiveObject extends Logging { val context = injectActiveObjectContext(target) val proxy = Proxy.newInstance(Array(intf), Array(target), true, false) actorRef.actor.asInstanceOf[Dispatcher].initialize(target.getClass, target, context) + ActorRegistry.unregister(actorRef) // do not store the dispatcher in the ActorRegistry since it will prevent GC actorRef.timeout = timeout if (remoteAddress.isDefined) actorRef.makeRemote(remoteAddress.get) AspectInitRegistry.register(proxy, AspectInit(intf, actorRef, remoteAddress, timeout)) diff --git a/akka-core/src/main/scala/actor/Actor.scala b/akka-core/src/main/scala/actor/Actor.scala index 06b00f4e24..497cfb185a 100644 --- a/akka-core/src/main/scala/actor/Actor.scala +++ b/akka-core/src/main/scala/actor/Actor.scala @@ -49,24 +49,15 @@ trait SerializableActor extends Actor */ trait StatelessSerializableActor extends SerializableActor -/** - * Mix in this trait to create a serializable actor, serializable through - * a custom serialization protocol. - * - * @author Jonas Bonér - */ -trait StatefulSerializableActor extends SerializableActor { - def toBinary: Array[Byte] -} - /** * Mix in this trait to create a serializable actor, serializable through * a custom serialization protocol. This actor is the serialized state. * * @author Jonas Bonér */ -trait StatefulSerializerSerializableActor extends StatefulSerializableActor { +trait StatefulSerializerSerializableActor extends SerializableActor { val serializer: Serializer + def toBinary: Array[Byte] } /** @@ -75,7 +66,8 @@ trait StatefulSerializerSerializableActor extends StatefulSerializableActor { * * @author Jonas Bonér */ -trait StatefulWrappedSerializableActor extends StatefulSerializableActor { +trait StatefulWrappedSerializableActor extends SerializableActor { + def toBinary: Array[Byte] def fromBinary(bytes: Array[Byte]) } diff --git a/akka-core/src/main/scala/actor/ActorRef.scala b/akka-core/src/main/scala/actor/ActorRef.scala index 036faa44bf..26b5bbf5a7 100644 --- a/akka-core/src/main/scala/actor/ActorRef.scala +++ b/akka-core/src/main/scala/actor/ActorRef.scala @@ -37,7 +37,7 @@ import com.google.protobuf.ByteString *

* Binary -> ActorRef: *

- *   val actorRef = ActorRef.fromBinary(bytes)
+ *   val actorRef = ActorRef.fromBinaryToRemoteActorRef(bytes)
  *   actorRef ! message // send message to remote actor through its reference
  * 
* @@ -830,8 +830,10 @@ sealed class LocalActorRef private[akka]( .setOriginalAddress(originalAddress) .setIsTransactor(isTransactor) .setTimeout(timeout) - if (actor.isInstanceOf[StatefulSerializableActor]) builder.setActorInstance( - ByteString.copyFrom(actor.asInstanceOf[StatefulSerializableActor].toBinary)) + if (actor.isInstanceOf[StatefulSerializerSerializableActor]) builder.setActorInstance( + ByteString.copyFrom(actor.asInstanceOf[StatefulSerializerSerializableActor].toBinary)) + else if (actor.isInstanceOf[StatefulWrappedSerializableActor]) builder.setActorInstance( + ByteString.copyFrom(actor.asInstanceOf[StatefulWrappedSerializableActor].toBinary)) serializer.foreach(s => builder.setSerializerClassname(s.getClass.getName)) lifeCycleProtocol.foreach(builder.setLifeCycle(_)) supervisor.foreach(s => builder.setSupervisor(s.toRemoteActorRefProtocol)) diff --git a/akka-core/src/test/scala/ActorPatternsTest.scala b/akka-core/src/test/scala/ActorPatternsTest.scala index f6205c2a91..65c9dbf9f4 100644 --- a/akka-core/src/test/scala/ActorPatternsTest.scala +++ b/akka-core/src/test/scala/ActorPatternsTest.scala @@ -1,6 +1,5 @@ package se.scalablesolutions.akka.patterns -import java.util.concurrent.atomic.AtomicInteger import se.scalablesolutions.akka.config.ScalaConfig._ import se.scalablesolutions.akka.actor.Actor import se.scalablesolutions.akka.actor.Actor._ @@ -11,8 +10,11 @@ import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import org.scalatest.matchers.MustMatchers import org.junit.{Before, After, Test} + import scala.collection.mutable.HashSet -import java.util.concurrent.{ CountDownLatch, TimeUnit } + +import java.util.concurrent.atomic.AtomicInteger +import java.util.concurrent.{CountDownLatch, TimeUnit} @RunWith(classOf[JUnitRunner]) class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMatchers with Logging { diff --git a/akka-core/src/test/scala/StmSpec.scala b/akka-core/src/test/scala/StmSpec.scala index 1544936446..37914069a8 100644 --- a/akka-core/src/test/scala/StmSpec.scala +++ b/akka-core/src/test/scala/StmSpec.scala @@ -104,26 +104,21 @@ class StmSpec extends describe("Transactor") { it("should be able receive message sent with !! and pass it along to nested transactor with !! and receive reply; multiple times in a row") { import GlobalTransactionVectorTestActor._ - try { - val actor = actorOf[NestedTransactorLevelOneActor].start - actor !! Add(2) - val size1 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) - size1 should equal(2) - actor !! Add(7) - actor ! "HiLevelOne" - val size2 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) - size2 should equal(7) - actor !! Add(0) - actor ! "HiLevelTwo" - val size3 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) - size3 should equal(0) - actor !! Add(3) - val size4 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) - size4 should equal(3) - } catch { - case e => - fail(e.toString) - } + val actor = actorOf[NestedTransactorLevelOneActor].start + actor !! Add(2) + val size1 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) + size1 should equal(2) + actor !! Add(7) + actor ! "HiLevelOne" + val size2 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) + size2 should equal(7) + actor !! Add(0) + actor ! "HiLevelTwo" + val size3 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) + size3 should equal(0) + actor !! Add(3) + val size4 = (actor !! Size).as[Int].getOrElse(fail("Could not get size")) + size4 should equal(3) } } /* From 836f04f7bbd9e581ed5d19980db1048229b3373a Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Thu, 24 Jun 2010 07:12:38 +0200 Subject: [PATCH 15/18] Comment changed --- akka-samples/akka-sample-camel/src/main/scala/Boot.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala index 924cb6c9e5..2cfb56e64f 100644 --- a/akka-samples/akka-sample-camel/src/main/scala/Boot.scala +++ b/akka-samples/akka-sample-camel/src/main/scala/Boot.scala @@ -41,7 +41,7 @@ class Boot { // Supervise(actorOf[Consumer2], LifeCycle(Permanent)) :: Nil)) // ----------------------------------------------------------------------- - // Routing example + // Tranformer example // ----------------------------------------------------------------------- val producer = actorOf[Producer1] From 3a448a30937dfb16b2a840ae17787a49cdd28c0e Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Thu, 24 Jun 2010 07:13:02 +0200 Subject: [PATCH 16/18] closes #289: Support for Spring configuration element --- .../src/main/resources/context-standalone.xml | 15 +++++++- .../main/scala/StandaloneApplication.scala | 20 ++++------- .../akka/spring/akka-0.10.xsd | 13 +++++++ .../main/scala/ActiveObjectFactoryBean.scala | 8 +++-- .../src/main/scala/AkkaNamespaceHandler.scala | 1 + .../scala/AkkaSpringConfigurationTags.scala | 4 +++ .../CamelServiceBeanDefinitionParser.scala | 33 +++++++++++++++++ .../main/scala/CamelServiceFactoryBean.scala | 35 +++++++++++++++++++ project/build/AkkaProject.scala | 2 +- 9 files changed, 113 insertions(+), 18 deletions(-) create mode 100644 akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala create mode 100644 akka-spring/src/main/scala/CamelServiceFactoryBean.scala diff --git a/akka-samples/akka-sample-camel/src/main/resources/context-standalone.xml b/akka-samples/akka-sample-camel/src/main/resources/context-standalone.xml index f0932ce1b3..36645a936d 100644 --- a/akka-samples/akka-sample-camel/src/main/resources/context-standalone.xml +++ b/akka-samples/akka-sample-camel/src/main/resources/context-standalone.xml @@ -1,11 +1,24 @@ +http://scalablesolutions.se/akka/akka-0.10.xsd +http://camel.apache.org/schema/spring +http://camel.apache.org/schema/spring/camel-spring.xsd"> + + + + + + + + + + diff --git a/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala b/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala index aa4292696a..b7e834fcba 100644 --- a/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala +++ b/akka-samples/akka-sample-camel/src/main/scala/StandaloneApplication.scala @@ -59,24 +59,16 @@ class StandaloneApplicationRoute extends RouteBuilder { object StandaloneSpringApplication { def main(args: Array[String]) { - import CamelContextManager.context + import CamelContextManager._ - // use Spring application context as active object registry - val springctx = new ClassPathXmlApplicationContext("/context-standalone.xml") - val registry = new ApplicationContextRegistry(springctx) - - // customize CamelContext - CamelContextManager.init(new DefaultCamelContext(registry)) - CamelContextManager.context.addRoutes(new StandaloneSpringApplicationRoute) - - // start CamelService - val camelService = CamelService.newInstance.load + // load Spring application context + val appctx = new ClassPathXmlApplicationContext("/context-standalone.xml") // access 'externally' registered active objects with active-object component - assert("hello msg3" == context.createProducerTemplate.requestBody("direct:test3", "msg3")) + assert("hello msg3" == template.requestBody("direct:test3", "msg3")) - // shutdown CamelService - camelService.unload + // destroy Spring application context + appctx.close // shutdown all (internally) created actors ActorRegistry.shutdownAll diff --git a/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd index c81fb12af3..9047b7c588 100644 --- a/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd +++ b/akka-spring/src/main/resources/se/scalablesolutions/akka/spring/akka-0.10.xsd @@ -229,6 +229,16 @@ + + + + + + + + + + @@ -239,4 +249,7 @@ + + + diff --git a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala b/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala index b6a51138dc..b4bc8795fc 100644 --- a/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala +++ b/akka-spring/src/main/scala/ActiveObjectFactoryBean.scala @@ -46,8 +46,12 @@ class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] with Logging { /* * @see org.springframework.beans.factory.FactoryBean#getObjectType() */ - def getObjectType: Class[AnyRef] = target.toClass - + def getObjectType: Class[AnyRef] = try { + target.toClass + } catch { + // required by contract to return null + case e: ClassNotFoundException => null + } /* * @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance() diff --git a/akka-spring/src/main/scala/AkkaNamespaceHandler.scala b/akka-spring/src/main/scala/AkkaNamespaceHandler.scala index 88f2b4c81b..466dbeca30 100644 --- a/akka-spring/src/main/scala/AkkaNamespaceHandler.scala +++ b/akka-spring/src/main/scala/AkkaNamespaceHandler.scala @@ -15,5 +15,6 @@ class AkkaNamespaceHandler extends NamespaceHandlerSupport { registerBeanDefinitionParser(ACTIVE_OBJECT_TAG, new ActiveObjectBeanDefinitionParser()); registerBeanDefinitionParser(SUPERVISION_TAG, new SupervisionBeanDefinitionParser()); registerBeanDefinitionParser(DISPATCHER_TAG, new DispatcherBeanDefinitionParser()); + registerBeanDefinitionParser(CAMEL_SERVICE_TAG, new CamelServiceBeanDefinitionParser); } } diff --git a/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala b/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala index 39cb09dd64..5e927ceba1 100644 --- a/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala +++ b/akka-spring/src/main/scala/AkkaSpringConfigurationTags.scala @@ -16,6 +16,7 @@ object AkkaSpringConfigurationTags { val SUPERVISION_TAG = "supervision" val DISPATCHER_TAG = "dispatcher" val PROPERTYENTRY_TAG = "property" + val CAMEL_SERVICE_TAG = "camel-service" // active-object sub tags val RESTART_CALLBACKS_TAG = "restart-callbacks" @@ -30,6 +31,9 @@ object AkkaSpringConfigurationTags { // dispatcher sub tags val THREAD_POOL_TAG = "thread-pool" + // camel-service sub tags + val CAMEL_CONTEXT_TAG = "camel-context" + // --- ATTRIBUTES // // active object attributes diff --git a/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala b/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala new file mode 100644 index 0000000000..f22e035b95 --- /dev/null +++ b/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala @@ -0,0 +1,33 @@ +/** + * Copyright (C) 2009-2010 Scalable Solutions AB + */ +package se.scalablesolutions.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 se.scalablesolutions.akka.spring.AkkaSpringConfigurationTags._ + + +/** + * @author Martin Krasser + */ +class CamelServiceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { + override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) { + + // TODO: make camel-context element optional + + val camelContextElement = DomUtils.getChildElementByTagName(element, CAMEL_CONTEXT_TAG); + if (camelContextElement eq null) return + val camelContextReference = camelContextElement.getAttribute("ref") + builder.addPropertyReference("camelContext", camelContextReference) + + // ... + } + + override def getBeanClass(element: Element): Class[_] = classOf[CamelServiceFactoryBean] + + override def shouldGenerateIdAsFallback = true +} \ No newline at end of file diff --git a/akka-spring/src/main/scala/CamelServiceFactoryBean.scala b/akka-spring/src/main/scala/CamelServiceFactoryBean.scala new file mode 100644 index 0000000000..3f8f1797ca --- /dev/null +++ b/akka-spring/src/main/scala/CamelServiceFactoryBean.scala @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2009-2010 Scalable Solutions AB + */ +package se.scalablesolutions.akka.spring + +import org.apache.camel.CamelContext +import org.springframework.beans.factory.{DisposableBean, InitializingBean, FactoryBean} +import se.scalablesolutions.akka.camel.{CamelContextManager, 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 + + def afterPropertiesSet = { + if (camelContext ne null) { + CamelContextManager.init(camelContext) + } + instance = CamelService.newInstance + instance.load + } + + def destroy = { + instance.unload + } +} \ No newline at end of file diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index cb5eefc23f..12c94ffaa3 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -75,7 +75,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { lazy val akka_http = project("akka-http", "akka-http", new AkkaHttpProject(_), akka_core, akka_camel) lazy val akka_camel = project("akka-camel", "akka-camel", new AkkaCamelProject(_), akka_core) lazy val akka_persistence = project("akka-persistence", "akka-persistence", new AkkaPersistenceParentProject(_)) - lazy val akka_spring = project("akka-spring", "akka-spring", new AkkaSpringProject(_), akka_core) + lazy val akka_spring = project("akka-spring", "akka-spring", new AkkaSpringProject(_), akka_core, akka_camel) lazy val akka_jta = project("akka-jta", "akka-jta", new AkkaJTAProject(_), akka_core) lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_), akka_core, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp) From e569b4f4bb1936847fe68ee365a5b6f91c7df485 Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Thu, 24 Jun 2010 07:35:14 +0200 Subject: [PATCH 17/18] Minor edits --- .../scala/CamelServiceBeanDefinitionParser.scala | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala b/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala index f22e035b95..88c6d91230 100644 --- a/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala +++ b/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala @@ -16,15 +16,11 @@ import se.scalablesolutions.akka.spring.AkkaSpringConfigurationTags._ */ class CamelServiceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { override def doParse(element: Element, parserContext: ParserContext, builder: BeanDefinitionBuilder) { - - // TODO: make camel-context element optional - val camelContextElement = DomUtils.getChildElementByTagName(element, CAMEL_CONTEXT_TAG); - if (camelContextElement eq null) return - val camelContextReference = camelContextElement.getAttribute("ref") - builder.addPropertyReference("camelContext", camelContextReference) - - // ... + if (camelContextElement ne null) { + val camelContextReference = camelContextElement.getAttribute("ref") + builder.addPropertyReference("camelContext", camelContextReference) + } } override def getBeanClass(element: Element): Class[_] = classOf[CamelServiceFactoryBean] From 87461dce940e9d2ddd94c7c1e940466925158fcd Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Thu, 24 Jun 2010 07:42:01 +0200 Subject: [PATCH 18/18] Documentation added. --- .../scala/CamelServiceBeanDefinitionParser.scala | 16 ++++++++++++++-- .../src/main/scala/CamelServiceFactoryBean.scala | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala b/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala index 88c6d91230..f8234ec8c7 100644 --- a/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala +++ b/akka-spring/src/main/scala/CamelServiceBeanDefinitionParser.scala @@ -1,5 +1,5 @@ /** - * Copyright (C) 2009-2010 Scalable Solutions AB + * Copyright (C) 2009-2010 Scalable Solutions AB */ package se.scalablesolutions.akka.spring @@ -12,9 +12,15 @@ import se.scalablesolutions.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) { @@ -22,8 +28,14 @@ class CamelServiceBeanDefinitionParser extends AbstractSingleBeanDefinitionParse builder.addPropertyReference("camelContext", camelContextReference) } } - + + /** + * Returns the class of {@link CamelServiceFactoryBean} + */ override def getBeanClass(element: Element): Class[_] = classOf[CamelServiceFactoryBean] + /** + * Returns true. + */ override def shouldGenerateIdAsFallback = true } \ No newline at end of file diff --git a/akka-spring/src/main/scala/CamelServiceFactoryBean.scala b/akka-spring/src/main/scala/CamelServiceFactoryBean.scala index 3f8f1797ca..040473951e 100644 --- a/akka-spring/src/main/scala/CamelServiceFactoryBean.scala +++ b/akka-spring/src/main/scala/CamelServiceFactoryBean.scala @@ -8,6 +8,8 @@ import org.springframework.beans.factory.{DisposableBean, InitializingBean, Fact import se.scalablesolutions.akka.camel.{CamelContextManager, CamelService} /** + * Factory bean for a {@link CamelService}. + * * @author Martin Krasser */ class CamelServiceFactoryBean extends FactoryBean[CamelService] with InitializingBean with DisposableBean { @@ -21,6 +23,10 @@ class CamelServiceFactoryBean extends FactoryBean[CamelService] with Initializin 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) @@ -29,6 +35,9 @@ class CamelServiceFactoryBean extends FactoryBean[CamelService] with Initializin instance.load } + /** + * Stops the {@link CamelService} singleton. + */ def destroy = { instance.unload }