Skip to content

Setter Injection for Mario #3

@mpmenne

Description

@mpmenne

Hey Scott, this is something that I could have done a better job of explaining...

So one thing that Spring is really good at is setter injection. Essentially, if you create setters in your Mario class for the PrintWriter and the ScreenWriter and you add a corresponding property tag in the Mario bean; Spring will inject your classes automatically.

so instead of having to say context.getBean(.....

we could just assume that the PyramidPrintWriter is already populated when the program starts up.

something like....

will be automatically injected into

public void setPyramidFilePrinter(PyramidFilePrinter pyramidFilePrinter) {
this.pyramidFilePrinter = pyramidFilePrinter;
}

public void setPyramidScreenPrinter(PyramidScreenPrinter pyramidScreenPrinter) {
this.pyramidScreenPrinter = pyramidScreenPrinter;
}

Cheers,
Mike

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions