Skip to end of metadata
Go to start of metadata

If above provided metadata facilities are not sufficient then a developer can extend the MetadataRepository class provided in the org.teiid.api jar to plug-in their own metadata facilities into the Teiid engine. For example, a user can write a metadata facility that is based on reading data from a database or a JCR repository. See Setting up the build environment to start development. For Example:

Sample Java Code

Then build a JAR archive with above implementation class and create file a named org.teiid.metadata.MetadataRepository in the META-INF/services directory with contents:

Once the JAR file has been built, it needs to be deployed in the JBoss AS as a module under <jboss-as>/modules directory. Follow the below steps to create a module.

  • Create a directory <jboss-as>/modules/com/something/main
  • Under this directory create a "module.xml" file that looks like
Sample module.xml file
  • Copy the jar file under this same directory. Make sure you add any additional dependencies if required by your implementation class under dependencies.
  • Restart the server

The below XML fragment shows how to configure the VDB with the custom metadata repository created

Sample vdb.xml file

Now when this VDB gets deployed, it will call the CustomMetadataRepository instance for metadata of the model. Using this you can define metadata for single model or for the whole VDB pragmatically.   Be careful about holding state and synchronization in your repository instance.

Development Considerations

  • MetadataRepository instances are created on a per vdb basis and may be called concurrently for the load of multiple models.
  • See the MetadataFactory and the org.teiid.metadata package javadocs for metadata construction methods and objects. For example if you use your own DDL, then call the MetadataFactory.parse(Reader) method. If you need access to files in a VDB zip deployment, then use the MetadataFactory.getVDBResources method.
  • Use the MetadataFactory.addPermission and add MetadataFactory.addColumnPermission method to grant permissions on the given metadata objects to the named roles. The roles should be declared in your vdb.xml, which is also where they are typically tied to container roles.
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.