So I have somewhat limited experience with serialization, Wicket, and multi
thread projects so bear with me.

Essentially my web application class is instantiating a POJ (parentObject)
which creates a starts a new timer and instantiates several POJs
(childObjects) that also have timers in them. These childObjects are stored
in a list in the parentObject class. Pages in my wicket application need to
access parentObject, so I made it accessible as so:

    public Object getParentObject
    {
       return this.parentObject;
    }

And it is retrieved in each page like so:

    ((MyApplication)Application.get()).getParentObject()

The problem currently is that the timertask for both the parentObject and
childObjects are no longer being called every minute as they should be. My
logs pick up the first start of the parentObject, but the logging message is
never outputted again signalling that the run() method of parent Object's
timertask is not being executed every minute. The same holds true for the
child Objects. It seems like the timers are only being executed once. Below
is some pseudocode for what I have

    public class childObject implements Serializable
    {
        private transient NamedParameterJdbcTemplate njt;
        private transient Timer timer;
        
        public childObject(DataSource ds)
        {
                this.njt = new NamedParamterJdbcTemplate(ds);
        }
        
        public void start()
        {
                timer = new Timer();
                
                timer.schedule(new TimerTask(){
                        
                        public void run()
                        {
                                //do some stuff that is never happening
                        }
                        
                }, 0, 60000);
        }
    }
    
    public class ParentObject implements Serializable
    {
        private DataSource ds;
        private List<ChildObject> childObjects;
        private transient Timer;
        
        public ParentObject(DataSource ds)
        {
                this.ds = ds;
                //add some stuff to childObjects
                
                timer = new Timer();
                
                timer.schedule(new TimerTask(){
                        
                        public void run()
                        {
                                for(some condition)
                                {
                                        //Do some stuff
                                        
                                        if(/*condition is met*/)
                                        {
                                 //starts the child's timer to do stuff
                                                childObjects.get(i).start();
                                        }
                                }
                        }
                        
                }, 0, 60000);
        }
    }
    
    public MyApplication extends WebApplication
    {
        private ParentObject object;
        private DataSource ds;
        
        public void init()
        {
                super.init();
    
                ApplicationContext context = new
ClassPathXmlApplicationContext("/applicationContext.xml");
                ds = (DataSource) context.getBean("dataSource");
                
                parentObject = new ParentObject(ds);
        }
    }

Do I even need to make these objects Serializable? The objects themselves
are never being attached to wicket components, although String, integer,
Date sorts of variables that are members of their classes are.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-And-Multi-threaded-Business-Object-tp4565337p4565337.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to