Hi,

There's no direct equivalent of the task namespace in OSGi blueprint, however 
you can convert what you have to standard Java and blueprint very easily.

public class MyMethodRunner implements Runnable {

    private final MyBean myBean;

    public MyMethodRunner (MyBean myBean) {
        this.myBean = myBean;
    }

    public void run() {
        myBean.myMethod();
    }
}
--------------------------------------------------------------------------------------------
<bean id="myScheduler" class="java.util.concurrent.ScheduledThreadPoolExecutor">
    <argument value="1"/>
</bean>

<bean id="theFuture" factory-ref="myScheduler" 
factory-method="scheduleAtFixedRate">
    <argument>
        <bean class="MyMethodRunner">
            <argument ref="myBean"/>
        </bean>
    </argument>
    <argument value="0">
    <argument value="60">
    <argument value="SECONDS">        
</bean>


Obviously you could make this more generic as necessary, or if you're very keen 
you could write a namespace handler extension for Aries blueprint that mirrors 
the Spring syntax :)

Tim Ward
-------------------
Apache Aries PMC member & Enterprise OSGi advocate
Enterprise OSGi in Action (http://www.manning.com/cummins)
-------------------


From: [email protected]
To: [email protected]
Subject: How to use scheduled tasks in aries blueprint
Date: Wed, 17 Apr 2013 16:07:13 +0200

I migrate from spring to blueprint and need the complement to spring’s 
scheduled-tasks. In my beans.xml it looks like: 
xmlns:task="http://www.springframework.org/schema/task";   <task:scheduled-tasks 
scheduler="myScheduler">    <task:scheduled ref="myBean" method="myMethod" 
cron="0 0/60 * * * ?" />  </task:scheduled-tasks>  <task:scheduler 
id="myScheduler" pool-size="1" /> Is there any way to get the same result in 
blueprint.xml? Best regardsRocco Kluegel  Finanzministerium des Landes 
Schleswig-Holstein  Amt für Informationstechnik  IT 5111 - ElsterPostman 
Entwicklung Feldstraße 25, 24105 Kiel Tel.  (0431) 2391-2436      (04120) 
7086001Fax   (0431) 2391-1755       (04120) 708897Mail: 
[email protected]       [email protected]                       
                      

Reply via email to