Converted TAB to SPACE
This commit is contained in:
parent
b7a7527ca2
commit
46d250fe73
19 changed files with 161 additions and 161 deletions
|
|
@ -42,11 +42,11 @@
|
|||
<artifactId>akka-core_2.8.0.RC3</artifactId>
|
||||
<version>0.9.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.multiverse</groupId>
|
||||
<artifactId>multiverse-alpha</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.multiverse</groupId>
|
||||
<artifactId>multiverse-alpha</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
|
|
|||
|
|
@ -17,19 +17,19 @@ import junit.framework.TestCase;
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,33 +4,33 @@ 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 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();
|
||||
}
|
||||
public void throwException() {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -741,33 +741,33 @@ private[akka] class Dispatcher(transactionalRequired: Boolean, var 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)
|
||||
// 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: _*)
|
||||
}
|
||||
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)
|
||||
}
|
||||
// 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 = {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class AkkaDeployClassLoader(urls : List[URL], parent : ClassLoader) extends URLC
|
|||
}
|
||||
|
||||
def listClassesInPackage(jar : URL, pkg : String) = {
|
||||
val f = new File(jar.getFile)
|
||||
val f = new File(jar.getFile)
|
||||
val jf = new JarFile(f)
|
||||
try {
|
||||
val es = jf.entries
|
||||
|
|
|
|||
|
|
@ -4,33 +4,33 @@ 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 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();
|
||||
}
|
||||
public void throwException() {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,12 +36,12 @@ object Chameneos {
|
|||
colour = complement(otherColour)
|
||||
meetings = meetings +1
|
||||
from ! Change(colour)
|
||||
mall ! Meet(self, colour)
|
||||
mall ! Meet(self, colour)
|
||||
|
||||
case Change(newColour) =>
|
||||
colour = newColour
|
||||
meetings = meetings +1
|
||||
mall ! Meet(self, colour)
|
||||
mall ! Meet(self, colour)
|
||||
|
||||
case Exit =>
|
||||
colour = FADED
|
||||
|
|
|
|||
|
|
@ -122,9 +122,9 @@ class RoutingSpec extends junit.framework.TestCase with Suite with MustMatchers
|
|||
}
|
||||
|
||||
@Test def testIsDefinedAt = {
|
||||
import se.scalablesolutions.akka.actor.ActorRef
|
||||
|
||||
val (testMsg1,testMsg2,testMsg3,testMsg4) = ("test1","test2","test3","test4")
|
||||
import se.scalablesolutions.akka.actor.ActorRef
|
||||
|
||||
val (testMsg1,testMsg2,testMsg3,testMsg4) = ("test1","test2","test3","test4")
|
||||
|
||||
val t1 = actorOf( new Actor() {
|
||||
def receive = {
|
||||
|
|
|
|||
|
|
@ -560,6 +560,6 @@ object LiftUtils {
|
|||
(pair(0), unquote(pair(1)))
|
||||
})
|
||||
val map: Map[String, String] = Map.empty
|
||||
(map /: list)((m, next) => m + (next))
|
||||
(map /: list)((m, next) => m + (next))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@
|
|||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>akka</id>
|
||||
<name>Akka Repo</name>
|
||||
<url>http://www.scalablesolutions.se/akka/repository/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>akka</id>
|
||||
<name>Akka Repo</name>
|
||||
<url>http://www.scalablesolutions.se/akka/repository/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>project.embedded.module</id>
|
||||
<name>Project Embedded Repository</name>
|
||||
|
|
|
|||
|
|
@ -57,44 +57,44 @@ class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] with Logging {
|
|||
* @see org.springframework.beans.factory.config.AbstractFactoryBean#createInstance()
|
||||
*/
|
||||
def createInstance: AnyRef = {
|
||||
if(scope.equals(VAL_SCOPE_SINGLETON)) {
|
||||
setSingleton(true)
|
||||
} else {
|
||||
setSingleton(false)
|
||||
}
|
||||
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"
|
||||
|
||||
setProperties(
|
||||
create(argumentList))
|
||||
create(argumentList))
|
||||
}
|
||||
|
||||
/**
|
||||
* This method manages <property/> element by injecting either
|
||||
* values (<property value="value"/>) and bean references (<property ref="beanId"/>)
|
||||
* values (<property value="value"/>) and bean references (<property ref="beanId"/>)
|
||||
*/
|
||||
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
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ trait ActiveObjectParser extends BeanParser with DispatcherParser {
|
|||
}
|
||||
|
||||
for(element <- propertyEntries) {
|
||||
val entry = new PropertyEntry()
|
||||
entry.name = element.getAttribute("name");
|
||||
val entry = new PropertyEntry()
|
||||
entry.name = element.getAttribute("name");
|
||||
entry.value = element.getAttribute("value")
|
||||
entry.ref = element.getAttribute("ref")
|
||||
objectProperties.propertyEntries.add(entry)
|
||||
entry.ref = element.getAttribute("ref")
|
||||
objectProperties.propertyEntries.add(entry)
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import org.springframework.beans.BeansException
|
|||
@author <a href="johan.rask@jayway.com">Johan Rask</a>
|
||||
*/
|
||||
class AkkaBeansException(errorMsg:String,t:Throwable) extends BeansException(errorMsg,t) {
|
||||
|
||||
def this(errorMsg:String) = {
|
||||
this(errorMsg,null)
|
||||
}
|
||||
|
||||
def this(errorMsg:String) = {
|
||||
this(errorMsg,null)
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,6 @@ class PropertyEntries {
|
|||
var entryList:ListBuffer[PropertyEntry] = ListBuffer[PropertyEntry]()
|
||||
|
||||
def add(entry:PropertyEntry) = {
|
||||
entryList.append(entry)
|
||||
entryList.append(entry)
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,12 @@ package se.scalablesolutions.akka.spring
|
|||
*/
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
transactional="true"
|
||||
timeout="1000"
|
||||
scope="prototype">
|
||||
<property name="source" ref="string"/>
|
||||
<property name="source" ref="string"/>
|
||||
</akka:active-object>
|
||||
|
||||
<bean id="string" class="java.lang.String">
|
||||
<constructor-arg value="someString"/>
|
||||
</bean>
|
||||
|
||||
<bean id="string" class="java.lang.String">
|
||||
<constructor-arg value="someString"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
transactional="true"
|
||||
timeout="1000"
|
||||
scope="prototype">
|
||||
<property name="source" ref="nonExistentRef"/>
|
||||
<property name="source" ref="nonExistentRef"/>
|
||||
</akka:active-object>
|
||||
|
||||
<bean id="string" class="java.lang.String">
|
||||
<constructor-arg value="someString"/>
|
||||
</bean>
|
||||
|
||||
<bean id="string" class="java.lang.String">
|
||||
<constructor-arg value="someString"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
|
@ -26,9 +26,9 @@ class ActiveObjectBeanDefinitionParserTest extends Spec with ShouldMatchers {
|
|||
target="foo.bar.MyPojo"
|
||||
timeout="1000"
|
||||
transactional="true"
|
||||
scope="prototype">
|
||||
<property name="someProp" value="someValue" ref="someRef"/>
|
||||
</akka:active-object>
|
||||
scope="prototype">
|
||||
<property name="someProp" value="someValue" ref="someRef"/>
|
||||
</akka:active-object>
|
||||
|
||||
val props = parser.parseActiveObject(dom(xml).getDocumentElement);
|
||||
assert(props != null)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
|
|||
}
|
||||
|
||||
it("should create an application context and inject a string dependency") {
|
||||
var ctx = new ClassPathXmlApplicationContext("appContext.xml");
|
||||
var ctx = new ClassPathXmlApplicationContext("appContext.xml");
|
||||
val target:ResourceEditor = ctx.getBean("bean").asInstanceOf[ResourceEditor]
|
||||
assert(target.getSource === "someString")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue