package org.togglz.spring.spi;

import org.springframework.context.ApplicationContext;
import org.togglz.core.spi.BeanFinder;

import java.util.ArrayList;
import java.util.Collection;

public abstract class AbstractSpringBeanFinder implements BeanFinder {

    protected abstract ApplicationContext getApplicationContext(Object context);

    @Override
    public <T> Collection<T> find(Class<T> clazz, Object context) {

        Collection<T> result = new ArrayList<T>();

        ApplicationContext applicationContext = getApplicationContext(context);

        if (applicationContext != null) {
            result.addAll(applicationContext.getBeansOfType(clazz).values());
        }

        return result;

    }

}

@@ -560,10 +560,13 @@
     
-if
+while
  (ap
@@ -671,16 +671,81 @@
 ues());%0A
+            applicationContext = applicationContext.getParent();%0A
         

FIX #251 - include parent contexts when looking for a bean (#252)