简体   繁体   English

Java连接器体系结构(JCA)中的网络边界在哪里?

[英]Where are the network boundaries in the Java Connector Architecture (JCA)?

I am writing a JCA resource adapter. 我正在编写JCA资源适配器。 I'm also, as I go, trying to fully understand the connection management portion of the JCA specification. 我也是这样,试图完全理解JCA规范的连接管理部分。 As a thought experiment, pretend that the only client of this adapter will be a Swing Java Application Client located on a different machine. 作为一个思想实验,假装此适配器的唯一客户端将是位于不同计算机上的Swing Java应用程序客户端。 Also assume that the resource adapter will communicate with its "enterprise information system" (EIS) over the network as well. 还假设资源适配器也将通过网络与其“企业信息系统”(EIS)进行通信。

As I understand the JCA specification, the .rar file is deployed to the application server. 据我了解JCA规范,.rar文件已部署到应用程序服务器。 The application server creates the .rar file's implementation of the ManagedConnectionFactory interface. 应用程序服务器创建.rar文件的ManagedConnectionFactory接口实现。 It then asks it to produce a connection factory, which is the opaque object that is deployed to JNDI for the user to use to obtain a connection to the resource. 然后它要求它生成一个连接工厂,它是部署到JNDI的不透明对象,供用户用来获取与资源的连接。 (In the case of JDBC, the connection factory is a javax.sql.DataSource.) (对于JDBC,连接工厂是javax.sql.DataSource。)

It is a requirement that the connection factory retain a reference to the application-server-supplied ConnectionManager, which, in turn, is required to be Serializable. 连接工厂要求保留对应用程序服务器提供的ConnectionManager的引用,而ConnectionManager又需要Serializable。 This makes sense--in order for the connection factory to be stored in JNDI, it must be serializable, and in order for it to keep a reference to the ConnectionManager, the ConnectionManager must also be serializable. 这是有道理的 - 为了将连接工厂存储在JNDI中,它必须是可序列化的,并且为了使它保持对ConnectionManager的引用,ConnectionManager也必须是可序列化的。 So fine, this little object graph gets installed in the application client's JNDI tree. 很好,这个小对象图安装在应用程序客户端的JNDI树中。

This is where I start to get queasy. 这是我开始变得不安的地方。 Is the ConnectionManager--the piece supplied by the application server that is supposed to handle connection management, sharing, pooling, etc.--wholly present on the client at this point? ConnectionManager - 由应用程序服务器提供的应该处理连接管理,共享,池化等的部分 - 此时完全出现在客户端上吗? One of its jobs is to create ManagedConnection instances, and a ManagedConnection is not required to be Serializable, and the user connection handles it vends are also not required to be Serializable. 其中一项工作是创建ManagedConnection实例,而ManagedConnection不需要是Serializable,并且用户连接处理它们也不需要序列化。 That suggests to me that the whole connection pooling machinery is shipped wholesale to the application client and stuffed into its JNDI tree. 这告诉我整个连接池机器批发到应用程序客户端并填充到其JNDI树中。

Does this all mean that JCA interactions from the client side bypass the server-side componentry of the application server? 这是否意味着来自客户端的JCA交互绕过了应用服务器的服务器端组件? Where are the network boundaries in the JCA API? JCA API中的网络边界在哪里?

Does this all mean that JCA interactions from the client side bypass the server-side componentry of the application server? 这是否意味着来自客户端的JCA交互绕过了应用服务器的服务器端组件? Where are the network boundaries in the JCA API? JCA API中的网络边界在哪里?

AFAIK, yes. AFAIK,是的。 There will be a local JNDI and the local JNDI will return local connections. 将有一个本地JNDI,本地JNDI将返回本地连接。 Same if true for other kind of object in the JNDI, such a configuration value ( env-entry ). 如果对于JNDI中的其他类型的对象,则为相同,例如配置值( env-entry )。 Of course, if you look up an EJB, the factory returns a proxy to the remote bean, but the JNDI is still local to my knowledge. 当然,如果查找EJB,工厂会将代理返回给远程bean,但JNDI仍然是我所知的本地代码。

The client embeds its own pool. 客户端嵌入了自己的池。 This means, as you pointed out, that connections obtained in the client will escape the server-side machinery. 这意味着,正如您所指出的那样,在客户端中获得的连接将逃离服务器端机器。

It gets even worse when we start to play with distributed transactions. 当我们开始使用分布式事务时,它会变得更糟。 A client may obtain a UserTransaction to start and stop distributed transactions on the client-side (not all app. server supports this, though). 客户端可以获取UserTransaction以在客户端启动和停止分布式事务(但并非所有应用程序服务器都支持此操作)。 The transaction context will be propagate during calls to remote EJB. 事务上下文将在调用远程EJB期间传播。 A distributed transaction may then span client-side connections and server-side connections. 然后,分布式事务可以跨越客户端连接和服务器端连接。

According to the J2EE philosophy, an application client should normally not use transactions and obtain connection directly; 根据J2EE理念,应用程序客户端通常不应使用事务并直接获取连接; it should solely communicate with remote EJB. 它应该只与远程EJB通信。

The specs are not really clear about more complicated scenario and there isn't that many information around. 关于更复杂的情况,规范并不是很清楚,并且没有太多的信息。 The spec do for instance not mandate the application server to expose the UserTransaction to the client. 例如,规范不要求应用服务器将UserTransaction暴露给客户端。

What I wrote here applies to Glassfish at least, but I would not rely on a consistent implementation of such features across all application servers. 我在这里写的内容至少适用于Glassfish,但我不会依赖所有应用程序服务器上这些功能的一致实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM