Sunday, November 14, 2004

Annotations and EJB 3.0

EJB 3.0 Preview " The EJB 3.0 specification uses annotations so that you can declare your EJB metadata directly within the bean class.

import javax.ejb.*;

public class ShoppingCartBean implements ShoppingCart
@Tx(TxType.REQUIRED) @MethodPermission({"customer"})
public void purchase(Product product, int quantity) {...}

@Remove void emptyCart() {...}

The @Stateful annotation marks the ShoppingCartBean as a stateful session bean. @Tx denotes transaction demarcation, while @MethodPermission defines role-based security for the bean method. EJB 3.0 provides annotations for every type of metadata so that no XML descriptor is needed and you can deploy your beans simply by deploying a plain old JAR into your application server."
Post a Comment