2012年6月28日木曜日

JBoss7のデータソース設定

JBoss7でのデータソース設定方法を説明したページがあったので書いておく。
コレもボチボチと訳してこかな。
[AS71:DataSource configuration]
https://docs.jboss.org/author/display/AS71/DataSource+configuration

ついでにJBoss7.1のドキュメントも
https://docs.jboss.org/author/display/AS71/Documentation

ちなみにコッチの方が1ページになってて見易い
Data Source Configuration in AS 7
https://community.jboss.org/wiki/DataSourceConfigurationInAS7#Installing_a_JDBC_driver_as_a_module


Data Source Configuration in AS 7

Datasources are configured through the datasource subsystem.
Datasourcesは、datasourceサブシステムを通して構成されます。
Declaring a new datasource consists of two separate steps:
新しいdatasourceを宣言することは、2つの別々のステップから成ります:
You would need to provide a JDBC driver and define a datasource that references the driver you installed.
あなたはJDBCドライバーを提供する必要があって、設置したドライバーを参照文に引用するdatasourceを定めるでしょう。

JDBC Driver Installation
JDBCドライバー・インストール

The recommended way to install a JDBC driver into the application server is to simply deploy it as a regular JAR deployment.
アプリケーション・サーバにJDBCドライバーを設置する推薦された方法は、単に普通にJARをデプロイしてそれを配備することです。
The reason for this is that when you run your application server in domain mode, deployments are automatically propagated to all servers to which the deployment applies;
これの理由は、あなたがドメインモードでアプリケーション・サーバを動かすとき、配備機構が配備があてはまるすべてのサーバーに自動的に伝播されるということです;
thus distribution of the driver JAR is one less thing for you to worry about!
このように、ドライバーJARの配布は、あなたが心配する1つのより少ないものです!

Any JDBC 4-compliant driver will automatically be recognized and installed into the system by name and version.
どんなJDBC 4対応ドライバーでも、名前とバージョンによってシステムに自動的に認識されて、設置されます。
A JDBC JAR is identified using the Java service provider mechanism.
JDBC JARは、Javaサービスプロバイダ・メカニズムを使って確認されます。
Such JARs will contain a text a file named META-INF/services/java.sql.Driver, which contains the name of the class(es) of the Drivers which exist in that JAR.
ファイルがMETA-INF/services/java.sql.Driverという名前をつけたテキストを、そのようなJARsは含みます。そして、それはそのJARの中に存在するドライバーの種類の名前を含みます。
If your JDBC driver JAR is not JDBC 4-compliant, it can be made deployable in one of a few ways.
あなたのJDBCドライバーJARがJDBC 4-対応でないならば、それは2、3の方向の1つで展開できるようになることができます。

Modify the JAR
JARを修正する

The most straightforward solution is to simply modify the JAR and add the missing file.
最も直接の解決は単にJARを修正することで、失っているファイルを加えることです。
You can do this from your command shell by:
あなたは、コマンドシェルから以下によってこうすることができます:

1.Change to, or create, an empty temporary directory.
1.空の一時的なディレクトリに移動、あるいは、作成してください。
2.Create a META-INF subdirectory.
2.META-INFサブディレクトリを作成してください。
3.Create a META-INF/services subdirectory.
3.META-INF/servicesサブディレクトリを作成してください。
4.Create a META-INF/services/java.sql.Driver file which contains one line - the fully-qualified class name of the JDBC driver.
4.META-INF/services/java.sql.Driverファイルを作成し、そのファイルにこの1行含めます-JDBCドライバのフルクラス名
5.Use the jar command-line tool to update the JAR like this:
5.jarコマンドラインツールを使い、このようにJARをアップデートします:
jar \-uf jdbc-driver.jar META-INF/services/java.sql.Driver

For a detailed explanation how to deploy JDBC 4 compliant driver jar, please refer to the chapter "Application Deployment".
JDBC 4対応ドライバー・ジャーを展開するために詳細な説明方法については、章「アプリケーションDeployment」を参照してください。

Datasource Definitions
データソース定義

The datasource itself is defined within the subsystem datasources:
datasource自体は、サブシステムdatasourcesの中で定義されます:
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
    <datasources>
        <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS">
            <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
            <driver>h2</driver>
            <pool>
                <min-pool-size>10</min-pool-size>
                <max-pool-size>20</max-pool-size>
                <prefill>true</prefill>
            </pool>
            <security>
                <user-name>sa</user-name>
                <password>sa</password>
            </security>
        </datasource>
        <xa-datasource jndi-name="java:jboss/datasources/ExampleXADS" pool-name="ExampleXADS">
           <driver>h2</driver>
           <xa-datasource-property name="URL">jdbc:h2:mem:test</xa-datasource-property>
           <xa-pool>
                <min-pool-size>10</min-pool-size>
                <max-pool-size>20</max-pool-size>
                <prefill>true</prefill>
           </xa-pool>
           <security>
                <user-name>sa</user-name>
                <password>sa</password>
           </security>
        </xa-datasource>
        <drivers>
            <driver name="h2" module="com.h2database.h2">
                <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
            </driver>
        </drivers>
  </datasources>

</subsystem>
(See standalone/configuration/standalone.xml)
(standalone/configuration/standalone.xml参照)

As you can see the datasource references a driver by it's logical name.
datasourceがそばにドライバーを参照文に引用するのをあなたが見ることができるように、それは論理的な名前です。

You can easily query the same information through the CLI:
あなたは、CLIによって同じ情報を簡単に問い合わせることができます:

[standalone@localhost:9999 /] /subsystem=datasources:read-resource(recursive=true)
{
    "outcome" => "success",
    "result" => {
        "data-source" => {"java:/H2DS" => {
            "connection-url" => "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
            "jndi-name" => "java:/H2DS",
            "driver-name" => "h2",
            "pool-name" => "H2DS",
            "use-java-context" => true,
            "enabled" => true,
            "jta" => true,
            "pool-prefill" => true,
            "pool-use-strict-min" => false,
            "user-name" => "sa",
            "password" => "sa",
            "flush-strategy" => "FailingConnectionOnly",
            "background-validation" => false,
            "use-fast-fail" => false,
            "validate-on-match" => false,
            "use-ccm" => true
        }},
        "xa-data-source" => undefined,
        "jdbc-driver" => {"h2" => {
            "driver-name" => "h2",
            "driver-module-name" => "com.h2database.h2",
            "driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource"
        }}
    }
}

[standalone@localhost:9999 /] /subsystem=datasources:installed-drivers-list
{
    "outcome" => "success",
    "result" => [{
        "driver-name" => "h2",
        "deployment-name" => undefined,
        "driver-module-name" => "com.h2database.h2",
        "module-slot" => "main",
        "driver-xa-datasource-class-name" => "org.h2.jdbcx.JdbcDataSource",
        "driver-class-name" => "org.h2.Driver",
        "driver-major-version" => 1,
        "driver-minor-version" => 2,
        "jdbc-compliant" => true
    }]
}
Using the web console or the CLI greatly simplifies the deployment of JDBC drivers and the creation of datasources.
ウェブ・コンソールまたはCLIを使用することは、JDBCドライバーの配備とdatasourcesの創造を大いに単純化します。

The CLI offers a set of commands to create and modify datasources:
CLIは、datasourcesをつくって、修正しなさいという一組の命令を提供します:
[standalone@localhost:9999 /] help
Supported commands:

[...]

data-source - allows to add new, modify and remove existing data sources
xa-data-source - allows add new, modify and remove existing XA data sources

For a more detailed description of a specific command, execute the command with '--help' as the argument.
特定の命令のより仔細な説明のために、引数として『--help』でコマンドを実行してください。

Using security domains
セキュリティ・ドメインの使用

Information can be found at https://community.jboss.org/wiki/JBossAS7SecurityDomainModel
Deployment of -ds.xml files

Starting with JBoss Application Server 7.1.0.Final you have the ability to deploy a -ds.xml file following the schema:
-ds.xmlファイルの配備の情報は、https://community.jboss.org/wiki/JBossAS7SecurityDomainModelで見つかります。

http://docs.jboss.org/ironjacamar/schema/datasources_1_1.xsd

It is mandatory to use a reference to an already deployed / defined entry.
すでに展開された/定義済みのエントリへの参照を使うことは、義務的です。

This feature is primarily intended for development, and thus has a few limitations to be aware of.
この特徴には主に発展を目的として、このように、気づいている2、3の限界があります。
It can not be altered in any of the management interfaces (consle, CLI, etc).
それは、管理インターフェース(コンソール、CLI、その他)の何でも変えられることができません。
Only limited runtime information is available.
限られた実行時情報だけが利用できます。
Also, password vaults and security domains are not deployable, so these can not be bundled with a datasource deployment.
また、パスワード金庫室とセキュリティ・ドメインは展開できないので、これらはdatasource配備とバンドルされることができません。

Component Reference
コンポーネント参照

The datasource subsystem is provided by the IronJacamar project.
datasourceサブシステムは、IronJacamarプロジェクトによって提供されます。
For a detailed description of the available configuration properties, please consult the project documentation.
利用できる構成特性の詳しい説明のために、プロジェクト・ドキュメンテーションを参照してください。

- IronJacamar homepage: http://www.jboss.org/ironjacamar
- Project Documentation: http://www.jboss.org/ironjacamar/docs
- Schema description: http://docs.jboss.org/ironjacamar/userguide/1.0/en-US/html/deployment.html#deployingds_descriptor


0 件のコメント:

コメントを投稿