了解jca 1.6中的@ConnectionDefinitions注释
我找不到显示在 ManagedConnectionFactory 实现上使用复数 @ConnectionDefinitions 的用例的示例。让我困惑的是,单一的 @ConnectionDefinition 注释不允许您为每个定义提供 @ConfigProperty。您只能使用 @ConfigProperty 来设置 ManagedConnectionFactory 的所有实例的默认属性,并且每个连接定义必须使用不同的 ConnectionFactory 接口。因此,假设您做了这样的事情:
@ConnectionDefinitions(value = {
@ConnectionDefinition(
connection = com.company.product.connector.MyConnection.class,
connectionFactory = com.company.product.connector.ConnectionFactory1.class,
connectionFactoryImpl = com.company.product.connector.ConnectionFactory1Impl.class,
connectionImpl = com.company.product.connector.MyConnectionImpl.class
)
@ConnectionDefinition(
connection = com.company.product.connector.MyConnection.class,
connectionFactory = com.company.product.connector.ConnectionFactory2.class,
connectionFactoryImpl = com.company.product.connector.ConnectionFactory2Impl.class,
connectionImpl = com.company.product.connector.MyConnectionImpl.class
)
})
public class MyManagedConnectionFactory implements
ManagedConnectionFactory, ResourceAdapterAssociation {
@Override
public Object createConnectionFactory(ConnectionManager connectionManager)
throws ResourceException {
//Return the connection factory.
}
}
createConnectionFactory() 如何知道是否返回 ConnectionFactory1 或 ConnectionFactory2?除非有人通过 ra.xml 覆盖注释,否则我认为无法使用配置属性作为条件。
确定 ManagedConnectionFactory 属于哪个连接定义似乎很困难,那么当您可以为每个 ConnectionFactory 拥有单独的 ManagedConnectionFactory 时为什么要这样做呢?
举个例子会很有帮助。
I cannot find an example that shows a use case for using the plural @ConnectionDefinitions on a ManagedConnectionFactory implementation. What confuses me is that the singular @ConnectionDefinition annotation does not let you provide @ConfigProperty for each definition. You can only use @ConfigProperty to set the default properties for ALL instances of the ManagedConnectionFactory, and every connection definition must use a different ConnectionFactory interface. So assuming you did something like this:
@ConnectionDefinitions(value = {
@ConnectionDefinition(
connection = com.company.product.connector.MyConnection.class,
connectionFactory = com.company.product.connector.ConnectionFactory1.class,
connectionFactoryImpl = com.company.product.connector.ConnectionFactory1Impl.class,
connectionImpl = com.company.product.connector.MyConnectionImpl.class
)
@ConnectionDefinition(
connection = com.company.product.connector.MyConnection.class,
connectionFactory = com.company.product.connector.ConnectionFactory2.class,
connectionFactoryImpl = com.company.product.connector.ConnectionFactory2Impl.class,
connectionImpl = com.company.product.connector.MyConnectionImpl.class
)
})
public class MyManagedConnectionFactory implements
ManagedConnectionFactory, ResourceAdapterAssociation {
@Override
public Object createConnectionFactory(ConnectionManager connectionManager)
throws ResourceException {
//Return the connection factory.
}
}
How will createConnectionFactory() know whether or not to return ConnectionFactory1 or ConnectionFactory2? Unless someone overrides the annotation anyways through ra.xml, I see no way to use a config-property as a conditional.
It seems difficult to determine which connection definition a ManagedConnectionFactory is a part of, so why do this when you can just have seperate ManagedConnectionFactory for every ConnectionFactory?
An example would be very helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论