package org.qi4j.library.struts2.support.list;

import com.opensymphony.xwork2.ActionSupport;
import org.qi4j.api.injection.scope.Structure;
import org.qi4j.api.injection.scope.This;
import org.qi4j.api.query.QueryBuilder;
import org.qi4j.api.query.QueryBuilderFactory;
import org.qi4j.api.unitofwork.UnitOfWork;
import org.qi4j.api.unitofwork.UnitOfWorkFactory;
import static org.qi4j.library.struts2.util.ParameterizedTypes.findTypeVariables;

public abstract class ProvidesListOfMixin<T> extends ActionSupport implements ProvidesListOf<T>
{

    @This ProvidesListOf<T> action;
    @Structure UnitOfWorkFactory uowf;

    Iterable<T> results;

    public Iterable<T> list()
    {
        return results;
    }

    /**
     * This is where we'll load the list of entities.  Not because it is any better than the execute() method, I
     * would actually prefer doing it in the execute method.  But since these list actions can be the target
     * of redirects after errors, actionErrors may not be empty which would mean execute() would never get called.
     * One way around this would be to have a different interceptor stack just for these list actions that doesn't
     * do validation, but for now we'll just use the prepare() method.  We can change it easily enough later if this
     * becomes an issue for some reason.
     */
    public void prepare() throws Exception
    {
        UnitOfWork uow = uowf.currentUnitOfWork();
        QueryBuilderFactory qbf = uow.queryBuilderFactory();
        QueryBuilder<T> qb = qbf.newQueryBuilder( typeToList() );
        results = qb.newQuery();
    }

    private Class<T> typeToList()
    {
        return (Class<T>) findTypeVariables( action.getClass(), ProvidesListOf.class )[ 0 ];
    }
}
@@ -419,33 +419,17 @@
 edTypes.
-findTypeVariables
+*
 ;%0A%0Apubli
@@ -596,16 +596,56 @@
 ry uowf;
+%0A    @Structure QueryBuilderFactory qbf;
 %0A%0A    It
@@ -1382,16 +1382,24 @@
 repare()
+%0A       
  throws 
@@ -1408,16 +1408,16 @@
 ception%0A
-
     %7B%0A  
@@ -1469,69 +1469,8 @@
 ();%0A
-        QueryBuilderFactory qbf = uow.queryBuilderFactory();%0A
     
@@ -1531,16 +1531,16 @@
 st() );%0A
-
         
@@ -1561,16 +1561,21 @@
 ewQuery(
+ uow 
 );%0A    %7D

Make it compilable after chnages related to QBF in core