In this section

Site navigation below

The Code Style site has evolved by gradual refinement and accumulation of features and content. This review is part of a fully backdated site log and archive that sheds light on when, why and how particular features were implemented.

This log is sometimes updated several times per week, sometimes with a long overdue backlog of items. Many log entries refer to the Code Style Java package that delivers the servlet services and utilities used to manage this site.

Subscribe to the news feed for this log: RSS news feed

Reverse chronology

20th August 2004

Added a MINIMUM interval field of one second to the AbstractSaveSentinel class to restrict the rate at which it checks status, an ioMessage field to store any IOException messages and an exceptions counter to monitor the number of save exceptions thrown. Made the run and saved variables volatile instance fields and the save thread an instance field. Commented out the start and stop methods for later implementation, and added accessors for the new message and exceptions fields.

"Good citizen" constructor for the ResultKeyBuilder ensures basic configuration, so removed redundant hasBasicConfiguration method and simplified the isClonable and isReady methods. Added null and empty string argument checks to the various configuration methods.

Updated JavaDoc comments for the ResultCache class and added synchronized modifiers to the size and hasValue methods. Removed the stop call from the reset method.

18th August 2004

Re-packaged the AbstractParseServlet class alongside its supporting classes in org.codestyle.proxy. Concrete implementations remain in org.codestyle.servlet, since they depend on the org.codestyle.template package. Other subclasses may use non-template based implementations.

Re-structured the configuration statements in the AbstractParseServlet's getBasicConfig method to a single try block. This highlighted an inconsistency in the exceptions thrown validating system ID strings, so standardised all cases on the JAXP TransformerConfigurationException. Also added a getServiceId method.

Adjusted the constructor, newResultKey, setSystemId, validateXslSystemId and validateXmlSystemId methods of ResultKeyBuilder to throw TransformerConfigurationException instead of a SAXException. Made equivalent changes to the constructor and addTemplate method of ResultMarshaller, and modified the addTemplate method of ResultProxy to validate the XSL system ID directly.

Adjusted the getCacheKey method of AbstractParseServlet subclasses to the new TransformerConfigurationException scheme and updated their unit tests as necessary.

Simplified the load method of ResultCache further by accepting a FileNotFoundException and starting the cache empty. All other exceptions are reported up to the client application as a new IOException. Added a cache locator validation check to the public constructor whether an instance exists or not to give consistency to the API.

Extended the getCustomConfig method and instance fields of the MockParseServlet class with enough configuration to produce a real ResultKey instance if required, but also added a setCacheKey to assign one arbitrarily.

17th August 2004

Changed the handleException method of the ExceptionHandler interface to be adaptable to the RequestDispatcher forward method by adding an HttpServletRequest parameter. Adjusted the TemplateExceptionHandler class and its test suite accordingly.

16th August 2004

Moved the doGet method of the parse servlet implementations to the AbstractParseServlet class, since it is common to all, and adjusted structure of getCacheKey methods of each. Added a string constant for the service URI. Added a block to configure a TemplateExceptionHandler in the getCustomConfig method of the ParseFAQ servlet and simplified the getCacheKey method with corrections for incorrect query formatting on HTTP POST requests.

Added Hansel coverage decorators to each of the parse servlets and their respective ResultType classes and completed testing.

Made amendments to various mock objects while testing the parse servlet classes and created a new MockHttpSession to test ParseFAQ. Added a Hashtable of servlet references to MockServletContext and a mutable server information string. Added an urlSession flag and HttpSession field to MockServletResponse with mutators and accessors. Re-worked some existing methods to operate correctly with the HttpSession reference.

15th August 2004

Adjusted the mutators for the MockResultValue class to assign default modified and expiry dates if those provided are invalid, in line with the new ResultValue constructors. Updated unit tests to new fault tolerant scheme.

14th August 2004

Completed testing for the ResultMarshaller class, making various amendments in progress. Removed time and date constants, since modified and expiry values are now controlled exclusively by ResultValue. Added a catch block for RuntimeException, since the Apache XMLReader throws this type when there is an IOException on the output stream. It would seem more appropriate to throw the original IOException according to the JAXP interface, so other parsers may not behave the same way. All exceptions are wrapped in a SourceException anyway, so this case noted in JavaDoc comments with other cases for logging and reporting purposes.

Added failOnWrite and failOnClose flags to the MockServletOutputStream class to throw IOException in specific cases for ResultMarshaller testing. Also added IOException cases to MockSourceBroker, and mutators to MockResultCache for getting a "bad" output stream. The bad output can be set to fail on write or when closing the stream.

Created a MockXMLReader class to test ResultMarshaller via SAXTransformer. This class is loaded by changing the default parser specified by the system property org.xml.sax.driver and always throws a SAXException when the parse method is called.

12th August 2004

Adjusted the ResultValue constructors to assign default values if the last modified or expiry dates are invalid. Intended to be more tolerant to faults where remote Web servers' clocks or HTTP header values are incorrect. No instance can be created without valid dates, so removed validation checks from the configure method and adjusted test cases accordingly.

Added static getDefaultModified and getDefaultExpires methods to the AbstractResultValue class for use by a new fault tolerant version of ResultValue.

Created new MockSourceBroker and MockResultCache classes to provide test case conditions for ResultMarshaller testing. MockSourceBroker returns bad modification and expiry dates. MockResultCache issues MockResultValue instances and throws a CacheValueException with the getOuputStream method.

Added an overloaded isWriteableFile method to the IOUtilities class with a File argument. Also added appropriate test cases to IOUtilitiesTest.

Completed testing for the SAXTransformer class.

11th August 2004

Completed testing for the ResultCache class, with various amendments. Expanded the if/else structure of the getCacheValue method to remove redundant logic that was blocking test coverage. Added a null CacheValue check to the getOutputStream method. Removed redundant null CacheValue checks in the empty and purge methods. Added a throws IOException declaration to the private load method, private constructor and static instantiation methods for the case where there is an error closing the cache registry file. Removed the redundant null cacheLocator parameter check in the private constructor and simplified the finalize() method.

Created a new AbstractSaveSentinel class to monitor and periodically save resources, particularly for the ResultCache implementation. The only abstract method is save, which coincides with the Cache interface.

Tests for ResultCache highlighted an error in the constructor of ResultValue, where the modified parameter was being ignored and instances set with the current date. Corrected and tightened-up tests as necessary.

Added a catch block to various clients and test cases that use the ResultCache class, including AbstractParseServlet, ResultProxyTest and ResultValueTest.

Removed the MockInputStream field from MockResultValue, which was not serializable, and made the getInputStream method return a new instance directly.

Changed various unit tests and test case documents to use a standard domain for testing non-existent Web resources, www.remote.example.

10th August 2004

Completed testing the ResultProxy class. Adjusted final null reference checks before closing the input stream from the ResultValue instance. At this stage the reference is definitely not null.

Added a failOnGetOutput flag and mutator to the MockServletOutputStream class. This setting triggers an IOException with the getOutputStream or getWriter methods for testing ResultProxy.

Added a copy element to the Ant test target to copy an invalid, serialized cache registry file to test the ResultCache load method. Requires the encoding property set to UTF-8 to maintain the integrity of the object data, which is composed of classes that will cause a ClassNotFoundException when de-serialized.

9th August 2004

Adapted ResultKey to implement the new ServletCacheKey interface through its existing configure(HttpServletResponse) method.

Created a new MockInputStream class with options to trigger an IOException with read requests or on closing the stream. All other methods throw IOException in any case. Also created a basic MockResultValue class that throws an IOException with getInputStream by default, and an option to disable this behaviour to return a MockInputStream for testing.

8th August 2004

Re-factored the org.codestyle.cache and org.codestyle.proxy packages to make the ResultCache and ResultValue implementations more generic and create abstract base classes for general purposes. Extracted basic modified, expires, and systemId fields, mutators, accessors and validation methods from ResultValue to create an AbstractCacheValue class with the isFresh method and date constants. Also extracted the generic file system storage methods from ResultValue to make a general purpose AbstractFileCacheValue in a new org.codestyle.cache.store sub-package.

Added getSystemId and length methods to the top level CacheValue interface, and new CacheValue factory methods to the Cache interface, overloaded with custom modified and expiry date versions. Added generic getCacheValue methods to the Cache interface based on the former getResult methods of ResultCache. Updated ResultCache with the new interface scheme and adapted all test classes as necessary.

Adopted similar interface-based field and method naming in the ResultProxy and ResultMarshaller classes. Made the ResultMarshaller cache field and constructor argument a Cache type, even though it is necessarily a ResultCache and adapted to the new interface-based method names and local variables. Made equivalent changes to ResultProxy.

Finally, applied the new proxy and cache scheme to the parse servlet implementations by renaming the getResultKey method to getCacheKey and changing the return type to ServletCacheKey. Adjusted the doGet of each class as necessary.

7th August 2004

Added a Hansel CoverageDecorator to the ResultProxy unit test suite and added various methods to cover un-tested method branches. Firstly, created a set of mock JAXP TransformerFactory types to test all permutations of the features required to instantiate the class, specifically SAXTransformerFactory, StreamSource and StreamResult support. Each unit test temporarily changes the system property javax.xml.transform.TransformerFactory to the relevant mock object reference.

Hit a block testing the ResultProxy method handleRequest where an IOException is thrown by a ResultValue. This class was not fully encompassed by the basic CacheValue type, and all its methods were final, so it was not possible to create a suitable mock object to stand in its place. Created a ServletCacheValue sub-interface of CacheValue with configure(HttpServletResponse) method to provide a generic type for the ResultValue class. Also added equals and hashCode methods to the CacheValue interface to ensure appropriate comparison methods are implemented.

Created an equivalent ServletCacheKey sub-interface of CacheKey with its own configure(HttpServletRequest) method.

6th August 2004

Added a Hansel CoverageDecorator to the ResultValue unit test suite to check code coverage and added tests as necessary. Completed tests for ResultValue and made the setExpires and setLastModified methods throw IllegalArgumentException with invalid dates. Modified the client ResultCache class and its tests to the new scheme.

Also added a Hansel CoverageDecorator to the ResultKey unit test suite and added tests as necessary. Removed the private default constructor, since no default constructor is implied.

5th August 2004

Added a getOutputStream(CacheValue) method to ResultCache to allocate temporary cache files on behalf of ResultValue instances, and a static cacheDir field for use with this method. This removes runtime dependence on a ResultCache instance when ResultValue is de-serialized, and avoids special exception handling. Simplified the exception cases in ResultValue by removing various ObjectStateException and CacheValueException statements.

Added a setSystemId method to ResultValue so that the ResultCache can assign the cache file path when it issues an OutputStream on its behalf. Once set, the file path cannot be modified, since a temporary file is created and must be used or disposed. Also tightened-up the isStored method by checking the file length is greater than zero, and applied this to various method validation checks. Added validation checks to the setLastModified and setExpires methods. Simplified the delete method and applied more restrictive package visibility to the accessor methods that are not part of the CacheValue interface.

Completed JUnit tests for ResultValue with tests for all recent methods and amendments, including:

Added a getOutputStream(CacheValue) method to the Cache interface, and setSystemId method to the CacheValue interface to make the changes to the ResultCache system more generic.

Added a new isWriteableFile method to IOUtilities class to serve the latest version of ResultValue and renamed the isWriteableDirectory methods to match. Updated unit tests and the SaveFilePanel and TidyFile client classes with the new names.

Corrected the various get and set header methods in MockServletResponse to be case insensitive to the header names.

4th August 2004

Changed the constructor for ResultMarshaller so that XSL templates do not have to be passed all together at instantiation. Made the Hashtable of compiled JAXP Templates objects static, so that all instances share the catalogue and added an addTemplate method so they can be assigned individually.

Adapted the ResultProxy class to the new scheme with its own addTemplate method that simply calls the equivalent method in ResultMarshaller. Also adapted the AbstractParseServlet to the new ResultProxy and ResultMarshaller scheme and updated all unit tests accordingly.

Added isValidModified and isValidExpires methods to ResultValue to check date parameters.

3rd August 2004

Continued review of Code Style Java package structure and dependencies. Divided the remaining org.codestyle.xml classes between new org.codestyle.servlet and org.codestyle.proxy packages.

Assigned the XML parse servlets to org.codestyle.servlet, including:

Assigned the transformation result proxy classes to org.codestyle.proxy, including:

Introduced a new org.codestyle.broker.source sub-package for more volatile SourceBroker type implementations, FileBroker, StringBroker, TrustedHttpBroker and UntrustedHttpBroker. Removed the un-used getStreamSource method from the SourceBroker interface to remove dependency on javax.transform and carried through all implementation classes.

Re-packaged the draft request valve classes to org.codestyle.servlet, including Client, RequestException, RequestHistory, RequestValve

2nd August 2004

Reviewed Java package structure and dependencies and adjusted the layering of the Code Style Java project. Moved various SAX interface types to a new org.codestyle.sax package, including AbstractXMLReader, ReportingParseException, ResourceResolver, SAXFeatures, and StrictErrorHandler (renamed from ValidationErrorHandler). Adapted imports in clients and unit test classes as necessary.

Previously on Code Style

These backdated pages record detailed changes to the Code Style Web site since July 2000, when development first got underway. Some pages may refer to documents or features that have since changed or are no longer part of the site, but the archive is checked to ensure there are no dead links.

Add this page to your chosen social bookmarking service

Style warning - please read

Home · CSS · Java · Javascript · HTML · Help · Log