Find JSRs
Submit this Search


Ad Banner
 
 
 
 

Common Annotations for the Java Platform Maintenance Release 1

Common Annotations for the Java Platform Maintenance Release 1.1

 

1.      Update Table 2-1 to reflect what the value of TransactionAttribute will be on both the methods in all the classses for clarity as follows -

 

 

Methods in derived classes

Effective TransactionAttribute value

foo() in ABean

REQUIRED (Default TransactionAttribute as defined by the EJB specification).

bar() in ABean

@Transaction(REQUIRED)

foo() in BBean

@TransactionAttribute(REQUIRES_NEW)

bar() in BBean

@TransactionAttribute(REQUIRED)

foo() in CBean

@TransactionAttribute(REQUIRES_NEW)

bar() in CBean

@TransactionAttribute(REQUIRES_NEW)

foo() in DBean

@TransactionAttribute(NEVER)

bar() in DBean

@TransactionAttribute(REQUIRES_NEW)

foo() in EBean

@TransactionAttribute(NEVER)

bar() in EBean

@TransactionAttribute(REQUIRED)

 

2.      Change the definition of the @DenyAll annotation to allow it to be defined on both type and method targets.

���� @Target({TYPE, METHOD})

3.      Simplify section 2.11 PermitAll, DenyAll and RolesAllowed interactions, to convey that method targeted annotations always take precedence over Class targeted instances of these annotations as follows -

����� If the PermitAll, RolesAllowed, or DenyAll annotations are applied on methods of a class, then the method level annotations take precedence (at the corresponding methods) over any class level annotation of type PermitAll, RoleAllowed, orDenyAll.

 

 

4.      Add a new attribute to the Resource annotation - String lookup() default ""; - The optional lookup attribute specifies the JNDI name of a resource that the resource being defined will be bound to. The type of the referenced resource must be compatible with that of the resource being defined.

5.      Add a new subsection 2.13 to define DataSourceDefinition annotation as follows:

�� javax.annotation.sql.DataSourceDefinition

This annotation is used to define a container DataSource and be registered with JNDI. The DataSource may be configured by setting the annotation elements for commonly used DataSource properties. Additional standard and vendor-specific properties may be specified using the properties element. The data source will be registered under the name specified in the name element. It may be defined to be in any valid Java EE namespace, and will determine the accessibility of the data source from other components. A JDBC driver implementation class of the appropriate type, either DataSource, ConnectionPoolDataSource, or XADataSource, must be indicated by the className element. The driver class is not required to be available at deployment  but  must be available at runtime prior to any attempt to access the DataSource.

The url property should not be specified in conjunction with other standard properties for defining the connectivity to the database. If the url property is specified along with other standard DataSource properties such as serverName and portNumber, the more specific properties will take precedence and url will be ignored.

Vendors are not required to support properties that do not normally apply to a specific data source type. For example, specifying the transactional property to be true but supplying a value for className that implements a data source class other than XADataSource may not be supported.

Vendor-specific properties may be combined with or used to override standard data source properties defined using this annotation.

DataSource properties that are specified and are not supported in a given configuration or cannot be mapped to a vendor specific configuration property may be ignored.

Although the annotation allows you to specify a password, it is recommended not to embed passwords in production code. The password element in the annotation is provided as a convenience for ease of development.

 

Examples:

�� @DataSourceDefinition(name="java:global/MyApp/MyDataSource",
����� className="com.foobar.MyDataSource",
����� portNumber=6689,
����� serverName="myserver.com",
����� user="lance",
����� password="secret"
�� )
 

��� Using a URL:

@DataSourceDefinition(name="java:global/MyApp/MyDataSource",
��� className="org.apache.derby.jdbc.ClientDataSource",
��� url="jdbc:derby://localhost:1527/myDB",
��� user="lance",
��� password="secret"
)
 
 

 

6.      Add a new subsection 2.14 to define DataSourceDefinitions annotation as follows:

javax.annotation.sql.DataSourceDefinitions

The DataSourceDefinition annotation is used to declare a container DataSource. Since repeated annotations are not allowed, the DataSourceDefinitions annotation acts as a container for multiple data source declarations.

 

1.      Add a new subsection 2.15 to define Managed Bean annotation as follows:

javax.annotation.ManagedBean

This annotation is used to declare a Managed Bean as specified in the Managed Beans specification.  Managed Beans are container managed objects that support a small set of basic services such as resource injection, lifecycle callbacks and interceptors. A Managed Bean may optionally have a name, a String specified via the value attribute.

package javax.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
@Target(TYPE)
@Retention(RUNTIME)
public @interface ManagedBean {
     String value() default "";
}

Examples:

 

@ManagedBean(�cart�)

public class ShoppingCart{

...

}