Lexmark X925 Lexmark Document Distributor - Page 70

Developing components, Understanding component design, Best practices for component design

Page 70 highlights

Developing components 70 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 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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82

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.
Developing components
70