There are many values in the OSB components which are different in each environment (local / development / test / ... / production server). We would like to use the same sourcecode to deploy it into the test server or production server, we want to use a CI tool so it is not possible to use constant values in the source.
The customization file could be a perfect solution for this job ... but it is not. At least it was not the best solution to me.
Let me explain it: I had to send an email in a proxy service. The receiver of the email must be different in the production, the test and the development environments (it is obvious as we wouldn't like to send emails to the business users during tests...). I set the receiver of the email in the message flow by modifying the the Transport Header. We cannot modify this value by the help of the Customization File.
Other example is to change the port number of the SMTP server (you can change the endpoint URL of the SMTP server but not the port number which is a separate property of SMTP server).
There are a lot of other examples too where the Customization File fail so I had to find an other solution to change the values in the proxy services.
Unfortunately I could find any other solution (OSB 11.1.1.3.0) how to change these values. I could work out just one solution: change the XML file of proxy service. It seems to be a sophisticated (or tough ...) solution but you can get used to it. :)
An XML file is created when you produce a proxy service. All you need to do is to find the value in the XML that you want to change and create an XPath to find it in the XML. Afterwards you can change the value with an ant task for example. Unfortunately this is not so easy either...
The first problem is that we don't want to modify the files in the source folder of our local machine. Let's imagine your workspace is in C:\work\OSB\workspace (apologize to the Linux users :) ). You are using your workspace for deploying OSB components into your local OSB domain so I don't think that you'd want to mess that folder.
Besides we need a JAR file as a result with all the environment dependent modifications and we just want to deploy it onto the given domain (see Continuous Integration).
So this is my scenario:
- create a deployable JAR file
- unzip the JAR file into a temporary folder
- change the values according to the given environment
- create the JAR files from temporary folder
<target name="build"> <delete failonerror="false" includeemptydirs="true" dir="${metadata.dir}"/> <java dir="${eclipse.home}" jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar" fork="true" failonerror="true" maxmemory="768m"> <jvmarg line="-XX:MaxPermSize=256m"/> <arg line="-data ${workspace.dir}"/> <arg line="-application com.bea.alsb.core.ConfigExport"/> <arg line="-configProject ${config.project}"/> <arg line="-configJar ${config.jar}"/> <arg line="-configSubProjects ${config.subprojects}"/> <arg line="-includeDependencies ${config.includeDependencies}"/> <sysproperty key="weblogic.home" value="${weblogic.home}"/> <sysproperty key="osb.home" value="${osb.home}"/> <sysproperty key="osgi.bundlefile.limit" value="500"/> <sysproperty key="harvester.home" value="${osb.home}/harvester"/> <sysproperty key="osgi.nl" value="en_US"/> <sysproperty key="sun.lang.ClassLoader.allowArraySyntax" value="true"/> </java> </target>
Performing the second step wasn't very difficult:
<unzip src="${config.jar}" dest="../${env.BUILD_ENVIRONMENT}/tmp"/>
There are more ways for modifying the values unfortunately I chose an inconvenient and sophisticated one. :)
<target name="_change.values"> <xmltask source="../${env.BUILD_ENVIRONMENT}/tmp/System/SMTP_Servers/EmailServer.SMTPServer" dest="../${env.BUILD_ENVIRONMENT}/tmp/System/SMTP_Servers/EmailServer.SMTPServer"> <!-- change email server URL --> <replace path="/xml-fragment/*[local-name(.)='serverURL']/text()" withText="${EmailServer.smtp.Server_URL}"/> <!-- change email server port number --> <replace path="/xml-fragment/*[local-name(.)='portNumber']/text()" withText="${EmailServer.smtp.Port_Number}"/> </xmltask> ...And I created a properties file and I defined the values.
EmailServer.smtp.Server_URL=XXXXXX EmailServer.smtp.Port_Number=25
Creating a JAR file is easy too:
<jar destfile="${config.jar}" basedir="../${env.BUILD_ENVIRONMENT}/tmp"/>
Unfortunately I had to implement a 2.1 and 2.2 step as well... When the JAR file was created by the Weblogic ANT task the Configuration Project level resources (e.g. SMTP server) weren't put into the JAR. I don't know it was a problem of the ANT task or I made something badly (but of course it is less likely...:) ).
So I had to copy some folders (see below) into the JAR by the help of ANT and modify the ExportInfo file into the JAR too.
UPDATE
I uploaded my deploy framework that I used to deploy the components, please let me know if you have any issue.