How to Assemble a Custom Adapter in its Own Bundle

Assembling and Deploying Oracle CEP Applications 24-19 Example 24–1 bundler.sh Command Line Options bundler -source JAR -name NAME -version VERSION [-factory CLASS+] [-service INTERFACE+] [-fragmenthost HOST] [-stagedir PATH] [-targetdir PATH] [+import PACKAGE|REGEX+] [-imods REGEX;MODS+] [-import PACKAGE+] [+export PACKAGE|REGEX+] [-emods REGEX;MODS+] [-dimport PACKAGE+] [-explode] [-verbose] Table 24–3 bundler.sh Command Line Options Argument Description -source JAR The path of the source JAR file to be bundled. -name NAME The symbolic name of the bundle. The root of the target JAR file name is derived from the name value. -version VERSION The bundle version number. All exported packages are qualified with a version attribute with this value. The target JAR file name contains the version number. -factory CLASS+ An optional argument that specifies a space-delimited list of one or more factory classes that are to be instantiated and registered as OSGi services. Each service is registered with the OSGi service registry with name -name and version -version properties. This argument is incompatible with the -fragmenthost argument. -service INTERFACE+ An optional argument that specifies a space-delimited list of one or more Java interfaces that are used as the object class of each factory object service registration. If no interface names are specified, or the number of interfaces specified does not match the number of factory classes, then each factory object will be registered under the factory class name. -fragmenthost HOST An optional argument indicating that the resultant bundle is a fragment bundle and specifies the symbolic name of the host bundle. This argument is incompatible with the -factory argument. -stagedir PATH An optional argument that specifies where to write temporary files when creating the target JAR file. Default: .bundler.tmp -targetdir PATH An optional argument that specifies the location of the generated bundle JAR file. Default: current working directory .. +import PACKAGE|REGEX+ A space-delimited list of one or more packages or regular expressions that select the packages to exclude from the manifest Import-Package attribute. By default, all dependent packages will be imported except java.. -imods REGEX;MODS+ The import modifiers will be applied to the packages matching regular expression. -import PACKAGE Additional packages to include on the manifest Import-Package attribute. Note that any specified import modifiers will not be applied. +export PACKAGE|REGEX+ A space-delimited list of one or more packages or regular expressions that select the packages to exclude from the manifest Export-Package attribute. By default, all bundle packages will be exported. -emods REGEX;MODS+ The export modifiers will be applied to the packages matching regular expression. -dimport PACKAGE+ Packages to include on the manifest DynamicImport-Package attribute. 24-20 Oracle Complex Event Processing Developers Guide Example 24–2 shows how to use the bundler.sh to create an OSGi bundle for an Oracle JDBC driver. Example 24–2 Using the Bundler Utility bundler.sh \ -source C:\drivers\com.oracle.ojdbc14_11.2.0.jar \ -name oracle11g \ -version 11.2.0 \ -factory oracle.jdbc.xa.client.OracleXADataSource oracle.jdbc.OracleDriver \ -service javax.sql.XADataSource java.sql.Driver \ -targetdir C:\stage The source JAR is an Oracle driver located in directory C:\drivers. The name of the generated bundle JAR is the concatenation of the -name and -version arguments oracle10g_11.2.0.jar and is created in the C:\stage directory. The bundle JAR contains the files that Example 24–3 shows. Example 24–3 Bundle JAR Contents 1465 Thu Jun 29 17:54:04 EDT 2006 META-INFMANIFEST.MF 1540457 Thu May 11 00:37:46 EDT 2006 com.oracle.ojdbc14_11.2.0.jar 1700 Thu Jun 29 17:54:04 EDT 2006 combeacoretoolsbundlerActivator.class The command line options specify that there are two factory classes that will be instantiated and registered as an OSGi service when the bundle is activated, each under a separate object class as Table 24–4 shows. Each service registration will be made with a name property set to oracle11g and a version property with a value of 11.2.0. Example 24–4 shows the Oracle CEP server log messages showing the registration of the services. Example 24–4 Service Registration Log Messages ... INFO: [Jun 29, 2006 5:54:18 PM] Service REGISTERED: { version=11.2.0, name=oracle11g, objectClass=[ javax.sql.XADataSource ], service.id=23 } INFO: [Jun 29, 2006 5:54:18 PM] Service REGISTERED: { version=11.2.0, name=oracle11g, objectClass=[ java.sql.Driver ], service.id=24 } INFO: [Jun 29, 2006 5:54:18 PM] Bundle oracle11g STARTED ...

3. Copy the application library JAR to the appropriate Oracle CEP server application

library directory: -explode This optional flag specifies that the content of the source JAR should be exploded into the target JAR file. By default, the source JAR is nested within the target JAR file and the generated bundle manifest will contain an appropriate Bundle-Classpath attribute. -verbose An optional flag to enable verbose output. Table 24–4 Factory Class and Service Interfacee Factory Class Service Interface oracle.jdbc.xa.client.OracleXADataSource javax.sql.XADataSource oracle.jdbc.OracleDriver java.sql.Driver Table 24–3 Cont. bundler.sh Command Line Options Argument Description