Rich Newman

ApplicationConfig Class – Spring JavaConfig

package moviefindertest.javaconfig;

import org.springframework.config.java.annotation.Bean;
import org.springframework.config.java.annotation.Configuration;
import org.springframework.config.java.util.DefaultScopes;

@Configuration
public class ApplicationConfig {
      @Bean
      public Movie AndreiRublevMovie() {
            return new Movie("Andrei Rublev", "Andrei Tarkovsky");
      }
      
      @Bean
      public MovieFinder simpleMovieFinder() {
            return new SimpleMovieFinder();
      }
      
      @Bean(scope=DefaultScopes.SINGLETON)
      public MovieLister simpleMovieLister() {
            return new MovieLister(simpleMovieFinder());
      }
      
      @Bean
      public MovieFinder colonDelimitedMovieFinder() {
            return new ColonDelimitedMovieFinder();
      }
      
      @Bean(scope=DefaultScopes.PROTOTYPE)
      public MovieLister colonDelimitedMovieLister() {
            return new MovieLister(colonDelimitedMovieFinder());
      }
      
      @Bean(scope=DefaultScopes.PROTOTYPE)
      public ComplexMovieListerFactory complexMovieListerFactory() {
            return new ComplexMovieListerFactory();
      }
      
      @Bean(scope=DefaultScopes.PROTOTYPE)
      public MovieLister complexMovieLister() {
            return complexMovieListerFactory().build();
      }
}
 

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: