Threading and ReuseIsight attempts to make efficient use of component code. Component runtime classes can be “reused” from one execution of the component to another, rather than creating a new instance each time. When executing parallel models or multiple models at the same time, the system may create multiple instances of such a component and reuse each one as demand for execution requires. For components that use JNI code, issues of reuse and threading extend into the native code. It can be difficult to build native code that is thread-safe and reusable unless the code was originally designed with those goals. Writing thread-safe and serially reusable code is beyond the scope of this document. Selection of the proper reusePolicy and maxConcurrent properties of your component is important to match with the capabilities of the native code. Component StructureProper structuring of a component and separation of the JNI part from the rest of the component can help to minimize many of the issues related to Java JNI technology. This section describes how to structure a component so that native code limitations are minimized. Separate the component into three distinct parts.
Component Structure
The main component code and the JNI wrapper should be built separately and placed into separate JAR files. The native code should be compiled and linked into a native library file (e.g,. DLL, SO, etc.). The component descriptor will list two dependencies: the Java wrapper JAR file and the native library file. The wrapper reference should be defined to use the shared loader option so that multiple instances of the component can use the same wrapper and native code. The component descriptor XML should be something similar to the following: <Requires> <!-- Java wrapper for native code --> <Reference name="mycomp.mywrapper" version="1.0.*" type="jar" sharedloader="true"/> <!-- Native code library --> <Reference name="mycomp.native.{platform}" version="1.0.*" type="library" libname="mylib"/> </Requires> Before the component is published to the library, the referenced files should be published. For example, from the command-line client: publish file:mywrapper.jar type:jar name:mycomp.mywrapper version:1.0.0 acl:#,AL,U,*,RE,U publish file:mylib.dll type:library subtype:win32 name:mycomp.native.win32 version:1.0.0 acl:#,AL,U,*,RE,U Next, publish the component. The descriptor XML in the component JAR file contains the name, version, and other details, as a result you do not need to specify them on the publish command: publish file:mycomp.jar type:metamodel acl:#,AL,U,*,RE,U |