Doesn't appear much has changed on the RequestFactoryGenerator in the
final release from RC1.  I ended up having to do a copy of
RequestFactoryGenerator and change AllReachableTypesVisitor to be:
private static class AllReachableTypesVisitor extends
RequestMethodTypesVisitor {

                private final RequestFactoryModel model;

                List<HasExtraTypes> visitedTypes = new 
ArrayList<HasExtraTypes>();

                public AllReachableTypesVisitor(RequestFactoryModel model) {
                        this.model = model;
                }

                @Override void examineTypeOnce(JClassType type) {
                        // Need this to handle List<Foo>, Map<Foo>
                        JParameterizedType parameterized = 
type.isParameterized();
                        if (parameterized != null) {
                                for (JClassType arg : 
parameterized.getTypeArgs()) {
                                        this.maybeVisit(arg);
                                }
                        }
                        JClassType base = ModelUtils.ensureBaseType(type);
                        EntityProxyModel peer = this.model.getPeer(base);
                        if (peer == null) {
                                return;
                        }
                        peer.accept(this);
                }

                @Override public boolean visit(ContextMethod x) {
                        if (!this.visitedTypes.contains(x)) {
                                this.visitedTypes.add(x);
                                System.out.println("Visiting extra types for: " 
+
x.getQualifiedSourceName());
                                this.visitExtraTypes(x);
                        }
                        return true;
                }

                @Override public boolean visit(EntityProxyModel x) {
                        if (!this.visitedTypes.contains(x)) {
                                this.visitedTypes.add(x);
                                System.out.println("Visiting extra types for: " 
+
x.getQualifiedSourceName());
                                this.visitExtraTypes(x);
                        }
                        return true;
                }

                @Override public boolean visit(RequestFactoryModel x) {
                        if (!this.visitedTypes.contains(x)) {
                                this.visitedTypes.add(x);
                                System.out.println("Visiting extra types for: " 
+
x.getFactoryType().getQualifiedSourceName());
                                this.visitExtraTypes(x);
                        }
                        return true;
                }

                void visitExtraTypes(HasExtraTypes x) {
                        if (x.getExtraTypes() != null) {
                                for (EntityProxyModel extra : 
x.getExtraTypes()) {
                                        System.out.println("Accepting type: " +
extra.getQualifiedSourceName());
                                        extra.accept(this);
                                }
                        }
                }
        }

The problem seems to be that somehow a type will get itself as an
extraType and so it gets into an infinite loop where it visits itself
when it's mentioned in an @ExtraTypes from a superclass.  To make it
not do that, I have it keep track of what ones it has already
visited.  Annotating the superclass seems to be the only way to make
its subclasses available, but it also causes the infinite loop by
default.  I have a few places in my code where I have proxies that
reference a superclass proxy that is for an abstract domain class and
will be assigned with a proxy subclass, but that failed until I added
them in @ExtraTypes to the superclass proxy.  It seems that
polymorphism in RequestFactory at the moment automatically takes care
of making sure superclass proxies are available, but it doesn't take
care of subclasses that are assignable to a proxy.

On Sep 8, 4:25 pm, Y2i <yur...@gmail.com> wrote:
> I also have @ExtraTypes on RF due to stack overflow in RC.  Haven't tried
> yet in the release.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to