The JCA (Java EE Connector Architecture) specification can be said to be the most "obscure" in the Java EE Specification collection, which was added when the JavaEE1.3 specification was released, much earlier than the current important member JPA, CDI, and so on. From an application development perspective, developing a very common Web application, with only a few pages, can be done with a servlet, using the JDBC API to store information in a database, and when deploying this application to a Java EE application Server, JCA technology is used. This very simple application uses only a large Java EE specification to set the servlet and JCA two specifications in more than 30 items. So why do so few people know such an important norm that this article explains some of these things?
JCA originally intended to be a Java Enterprise Version Connector architecture, so a jerky word does not describe its functionality well. Simply put, the function of this specification is to define how to connect Java EE Application Server and external information system, including but not limited to database, message middleware, distributed cache system, ERP/CRM as representative enterprise software system, tuxedo and other affairs/message middleware, etc. We know that the enterprise in Java EE is the meaning of enterprises, the design goal of this set of specifications has been defined for enterprise application software design. In the context of an enterprise domain, many applications can be run, and JCA can play a powerful role if a set of software is developed and deployed in the application server with Java EE Specification technology and it needs to interact with other application systems.
JCA produced in the most prosperous 1.3 version of the Java EE era, the JCA 1.0 version was proposed by JSR16, at that time, the entire technology stack has been more complete, a demand arose: how to unify the JDBC/JMS and other connection management? At the same time, Bea's tuxedo product also faces problems integrating with the Java EE. The JCA1.0 version defines connection management and how transactions and security are managed on top of the connection, but only the demand for outbound (outbound) One-way requests is considered.
in version 5 o'clock, the Java EE was renamed to Java. This large version focuses on JPA and ejb3,jca unchanged. The JCA upgrade to the 1.6,JSR number is 322 when the JavaEE6 version is released, and in addition to the complete functionality, it is mainly to add support for annotation, which can be used either as XML or annotation to describe the relevant implementation classes of JCA.
Last year, Javaee7,jca was released with minor changes, upgrading to 1.7, but still in the JSR322 specification number. So what we're seeing now is the 1.7 version of the JCA specification in the application server that supports JAVAEE7. In the latest Wildfly (formerly Jbossas) application Server, database connection pooling, JMS connections, and receiving configuration information such as message MDB information are configuration options that can be identified and processed by the Ironjacamar (JBoss Open source organization JCA implementation).
Let's take a look at the standard JCA architecture diagram.
Four parts are application servers (application server), application components (application Component), resource adapters (Resource Adapter), and enterprise information systems (Enterprises information System).
Our general development is to deploy the war in webserver, which corresponds to the application component and application server, respectively. Enterprise Information System can be run independently of the application system, such as database, ERP, etc., the resource adapter is designed to connect with the Enterprise Information System connection adapter software, you can connect Java EE Application Server and external application system, and provide resource services to the application components to use.
> Here's a question that you might be wondering, why do you define a JCA canonical interface when you can get a connection from a JDBC or JMS interface? The answer is simply to unify the API of the access layer and be managed by the container. A resource pool container (which can be called a JCA container) in an application server requires all external information system connections to be managed and unified for application use. For application developers, the use of these resources is simple, only through Jndi to obtain the available resources, get references and make calls, after use is closed, the container will be recycled and put back into the available resource pool for subsequent use. All such resources are identified and managed by the resource container, and the JCA specification defines such an interface. We see clearly defined in the JCA Javadoc that the SPI Packet is a collection of interfaces that let the resource adapter implement it.
Let's go a little deeper into the code to see important interfaces:
The entry point is Resourceadapter, this interface represents an instance of the resource manager, the method defines the life-time callback method of the instance, in which the parameters of the Start method implement the Bootstrapcontext interface, which can pass the service capability of the application server as the context.
Through the configuration information, you can obtain the outbound information ingress interface Managedconnectionfactory, through this interface method, can obtain the managed connection managedconnection. We have to understand that in the Java EE World, almost any resource is managed, or can be viewed as a logical resource. The interface implementation class obtained through Jndi, in different application scenarios, the background program has done a lot of work: it is possible to add a rich function, it may be just an empty proxy reference, and so on when necessary to access the real object, to save resources. Through the Managedconnection interface, the application can further obtain the object that implements the business interface, thus interacting with the external information system.
workmanager dispatches work, and work expands the runnable interface so that the code logic that needs to execute the standalone thread is encapsulated in the work implementation class and submitted to Workmanager to dispatch execution. In general, the application server maintains a thread pool to allocate the available thread resources rationally and to efficiently dispatch management. This is similar to the need to open a port to receive messages, and the vast majority of JMS-implemented resource adapters do so.
So much has been said, and perhaps we all feel that the need for more than JCA seems to be possible, why is it complicated to use JCA? This leads to the core idea of Java EE--transactional.
This context can also convey security-related information, which is the security-related content of Java EE. JCA also defines the security of connection management so that it can be easily managed and mapped using the security identities of servers and external systems, authorization information, and so on. After JCA1.6, the definition of inbound's business and security has also been perfected.
Since this is so good, how do we fully use JCA in Java business software? And so on, JCA has some places to consider in technology selection.
First is transaction support, and we know that transactions can say and system extensibility is enemies. There is a certain state in the transaction process, and one of the remote invocation services/Extensible design principles is stateless, and this contradiction cannot be avoided. In business areas that do not require transactional support or are not demanding, such as forums, blogs, etc., we can choose to cancel the transaction support to improve system efficiency. In fact, this is one of the reasons why Java EE technology is facing embarrassment in the Internet field.
Secondly, the focus of JCA is mainly on the connection management, the specification does not define how to get the business object reference after the connection, and the wide extent of the business object interface. So for complex business systems, most of the configuration items in the resource adapter are private, not all normalized, and the introduction of JCA has limited help in practical applications.
Thirdly, the connection pool is one of the core components of high performance business system, and the management of database connection pool is the main content of operation and maintenance work. However, the connection pooling function is numerous, the configuration is cumbersome, each application server implementation is inconsistent, and this part of the content is not defined in the specification. So it is very difficult for applications to migrate between different servers, and the optical connection pool configuration requires a lot of work.
So what are the scenarios for use? If you use Java EE-compliant application servers for development, such as Jbossas (Wildfly,redhat JBoss EAP), Weblogic,glassfish,webshpere, and so on, you are already using JCA. In addition to the need to support distributed transaction software systems, two development, JCA is a good technical choice. Typical examples are various MQ/JMS systems with transactional capabilities, and tuxedo-connected WTC resource adapters.
A more important factor is that the JCA specification is a manifestation of the integration technology experience of the system, and any developer based on Java EE development needs to interact with the external system, which will be found to be very similar to the current JCA-defined architecture when the design/coding/online operation/system matures. Learning the JCA specification can quickly master the architecture model, which is the power of knowledge cohesion.
jca--an obscure but important Java EE specification