Working with JDeveloper Update Centers and Bundle.xml

First, if you haven't moved up to JDeveloper 11g, do so.  All of the posts I do on this site are based on at least 11.1.1.2.  For extension developers, 11g added some very nice ease-of-development features that you will want to take advantage of.

If you've written an extension for JDeveloper, and you want to share it with others, you will need to learn about the Update Center and how to work with the bundle.xml file.

There are a few blog posts already out there about how to package and setup a basic Update Center for JDeveloper. The basics haven't changed that much from JDev 10.1.3, so even the older docs will be of help.  These two in particular do a good job of showing how all of it works

Oracle How To... (by Olivier Le Diouris)

Beginners Guide to JDeveloper Extensions (by Shay Shmeltzer)

However there isn't that much out there that really explains what is going on with the packages that you put together, and how to do some more complex things with that package.

One of the most helpful tips that I learned when I first started working with my own update center was to think of the package as just another .zip file.  If you package all of the needed files into the directory structure that JDeveloper uses, you can place files like Help documents into the JDev Help directory just by using the bundle.xml and the way you setup your .zip files.

By default, the .zip file that you create for your update center, is placed and extracted into the "extension" directory of JDeveloper

<oracle_home>/middleware/jdeveloper/jdev/extension

This is perfectly fine if your extension doesn't have any files that need to go into specific directories, that are above the "extensions" directory, for JDeveloper to find them.

However, lets say that your extension.xml file makes reference to some help documents that are supposed to be in the "doc/ohj" directory, or maybe you are trying to install a new Role file as we talked about in one of my previous posts [ Creating your own Role for JDeveloper ]

For this type of situation, you want to make use a special element in the bundle.xml file called <destination>

--------------------------------------------------------------------------------------------------------------------------------------------------------

<?xml version = '1.0' encoding = 'UTF-8'?>
<update-bundle version="1.0"
               xmlns="http://xmlns.oracle.com/jdeveloper/updatebundle"
               xmlns:u="http://xmlns.oracle.com/jdeveloper/update">
  <u:update id="jdev.customrole">
    <u:name>Custom Roles File</u:name>
    <u:version>1.0</u:version>
    <u:author>John 'JB' Brock</u:author>
    <u:author-url>http://blogs.oracle.com/jdevextensions/</u:author-url>
    <u:description>
      Adds the custom role file for JB's Role, to the roles directory.
    </u:description>
    <u:requirements>
      <u:requires-extension id="oracle.jdeveloper"
                            minVersion="11.1.1"
                            maxVersion="11.1.4" />
    </u:requirements> 

    <u:destination>${oracle.home}</u:destination> 

    <u:post-setup-hook>package.mysetupclass</u:post-setup-hook>

  </u:update>
</update-bundle>

--------------------------------------------------------------------------------------------------------------------------------------------------------

In the above example of a bundle.xml file, you'll see the destination element at the bottom of the file.  The only valid argument for this element is ${oracle.home}

While the value says Oracle.Home, it's really a reference to the JDeveloper Home directory. By default that would be:

C:\oracle\middleware\jdeveloper

Creating a directory structure like this in your .zip file, with appropriate files in the right directories,

dir_structure

will then place files into the appropriate location, such as the roles file into the "roles" directory under the JDeveloper Home location.

 

The second helpful element in the bundle.xml file is the  <post-startup-hook>.  This element will let you specify a java class in your extension, that should be run "once" after the installation of your extension. It will run after the IDE is restarted from a new extension install.

This is a great way to do custom setup work that relies on environment or system properties that you may not be able to determine before the extension is actually installed. 

Placing a line similar to this, at the bottom of the update section of the bundle.xml will do the trick.

<u:post-startup-hook>package.mysetupclass</u:post-startup-hook>

 

Troubleshooting

If you have trouble getting your extension to load into the proper directories.  Make sure you try loading the .zip file using the "Install from local file" option in the JDev IDE Update Center first. 

If that works properly, but it doesn't load properly when you use your own personal Update Center xml file, the cause is most likely that you have not added the <destination> element to the Update section in the the update center xml file.  It has to be in both the bundle.xml and in the update.xml (or whatever name you used) for it to work both ways.

The post-startup-hook also needs to be in both files.

 

As always, if you have any comments, questions, or info about how you may have done something a little differently, please post a comment so that everyone can learn from your experience.

Comments:

Nice post! I would like to ask if there are changes in the way extensions are distributed between JDeveloper 11.1.1.3 and 11.1.1.4? We used Update Center to load our own extensions in JDeveloper 11.1.1.3 with success. After the new release (11.1.1.4) we are facing problems regarding the update to a new version of the extension. The actual behavior is the following: The first time (no previous version installed) the extension is installed successfully. The extension consists of a jar file and an external library folder, so after JDeveloper restarts we can find the following under [oracle_home]/jdeveloper/jdev/extensions : - our.extension.jar - our.extension (folder) If we create a new release, the Update Center finds it but after JDeveloper restarts the extension is corrupted: - the old our.extension.jar still exists, - the old our.extension folder is deleted but the new one is not copied. It seems that when JDeveloper attempts to delete the old extension, this is already loaded and used by the IDE. We have to close JDeveloper, delete the old jar manually and rerun update center to finish with the installation.

Posted by em on April 27, 2011 at 08:54 PM PDT #

There should not be any differences in the behavior between 11.1.1.3 and 11.1.1.4. Can you send me a copy of the original and the updated extension zip via email? I'll look into it and get back to you. This may be easier to discuss in the forums instead of in the comments here. Please start a topic at: http://forums.oracle.com/forums/forum.jspa?forumID=83&start=0 My email address is first (DOT) last (AT) oracle.com Thanks John Brock

Posted by John Brock on April 27, 2011 at 11:17 PM PDT #

Hi John,
I am working on extension project, my work should be included to in a extension. My requirement is when I add my extension to jdev. It should add a library to jdev. This library will have all my code. Once user want to use my code user just need to include this library into there project. I am not able to find something helpfull by which I can hook a new library to jdev.

Thanks
Vipin

Posted by Vipin Kumar on October 30, 2012 at 11:24 PM PDT #

Hi John,

Thanks a lot for the help, with the little documentation available and your help I am able to figure out the way to create my extension. Still there are some issue yet to resolve but basic structure is ready to use.

again thanks for the help.

Regards
Vipin Kumar

Posted by Vipin Kumar on November 05, 2012 at 04:44 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

profile image
My name is John 'JB' Brock.
This Blog will focus on tips and tricks for working with the JDeveloper Extension SDK.
I hope to bring clarity to some of the mysteries around developing extensions for JDeveloper.


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today