A Techno Blog, mainly about Java

Better EE w Spring

link : "a whirlwind tour of IoC in general and Spring in particular"

July 17, 2005 Posted by | IoC | Leave a comment


JSK 1.5 (Tiger) download

I am interested in learning about annotations : "eliminates the need for maintaining "side files" that must be kept up to date with changes in source files. Instead the information can be maintained in the source files".

Have seen annotations before (i.e. @depracated). The release 5.0 platform has a general purpose annotation (also known as metadata) facility that permits you to define and use your own annotation types.

Annotation type declarations are similar to normal interface declarations. An at-sign (@) precedes the interface keyword. Each method declaration defines an element of the annotation type. Method declarations must not have any parameters or a throws clause. Return types are restricted to primitives, String, Class, enums, annotations, and arrays of the preceding types. Methods can have default values. Here is an example annotation type declaration:

 * Describes the Request-For-Enhancement(RFE) that led
 * to the presence of the annotated API element.
public @interface RequestForEnhancement {
    int    id();
    String synopsis();
    String engineer() default "[unassigned]"; 
    String date();    default "[unimplemented]";

An annotation is a special kind of modifier, and can be used anywhere that other modifiers (such as public, static, or final) can be used. By convention, annotations precede other modifiers. Annotations consist of an at-sign (@) followed by an annotation type and a parenthesized list of element-value pairs. The values must be compile-time constants. Here is a method declaration with an annotation corresponding to the annotation type declared above:

    id       = 2868724,
    synopsis = "Enable time-travel",
    engineer = "Mr. Peabody",
    date     = "4/1/3007"

I believe Hibernate 3 now has this feature so that you can define mappings in source code rather than XML mapping file

Continue reading

July 17, 2005 Posted by | J2EE | Leave a comment