BlueMix 如何在部署期间执行自动装配?
How does BlueMix perform Autowiring during deployment?
我下载了 BlueMix Java SQLDB 样板,我正在使用它,考虑扩展其他表等。我对 'autowiring' 发生的链接有点困惑BlueMix 中的数据库服务到位于 deployment/runtime.
的应用程序
在样板文件中 persistence.xml 中有一些配置说:
<persistence-unit name="openjpa-todo">
<!-- The cloudAutowiring-1.0 Liberty feature will resolve this to whatever
the database service name is -->
<!-- When running locally without this feature, create a datasource with
the JNDI name "jdbc/mydbdatasource" in server.xml -->
<!-- If using MySQL locally then use the "url" property and append "?relaxAutoCommit=true", for example:
<dataSource id='mysql-datasource' jdbcDriverRef='mysql-driver' jndiName='jdbc/mydbdatasource'>
<properties user='root' password='password' url="jdbc:mysql://localhost:3306/db?relaxAutoCommit=true"/>
</dataSource> -->
<jta-data-source>java:comp/env/jdbc/mydbdatasource</jta-data-source>
<class>example.jpa.TODO</class>
<properties>
<!-- allow table definitions/creation on-the-fly jpa-2.0 feature -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
<!-- allow table definitions/creation on-the-fly jpa-2.1 feature -->
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
BlueMix/Liberty 如何从部署的服务映射到 jta-data-source/persistence-unit?
自动装配是否需要满足任何条件或要求?
实际上很酷。在部署应用程序期间,buildpack 允许您执行一些额外的逻辑。 Liberty buildpack 中有一些逻辑可以自动连接几个服务。监控和分析、日志记录,仅举几例。节点 buildpack 也这样做。
我已经捕获了下面的一些自动装配。
2015-04-10T15:24:51.98-0400 [STG] OUT -----> Liberty Buildpack Version: v1.15-20150402-1422
2015-04-10T15:24:51.98-0400 [STG] OUT -----> Retrieving IBM 7.1.2_sr2fp11ifx-20150312 JRE (ibm-java-jre-7.1-2.11-pxa6470_27sr2fp11ifx-20150312_01-sfj.tgz) ... (0.0s)
2015-04-10T15:24:52.82-0400 [STG] OUT Expanding JRE to .java ... (0.8s)
2015-04-10T15:24:52.82-0400 [STG] OUT -----> Retrieving App Management Agent 2015.03.09_101422 (com.ibm.ws.cloudoe.app-mgmt-proxy-agent.zip) ... (0.0s)
2015-04-10T15:24:52.92-0400 [STG] OUT Expanding App Management to .app-management (0.0s)
2015-04-10T15:24:52.92-0400 [STG] OUT -----> Retrieving com.ibm.ws.liberty-2015.3.0.0-201504021422.tar.gz ... (0.0s)
2015-04-10T15:24:53.74-0400 [STG] OUT Installing archive ... (0.8s)
2015-04-10T15:24:53.76-0400 [STG] OUT -----> Retrieving com.ibm.ws.liberty.ext-2015.3.0.0-201504021422.tar.gz ... (0.0s)
2015-04-10T15:24:54.15-0400 [STG] OUT Installing archive ... (0.3s)
2015-04-10T15:24:54.33-0400 [STG] OUT -----> Retrieving and installing client jar(s) from com.ibm.ws.icap.clientJars.cloudant.zip (0.1s)
2015-04-10T15:24:54.34-0400 [STG] OUT -----> Auto-configuration is creating config for service instance 'Cloudant NoSQL DB-wr' of type 'cloudantNoSQLDB'
2015-04-10T15:24:54.36-0400 [STG] OUT -----> Liberty buildpack is done creating the droplet
2015-04-10T15:24:54.63-0400 [STG] ERR
2015-04-10T15:25:06.80-0400 [STG] OUT -----> Uploading droplet (147M)
buildpack 寻找的是与您的应用绑定的服务。如果存在 Cloudant 或 Monitoring and Analytics 等绑定服务,它将添加正确的资源。对于 Cloudant,因为它是 JDBC,它将为您创建 JDBC 连接。
此外,Liberty buildpack 为以下服务类型提供自动配置:SQL 数据库 ClearDB MySQL 数据库 MySQL ElephantSQL PostgreSQL Cloudant ™ 否SQL 数据库 MongoLab dashDB 数据缓存 会话缓存 MQ Light 监控和分析 Auto-Scaling 单点登录 New Relic
我下载了 BlueMix Java SQLDB 样板,我正在使用它,考虑扩展其他表等。我对 'autowiring' 发生的链接有点困惑BlueMix 中的数据库服务到位于 deployment/runtime.
的应用程序在样板文件中 persistence.xml 中有一些配置说:
<persistence-unit name="openjpa-todo">
<!-- The cloudAutowiring-1.0 Liberty feature will resolve this to whatever
the database service name is -->
<!-- When running locally without this feature, create a datasource with
the JNDI name "jdbc/mydbdatasource" in server.xml -->
<!-- If using MySQL locally then use the "url" property and append "?relaxAutoCommit=true", for example:
<dataSource id='mysql-datasource' jdbcDriverRef='mysql-driver' jndiName='jdbc/mydbdatasource'>
<properties user='root' password='password' url="jdbc:mysql://localhost:3306/db?relaxAutoCommit=true"/>
</dataSource> -->
<jta-data-source>java:comp/env/jdbc/mydbdatasource</jta-data-source>
<class>example.jpa.TODO</class>
<properties>
<!-- allow table definitions/creation on-the-fly jpa-2.0 feature -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
<!-- allow table definitions/creation on-the-fly jpa-2.1 feature -->
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
BlueMix/Liberty 如何从部署的服务映射到 jta-data-source/persistence-unit?
自动装配是否需要满足任何条件或要求?
实际上很酷。在部署应用程序期间,buildpack 允许您执行一些额外的逻辑。 Liberty buildpack 中有一些逻辑可以自动连接几个服务。监控和分析、日志记录,仅举几例。节点 buildpack 也这样做。
我已经捕获了下面的一些自动装配。
2015-04-10T15:24:51.98-0400 [STG] OUT -----> Liberty Buildpack Version: v1.15-20150402-1422
2015-04-10T15:24:51.98-0400 [STG] OUT -----> Retrieving IBM 7.1.2_sr2fp11ifx-20150312 JRE (ibm-java-jre-7.1-2.11-pxa6470_27sr2fp11ifx-20150312_01-sfj.tgz) ... (0.0s)
2015-04-10T15:24:52.82-0400 [STG] OUT Expanding JRE to .java ... (0.8s)
2015-04-10T15:24:52.82-0400 [STG] OUT -----> Retrieving App Management Agent 2015.03.09_101422 (com.ibm.ws.cloudoe.app-mgmt-proxy-agent.zip) ... (0.0s)
2015-04-10T15:24:52.92-0400 [STG] OUT Expanding App Management to .app-management (0.0s)
2015-04-10T15:24:52.92-0400 [STG] OUT -----> Retrieving com.ibm.ws.liberty-2015.3.0.0-201504021422.tar.gz ... (0.0s)
2015-04-10T15:24:53.74-0400 [STG] OUT Installing archive ... (0.8s)
2015-04-10T15:24:53.76-0400 [STG] OUT -----> Retrieving com.ibm.ws.liberty.ext-2015.3.0.0-201504021422.tar.gz ... (0.0s)
2015-04-10T15:24:54.15-0400 [STG] OUT Installing archive ... (0.3s)
2015-04-10T15:24:54.33-0400 [STG] OUT -----> Retrieving and installing client jar(s) from com.ibm.ws.icap.clientJars.cloudant.zip (0.1s)
2015-04-10T15:24:54.34-0400 [STG] OUT -----> Auto-configuration is creating config for service instance 'Cloudant NoSQL DB-wr' of type 'cloudantNoSQLDB'
2015-04-10T15:24:54.36-0400 [STG] OUT -----> Liberty buildpack is done creating the droplet
2015-04-10T15:24:54.63-0400 [STG] ERR
2015-04-10T15:25:06.80-0400 [STG] OUT -----> Uploading droplet (147M)
buildpack 寻找的是与您的应用绑定的服务。如果存在 Cloudant 或 Monitoring and Analytics 等绑定服务,它将添加正确的资源。对于 Cloudant,因为它是 JDBC,它将为您创建 JDBC 连接。
此外,Liberty buildpack 为以下服务类型提供自动配置:SQL 数据库 ClearDB MySQL 数据库 MySQL ElephantSQL PostgreSQL Cloudant ™ 否SQL 数据库 MongoLab dashDB 数据缓存 会话缓存 MQ Light 监控和分析 Auto-Scaling 单点登录 New Relic