More Related Content Similar to Oracle REST Data Services Best Practices/ Overview (20) Oracle REST Data Services Best Practices/ Overview2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Oracle REST Data Services
( Formerly APEX Listener)
Kris Rice
Senior Director Database Tools
Best Practices
3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor
• The following is intended to outline our general product direction. It is
intended for information purposes only, and may not be incorporated
into any contract. It is not a commitment to deliver any material,
code, or functionality, and should not be relied upon in making
purchasing decisions. The development, release, and timing of any
features or functionality described for Oracle’s products remains at
the sole discretion of Oracle.
3
4. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Agenda
• Overview
• New Features in 2.x
• Installation
• Configuration
• Multiple Database
• RESTful APIs
• Obligatory Oracle Database Cloud
4
5. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Overview
Oracle REST Data Services
OWA Toolkit support
Application Express customization
Oracle DB JSON Support
Oracle NoSQL Database support
Turns Database into an RESTFul API service
Allows publishing of URI based access to Oracle
database over REST
Results in JSON or CSV
Mapping of URI to SQL or PL/SQL
All HTML methods GET, PUT, POST, DELETE, PATCH
Oauth2 integration
Highly scalable
5
6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Architecture
Oracle REST Data Services
J2EE Application
No Oracle Home required
Supported deployments
WebLogic
Glassfish
Apache Tomcat
Standalone – For development
6
7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Architecture
Oracle REST Data Services
7
Java Mid Tiers
HTTPS
JDBC
Internet
Firewall
Firewall
Oracle
NoSQL
Apache httpd
RMI
Separate static content
No Mid-Tier state
Scales Horizontally
Use AJP to talk to backend
Allows internal and external access
8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
2.0 Features
8
Command Line Configuration
Multi Database support
ICAP Server integration
FOP support
2.0.8 adds FOP 1.1
PL/SQL and JavaScript based validation Function
Extensibility
REST Filtering
9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
2.0 - Database Users
9
APEX_LISTNER
•Reads REST Definitions
APEX_PUBLIC_USER
•Apex/OWA main connection pool
•Size according to number of concurrent apex users
APEX_REST_PUBLIC_USER
•REST Connection pool for all REST operation
•Size according to concurent REST calls
10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
2.0 Installation – Step 1
10
Application Express 4.2.2+ required
Run apex_rest_config.sql
11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
2.0 Installation – Step 2
11
Run java –jar ords.war
Prompts for:
Location to store configuration
Database host/port/sid or service
3 Database Users
Path to APEX images
12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Configuration via SQL Developer
12
File Based for manual setup
SQL Developer based
Secured via webserver
Retrieve remote config
REST based deployment
Configuration Validation
SQLDev is an Oauth client
13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Configuration via Command Line
13
Running java -jar ords.war help
configdir Set the value of the web.xml config.dir property
help Describe the usage of this program or its commands
map-url Map a URL pattern to the named database connection
migrate Migrate a 1.x configuration to 2.x format
setup Configure database connection
standalone Launch in standalone
static Generate a Web Application Archive (WAR)
to serve Oracle Application Express static resources
user Create or update credentials for a user for sqldev config
14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Configuration Files
14
defaults.xml
All Common settings and defaults for all connection pools
ords/standalone/standalone.properties
Standalone settings such as /i/ and port #
conf/apex.xml
Configuration for APEX/OWA
conf/apex_al.xml
APEX_LISTENER – reads REST Configuration
conf/apex_rt.xml
APEX_PUBLIC_PUBLIC_LISTENER – Base connection for REST
credentials
Users for configuration from SQL Developer
role-mapping.xml
Maps Webserver Roles into RESTful Roles
url-mapping.xml
Multiple database configurations
15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Connection Pooling
15
Each REST enabled schema grants proxy connect
Allows for smaller common pool
Connection opens proxied connection
All SQL/PLSQL execute at the schema
Proxied connection is closed and returned to the pool
16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
THE number one thing you must do
16
Configure the database connection pool
Set the max size
Set the initial size
Set the timeouts
17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Multiple Database
17
Routes based on rules to any number of databases
Rules are contained in url-mappings.xml
3 Type of Rules: uri-pattern,base-url, and base-path
<pool name="leads_db"
base-url="sales.example.com/apex/leads" />
<pool name="leads_db"
base-path="/sales/leads" />
<pool name="sales_db"
uri-pattern="https://.*.sales.example.com/apex/.*" />
18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Multi-Database Base-URL Example
18
Assume the listener is deployed at context path: /apex, then:
<pool name="leads_db" base-url="sales.example.com/apex/leads" />
<pool name="support_db" base-url="https://support.example.com/apex" />
Match Rule 1
http://sales.example.com/apex/leads/f?p=1:1
https://sales.example.com/apex/leads/f?p:=1:1
Match Rule 2
https://support.example.com/apex/f?p:=1:1
http://support.example.com/apex/f?p:=1:1
No Matches
http://example.com/apex/f?p:=1:1
http://example.com/apex/leads/f?p:=1:1
19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Multi-Database Base-Path Example
19
Assume the listener is deployed at context path: /apex, then:
<pool name="leads_db" base-path="/sales/leads" />
Match Rule 1
http://example.com/apex/sales/leads/f?p=1:1
No Matches
http://example.com/apex/sales/f?p=1:1
http://example.com/apex/f?p=1:1
20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Multi-Database Pattern Example
20
Assume the listener is deployed at context path: /apex, then:
<pool name="sales_db”
uri-pattern="https://.*.sales.example.com/apex/.*"/>
Match Rule
https://leads.sales.example.com/apex/f?p=1:1
https://deals.sales.example.com/apex/f?p=1:1
No Matches
http://hr.example.com/apex/f?p=1:1
21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Deployment Choices
21
Multiple Mappings
/sales /emp /nhl
/sales /emp /nhl
One ORDS with mappings
Single webserver
Single management
Single upgrade/patch
One ORDS per mapping
Multiple webserver
Individual control
Staggered upgrades
22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Virus Scanner Integration
22
A lightweight HTTP-like protocol specified in RFC 3507
Scans all file uploads for viruses before it reaches the
database
Supported by most commercial Virus scan server
Tested with Symantec and McAfee
Multiple Open source options such as ClamAV
23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
ClamAV
23
Install ClamAV
http://oracle-base.com/articles/linux/linux-antivirus-clamav.php
Add ICAP support
http://c-icap.sourceforge.net/install.html
24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JavaScript based Validation
24
Completely eliminates the database
Leverages JavaScript knowledge
Limit based on HTTP Headers
function isValid()
{
if ( URI.indexOf('hi')>0 ) { return 'false';}
return 'true';
}
25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
PL/SQL based Validation
25
Use binds in PL/SQL Validation
The following are automatically bound if detected
URL
PROCNAME
P_FLOW_ID
P_FLOW_STEP_ID
P_INSTANCE
P_PAGE_SUBMISSION_ID
P_REQUEST
26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Extensibility
26
Pre and Post Process in PL/SQL
<entry key="procedure.postProcess"></entry>
<entry key="procedure.preProcess"></entry>
Pre and Post Process in Java
FOP2PDF
Caching
File Download
Preprocess files in Java
Virus Scanner
Excel Upload
Register new Java extentions
<entry key="apex.extensions"></entry>
27. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Java Extensibility - Example
27
Called for every request before the database call
Requests can be Handled, Modified, or Declined
28. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
REST Filtering
28
Developer now has ability to filter REST requests on the server
Operators
$eq,$gt,$lt,$lte,$gte,$ne,$instr
Logical
$and, $or
Time Based ( coming in 3.0 )
$asof
Examples:
{ "qty": { "$gt": 20 } }
{"$and": [{"price": {"$ne": 1.99}},{"price": {"$notnull": ""}}]
{"price": [{"$ne": 1.99}},{"$notnull": ""}]
{"$or": [{"qty": {"$lt": 20}},{"sale": {"$eq": "TRUE"}}]
$asof: {"$timestamp": ”……"}
29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Something went wrong aka Debug Mode
29
Printing Errors to the browser
Enable simple debug
Full logging of everything via java.util.logging
Full write up on Colm’s Blog
http://is.gd/ords_debug
30. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Log Requests to Database
30
Capture all PLSQL calls
Capture all Binds
31. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
3.0 New Features
31
Fully committed to REST enablement
Simplified installation
Auto Table enablement
Client REST filtering
PL/SQL API for Rest definition
Bulk CSV loading over REST
Oracle NoSQL Support
Database 12.1.0.2 JSON Collections
New Plugin framework
Jetty for Embedded webserver
32. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
3.0 New Features
32
One line install
java -jar build/built/ords.war install
Installs new ORDS_METADATA schema
Migrates settings from 2.0 to 3.0
33. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Auto REST Enablement
33
Simple menu to enable tables
Any combination of operations
Query
Insert
Update
Delete
Metadata
Bulk Loading
34. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Bulk Loading over REST
34
Factored CSV import from SQL Developer
POST the CSV in the body to
/ords/schema-alias/tables/table-alias/batchload
Feedback is in the response body
Multiple options for the load
Passed via headers
delete=false|true|truncate
batchRows=50|<n>
batchesPerCommit=10|<n>
errors=50|<n>|UNLIMITED
errorsMax=<n>
responseFormat=RAW|SQL
responseEncoding=UTF8|<encoding-name>
responseLocales=null|<locales>
dateFormat= <format-string>
timestampFormat=<format-string>
timestampTZFormat=<format-string>
locale=<locale>
35. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Oracle NoSQL
35
Connect to any KVStore
NoSQL 3.0 introduces TableAPI
Access via full primary key, partial key, or indexes
REST is accessible from any language
36. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Standalone - Jetty
36
Eclipse Project
http://www.eclipse.org/jetty/
Full webserver
Auto creation of Self Signed SSL
SPDY Support
Apache style access log
37. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
THE number one thing you must do
37
Configure the database connection pool
Set the max size
Set the initial size
Set the timeouts
38. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Oracle Cloud
Easy and Graceful Deployment
Deploy Anywhere
Gracefully move workloads between on-premise and public cloud
Same Architecture
Same Standards
Same Products
On Premises
Traditional Deployment
or Private Cloud
On Cloud
Automated or
Fully Managed
Unified Management
Enterprise Manager manages both On Premise and Cloud*
39. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 39
Oracle Database Cloud – Schema Service
Introduction
• Fully Managed Service
• Monthly Subscription by Database Size (5, 20, 50 GB)
• Single Database Schema, Each tenant is a single schema
• Database patches and upgrades performed during scheduled maintenance
windows
• Deployed on Engineered Systems
• DB Edition is a modified “limited” (security locked down) EE
• Available since October 2013
Database schema service provides http access, see full instance services to gain full access to a full Oracle Database.
40. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Oracle Database Cloud - Schema Service
Schema Service Tools
• Drag and drop data
movement
• Database Browsing
• Define RESTful Web
Services
• Deploy APEX Apps
• SQL worksheet*
• Command Line SQL over
https*
SQL Developer
Oracle REST
Data Services
Oracle Application
Express (APEX)
Java Cloud Service -
SaaS Extension
• Allows publishing of URI
based access to Oracle
database over REST
• Results in JSON or CSV
• Mapping of URI to SQL
or PL/SQL
• All HTML methods GET,
PUT, POST, DELETE,
PATCH
• Oauth2 integration
• Highly scalable
• Java platform specially built to
deploy extension for Oracle
Software as a Service offerings,
including Sales Cloud, Service
Cloud, and Marketing Cloud.
• Dedicated environment running
WebLogic Server.
• Three pre-configured sizes
• Applications are managed
through Oracle Cloud tooling; no
customer access to the
underlying infrastructure is
required.
• Available as an Extra Cost
Service.
• Create Tables
• Run any SQL
• Run SQL Scripts
• Browse Database Objects
• Define RESTful Web Services
• Build APEX Apps
• Deploy pre-built productivity
apps “Packaged Apps”
• Deploy custom apps
Included with Schema Service
40
41. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Oracle Database as a Service – Rich New Tools
Local HTML5 Admin App
41
Editor's Notes *EM to cloud coming Over provisioned space by 20%.