Spring libraries and dependancies

Spring libraries

Spring two AspectJ libraries on the classpath of application: aspectjweaver.jar and aspectjrt.jar. These libraries are available in the ‘lib’ directory of an AspectJ installation (version 1.5.1 or later required), or in the ‘lib/aspectj’ directory of the Spring-with-dependencies distribution.

The form tag library comes bundled in spring.jar. The library descriptor is called spring-form.tld. To use the tags from this library, add the following directive to the top of JSP page:

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

where form is the tag name prefix you want to use for the tags from this library.

Effecting the dependency injection of Spring-managed beans into Tapestry pages in Tapestry version 4.x is so much simpler. All that is needed is a single add-on library, and some (small) amount of (essentially boilerplate) configuration. Simply package and deploy this library with the (any of the) other libraries required by your web application (typically in WEB-INF/lib).

Library dependencies

The following additional jars to be on the classpath of your application in order to be able to use the Spring Framework’s email library.

  1. The JavaMail mail.jar library
  2. The JAF activation.jar library

All of these libraries are available in the Spring-with-dependencies distribution of the Spring Framework.

Required libraries (JARS)

At a minimum you will need the following libraries to use the Spring Framework’s support for AspectJ LTW:

1. spring.jar (version 2.5 or later)

2. aspectjrt.jar (version 1.5 or later)

3. aspectjweaver.jar (version 1.5 or later)

Dependencies

Typical enterprise application is not made up of a single object (or bean in the Spring parlance). Even the simplest of applications will no doubt have at least a handful of objects that work together to present what the end-user sees as a coherent application.

Injecting dependencies

The basic principle behind Dependency Injection (DI) is that objects define their dependencies (that is to say the other objects they work with) only through constructor arguments, arguments to a factory method, or properties which are set on the object instance after it has been constructed or returned from a factory method.

Then, it is the job of the container to actually inject those dependencies when it creates the bean. This is fundamentally the inverse, hence the name Inversion of Control (IoC), of the bean itself being in control of instantiating or locating its dependencies on its own using direct construction of classes, or something like the Service Locator pattern.

Constructor Injection

Constructor-based DI is effected by invoking a constructor with a number of arguments, each representing a dependency. Additionally, calling a static factory method with specific arguments to construct the bean, can be considered almost equivalent, and the rest of this text will consider arguments to a constructor and arguments to a static factory method similarly. Find below an example of a class that could only be dependency injected using constructor injection.

public class SimpleMovieLister {
// the SimpleMovieLister has a dependency on a MovieFinder
private MovieFinder movieFinder;
// a constructor so that the Spring container can 'inject' a MovieFinder
public SimpleMovieLister(MovieFinder movieFinder) {
this.movieFinder = movieFinder;
}

 


Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences. I am on Google+ and Facebook. I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on javagenious.com(At)gmal.com ; I would like to hear from you :)

Share This Post

Related Articles

Powered by WordPress · Designed by Theme Junkie
You might also likeclose