Home > Spring Gets Expanded Java Annotation Support

News

Spring Gets Expanded Java Annotation Support

7/11/2008

Bookmark and Share

When writing a complex Java program filled with many interlocking objects, any automation of routine tasks can be a big help. So Java developers using the Java Spring framework should welcome recent additional support for annotations, which could take care of many mundane construction and configuration duties. Spring is an open source collection of components for developing Java Enterprise Edition-based applications.

Codified in Java Specification Request 250 and added to version 5 of Java, annotations "allow you to add metadata to Java source code," explained Rod Johnson, chief executive officer of SpringSource, which sells a commercial version of Spring, as well as corrals the open source Spring development. Johnson gave a presentation on the latest version of Spring, version 2.5, at the JavaOne Conference, held earlier this year in San Francisco.

Annotations are not merely human-readable metadata. They are a set of extensible keywords, each prefixed by the @ symbol, that class constructors and other Java tools can interpret and process. Annotations have actually been around since Spring version 1.2, Johnson said. You could annotate a method or type so that it could be exported to Java Management Extensions (JMX), a Java-based tool for managing distributed Java applications.

The latest Spring really embraces annotations, however. "In Spring 2.5, we've extended annotation support to provide comprehensive support for dependency injection," Johnson said. Dependency injection, the heart of Spring, allows a program to call an external service without knowing the particulars of where that service is located. The nice thing about these annotations, named @autowired and @resource, is that they can eliminate external configurations of applications. Also, they can be used to change the configuration of a program without changing the source code, Johnson said.

Another new set of annotations supported in 2.5, called meta-annotations, can help developers build a semantic model of the application. Some of these annotations have been standardized, and you can also annotate your own types through @component. These annotations identify and document the role of types, such as service object or repository. This allows Spring to scan a program, and find every class and consider it as a candidate for reuse. With Spring, "changes are picked up automatically. So in development, if you pick up a new class, annotate with @component, it instantly becomes a Spring [component] without the need to author any configuration," Johnson said. Using Eclipse Spring IDE plug-in, you can also generate a map of your application using these annotations.

For more information, go to the Spring 2.5 reference guide.

Cite this Site

Joab Jackson, "Spring Gets Expanded Java Annotation Support," Campus Technology, 7/11/2008, http://www.campustechnology.com/article.aspx?aid=65226

copy text (above) for proper citation



Recommended Reading
  • Tufts Grants Rights for Mileage-Increasing Transportation Technology to Electric Truck

    Tufts University has optioned rights to a technology that can recharge the batteries of any hybrid electric and electric-powered vehicle while it is driven. The Tufts-developed technology could increase by 20 percent to 70 percent the miles per gallon or total driving range performance of vehicles like the Honda Civic, Ford Escape, and Toyota Prius hybrids and the Tesla Motors and Phoenix Motorcars electric vehicles.

  • U Florida and Cyntellect Collaborate to Unlock Mysteries of Cancer Stem Cells

    The University of Florida has entered into a research agreement with life sciences company Cyntellect. The university's Interdisciplinary Center for Biotechnology Research will work with the company to focus on a variety of research areas including the purification and analysis of cancer stem cells (CSCs), rare cells believed to be directly involved in propagating cancers.

  • George Mason U Receives Grant To Deploy Intergraph Apps for Intelligence Curriculum

    George Mason University (GMU) in Fairfax, VA has been awarded a grant from Intergraph to enable students enrolled in GMU's Geospatial Intelligence Graduate Certificate program to use the company's geospatial production and exploitation software as part of their core curriculum.

  • Institute for Cyber Security at U Texas, San Antonio Opens Incubator

    The University of Texas at San Antonio (UTSA) Institute for Cyber Security (ICS) has launched a new Internet security incubator. The incubator was developed to commercialize promising technologies that address major cyber security and privacy issues. The first companies to enter the incubator are Denim Labs and SafeMashups.

  • ISO/IEC Publishes Office Open XML Standard

    ISO/IEC has published the Office Open XML (OOXML) file format standard, formally known as ISO/IEC 29500:2008. It describes file formats originally designed by Microsoft for its Office 2007 productivity suite, which are used in presentation, spreadsheet and word processing applications.

  • Dynamics NAV 2009 ERP Coming Next Month

    Microsoft exec Kirill Tatarinov Wednesday described some new features to expect in the forthcoming Microsoft Dynamics NAV 2009 enterprise resource planning solution. He gave the keynote address at Microsoft's Convergence 2008 event in Copenhagen, Denmark.