此内容没有您所选择的语言版本。

16.5. Custom


If above provided metadata facilities are not sufficient for user's needs then user can extend the MetadataRepository class provided in the org.teiid.api JAR to plug-in their own metadata facilities into the JBoss Data Virtualization engine.
  1. Users can write metadata facility that is based on reading data from database or a JCR repository or so forth. Here is an example:
    package com.something;
    
    import org.teiid.metadata.MetadataRepository;
    ...
    			
    public class CustomMetadataRepository extends MetadataRepository {
        @Override
        public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory)
            throws TranslatorException {
            /* Provide implementation and fill the details in factory */
            ...
        }
    }
    
    Copy to Clipboard Toggle word wrap
  2. Build a JAR archive with above implementation class and create file named org.teiid.metadata.MetadataRepository in the META-INF/services directory with these contents:
    com.something.CustomMetadataRepository
    
    Copy to Clipboard Toggle word wrap
  3. Deploy the JAR to Red Hat JBoss EAP as a module under the modules directory. Follow the below steps to create a module.
    • Create a directory called modules/com/something/main.
    • Under this directory create a "module.xml" file that looks like:
      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.0" name="com.something">
          <resources>
              <resource-root path="something.jar" />
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.resource.api"/>
              <module name="org.jboss.teiid.common-core"/>
              <module name="org.jboss.teiid.teiid-api" />
          </dependencies>
      </module>
      
      Copy to Clipboard Toggle word wrap
    • 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.
This is how you configure the VDB with the custom metadata repository you have created:

Example 16.4. Sample vdb.xml file

<vdb name="{vdb-name}" version="1">
    <model name="{model-name}" type="PHYSICAL">
        <source name="AccountsDB" translator-name="oracle" connection-jndi-name="java:/oracleDS"/>
        <metadata type="{metadata-repo-module}"></metadata>
    </model>
</vdb>
Copy to Clipboard Toggle word wrap
When the VDB is 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.

Important

Be careful about holding state and synchronization in your repository instance.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat