Modular Code Generation via SAX Introspection
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current code generation methods for large projects, such as Enterprise Java Beans, are cumbersome and costly, making it difficult to find errors and modify code efficiently, especially in modular and complex systems like application servers.
Innovation Solution
A modular code generation approach using the Simple API for XML (SAX) to introspect compiled files, generate markup language descriptions, create event handlers, and parse these descriptions to generate output code, allowing for parallel processing and easier maintenance.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If traditional code generation methods using printout statements are used to generate complete files at once, then code generation can be implemented for small projects, but the process becomes unwieldy and expensive for large projects
Solution Approach 1:
The code generation process is divided into separate event handler classes, each responsible for generating specific portions of code. Instead of generating complete files at once, the system processes code generation in modular segments through multiple event handlers that can be independently maintained and executed.
2Ease of operation
If traditional code generation methods are used, then code can be generated for small projects, but tracking down errors and making modifications becomes difficult and time-consuming
Solution Approach 1:
By organizing code generation into separate event handler classes, each handling specific code segments, the system enables targeted error tracking and modification. Developers can locate and fix issues in specific handler classes rather than searching through large monolithic code generation processes.
Solution Approach 2:
The modular event handler structure provides implicit feedback mechanisms where each handler can be independently tested and validated. This allows for easier identification of where errors occur in the code generation process and enables targeted corrections without affecting other parts of the system.
3Adaptability or versatility
If traditional code generation methods are used, then existing code can be maintained, but adapting to new generation requirements becomes slow and expensive
Solution Approach 1:
The system structures code generation into independent event handler classes that can be individually modified to accommodate new requirements. This modular architecture allows the code generation process to adapt to changing needs by updating specific handlers rather than rewriting entire code generation systems.
Solution Approach 2:
The event handler architecture enables dynamic adaptation where new handlers can be added or existing ones modified based on evolving generation requirements. The system can dynamically adjust its code generation behavior by invoking different combinations of event handlers based on the specific requirements of the project.
Data Source
AI summary
A system and method for generating code that reduces the cost for large projects and that provides easier and quicker ways of finding errors and making modifications is disclosed. A method of generating code to be deployed in an application server comprises the steps of receiving an archive file to be deployed, introspecting an input class included in the archive file to generate information relating to the input class, generating a markup language description of the input class based on the generated information relating to the input class, creating an event handler for a method node found in the markup language description, registering the event handler, parsing the markup language description and invoking the registered event handler, and generating output code using the invoked event handler.


