Java Reference
In-Depth Information
In this example, we decorated one of the methods in our EJB with the
@Schedule
annotation. We used a value of
"*"
for its
hour
attribute to specify that the method
should be invoked every hour. We used the vale of
"*"
for the
minute
attribute as
well to specify that the method should be invoked every minute. Finally, we used the
value of
"*/30"
for its
second
attribute to specify that the method should be invoked
every 30 seconds.
The
@Schedule
annotation uses a syntax similar to the cron utility commonly found
in Unix and Unix-like operating systems such as Linux. Refer to
http://www.
unixgeeks.org/security/newbie/unix/cron-1.html
for a good introduction
to cron.
After deploying and executing our project in NetBeans, we should see the following
output in the GlassFish output console:
Generating session beans from JPA
entities
One very nice NetBeans feature is that it allows generation of stateless session beans
from existing JPA entities, the generated session beans act
as DAOs (Data Access
Objects)
. This feature, combined with the ability to generate JPA entities from an
existing database schema, allows us to completely generate the data access layers of
our application without having to write a single line of Java code.