Programming Guides › Connector Programming Guide › Writing Scripts › Implementing in Java or JavaScript Considerations
Implementing in Java or JavaScript Considerations
Deciding to implement in Java or JavaScript encompasses a number of considerations:
- Almost anything that can be implemented in Java can be implemented in JavaScript, therefore, the relative power of each approach is not alarge consideration. In particular, note that the CA IAM CS scripting support allows streaming of search results through the use of the searchResultsBlockingQueue scripting variable. The SDKSCRIPT connector demonstrates this.
- Scripting languages tend to speed up the edit and test cycle as no recompilation or CA IAM CS restarts are required when JavaScript code is changed. However, they are much less strict in their type safety checking, so thorough testing is the only way to find the bugs that a Java compiler would pick-up at build time. Therefore, scripting is perfect for minor customizations or proof of concepts, but for larger production connectors, consider Java.
- As the Rhino 1.7R1 JavaScript engine used by CA IAM CS does not support embedded debugging, the primitive approach of using trace messages is the only option available to debug your scripts at this time. This approach can prove prohibitive if your scripts become too long and complicated, unless they are composed of sections of script that have already been independently tested and verified.
- Where minor customer-specific customizations of an existing connector are the focus, scripted opbindings are a good option.
- If most of the logic for a connector depends on fairly simple textual manipulation, consider using scripts. For example, preparing specially formatted arguments to be passed as command-line arguments to existing native endpoint system executables.
- If the customizations are more far-reaching, then writing a custom connector derived from the classes of the existing connector is easy to achieve using the CA IAM CS framework. Writing a few specialized classes and referencing their names in a new connector.xml can be all that is required. In such circumstances, implementation code can be shared even if a different LDAP schema is used for the new specialized connector. This is the concrete benefit of referencing only connector terminology attribute names in connector code.
- There is a slight performance cost to using scripts compared to Java code. However the cost is minimal as CA IAM CS helps ensure that scripts are only compiled once and maintained in a pool for fast reuse. Of more concern is that the loose type-checking in most scripting languages (including JavaScript) can mean that problems picked up by the compiler in Java are only discovered later during execution.
- You can start a connector as a scripted solution and later migrate it to Java. For example, if the connectors code grows beyond initial expectations and becomes hard to maintain and or nonperformant.
Important! Pay careful attention to XML quoting issues so that scripts are not corrupted when they are included as fields within an opbindings XML metadata document. To avoid script corruption, use CDATA sections as demonstrated in sdkscript_opbindings.xml. If for some reason you cannot use CDATA sections, then use the correct quoted characters in your script text instead. For example, replace < characters in a script with < when the script is included in an XML document.
Note: The scripting language supported for CA IAM CS is JavaScript as provided by the Rhino opensource project, which Sun Microsystems bundle with JDK 6 onwards. For more information, see the Rhino opensource project at http://www.mozilla.org. The version used by JCS 1.7R1 is later than the bundled version (1.6R2), as the bundled version is deficient in regards to exceptions thrown from your JavaScript scripts.
Note: CA IAM CS uses Rhino to handle JavaScript. Rhino 1.6R2 is included with JDK 6, but CA IAM CS requires Rhino 1.7R1. For more information, see the Rhino project at http://www.mozilla.org.
Copyright © 2013 CA.
All rights reserved.
|
|