Hi, I want to write a JMX service that upon the activation of its "test" 
method, a perioudic job will begin.

I added the following lines to the jboss-service.xml:



 



I then wrote the interface of the service:

@Local
@Remote
public interface TestTimer 
{
        public void test();
}


And then I implemented the service itself:
@Service (objectName="trail:service=TestTimer")
@Management(TestTimer.class)
@Depends ("acme:service=Scheduler")
public class TestTimerMBean  implements TestTimer, Schedulable {
        private SchedulerMBean schedulerMBean;
        public void test() 
        {
                try
                {
                        System.out.println("Hello time " + 
System.currentTimeMillis());
                
                        MBeanServer server = MBeanServerLocator.locate();

                        schedulerMBean = (SchedulerMBean) MBeanProxyExt.create(
                           SchedulerMBean.class,
                    "acme:service=Scheduler",
                    server);
               
                        if (schedulerMBean != null)
                   System.out.println("succeeded in looking up scheduler");
                        
                        
                        System.out.println("@@@@@My class name is " + 
getClass().getName());
                        
schedulerMBean.setSchedulableClass(getClass().getName());
                        schedulerMBean.setInitialRepetitions(20);
                        schedulerMBean.setInitialStartDate("NOW");
                        schedulerMBean.setSchedulePeriod(2000);
                        schedulerMBean.start();
                        schedulerMBean.startSchedule();
                                        }
                catch (Exception e)
                {
                        e.printStackTrace();
                }

        }

        public void perform(Date arg0, long arg1) {
                // TODO Auto-generated method stub
                
                
                try
                {
                        File f = new File("c:\\sched.txt");
                        
                        FileOutputStream fos = new 
FileOutputStream(f,f.exists());
                        fos.write(("date is " + arg0 + "arg is " + 
arg1).getBytes());
                        fos.close();
                }
                catch (Exception e)
                {
                        e.printStackTrace();
                }
        }
}


When I deploy, I can see that there is a perioudic job that runs, but I dont 
see that the method "perform" is executed (the file c:\sched.txt is not created 
and i do have permissions  - i also tried using system.out.println - and 
nothing - the jboss application server runs on my machine )
What am I doing wrong here?

Thanks
Yair


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3948335#3948335

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3948335


-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to