lundi mai 30, 2011

Brno Oracle Java Developer Event - Success!

I spent last Thursday in Brno to deliver a number of Java EE talks and a keynote at the Oracle Developer Java Conference. It was great because it had a good developer feel and was similar in spirit to other community-driven conferences that I recently attended. Maybe the best part was the attendance - well over 400 (excluding Oracle employees and speakers) which is great for a first time.

Dalibor Topic fought the ash cloud and managed to reach Brno to kick off the day with a Java keynote with updates on Java 7 and current thinking about Java 8 and beyond. Doug Clarke, Java Persistence Director of Product Management at Oracle was here to cover advanced JPA features as well as recent evolution in EclipseLink with a nice multi-tenancy demo (I understand there's a screencast coming soon). I took this opportunity to interview Doug on EclipseLink. The recording will soon be up on the GlassFish Podcast.

And of course, last but not least, the Prague web services engineering team was strongly represented and covering JAX-RS and Jersey. Given how the last session overran by more than half an hour I'd say this was a successful and engaging presentation. Both Marek (JAX-RS co-spec lead) and Jakub (Jersey lead) blogged about the event and shared code demo.

That's a pretty poor photo there that I have but I'm hoping to see better ones given the presence of a profesional photographer (doing a keynote and three sessions I sure felt like a rockstar with photos of me taken at each of them...).

mardi mai 24, 2011

Intercepting startup and shutdown events

This blog has moved to alexismp.wordpress.com
Follow the link for the most up-to-date version of this blog entry.

Startup and shutdown actions is a pretty common use-case for enterprise development and GlassFish 3.x offers at least two different ways to implement such call-backs: lifecycle modules and EJB 3.1 startup beans.

GlassFish Lifecycle modules

The first one has been around for a little while and is called Lifecycle modules. These are specific to GlassFish and thus not portable to other application servers but they offer a simple and effective way to implement behavior that applies to the entire application server instance (or to an entire cluster), independently of any deployed application.

A single class implementing com.sun.appserv.server.LifecycleListener (available from as-install/glassfish/modules/glassfish-api.jar) can intercept five different events: Initialization, Startup, Ready, Shutdown, and Termination (check the documentation for more details). Here's a canonical example :

public class GlassFishEvents implements com.sun.appserv.server.LifecycleListener {

    private static final Logger logger = Logger.getLogger("admin.events");

    @Override
    public void handleEvent(LifecycleEvent le) throws ServerLifecycleException {
       switch (le.getEventType()) {
          case LifecycleEvent.INIT_EVENT:
             logger.severe("INIT_EVENT");
             break;
          case LifecycleEvent.READY_EVENT:
             logger.severe("READY_EVENT");
             break;
          case LifecycleEvent.SHUTDOWN_EVENT:
             logger.severe("SHUTDOWN_EVENT");
             break;
          case LifecycleEvent.STARTUP_EVENT:
             logger.severe("STARTUP_EVENT");
             break;
          case LifecycleEvent.TERMINATION_EVENT:
             logger.severe("TERMINATION_EVENT");
             break;
          default:
             logger.severe("UNKNOWN event");
       }
    }
}

Registering the lifecycle module can be done via the admin console or the CLI (asadmin create-lifecycle-module) with optional ordering (relative to other modules, similar to servlets), an enabled/disabled state (default is enabled) and the ability to prevent the server from starting if the module fails to load.


Startup and singleton EJB

An alternate way is to use EJB 3.1 (part of Java EE 6) and in particular a bean combining the @Startup and @Singleton annotations. Its lifecycle methods marked with JSR 250 common annotations will contain the event callback logic. Here's a simple example simulation the creation of database tables :

@javax.ejb.Singleton
@javax.ejb.Startup
public class CreateTables {
    @PostConstruct
    public void init() {
       logger.warning("Creating tables");
    }

    @PreDestroy
    public void cleanup() {
       logger.warning("Dropping table...");
    }
}

While this offers a more portable solution, it has some notable differences with GlassFish lifecycle modules.

First of all there are only two events that can be intercepted: @PostConstruct, @PreDestroy which are application events, not runtime system events. Undeploying the application is also the only way to disable the behavior and since this is an application-level event interception, there cannot be action taken on other parts of the runtime on failure (arguably you can do a lot more in the rest of you application).

Finally there is no notion of ordering but rather you can express explicit dependencies using @DependsOn as shown here to simulate populating tables that need to be previously created :

@javax.ejb.Singleton
@javax.ejb.Startup
@javax.ejb.DependsOn("CreateTables")
public class PopulateTables {
    @PostConstruct
    public void init() {
       logger.warning("Populating tables");
    }

    @PreDestroy
    public void cleanup() {
       logger.warning("archiving table data");
    }
}

Also note that a Singleton approach only applies to a single instance (not a cluster-wide singleton). If you're wondering which approach to chose, it really boils down to whether you want to implement system-level or application-level events.

Of course you can combine the two approaches which would trigger a log similar to this one on a startup/shutdown cycle :

SEVERE: INIT_EVENT
WARNING: Creating tables
WARNING: Populating tables
SEVERE: STARTUP_EVENT
SEVERE: READY_EVENT
...
SEVERE: SHUTDOWN_EVENT
WARNING: archiving table data
WARNING: Dropping table...
SEVERE: TERMINATION_EVENT

vendredi févr. 20, 2009

CommunityOne Olso - April 15th 2009 - Call for Papers

The CommunityOne conference is said to be heading East to New York (March 18 - 19, 2009) and West to San Francisco (June 1 - 3, 2009), so I'm not sure what direction it's heading when going to Olso...
Update: the site is online (has been a little while in fact): http://no.sun.com/communityone

So there it is : CommunityOne Oslo is happening on April 15th 2009 and the call for papers is open. Simply a 150-word (max) abstract to CommunityOne-Oslo-AT-sun.com. The keynote speaker will be Ian Murdock, now Vice President of Cloud Computing Strategy at Sun.

Suggested topics include :
• Development and deployment in the cloud and virtualization
• Social networks and Web 2.0 trends
• RIAs, scripting, and tools
• Dynamic languages, databases, and Web and application servers
• Open-source projects, business models, and trends
• And more

I understand this will be held in the heart of Oslo in a very nice place and that there will be a (social) GlassFish get together at some point in the day.

mercredi avr. 18, 2007

GlassFish Day Update

Eduardo has been busy covering the work in progress for GlassFish Day (part of CommunityOne). The event is FREE and still taking registrations.

• Overview of GlassFish Day and CommunityOne
• Spring at GlassFish Day
• Jetty at GlassFish Day
• Terracotta at GlassFish Day
• JVantage now support GlassFish
• Do you have something Cool to Show? - Submit it to GlassFish Day
• GlassFish Day Session #4 - Visit the Future...

Once you're registered for GlassFishDay/CommunityOne, you can attend any event (see agenda) and we'll be working until the very end to made the GlassFish content as interesting as possible, so keep reading The Aquarium. Note finally that if you are an SDN member GlassFishDay/CommunityOne will get you a free pass to the first day of JavaOne!

About

This blog has moved

Alexis Moussine-Pouchkine's Weblog

GlassFish - Stay Connected

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today
Blogroll

No bookmarks in folder

News

No bookmarks in folder