Developing components
Developing components
Understanding component design
A typical component contains four classes:
•
Service interface—This defines the contracts for the service implementation class and serves as a property type
for the bean implementation class.
•
Service implementation—This implements service interface class.
•
Bean interface—This sets properties for the bean implementation class.
•
Bean implementation—This implements the bean interface and calls the methods of the service implementation
class.
Best practices for component design
•
Implement a standard JavaScript component interface:
–
Implement the new operator to create instances of the component.
–
Use uppercase letters for constants.
–
Define all constants as children of the component class.
–
Implement the setInput method, and accept an array where appropriate.
–
Implement the result field, and return an array where appropriate.
•
Each method is automatically logged to the confirmation page when called. Use
com.lexmark.workflow.framework.annotation.ConfirmBeanMethodLoggingOverride to
hide methods or arguments that should not appear in the confirmation page, such as passwords:
–
To prevent a method from appearing at all on the confirmation page, add
@ConfirmBeanMethodLoggingOverride(hide=true) before the method declaration.
–
To prevent only the arguments of a method from appearing on the confirmation page, add
@ConfirmBeanMethodLoggingOverride(hideArguments=true) before the method declaration.
The arguments are replaced with the text <hidden‑args> on the confirmation page.
•
Log all activity using the Apache log4j framework, using the following levels:
–
ERROR—Fatal errors, such as system failures
–
WARN—Non‑fatal errors, such as script exceptions
–
INFO—Diagnostic information, such as progress or status
–
DEBUG—Debugging information
•
Handle script errors by throwing exceptions. Avoid catching exceptions within the component.
•
Use com.lexmark.workflow.framework.service.temporaryFile.TemporaryFileService
for output files and temporary files.
•
Add a new bean, xxxVersionBean, in applicationContext.xml to show the version number of the component in
LMC.
70