refactor java backend to use more dependency injection

**please review**
This is a standard pattern for resolving circular dependencies: Definition
-> IndexingTable -> Definition in this case. If you have a suggestion for
how to completely eliminate the cycle, that would be better though.
On Aug 21, 2014 4:36 PM, "Cosmin Radoi" <notifications@github.com> wrote:

> In
> src/javasources/KTool/src/org/kframework/backend/java/indexing/IndexingTable.java:
>
> > @@ -31,8 +36,20 @@
> >      private List<Rule> unindexedRules;
> >      private final Definition definition;
> >
> > -    public IndexingTable(Definition definition) {
> > -        this.definition = definition;
> > +    private final Data data;
> > +
> > +    @Singleton
> > +    public static class Data implements Serializable {
> > +        public final TopIndex TOP_INDEX = new TopIndex();
> > +        public final IndexingPair TOP_INDEXING_PAIR = new IndexingPair(TOP_INDEX, TOP_INDEX);
> > +        public final BottomIndex BOTTOM_INDEX = new BottomIndex();
> > +        public final IndexingPair BOTTOM_INDEXING_PAIR = new IndexingPair(BOTTOM_INDEX, BOTTOM_INDEX);
> > +    }
> > +
> > +    @Inject
> > +    public IndexingTable(Provider<Definition> definition, Data data) {
> > +        this.definition = definition.get();
>
> why is a Provider<Definition> needed here? I guess you will have to
> decide on a Definition when there is more than one loaded. But how that
> the provider help here considering the Definition is simply .get()?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/kframework/k/pull/862/files#r16570784>.
>