SQL Dev SDK How To Create a Java Defined ExtensionThis is a featured page

SQL Dev SDK How To create a Java Defined Extension

Purpose

This tutorial shows you how to develop a Java defined extensions to Oracle SQL Developer.

Time to Complete

Approximately 30 minutes

Oracle SQL Developer is a free graphical tool that enhances productivity and simplifies database development tasks. Using Oracle SQL Developer, users can browse database objects, run SQL statements, edit and debug PL/SQL statements and run reports, whether provided or created. Developed in Java, Oracle SQL Developer runs on Windows, Linux and the Mac OS X. This is a great advantage to the increasing numbers of developers using alternative platforms. Oracle SQL Developer is built on an extensible framework and, as such, is extensible itself.

Users can create basic XML extensions or more involved Java extensions to add utilities or other functionality to the product.
This tutorial demonstrates how a Java defined extensions can be created.

Prerequisites


Before you perform this tutorial, you should:
1.
Install Oracle Database 11g
Note: You can use any Oracle Database above 9.2.0.1

2.
Install Oracle SQL Developer 1.5.1.

Note: Oracle SQL Developer is available for download for FREE from OTN.
To install Oracle SQL Developer, unzip it into any directory on your machine.

3.
Install Java 1.5 or higher. A Java IDE is recommended.

4.
Install the latest version of ANT. JDeveloper or Eclipse Java IDEs will have this.

5.
Download and unzip java_simple_tablespace.zip into your working directory (i.e. d:\wkdir)
ftp://ftp.oracle.com/svrtech/outgoing/sqldev_sdk/java_simple_tablespace.zip

Extend the Simple XML Tablespace Extension

This Java Extension example builds apon the XML User Defined Extension example in the
How To create an XML User Defined Extension

This example demonstrates how a Java Defined Extension allows
  • All four small XML extensions can be packaged as one extension.
  • A customer icon can be specified for Tablespaces

To build the extension first modify the the build.properties file with the location of your SQL Developer 1.5.1 install.
The Deploy ANT target can then be run to build and deploy the extension. The next time SQL Developer is started the extension will be picked up.

Extension Framework

SQL Developer is written in Java and can be extended in many ways though public APIs.
Usng the Java IDE of your choice (JDeveloper, Eclipse, ... ) ,you can build a SQL Developer extension.
An ANT build file is provided with this example.

A SQL Developer extension consists of 5 main parts
  • extension.xml which is the initial hook by which the extension is defined and loaded into SQL Developer.
  • Extension Addin Java class, which provides additional hooks by which the extension is defined and loaded into SQL Developer programatically.
  • Java classes which provided the extensions functionality
  • XML files which provide a neater mechanism for extending certain parts of SQL Developer like the navigator
  • Resource files like icon images

Java extensions are deployed into jar files, which when placed in SQL Developers extension directory are loaded during SQL Developers next start up.

Extension Classpath

For an extension to reference and extend SQL Developer functionality, the main SQL Developer classes must be on the classpath.
The buid.xml ANT file provided with this example, setups up the required classpath to build the extension.
It is important that the build.properties is setup first so that your installation of SQL Developer can be referenced.

Extension XML Hook

Extensions are loaded into SQL Developer during its startup. SQL Developer looks in its extension directory for jar files.
Referecing each jars meta-inf\extension.xml

The extension.xml defines the extension to be loaded, usually referencing an Addin which programatically defines the majority of the functionality.

<extension xmlns="http://jcp.org/jsr/198/extension-manifest" id="@@extension.id@@"
version="@@extension.version@@" esdk-version="1.0">
<name>Oracle Tablespace Discoverer Project</name>
<owner>Oracle Corporation</owner>
<dependencies>
<import>oracle.sqldeveloper</import>
<import>oracle.javacore</import>
</dependencies>
<hooks>
<jdeveloper-hook xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension">
<addins>
<addin>oracle.dbtools.tablespace_discoverer.TablespaceDiscoverer</addin>
</addins>
</jdeveloper-hook>
<feature-hook>
<description>Browse tablespaces and their associate objects</description>
<optional>false</optional>
</feature-hook>
<sqldev-navigator-hook xmlns="http://xmlns.oracle.com/sqldeveloper/sqldev-navigator">
<descriptor>/oracle/dbtools/tablespace_discoverer/nav/xml/tablespace_nav.xml</descriptor>
</sqldev-navigator-hook>
</hooks>
</extension>

Addin Interface

The Addin specified in the above extension.xml will be called during SQL Developers startup. Its job is to initialize and setup the extension.
For this simple example it just registers the XML files which provide the extensions functionality.

/*** @(#)TablespaceDiscoverer.java
* Copyright 2008 by Oracle Corporation,

* 500 Oracle Parkway, Redwood Shores, California, 94065, U.S.A.

* All rights reserved.
*/
package oracle.dbtools.tablespace_discoverer;
import oracle.ide.Addin;

import oracle.dbtools.raptor.dialogs.actions.XMLBasedObjectAction;
import oracle.dbtools.raptor.oviewer.base.ViewerAddin;import oracle.dbtools.raptor.report.addin.ReportAddin;
/**

* @author Dermot ONeill

* This addin will implement the Tablespace Discoverer SDK Example

*/

public class TablespaceDiscoverer implements Addin {
public void initialize() {
ViewerAddin.registerPackage("oracle.dbtools.tablespace_discoverer.nav.xml");
ViewerAddin.registerPackage("oracle.dbtools.tablespace_discoverer.editors.xml");
XMLBasedObjectAction.registerPackage("oracle.dbtools.tablespace_discoverer.actions.xml");
ReportAddin.registerReportPackage("oracle.dbtools.tablespace_discoverer.reports.xml");
}
}

Conclusion

Hopefully the above examples have outlined how to create your own SQL Developer extensions.
Please add to this wiki any notes you would like to share regarding SQL Developer extension framework.


Resources

File to build this sample extension
ftp://ftp.oracle.com/svrtech/outgoing/sqldev_sdk/java_simple_tablespace.zip

Similar, Oracle By Example paper for SQL Developer 1.2.1
http://www.oracle.com/technology/obe/sqldev_obe/extension/extensions.htm

Extending SQL Developer 1.2.1
http://www.oracle.com/technology/oramag/oracle/07-jul/o47sql.html


dermoton
dermoton
Latest page update: made by dermoton , Jul 31 2008, 12:00 PM EDT (about this update About This Update dermoton Edited by dermoton


view changes

- complete history)
Keyword tags: None
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.