removed @PreDestroy functionality
This commit is contained in:
parent
528500c366
commit
e1becf77d2
4 changed files with 8 additions and 24 deletions
|
|
@ -91,18 +91,18 @@ class ActiveObjectFactoryBean extends AbstractFactoryBean[AnyRef] with Logging w
|
|||
|
||||
/**
|
||||
* Stop the active object if it is a singleton.
|
||||
* It will call the instance destroy method before
|
||||
* stopping the active object.
|
||||
*/
|
||||
override def destroyInstance(instance:AnyRef) {
|
||||
for(method <- instance.getClass.getMethods) {
|
||||
if(method.isAnnotationPresent(classOf[PreDestroy])) {
|
||||
method.invoke(instance)
|
||||
}
|
||||
}
|
||||
ActiveObject.stop(instance)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Invokes any method annotated with @PostConstruct
|
||||
* When interfaces are specified, this method is invoked both on the
|
||||
* target instance and on the active object, so a developer is free do decide
|
||||
* where the annotation should be. If no interface is specified it is only invoked
|
||||
* on the active object
|
||||
*/
|
||||
private def postConstruct(ref:AnyRef) : AnyRef = {
|
||||
// Invoke postConstruct method if any
|
||||
for(method <- ref.getClass.getMethods) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ public class Pojo implements PojoInf,ApplicationContextAware {
|
|||
private String string;
|
||||
|
||||
private boolean gotApplicationContext = false;
|
||||
private boolean preDestroyInvoked = false;
|
||||
private boolean postConstructInvoked = false;
|
||||
|
||||
public boolean gotApplicationContext() {
|
||||
|
|
@ -28,19 +27,10 @@ public class Pojo implements PojoInf,ApplicationContextAware {
|
|||
return string;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy(){
|
||||
preDestroyInvoked = true;
|
||||
}
|
||||
@PostConstruct
|
||||
public void create() {
|
||||
postConstructInvoked = true;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPreDestroyInvoked() {
|
||||
return preDestroyInvoked;
|
||||
}
|
||||
|
||||
public boolean isPostConstructInvoked() {
|
||||
return postConstructInvoked;
|
||||
|
|
|
|||
|
|
@ -7,12 +7,8 @@ public interface PojoInf {
|
|||
|
||||
public String getString();
|
||||
public boolean gotApplicationContext();
|
||||
public boolean isPreDestroyInvoked();
|
||||
public boolean isPostConstructInvoked();
|
||||
|
||||
@PreDestroy
|
||||
public void destroy();
|
||||
|
||||
@PostConstruct
|
||||
public void create();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,8 +76,6 @@ class ActiveObjectFactoryBeanTest extends Spec with ShouldMatchers {
|
|||
assert(pojoInf.isPostConstructInvoked)
|
||||
assert(pojoInf.getString == "akka rocks")
|
||||
assert(pojoInf.gotApplicationContext)
|
||||
ctx.close
|
||||
assert(pojoInf.isPreDestroyInvoked)
|
||||
}
|
||||
|
||||
it("should stop the created active object when scope is singleton and the context is closed") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue