23 November 2006

Hacking Eclipse WTP OC4J To Add Parent Attribute

A recent posting on the OTN OC4J forum asked whether it was possible to set the parent attribute of an application when it was deployed using the Eclipse WTP OC4J plugin.

The out-of-the-box plugin doesn't do it, but it's possible to add rudimentary support for it by editing a few of the plugins XML files.

You'll find the latest version of the plugin in the following directory: eclipse\plugins\org.eclipse.jst.server.generic.oc4j_1.5.0.v200606130315

What we need is to specify somewhere what the "parent" of the application being deployed is.

One way to do this is to edit oracle.10.1.3.serverdef file and add an additional property field that is shown in the server configuration dialog:
<property id="application.parent"
label="Parent Application:"
default="default" />
This addition results in the new property appearing on the OC4J server definition page:

The "Parent Application" property specified on the server defintion is then passed through to the Ant build file that performs the deployment.

Now by simply editing the oracle.10.1.3.xml file (which contains the deployment targets that are called by the plugin) the appplication.parent property can be appended to the deployment operation:
<target name="deploy.j2ee.ear" depends="check.skip.ear.deploy" unless="skip.deploy">
<antcall target="package.module.ear"/>
Now when a deployment is performed using this OC4J server definition, the parent property of the deployed application will be set to the value specified as shown in this snippet from the oc4j server.xml configuration file.
<application name="otn-parent-deploy-ear"
parent="default" start="true" /
Its not the perfect solution since the parent value is specified at an OC4J server definition level and you can't specify the parent on an application-by-application basis. Which effectively means if you need to have different parent applications, you effecitvely need to create an OC4J server definition for each parent setting you need.

But if for some reason you really need to specify a specific parent value when deploying using the Eclipse WTP OC4J plugin, this is one way to accomodate it.

No comments: