Thursday, September 12, 2013

Common customization file to deploy OSB services to different environments

Common customization file to deploy OSB services to different environments

The customization file can be used to customize the OSB services.
This post will explain how to use the common customization file to customize the OSB services.

Steps to use common customization file to customize the OSB services

1. Create a environment specific property files with the end point details ex Dev_build.properties

# SFDC Details
sfdc.protocol=http
sfdc.host=10.23.23.11

siebel.protocol=http
siebel.host=10.23.23.12


2. Common customization file

To customize the end point details for the business service, we have to change the Service URI and Service URI Table.
we have to tokenize the endpoint details so that the values can be replaced from the environment specific file.

For each new OSB service generate the customization file and copy the required sections(mainly <cus:envValueAssignments> of Service URI and Service URI table <cus:envValueAssignments>) to the common customization file.

<?xml version="1.0" encoding="UTF-8"?>
<cus:Customizations xmlns:cus="http://www.bea.com/wli/config/customizations" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xt="http://www.bea.com/wli/config/xmltypes">
  <cus:customization xsi:type="cus:EnvValueCustomizationType">
    <cus:description/>
    <cus:envValueAssignments>
      <xt:envValueType>Service URI</xt:envValueType>
      <xt:location>0</xt:location>
      <xt:owner>
        <xt:type>BusinessService</xt:type>
        <xt:path>VenusOSB/BusinessServ/BS_ServCloudVenusInbound</xt:path>
      </xt:owner>
      <xt:value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">@sfdc.protocol@://@sfdc.host@/services/service1</xt:value>
    </cus:envValueAssignments>

    <cus:envValueAssignments>
      <xt:envValueType>Service URI Table</xt:envValueType>
      <xt:location xsi:nil="true"/>
      <xt:owner>
        <xt:type>BusinessService</xt:type>
        <xt:path>VenusOSB/BusinessServ/BS_ServCloudVenusInbound</xt:path>
      </xt:owner>
      <xt:value>
        <tableElement xmlns="http://www.bea.com/wli/sb/transports">
          <URI>@sfdc.protocol@://@sfdc.host@/services/service1</URI>
          <weight>1</weight>
        </tableElement>
      </xt:value>
    </cus:envValueAssignments>

    <cus:envValueAssignments>
      <xt:envValueType>Service URI</xt:envValueType>
      <xt:location>0</xt:location>
      <xt:owner>
        <xt:type>BusinessService</xt:type>
        <xt:path>VenusOSB/BusinessServ/BS_RCRMVenusInbound</xt:path>
      </xt:owner>
      <xt:value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">@siebel.protocol@://@siebel.host@/eai_enu/start.swe</xt:value>
    </cus:envValueAssignments>
    <cus:envValueAssignments>
      <xt:envValueType>Service URI Table</xt:envValueType>
      <xt:location xsi:nil="true"/>
      <xt:owner>
        <xt:type>BusinessService</xt:type>
        <xt:path>VenusOSB/BusinessServ/BS_RCRMVenusInbound</xt:path>
      </xt:owner>
      <xt:value>
        <tran:tableElement xmlns:tran="http://www.bea.com/wli/sb/transports">
          <tran:URI>@siebel.protocol@://@siebel.host@/eai_enu/start.swe</tran:URI>
          <tran:weight>1</tran:weight>
        </tran:tableElement>
      </xt:value>
    </cus:envValueAssignments>

  </cus:customization>


 <cus:customization xsi:type="cus:FindAndReplaceCustomizationType">
    <cus:description/>
    <cus:query>
      <xt:resourceTypes>BusinessService</xt:resourceTypes>
      <xt:envValueTypes>Service Retry Iteration Interval</xt:envValueTypes>
      <xt:envValueTypes>Service URI Weight</xt:envValueTypes>
      <xt:envValueTypes>Service Retry Count</xt:envValueTypes>
      <xt:envValueTypes>Service URI</xt:envValueTypes>
      <xt:refsToSearch xsi:type="xt:ResourceRefType">
        <xt:type>BusinessService</xt:type>
        <xt:path>VenusOSB/BusinessServ/BS_ServCloudVenusInbound</xt:path>
      </xt:refsToSearch>
      <xt:refsToSearch xsi:type="xt:ResourceRefType">
        <xt:type>BusinessService</xt:type>
        <xt:path>VenusOSB/BusinessServ/BS_RCRMVenusInbound</xt:path>
      </xt:refsToSearch>
      <xt:includeOnlyModifiedResources>false</xt:includeOnlyModifiedResources>
      <xt:searchString>Search String</xt:searchString>
      <xt:isCompleteMatch>false</xt:isCompleteMatch>
    </cus:query>
    <cus:replacement>Replacement String</cus:replacement>
  </cus:customization>
  <cus:customization xsi:type="cus:ReferenceCustomizationType">
    <cus:description/>
  </cus:customization>
</cus:Customizations>


3. Execute the below ant script with the corresponding environment name to replace the token values in the customization file.

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="replacetokens" default="set.build.properties">
  <property environment="env"/>
  <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
      <pathelement location="../lib/ant-contrib/ant-contrib-1.0b3.jar"/>
    </classpath>
  </taskdef>
 <target name="set.build.properties">
  <copy file="${basedir}/tokenized_customization_file.xml" tofile="OSB_customization_file.xml">
    <filterchain>
    <filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
            <param type="propertiesfile" value="${basedir}/${env.EAI_ENV_TYPE}_build.properties"/>
            <param type="tokenchar" name="begintoken" value="@"/>
            <param type="tokenchar" name="endtoken" value="@"/>
    </filterreader>
    </filterchain>
    </copy>

 
   </target>
</project>

This will generate OSB_customization_file.xml with the actual values, this file can be used while deployment or after to customize the OSB services.

6 comments:

  1. My understanding is like:-
    1.)Manually export customisation.xml from sbconsole.
    2.)Tokenise it using above post.
    3.)Execute script mentioned in above post to make final customisation.xml
    4.)Execute OSB deploy script 'ImportToOSB'.

    However, with this approach,
    1.)we need to create different Customisation for every environment to avoid confusion.
    2.)Every time before making changes , we need to export Customisation.xml manually before every deploy.

    If i'm putting anything wrong, then please correct me.

    Regards,
    Vinit

    ReplyDelete
    Replies
    1. Yes, your understanding is correct but we are following little different approach.


      First time we have generated the full customization file from the console for all the services and removed some of the not required sections and tokenized the file accordingly.

      Whenever we add new OSB service, the customization file for that service will be generated from the console and the required section from this file will be added into the common customization file and tokenized accordingly.

      We have created different environment property file for each environment and during deployment time firstly the actual customization file will be generated from the environment file and the common tokenized customization file.

      The generated customization file will be attached while deploying the service.

      I hope this help you to understand the approach.

      Regards
      Albin I

      Delete
  2. Is there a feasibility to update the value of assigned variable based on the variable name or assigned value as key?

    ReplyDelete
  3. Is it possible to use a table in the database containing the properties instead of using a property file?

    ReplyDelete
  4. I want know if a customization file can update a Value in a "resource" xml file?

    ReplyDelete
  5. I was wondering if a customization file can update a value inside a resource xml file.

    ReplyDelete