我有一些代码如下:
public class ConsignmentChartsController extends DefaultWidgetController {
@Autowired
private PieChartRenderer pieChartRenderer;
}
public interface PieChartRenderer {
void render(Charts chart, final Map<String, Number> chartData);
}
public class DefaultPieChartRenderer implements PieChartRenderer {
@Autowired
private List<ChartColor> colors;
...........
@Required
public void setColors(final List<ChartColor> colors) {
this.colors = colors;
}
}
public enum ChartColor {
PURPLE() {
@Override
public Color getColor() {
return (new Color("rgba(218,114,218,1)"));
}
},
BLUE() {
@Override
public Color getColor() {
return (new Color("rgba(114,166,218,1)"));
}
},
public abstract Color getColor();
}
我想在spring.xml
文件中定义这些bean。如何定义ChartColor
bean然后将其注入DefaultPieChartRenderer
,并定义DefaultPieChartRenderer
bean并注入ConsignmentChartsController
?