Data Cartridge Name Data Cartridge Application Context

15-2 Oracle Complex Event Processing CQL Language Reference For more information, see: ■ Section 15.1.2, Class Loading ■ View on page 20-25 ■ Chapter 13, User-Defined Functions

15.1.2 Class Loading

The Oracle Java data cartridge supports the following policies for loading the Java classes that your Oracle CQL queries reference: ■ Section 15.1.2.1, Application Class Space Policy ■ Section 15.1.2.2, No Automatic Import Class Space Policy ■ Section 15.1.2.3, Server Class Space Policy For more information, see: ■ Section 15.1.2.4, Class Loading Example ■ Section 15.1.3, Method Resolution ■ How to Export a Package in the Oracle Complex Event Processing Developers Guide for Eclipse.

15.1.2.1 Application Class Space Policy

This is the default class loading policy. In this mode, the Oracle Java data cartridge uses the class-space of the application in scope when searching for a Java class. This is only applicable when a type is specified only by its local name, that is, there is a single identifier, and no other identifiers are being used for its package. That is: select String“foo” … And not: select java.lang.String“foo” … In this case the procedure is as follows: ■ Attempt to load the class defined by the single identifier call it ID1 using the application’s class-space as usual; if this fails then: ■ Verify if the application defines any class within its bundle’s internal class-path whose name matches ID1, independent of the package; if this fails then: ■ Verify if application specifies an Import-Package MANIFEST header statement which in conjunction with ID1 can be used to load a Java class. For an example, see Section 15.1.2.4, Class Loading Example . Note: To simplify Oracle Java data cartridge type names, you can use aliases as Section 2.8.2, Defining Aliases Using the Aliases Element describes. Oracle Java Data Cartridge 15-3

15.1.2.2 No Automatic Import Class Space Policy

This is an optional class loading policy. To use this policy, you must include the following MANIFEST header entry in your Oracle CEP application: OCEP_JAVA_CARTRIDGE_CLASS_SPACE: APPLICATION_NO_AUTO_IMPORT_CLASS_SPACE This mode is similar to the application class space policy except that Oracle CEP will not attempt to automatically import a package when a package is not specified. For more information, see Section 15.1.2.1, Application Class Space Policy .

15.1.2.3 Server Class Space Policy

This is an optional class loading policy. To use this policy, you must include the following MANIFEST header entry in your Oracle CEP application: OCEP_JAVA_CARTRIDGE_CLASS_SPACE: SERVER_CLASS_SPACE In this mode, Oracle CEP still uses the application’s class-space, but Oracle CEP will not attempt to automatically import a package when a package is not specified. an Oracle CQL query can reference any exported Java class, regardless of the application or module that is exporting it. The query can also access all classes visible to the OSGi framework’s parent class-loader, which includes the runtime JDK classes. This means that an Oracle CQL application may contain an Oracle CQL query that references classes defined by other Oracle CEP applications, as long as they are exported. This behavior facilitates the creation of Java-based cartridges whose sole purpose is to provide new Java libraries. For an example, see Section 15.1.2.4, Class Loading Example .

15.1.2.4 Class Loading Example

Consider the example that Figure 15–1 shows: application B1 imports package mypackage3 that application B2 exports. Figure 15–1 Example Oracle CEP Applications Table 15–1 summarizes which classes these two different applications can access depending on whether they are running in the application class space or server class space. Note: You may only reference a Java class that is part of the internal class-path of an Oracle CEP application if it is exported, even if a processor within this application defines the Oracle CQL query.