Skip to main content

Posts

Showing posts from December, 2011

Creating Calendar Based Timers in Java EE 6

Java EE 6 allows developers to create application timers that are initialized when either a Stateless Session Bean, a Singleton Bean or a Message Driven Bean are deployed to the application server. To indicate that a method on any of these beans is to be invoked on a timed basis, the method must be annotated with either the @Schedule annotation (for single timer schedules), or the @Schedules annotation (for multiple timer schedules). The code below shows a very simple Stateless Session Bean configured with 2 scheduled timers.  The first timer is configured with one schedule whereas the second is configured with 2 schedules. package com.acme.timer; import javax.ejb.Schedule; import javax.ejb.Schedules; import javax.ejb.Stateless; import javax.ejb.Timer; @Stateless public class CalendarTimer { @SuppressWarnings("unused") @Schedule(second = "*/10", minute = "*", hour = "8-17", dayOfWeek = "Mon-Fri", dayOfMonth = "*...

Using GlassFish from Eclipse

When I think of developing apps using GlassFish, I usually think of using NetBeans for the development. As you'd expect however, Oracle provides some good tooling to allow you to develop against GlassFish from within Eclipse - even to the point of installing the application server directly from within Eclipse.  So, how is this done? Installing GlassFish Server Tools Contrary to what you'd expect, to install GlassFish tooling, you don't use the Eclipse Marketplace for installation.  To install, right click within the "Servers" pane and select "New | Server" to display the "Define a New Server" dialog. On this dialog, select "Download additional server adaptors" and in the resulting dialog select "Oracle GlassFish Server Tools". After accepting the licence conditions, the GlassFish Server tools will be downloaded upon which you'll need to restart Eclipse to complete the installation. Defining a GlassFish Instanc...