ComplexMovieListerFactory Class – Spring Java

package moviefindertest.springxml;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.ListableBeanFactory;

public class ComplexMovieListerFactory implements BeanFactoryAware {
      private ListableBeanFactory beanFactory;

      public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
            this.beanFactory = (ListableBeanFactory)beanFactory;
      public MovieLister build()
            Map<String, Movie> allMovies = beanFactory.getBeansOfType(Movie.class);
            List<Movie> movies = new ArrayList<Movie>();
            for(Movie movie : allMovies.values())

            ComplexMovieFinder complexMovieFinder = new ComplexMovieFinder();
            MovieLister complexMovieLister = new MovieLister(complexMovieFinder);
            return complexMovieLister;


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s