Section 18.1, "Understanding Data Cartridge Application Context"
Section 18.2, "How to Configure Oracle Spatial Application Context"
Section 18.3, "How to Configure Oracle JDBC Data Cartridge Application Context"
For more information on data cartridges, see "Introduction to Data Cartridges" in the Oracle Complex Event Processing CQL Language Reference.
Depending on the data cartridge implementation, you may be able to define an application context that the Oracle CEP server propagates to an instance of the data cartridge and the complex objects it provides.
You may configure an application context for the following data cartridges:
Section 18.2, "How to Configure Oracle Spatial Application Context"
Section 18.3, "How to Configure Oracle JDBC Data Cartridge Application Context"
For more information on data cartridges, see "Introduction to Data Cartridges" in the Oracle Complex Event Processing CQL Language Reference.
You define an application context for an instance of Oracle Spatial using element spatial:context
in your Oracle CEP application's Event Processing Network (EPN) assembly file.
All constructors and methods from com.oracle.cartridge.spatial.Geometry
and Oracle Spatial functions are aware of spatial:context
. For example, the SRID is automatically set from the value in the Oracle Spatial application context.
For more information, see:
"SDO_SRID" in the Oracle Spatial Developer's Guide at http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_objrelschema.htm#SPATL492
"Understanding Oracle Spatial" in the Oracle Complex Event Processing CQL Language Reference
To configure Oracle Spatial application context:
Open the EPN editor in the Oracle CEP IDE for Eclipse.
Import the package com.oracle.cep.cartridge.spatial
into your Oracle CEP application's MANIFEST.MF
file.
For more information, see Section 4.7.5, "How to Import a Package".
Right-click any component and select Go to Assembly Source.
Edit the EPN file to add the required namespace and schema location entries as Example 18-1 shows:
Example 18-1 EPN Assembly File: Oracle Spatial Namespace and Schema Location
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:wlevs="http://www.bea.com/ns/wlevs/spring" xmlns:spatial="http://www.oracle.com/ns/ocep/spatial/" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd http://www.bea.com/ns/wlevs/spring http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd" http://www.oracle.com/ns/ocep/spatial http://www.oracle.com/ns/ocep/spatial/ocep-spatial.xsd">
Edit the EPN file to add a spatial:context
element as Example 18-2 shows.
Assign a value to the id
attribute that is unique in this EPN.
This is the name you will use to reference this application context in subsequent Oracle CQL queries. In Example 18-2, the id
is SpatialGRS80
.
Note:
Theid
value must not equal the Oracle Spatial name spatial
. For more information, see "Data Cartridge Name" in the Oracle Complex Event Processing CQL Language Reference.Configure the other attributes of the spatial:context
element to suit your application requirements.
Table 18-1 lists the attributes of the spatial:context
element.
Table 18-1 spatial:context Element Attributes
Attribute | Description |
---|---|
The default tolerance for contain or inside operator. Default: 0.0000005 |
|
Defines the Reciprocal Of Flattening ( Default: 298.257223563 |
|
Defines the Semi-Major Axis ( Default: 6378137.0 |
|
SRID integer. Valid values are:
Default : |
|
The minimum distance to be ignored in geometric operations including buffering. Default: 0.000000001 |
Example 18-3 shows how to create a spatial context named SpatialGRS80
in an EPN assembly file using the Geodetic Reference System 1980 (GRS80) coordinate system (srid="4269"
).
Create Oracle CQL queries that reference this application context by name.
Example 18-4 shows how to reference a spatial:context
in an Oracle CQL query. In this case, the query uses link name SpatialGRS80
(defined in Example 18-2) to propagate this application context to the Oracle Spatial. The spatial:context
attribute settings of SpatialGRS80
are applied to the createPoint
method call. Because the application context defines the SRID, you do not need to pass that argument into the createPoint
method.
Example 18-4 Referencing spatial:context in an Oracle CQL Query
<view id=”createPoint”> select com.oracle.cep.cartridge.spatial.Geometry.createPoint@SpatialGRS80(lng, lat, 0d) from CustomerPos[NOW] </view>
For more information, see "Using Oracle Spatial" in the Oracle Complex Event Processing CQL Language Reference.
You define an application context for an instance of an Oracle JDBC data cartridge using:
A jdbc:jdbc-context
element in the EPN assembly file.
A jc:jdbc-ctx
element in the component configuration file.
The jc:jdbc-ctx
element:
references one and only one jdbc:jdbc-context
references one and only one data-source
defines one or more SQL functions
Note:
You must provide alias names for everySELECT
list column in the SQL function.For more information see, "Understanding the Oracle JDBC Data Cartridge" in the Oracle Complex Event Processing CQL Language Reference.
To configure Oracle JDBC data cartridge application context:
Open the EPN editor in the Oracle CEP IDE for Eclipse.
Right-click any component and select Go to Assembly Source.
Edit the EPN file to add the required namespace and schema location entries as Example 18-5 shows:
Example 18-5 EPN Assembly File: Oracle JDBC Data Cartridge Namespace and Schema Location
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" xmlns:wlevs="http://www.bea.com/ns/wlevs/spring" xmlns:jdbc="http://www.oracle.com/ns/ocep/jdbc/" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd http://www.bea.com/ns/wlevs/spring http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd" http://www.oracle.com/ns/ocep/jdbc http://www.oracle.com/ns/ocep/jdbc/ocep-jdbc.xsd">
Edit the EPN file to add a jdbc:jdbc-context
element as Example 18-6 shows.
Assign a value to the id
attribute that is unique in this EPN.
This is the name you will use to reference this application context in subsequent Oracle CQL queries. In Example 18-6, the id
is JdbcCartridgeOne
.
Note:
Theid
value must not equal the Oracle JDBC data cartridge name jdbc
. For more information, see "Data Cartridge Name" in the Oracle Complex Event Processing CQL Language Reference.Right-click the desired processor and select Go to Configuration Source.
Edit the component configuration file to add the required namespace entries as Example 18-7 shows:
Example 18-7 Component Configuration File: Oracle JDBC Data Cartridge Namespace
<?xml version="1.0" encoding="UTF-8"?> <wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jc="http://www.oracle.com/ns/ocep/config/jdbc xsi:schemaLocation=" http://www.oracle.com/ns/ocep/config/jdbc http://www.oracle.com/ns/ocep/config/jdbc/ocep_jdbc_context.xsd">
Edit the component configuration file to add a jc:jdbc-ctx
element as Example 18-8 shows.
Add a name child element whose value is the name of the Oracle JDBC application context you defined in the EPN assembly file as Example 18-9 shows.
Add a data-source
child element whose value is the name of a datasource defined in the Oracle CEP server config.xml
file.
For more information, see:
"Configuring JDBC for Oracle CEP" in the Oracle Complex Event Processing Administrator's Guide.
Example 18-10 shows how to specify the datasource named StockDS
.
Create one or more SQL functions using the function
child element as Example 18-11 shows.
Example 18-11 jc:jdbc-ctx Element in Component Configuration File: function
<jc:jdbc-ctx> <name>JdbcCartridgeOne</name> <data-source>StockDS</data-source> <function name="getDetailsByOrderIdName"> <param name="inpOrderId" type="int" /> <param name="inpName" type="char" /> <return-component-type> com.oracle.cep.example.jdbc_cartridge.RetEvent </return-component-type> <sql><![CDATA[ SELECT Employee.empName as employeeName, Employee.empEmail as employeeEmail, OrderDetails.description as description FROM PlacedOrders, OrderDetails , Employee WHERE PlacedOrders.empId = Employee.empId AND PlacedOrders.orderId = OrderDetails.orderId AND Employee.empName = :inpName AND PlacedOrders.orderId = :inpOrderId ]]></sql> </function> </jc:jdbc-ctx>
Note:
You must provide alias names for everySELECT
list column in the SQL query.For more information, see "Defining SQL Statements" in the Oracle Complex Event Processing CQL Language Reference.
Create Oracle CQL queries that invoke the SQL functions using the Oracle JDBC data cartridge application context.
Example 18-12 shows how to reference a jdbc:jdbc-context
in an Oracle CQL query. In this case, the query uses link name JdbcCartridgeOne
(defined in Example 18-11) to propagate this application context to the Oracle JDBC data cartridge. The Oracle CQL query in Example 18-12 invokes the function getDetailsByOrderIdName
defined by Oracle JDBC data cartridge context JdbcCartridgeOne
.
Example 18-12 Referencing JDBC Application Context in an Oracle CQL Query
<processor>
<name>Proc</name>
<rules>
<query id="q1"><![CDATA[
RStream(
select
currentOrder.orderId,
details.orderInfo.employeeName,
details.orderInfo.employeeemail,
details.orderInfo.description
from
OrderArrival[now] as currentOrder,
TABLE(getDetailsByOrderIdName@JdbcCartridgeOne(
currentOrder.orderId, currentOrder.empName
) as orderInfo
) as details
)
]]></query>
</rules>
</processor>
For more information see, "Defining Oracle CQL Queries With the Oracle JDBC Data Cartridge" in the Oracle Complex Event Processing CQL Language Reference.