3.1: Explain the problems associated with instantiating classes directly.
3.2: Rewrite the calculator component from Chapter 2 to use factories instead of direct class instantiations .
3.3: The calculator component has extensions, as created in the previous chapter. The extensions were hard-coded using strings in a class file. Change the extension to be a service that is discovered using the Discovery package. Ideally, the administrator should be able to define which extension the calculator loads.
3.4: Create a batch file extension to the calculator. For the time being, the file contains an integer number on a line, where each file can have multiple lines. The extension would be able to open the file and add each number, and the result would be a running total. The extension is used by the calculator component by having a user type in the filename, which is passed to the extension for further processing. The challenge in this part of the exercise is how to extend the calculator to accept letters and not just numbers . The batch file extension starts another Java process using the Launcher package, which adds the numbers and returns a result. How the result is communicated back to the original calculator process is left up to the programmer.