Monday May 09, 2011

Migrating Objects in the MDS

There are some great blogs out there that address MDS management via ANT. As good as they were I didn’t find the exact answer I was after which was migrating common objects such as Domain Value Maps, XSD, WSDL, etc, development lifecycle. Thanks to Edwin and Clemens who provided the base for this post.

To maximise reuse in a SOA Suite deployments developers can utilise the MDS. Instead of storing the objects within the SOA Composite itself. The objects can be stored in the common area in the MDS for all developers to use.

In this post I use a Domain Value Map and migrate it from the developers local machine through to production using a generic ANT script. The same concept can be applied to other common objects such as XSD and WSDLs.

  1. By default JDeveloper uses a file based MDS repository. This can be used to develop SOA composites even without connectivity the the server. To modify the file based MSD you use OS commands. It is recommended practice to place custom objects in the apps folder. This needs to be created.

    In widows explorer change directory to the JDeveloper home and create an apps directory in the integration/seed directory.


  2. In JDeveloper you can make a connection to the file MDS and you will be able to see the new directory


  3. In this example I create a generic project that I use to crate my Domain Value Map.


  4. Once the DVM has been created you need to move it to the MDS so SOA Composites can find it at design time. This is done using OS commands. To make my DVM easier to find I also create a DVM folder in the apps directory we created in step 1.



    Once copied you will be able to view it in JDeveloper.


  5. Now the developer can use this DVM as a shared object. The issue now is if you tray and deploy a SOA project to the server which uses this DVM it will fail. The DVM does not exist on the server, so before you deploy the project you need to deploy the DVM to the server. I have created an ANT script to help you migrate these objects. You can download them here.

    build.properties
    build.xml
    ant-contrib-1.0b3-bin.zip

  6. Unzip the ant-contrib-1.0b3-bin.zip file and copy the ant-contrib-1.0b3.jar file to JDEV_HOME/ant/lib

  7. You will need to make some adjustments for your environment.  Below is a copy of the build.properties you will need to change the home directories to match your environment.

    # global  
    wn.bea.home=d:/oracle/product/jdeveloper/11.1.1.4
    oracle.home=${wn.bea.home}/jdeveloper
    java.passed.home=${wn.bea.home}/jdk160_21
    wl_home=${wn.bea.home}/wlserver_10.3
      
    # temp  
    tmp.output.dir=d:/temp
      
    local.enabled=true
    local.reposistory=d:/oracle/product/jdeveloper/11.1.1.4/jdeveloper/integration/seed/apps/
    local.undeploy=true
    
    exclude.pattern=
    search.pattern=/dvm/*
    download.description=dvm
    target.environment=dev
    source.environment=local
    deployment.plan.environment=dev
      
    # dev deployment server weblogic
    dev.serverURL=http://dev.nz.oracle.com:8001
    dev.overwrite=true
    dev.user=weblogic
    dev.password=welcome1
    dev.forceDefault=true
    dev.server=dev.nz.oracle.com
    dev.port=8001

    Some properties of interest are:

    search.pattern  this is the search that is performed to find the objects you want to migrate. If the source environment is a DB MDS you can have multiple searches, e.g. /dvm/*;/xsd/*

    target.environment
    this is the environment you want to move the objects to. This value must match the prefix of the connection properties, e.g. dev.serverURL.

    source.environment this is the source enviroment where the objects are sourced. This value must match the prefix of the connection properties, e.g. dev.serverURL

    tmp.output.dir this is the directory that is used to create all the files as they are prepared to be deployed into the target environment.

    In this example I have only provided a local and a development environment. You can add new environments such as test and production if required, e.g.
    # test deployment server weblogic
    test.serverURL=http://test.nz.oracle.com:8001
    test.overwrite=true
    test.user=weblogic
    test.password=welcome1
    test.forceDefault=true
    test.server=test.nz.oracle.com
    test.port=8001
  8. The build.xml should not need changing but I’m sure you may want to add some enhancements if required.
    <?xml version="1.0" encoding="iso-8859-1"?>  
    <project name="soaDeployAll" default="main">  
        <echo>basedir ${basedir}</echo>  
      
        <property environment="env"/>   
        <echo>current folder ${env.CURRENT_FOLDER}</echo>  
      
        <property file="${env.CURRENT_FOLDER}/build.properties"/>    
        <property name="mds.deploy.dir" value="${tmp.output.dir}/${source.environment}"/>
    
      
        <tstamp>
    
           <format property="time" pattern="yyyyMMddhhmm" offset="-5" unit="hour"/>      
        </tstamp>   
        <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
    
    
        <target name="main">      
          
          <echo>Please select a correct operation</echo>
    
          
        </target>  
        <target name="migrateObjects">   
          <if> 
    
    
            <equals arg1="${source.environment}" arg2="local" />      
            <then>         
              <antcall target="exportLocalMDSobjects"/>   
              <antcall target="deployMDSobjects"/>
    
    
            </then>      
            <else>         
              <antcall target="exportRemoteMDSobjects"/>   
              <antcall target="deployMDSobjects"/>
    
            
            </else>   
          </if>          
        </target>  
        
        <target name="exportLocalMDSobjects">  

            <echo>Export Local MDS Objects ${local.folder}</echo>          <echo>export and create local MDS temp</echo>               <echo>create zip from file MDS store</echo>                 <mkdir dir="${mds.deploy.dir}"/>                <zip destfile="${mds.deploy.dir}/${download.description}${time}_mds.jar" compress="false">             <fileset dir="${local.reposistory}" includes="${search.pattern}" excludes="${exclude.pattern}"/>          </zip>            <echo>create zip with MDS jar</echo>                  <zip destfile="${mds.deploy.dir}/${download.description}${time}_mds.zip" compress="false">             <fileset dir="${mds.deploy.dir}" includes="*.jar"/>          </zip>            </target>         <target name="exportRemoteMDSobjects">             <propertycopy name="export.serverURL"    from="${source.environment}.serverURL"/>          <propertycopy name="export.overwrite"    from="${source.environment}.overwrite"/>          <propertycopy name="export.user"         from="${source.environment}.user"/>          <propertycopy name="export.password"     from="${source.environment}.password"/>          <propertycopy name="export.forceDefault" from="${source.environment}.forceDefault"/>            <echo>Export objects from ${export.environment} MDS</echo>            <echo>Export from ${export.serverURL} with user ${export.user}</echo>          <echo>Export jarFile ${mds.deploy.dir}/${download.description}${time}_mds.zip</echo>            <mkdir dir="${mds.deploy.dir}"/>         <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false" target="exportSharedData">               <property name="wl_home" value="${wl_home}"/>               <property name="oracle.home" value="${oracle.home}"/>               <property name="serverURL" value="${export.serverURL}"/>               <property name="user" value="${export.user}"/>               <property name="password" value="${export.password}"/>                 <property name="pattern" value="${search.pattern}"/>              <property name="jarFile" value="${mds.deploy.dir}/${download.description}${time}_mds.jar"/>         </ant>            <echo>create zip with MDS jar</echo>                  <zip destfile="${mds.deploy.dir}/${download.description}${time}_mds.zip" compress="false">             <fileset dir="${mds.deploy.dir}" includes="*${time}_mds.jar"/>          </zip>     </target>        <target name="deployMDSobjects">             <propertycopy name="deploy.serverURL"    from="${target.environment}.serverURL"/>          <propertycopy name="deploy.overwrite"    from="${target.environment}.overwrite"/>          <propertycopy name="deploy.user"         from="${target.environment}.user"/>          <propertycopy name="deploy.password"     from="${target.environment}.password"/>          <propertycopy name="deploy.forceDefault" from="${target.environment}.forceDefault"/>            <echo>deploy objects to ${target.environment} MDS</echo>            <echo>deploy on ${deploy.serverURL} with user ${deploy.user}</echo>          <echo>deploy sarFile ${mds.deploy.dir}/${download.description}${time}_mds.zip</echo>            <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false" target="deploy">               <property name="wl_home" value="${wl_home}"/>               <property name="oracle.home" value="${oracle.home}"/>               <property name="serverURL" value="${deploy.serverURL}"/>               <property name="user" value="${deploy.user}"/>               <property name="password" value="${deploy.password}"/>               <property name="overwrite" value="${deploy.overwrite}"/>               <property name="forceDefault" value="${deploy.forceDefault}"/>               <property name="sarLocation" value="${mds.deploy.dir}/${download.description}${time}_mds.zip"/>          </ant>          </target>     </project>

  9. The final file is the bat file to run the ANT script. this will need to be changed to meet your environment.

    set ORACLE_HOME=d:\oracle\product\jdeveloper\11.1.1.4
    set ANT_HOME=%ORACLE_HOME%\jdeveloper\ant
    set PATH=%ANT_HOME%\bin;%PATH%
    set JAVA_HOME=%ORACLE_HOME%\jdk160_21

    set CURRENT_FOLDER=%CD%

    ant -f build.xml %1

  10. You can run the ANT script from any directory you choose to download the scripts. The bat file will set the correct path to find the right executables. As all the dynamic variables are set in the build.properties you only need to specify the project to execute. Open a command prompt and change directory to where you ANT scripts are. Execute the following:

    mdsConfig.bat migrateObjects


  11. You should now see you DVM in your DB MDS in JDeveloper.


  12. The last test it to see that your DVM has now been loaded in the server and can be accessed from the SOA Composer.




About

Discussions and Examples using Oracle Fusion Middleware. Some image links are broken when using Firefox, Safari, and Chrome. If you want to see the full image please use IE.

Twitter:@james8001

tumblr hit counter vistors, thanks for your support

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