package com.venky.swf.plugins.background.extensions;

import com.venky.extension.Extension;
import com.venky.extension.Registry;
import com.venky.swf.db.Transaction;
import com.venky.swf.plugins.background.core.agent.Agent;
import com.venky.swf.plugins.background.core.agent.PersistedTaskPollingAgent;

public class BeforeCommitExtension implements Extension{
	private static BeforeCommitExtension instance = new BeforeCommitExtension();
	static {
		Registry.instance().registerExtension("before.commit", instance);
		Registry.instance().registerExtension("after.commit", new PersistedTaskTrigger());
	}
	public void invoke(Object... context) {
		Transaction txn = (Transaction)context[0];
		String triggerAgent = PersistedTaskPollingAgent.class.getName()+".trigger" ;
        Registry.instance().callExtensions("before." + triggerAgent,txn);
	}

	public static class PersistedTaskTrigger implements Extension {

        @Override
        public void invoke(Object... context) {
            Transaction txn = (Transaction)context[0];
            String triggerAgent = PersistedTaskPollingAgent.class.getName()+".trigger" ;
            Boolean trigger = txn.getAttribute(triggerAgent) ;
            if (trigger != null && trigger) {
                Agent.instance().start(PersistedTaskPollingAgent.PERSISTED_TASK_POLLER);
            }

        }
    }
	
}

@@ -513,93 +513,8 @@
 e);%0A
-%09%09Registry.instance().registerExtension(%22after.commit%22, new PersistedTaskTrigger());%0A
 %09%7D%0A%09
@@ -755,292 +755,9 @@
 n);%0A
-%09%7D%0A%0A%09public static class PersistedTaskTrigger implements Extension %7B%0A%0A        @Override%0A        public void invoke(Object... context) %7B%0A            Transaction txn = (Transaction)context%5B0%5D;%0A            String triggerAgent = PersistedTaskPollingAgent.class.getName()+%22.trigger%22 ;%0A    
+%0A
     
@@ -819,20 +819,16 @@
         
-    
 if (trig
@@ -853,20 +853,16 @@
 gger) %7B%0A
-    
         
@@ -950,31 +950,13 @@
     
- 
-   %7D%0A%0A        %7D%0A    %7D%0A%09
+%7D%0A%0A%09%7D%0A
 %0A%7D%0A

Revert last update