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

24rd July 2004

Added a private Thread field to ResultCache to periodically save the cache registry, and a run method to make the cache itself the Runnable instance. The private constructor initialises the thread, which is set as a daemon so that it stops when the user threads die.

23rd July 2004

Removed the validateServiceId method from ResultKeyBuilder and replaced it with simple null check in the constructor. Added a new private constructor with pre-configured, copied ResultKey argument for use by the makeClone method. The XSL system ID value passed by the clone method is validated by the public constructor, so the private constructor does not re-validate or throw a TransformerConfigurationException.

Re-structured the exceptions in the handleRequest method of ResultProxy to throw back to the client servlet for further handling. This method now distinguishes exceptions that occur before and after the HttpServletResponse is committed.

Re-structured init method of each of the parse servlet classes for more efficient error reporting.

22nd July 2004

Created a new ResultType interface, an AbstractResultType and a set of concrete implementations to replace the former SourceType class. This scheme simplifies instantiation and general usage in the parse servlet classes through concrete types TextType, JavascriptType, XhtmlType, RdfType and RssType, which issue XSL output types and HTTP Content-Type headers according to request parameters and Accept headers.

Moved the handleRequest method from the AbstractParseServlet class to ResultProxy to avoid excessive coupling in the former. Renamed initializeSourceType method in each of the parse servlet classes to assignResultType under the new scheme and adapted their doGet methods to call the ResultProxy version of the handleRequest method.

Moved the draft configureResponse methods from AbstractParseServlet to ResultKey and ResultValue respectively. Both take an HttpServletResponse argument and configure its HTTP headers according to their own properties. The ResultValue assigns the Content-Length, Last-Modified and Expires headers. ResultKey initially assigns Content-Type.

Re-instated the getLastModified method in the parse servlets, which now get a ResultKey and return the modified date of its ResultValue pair. Normally, the ResultValue will be called from the cache, but this call will generate a fresh result if required.

Changed ResultKeyBuilder to throw IllegalArgumentException in the case of null constructor arguments rather than the JAXP TransformerConfigurationException.

Changed the name of the ExceptionHandler interface and TemplateExceptionHandler class to avoid clashes with the JAXP ErrorHandler interface. Updated all parse servlet clients accordingly.

Created a SAXFeatures class of string constants for SAX parser features (see SAX Features and Properties), particularly XML validation.

Marked the original parse servlet helper class ParseHandler deprecated, since it is no longer used under the new ResultProxy scheme.

21th July 2004

Added an ExceptionHandler and serviceId assignment to the getCustomConfig method of each of the parse servlet classes. These implementations take a DocumentTemplate-based TemplateExceptionHandler.

Re-structured the ViewSource servlet to separate request validation from output processing. Identified a problem handling CSS and Javascript content types with the latest version of HttpRequest, which did not explicitly permit the HTTP Content-Type headers for these types. Added text/css and application/x-javascript to the permitted types array and made a set of unit tests and test files for ViewSource to verify all permutations.

Adjusted HttpRequest to throw an IOException for bad response types, except where the HTTP If-Modified-Since header has been set and a 304, not modified, response is received. Updated unit tests accordingly.

20th July 2004

Re-factored the parse servlets implementation, firstly to make a clear split between final and abstract methods so the implementation of existing subclasses is exclusively handled via abstract methods. Introduced new getCustomConfig and getBasicConfig methods to standardise the initialisation process. Then adapted the set to work with the new ResultProxy system, including the addition of a serviceId field and a new ErrorHandler type field to handle exceptions without the former dependence on the DocumentTemplate class and package. Added a new abstract getResultKey method and separate configureResponse methods for a ResultKey and a ResultValue.

Carried through the new AbstractParseServlet scheme in each of its subclasses with a doGet method that initially calls an adapted version of the original handleRequest method. Added a getCustomConfig method to each and a getResultKey method based on the former setParameters method.

Added a new encodeURL method to the ServletUtilities class, which uses reflection to invoke the appropriate HttpServletResponse URL encoding method for re-writing session ID values. This method provides backward compatibility with the servlet 2.0 API implementation, encodeUrl, and gives preferential support for the 2.1 API method, encodeURL, without deprecation warnings.

Created a MockServlet21Response class with a distinct encodeURL method to test the new method, and adjusted the superclass MockServletResponse to distinguish calls to its deprecated encodeUrl method. Added JUnit test cases for calls to the appropriate versions of these methods in the new ServletUtilities method.

Renamed the original ErrorHandler class to TemplateErrorHandler to implement the new ErrorHandler interface. Modified the constructor to take a DocumentTemplate only, and the handleError method to take the servlet response and the Throwable instance.

Completed testing of the SiteMap class for the remaining link navigation types up, section and bookmark. Finally, modified all session encoding in the class to call the new ServletUtilities encodeURL method.

Added a String constant to the Document class for the XHTML link type bookmark.

19th July 2004

Extended the SiteMap class to render DC.Rights metadata and generic copyright type links, with new methods for rendering special link types in sibling documents. Also separated handling of DC.isPartOf and DC.hasPart relations to a new renderTypes method, with generic section, up and bookmark navigational links. Re-factored several other methods to clarify the relational logic amongst sections, target and sibling documents to reduce the complexity of main renderMetadata method.

Added further String constants to the Document class to signify XHTML link types previous, next, first, last, up and section, for use by SiteMap. Corrected a duplicate index type document in the test case configuration file.

Implemented the encodeUrl method in the MockHttpServletResponse class, to test SiteMap, and added a constructor to assign a session ID and request URL-rewriting.

18th July 2004

Corrected handling of exceptions in the ResultMarshaller class to ensure that the new ResultValue file is deleted if there is a problem transforming the XML source. Also isolated handling of SourceException cases from transformation exceptions.

Completed the initial implementation of the Document class with the addition of String constants for XHTML link types: appendix, contents, copyright, help and glossary. These identifiers are used for validation in the setSpecialType method.

Completed testing for the new Section class and added basic navigational link handling to the SiteMap class, with a general purpose getLinkElement method.

17th July 2004

Developed unit tests to verify Dublin Core metadata rendering in the SiteMap class, including cases for DC.Title, DC.Subject, DC.Identifier, DC.tableOfContents, DC.isPartOf and DC.hasPart relations. Corrected various methods as necessary and added JavaDoc specifications in parallel to baseline the implementation.

Re-packaged the recent SiteMap implementation classes in a new org.codestyle.site package so that clients are not dependent on the org.codestyle.template package. These packages are initially independent of each other, but the template and org.codestyle.xml packages are likely to make use of the SiteMap implementation in future.

Removed the generic renderMetadata methods from AbstractSiteNode and its SiteNode interface. Rendering is now controlled by the SiteMap class so that Document and Section classes do not need to know about metadata schemes and XHTML markup. Completed unit tests on the Document class.

16th July 2004

Refactored handling of document metadata in the SiteMap hierarchy by breaking down its single entry point method with several simpler supporting methods. Implemented rendering of DC.Subject, DC.Title, DC.Identifier, DCTERMS.hasPart and DCTERMS.isPartOf through various parent, grandparent and child relations from a single target document reference.

Moved the string constants and methods for building XHTML meta elements from the AbstractSiteNode class to SiteMap, which requires control over metadata generation. Removed calls to these metadata methods in the concrete Document and Section subclasses.

Developed an XML SiteMap configuration test file to test site node relations, rather than construct complex object structures manually, and added SiteMapTest cases for the new Dublin Core metadata relations. Removed equivalent tests from SectionTest, since awareness of and responsibility for metadata schemes has been lifted from the Section class.

Moved the setParent method stub from SiteNode to the primary Node interface and added a new getParent method. Changed to generic Node type references and modified the size method to return -1 if the node is not a node container, e.g. a Document. Also renamed the addNode method in the ParentNode interface to addChild and added a getChildren method.

15th July 2004

Added an overloaded newBroker instance method to SourceBrokerFactory that takes only an InputKey type for HTTP source that is known to be un-trusted. Extracted the generic code from the original newBroker method and created a private instance method that takes an InputKey and a verified serviceHost reference from the two public versions. The single argument version passes an implicit UNTRUSTED constant. Created new JUnit test cases for these new methods.

Added a private boolean field and mutator to the MockServletOutputStream class to request an IOException when the write methods are called.

Removed redundant resultRow field and columnCount argument from the DBResults constructor, which can be deduced from the column names String array.

14th July 2004

Broke-down the ResultProxy class to reduce complexity and coupling by creating new ResultMarshaller and SAXTransformer classes. ResultMarshaller downloads and prepares fresh XML source where necessary and selects the appropriate XSL transformer from a set of compiled JAXP Templates objects. The SAXTransformer has a single public transform method that processes an XML InputSource to a ResultStream using a TransformerHandler and EntityResolver. The internal Transformer and XMLReader instances are configured according to a ResultKey object specification.

Added a "Good Citizen" constructor to the cached ResultValue class with modified and expires arguments.

13th July 2004

Renamed all abstract classes with an "Abstract" prefix, which highlighted some cases where abstract classes were serving as interfaces. In particular, re-cast DocumentTemplate as an interface and various other package hierarchies as true interfaces. DocumentTemplate extends Presentable, and Navigable and adds the getContentType method, AbstractXhtmlTemplate and ErrorTemplate now implement DocumentTemplate and extend AbstractContent directly.

Re-cast SourceBroker as an interface and adjusted former sub-classes to implement it, which only required changes to their signatures.

Re-cast Cache, CacheKey and CacheValue as interfaces and moved the purge method implementation from Cache to ResultCache. Adjusted all interfaces and classes in this package to implement Serializable directly. Adapted the concrete ResultCache, ResultKey and ResultValue classes to implement these interfaces, and simplified the equals method of ResultKey by comparing hash code values rather than making a field by field comparison.

Re-cast Sample and Sequence as interfaces and renamed AbstractSample and AbstractSequence to take on board some of their former concrete methods. Simplified the class hierarchies in both cases and removed a superfluous abstract class ViewableContent. The abstract classes now extend AbstractContent directly and implement the relevant interface.

Simplified the ParseFAQ servlet's setParameters method by creating a new setSessionParameters method. Adjusted ResourceResolver to implement Serializable directly.

Simplified the getParametersTable method in AbstractXhtmlTemplate by breaking-out the case where multiple parameters are present to a new getMultiRows(String[] paramValues) method and added a getSingleRow(String[] paramValues) method to complement it. Also simplified CodeStyleTemplate by making use of these methods.

Added missing JavaDoc @param statements to all classes where they had been omitted.

12th July 2004

Re-packaged the new Node, ParentNode, XmlSerializable and XmlSerialObject classes in a new org.codestyle.data package to avoid cyclic dependencies between org.codestyle.template and org.codestyle.xml. Also created a general purpose InputKey interface to obtain SourceBroker instances instead of CacheKey instances to de-couple org.codestyle.broker and org.codestyle.cache.

Created a SimpleKey implementation of the InputKey interface to use with SiteMap to obtain a SourceBroker.

Removed the redundant siteName and baseUrl fields from AbstractSiteNode. The SiteMap class is responsible for building absolute URLs from Document references.

Added JavaDoc @exception statements to all classes where they had been omitted.

10th July 2004

Added a directory copy to the Ant build file to move test SiteMap configuration files.

9th July 2004

Added siteName, baseUrl and parentNode fields to the AbstractSiteNode class with mutator methods for each, and a stub for the renderDCSubjectMetadata(Writer out) method. Added a findNode method to the Node interface to locate nodes in a hierarchy by a unique identifier.

8th July 2004

Created a new interface and abstract class superstructure for the recent SiteMap implementation. The XmlSerializable interface signifies an object that can be loaded from an XML source, analogous to the java.io.Serializable interface. The Node interface represents an XML element node in such an object and includes a self-validation method. The ParentNode sub-interface extends Node and has a method for adding child nodes.

Added self-validation methods to the concrete Document and Section classes to fulfil the SiteNode interface and changed Section to implement the ParentNode sub-interface.

Created an abstract XmlSerialObject base class using generic methods extracted and adapted from the draft SiteMap implementation, and added a concrete getRootNode method. Also added a registerNode template method to handle the addition of a Node according to type, and implemented this in SiteMap by setting references to the site name and base URL.

Completed adjustments to the length of field and local variable names throughout the Code Style Java project.

7th July 2004

Re-wrote the draft Section class originally created in May 2003 to follow the new SiteMap element structure through the SiteNode interface and AbstractSiteNode class. Added concrete implementations of the getTitle and getSubject methods to AbstractSiteNode to fulfil new stubs in the SiteNode interface.

Added a renderDCSubjectMetadata(Writer out) method to the SiteNode interface to add Dublin Core subject meta elements to a character stream. Implemented this method in the Document and Section classes with recursive calls to their parent nodes. A Document instance thereby shares the subject associated with each of the parent sections to which it belongs.

Created a new NetUtilities class to make the validateSystemId method from ResultKeyBuilder more generally available. Adapted the method to throw more generic MalformedURLException and IOException instances.

Added a reference to SiteMap.xml to the servlet container configuration and Ant build file for unit testing.

Conducted a review of field and local variable names using PMD and adjusted to between 3 and 12 characters in length wherever necessary. Corrected various other issues highlighted by the review. Identified and removed an un-used column count parameter in the DBResults constructor. Removed a Boolean instantiation in the setFeature method of AbstractXMLReader. Added accessor methods for the fields of the private Entry class in StylesheetCache.

6th July 2004

Wrote a new draft SiteMap class to de-serialize the SiteMap.xml scheme, and a Document class implementation of the SiteNode interface.

5th July 2004

Wrote a SiteNode interface and AbstractSiteNode based on the new draft SiteMap XML structure.

4th July 2004

Added a unit test for a pre-existing HttpSession in the setParameters method of the ParseFAQ servlet. If a session is being maintained by URL-rewriting, this method passes a session-id parameter to the stylesheet to add to all navigational hyperlinks.

Created a first draft SiteMap.xml and SiteMap.dtd to store site metadata that can be de-serialized into a Java object.

Re-named FAQ.dtd to upper case and finalised the Document Type Declaration accordingly.

2nd July 2004

Added output of server name and version information to the Diagnostic servlet.

1st July 2004

Wrote a basic servlet for setting up an HttpSession and generating session-encoded hyperlinks to test the ParseFAQ servlet and XSL stylesheet. Applies URL-rewriting to links to check subsequent handling by servlets and JSP.

Created a minimal draft ParseFAQTest class for further unit testing and made some minor adjustments to the MockServletRequest class to prepare to add a MockHttpSession to the set.

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