Schedule Class Execution

M

Memi Lavi

Hi Guys.

I'm newbie to the Java world, and I've stumbled across an issue I
can't resolve:
We are developing a large-scale web based application, based on
WebSphere 5.02 & AS/400, DB2.
We need to implement scheduler in our project, means - execute some
class' methods asynchronously, on a pre-specified timing (ie. every 10
minutes).
I've looked into the docs, and found the Timer class in Java.utils,
but according to the docs the tasks are executed sequentially, and not
asynchronously, and I don't like it.
I've also found the Timer class of the WebSphere itself, but I feel
uncomfortable using proprietry API in a Java project.

So, what are the solutions to this situation?

Thanks!
 
E

Eric Sosman

Memi said:
Hi Guys.

I'm newbie to the Java world, and I've stumbled across an issue I
can't resolve:
We are developing a large-scale web based application, based on
WebSphere 5.02 & AS/400, DB2.
We need to implement scheduler in our project, means - execute some
class' methods asynchronously, on a pre-specified timing (ie. every 10
minutes).
I've looked into the docs, and found the Timer class in Java.utils,
but according to the docs the tasks are executed sequentially, and not
asynchronously, and I don't like it.
I've also found the Timer class of the WebSphere itself, but I feel
uncomfortable using proprietry API in a Java project.

So, what are the solutions to this situation?

Hint: A TimerTask can start a new Thread ...
 
C

Chris Smith

Memi said:
I'm newbie to the Java world, and I've stumbled across an issue I
can't resolve:
We are developing a large-scale web based application, based on
WebSphere 5.02 & AS/400, DB2.
We need to implement scheduler in our project, means - execute some
class' methods asynchronously, on a pre-specified timing (ie. every 10
minutes).
I've looked into the docs, and found the Timer class in Java.utils,
but according to the docs the tasks are executed sequentially, and not
asynchronously, and I don't like it.
I've also found the Timer class of the WebSphere itself, but I feel
uncomfortable using proprietry API in a Java project.

So, what are the solutions to this situation?

You can't use java.util.Timer from an EJB anyway, because of
multithreading restrictions. If you're using EJB 2.1 (I'm not familiar
with WebSphere versions and their correspondence to EJB specs), then you
might look into EJBContext's getTimerService method. If you're using
pre-2.1, it might be okay to use a container-specific API until you can
upgrade. Otherwise, you're pretty much screwed... it might be possible
for a client to arrange to notify the bean on a regular schedule, but
that's a very ugly answer.

This all happens because, according to Sun, threads are never a business
concern, so if you need to do something like this then you must not be
writing a "business" component (read: must not be writing a component
that acts identically to the components the EJB spec team had in mind
when designing the spec). This is the same weird logic that makes "Jack
can add comments to his clients' accounts, but not to anyone else's
clients" an advanced and unusual requirement for an application.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
T

Tony Morris

I'm newbie to the Java world, and I've stumbled across an issue I
can't resolve:
We are developing a large-scale web based application, based on
WebSphere 5.02 & AS/400, DB2.

What a scary thought.

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform
 
S

Sudsy

Tony said:
What a scary thought.

Mind if I ask why? One of the things which blew my socks off
was the realization of true interoperability provided by the
Java framework. Yes, I know that was the intent but those of
us who've been in the industry for a while are all too
familiar with the hype and how it differs from reality.
From the time I was able to develop servlets on a Win 98
laptop, FTP the class files to a Sun Sparc 5 and actually
have everything work...needless to say, I was impressed.
Things have only gotten better since. Being able to juggle
the back-end database is a positive boon. I've developed an
environment which can generate all the deployment descriptors
for WebSphere and WebLogic J2EE servers, utilizing Oracle,
DB/2 and Sybase RDBMSs. Eclipse can do the same.
It gets even better with JCA to integrate with legacy apps,
including CICS and the like. Quite frankly, I wouldn't be at
all squeamish about the environment described. These days, it
all actually WORKS!
 
R

Roedy Green

Mind if I ask why?

The documentation for Websphere comes in a wheelbarrow. The thought
of a newbie tackling that as his first Java project ...

You are obviously not a newbie, just a Java newbie.
 
M

Memi Lavi

Hi Chris.

Thanks for the detailed answer.
I did not understand what the EJB has to do with the timer. Do you
mean Session Bean or Entity Bean? The timer has nothing to do with the
database, so I guess you mean Session Bean. Why do I have to use it
for the timer? I thought there is some standard service in the
container which can be utilized for this. Am I missing something?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top