我很高兴宣布 IronJacamar 1.0 的第二个 beta 版本,该版本实现了 Java EE 连接器架构 1.6 规范。
完整的发布说明在此:此处。
部署描述符
我们已经添加了对我们的部署描述符的支持
- ironjacamar.xml -- 我们对标准 ra.xml 描述符的供应商特定扩展
- -ra.xml -- 资源适配器的部署配置文件
- -ds.xml -- 数据源的部署配置文件
ironjacamar.xml 文件的示例
<ironjacamar>
<connection-definitions>
<connection-definition jndi-name="java:/eis/MyCF"
class-name="org.jboss.jca.test.deployers.spec.rars.ra15out.TestManagedConnectionFactory">
<config-property name="MyProperty">Override</config-property>
</connection-definition>
</connection-definitions>
</ironjacamar>
这些格式被设置为在 JBoss 应用服务器 7 中使用,因此请确保检查 XSD 并提供您的反馈。
数据源
由于我们现在支持基于 -ds.xml 格式部署数据源,我们还可以在我们的嵌入式设置中部署数据源,从而帮助测试需要数据源的应用程序。这些部署将使用我们的 JDBC 资源适配器,该适配器提供 JDBC4 API 和连接池。
H2 数据源的部署示例
package org.jboss.jca.adapters.jdbc.unit;
import org.jboss.jca.embedded.EmbeddedJCA;
import java.io.File;
import java.net.URL;
import java.sql.Connection;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.jboss.logging.Logger;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Test cases for getting a connection from the H2 database
*
* @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
* @version $Revision: $
*/
public class H2TestCase
{
// --------------------------------------------------------------------------------||
// Class Members ------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
private static Logger log = Logger.getLogger(H2TestCase.class);
private static final String JNDI_NAME = "java:/H2DS";
/*
* Embedded
*/
private static EmbeddedJCA embedded;
// --------------------------------------------------------------------------------||
// Tests --------------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
/**
* Get a connection from the database
* @exception Throwable Thrown if case of an error
*/
@Test
public void testConnection() throws Throwable
{
Context context = null;
try
{
context = new InitialContext();
DataSource ds = (DataSource)context.lookup(JNDI_NAME);
assertNotNull(ds);
Connection c = ds.getConnection();
assertNotNull(c);
}
catch (Throwable t)
{
log.error(t.getMessage(), t);
fail(t.getMessage());
}
finally
{
if (context != null)
{
try
{
context.close();
}
catch (NamingException ne)
{
// Ignore
}
}
}
}
// --------------------------------------------------------------------------------||
// Helper Methods -----------------------------------------------------------------||
// --------------------------------------------------------------------------------||
/**
* Get the URL for a test archive
* @param archive The name of the test archive
* @return The URL to the archive
* @throws Throwable throwable exception
*/
private static URL getURL(String archive) throws Throwable
{
File f = new File(System.getProperty("archives.dir") + File.separator + archive);
return f.toURI().toURL();
}
// --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
// --------------------------------------------------------------------------------||
/**
* Lifecycle start, before the suite is executed
* @throws Throwable throwable exception
*/
@BeforeClass
public static void beforeClass() throws Throwable
{
// Create and set an embedded JCA instance
embedded = new EmbeddedJCA();
// Startup
embedded.startup();
// Deploy jdbc-local.rar
embedded.deploy(getURL("jdbc-local.rar"));
// Deploy H2 datasource
embedded.deploy(getURL("test/h2-ds.xml"));
}
/**
* Lifecycle stop, after the suite is executed
* @throws Throwable throwable exception
*/
@AfterClass
public static void afterClass() throws Throwable
{
// Undeploy H2 datasource
embedded.undeploy(getURL("test/h2-ds.xml"));
// Undeploy jdbc-local.rar
embedded.undeploy(getURL("jdbc-local.rar"));
// Shutdown embedded
embedded.shutdown();
// Set embedded to null
embedded = null;
}
}
当然,在即将发布的版本中将对 Arquillian 提供支持。
工具
我们的工具进行了几项改进。
我们的验证器工具现在有了 Maven 插件,因此您可以直接从 POM 文件中使用它。并且代码生成器现在能够根据 Ant+Ivy 或 Maven 生成完整的构建环境。
我们希望您喜欢这些改进。
未来之路
我们将继续进行 JBoss 应用服务器 7 的集成,并根据您的反馈继续增强容器。
向即将摇滚的人致敬!