zaterdag 29 september 2012

Sharing a File-based MDS repository

If you want to use a file-based MDS repository within JDeveloper, most textbooks explain that you have to create this repository in a very specific directory: <Jdev home>/jdeveloper/integration/seed. In this directory, you have to create the subdirectory 'apps' and your project MDS repositories. This is all very well when you're the only developer in the project, once you're in a team this is a nuisance. Especially in the early stages of a project, the MDS artifacts and structure that your team creates change frequently. If you're not using a database-based MDS during development, you'd like your file-based MDS to be on a share. Thanks to a tip I got from Geoffrey de Lamalle during a SOA summer camp, it is possible to do just that! This is how you do it:

Create, within in your application, a generic project in JDeveloper, call it what you like, for instance myProjectMDS. Create it on a share (e.g. Z:/mds/myApplicationMDS) and create the following subdirectory structure:

(Z:/mds/myApplicationMDS)/src/apps/myMDS/xsd

This directory will hold the XML schema's that are shared in this project (obviously this is a very simplified example). You can extend or change this structure as you like.

Now, how do we let JDeveloper know where this project specific MDS repository is located?

First, change the file jdev.conf, you can find it in the map <Jdev home>/jdeveloper/jdev/bin. Add the following line:

AddVMOption -Dmyapp.home=Z:\mds

Next, change the file ant-sca-compile.xml, found in the map <Jdev home>/jdeveloper/bin. You have to add to <target name ="scac"> the following line:

<jvmarg value="-Dmyapp.home=Z:\mds"/>

Finally, change one more file, called adf-config.xml. It is located in your application directory in the subdirectory .adf/META-INF. Here, you will tell your application which metadata stores to use. Add the following lines:

<metadata-namespaces>
...
   <namespace path="/apps/myMDS" metadata-store-usage="mstore-usage_2"/>
...
</metadata-namespaces>

 <metadata-store-usages>
...
<metadata-store-usage id="mstore-usage_2">
    <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
      <property value="${myapp.home}/myApplicationMDS" name="metadata-path"/>
      <property value="src" name="partition-name"/>    
   </metadata-store>
 </metadata-store-usage>
...
</metadata-store-usages>
  
Restart JDeveloper and the changes should take effect.

Manually deleting MDS entries

The MDS in the Oracle Soa Suite 11g is a very powerful concept. We use it a lot in our projects. At the start of each project, we enthusiastically add all kinds of artifacts, only to find out later that we didn't really need them, that the folder structure of our project in the MDS has changed, that we didn't like the names we gave the artifacts etc etc. Sounds familiar? Eventually, obsolete items start to clutter our projects. Recently I got a tip on how to manually delete items from the MDS and I would like to share this valuable piece of information. It goes like this:

  • Go to the Enterprise Manager
  • Go to the SOA Infrastructure menu
  • Go to Administration -> System MBean Browser


  • Scroll down to the entry "oracle.mds.lcm"
  • expand Server: (your servername) -> Application: soa-infra -> MDSAppRuntime, here you will find the bean MDSAppRuntime

  • Go the the tab called "Operations" and click the link "deleteMetadata" (I always choose the first one)
  • if you click on the pencil next to the item "docs", you can add the documents you want to delete. Wildcards are permitted!

  • once you're done adding the artifacts you wish to delete, click on the button "OK'. Back in the previous screen, you now click on "Invoke".
That's it! Your project MDS is neat and tidy again. Of course, be careful not to remove essential, internal SOA Suite artifacts...