public class PrintService { static PrintService singleton; Printable target; public PrintService getPrintService() { return singleton; } public void setTarget(Printable p){ target = p; } public void doPrint() { // set stuff up // print target } }
Example 2: Typical print service in an application.