4

I am trying to extract a ZIP file using SDK zip API. I wrote the extraction code directly in my service class and my architect said the code has to be shifted to another module and should be implemented using JCA. I don't understand the use of JCA. He said it is a Java EE principle. All external systems, like the file system, should be accessed using JCA.

If this is the procedure then what about the database? It is also an external resource to my Java application. Why should not I use JCA to access a database?

I don't understand the importance and advantage at all. I tried to read online also. But I did not find any page which explains the advantages. Besides, there aren't any good tutorials which explains the development step by step. Most of the links are broken.

What is the explanation?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Krishna Chaitanya
  • 2,533
  • 4
  • 40
  • 74

2 Answers2

3

JCA is a "generic architecture for connection to legacy systems", mainly larger more mainframe-like systems (such as SAP).

It's definitely not something you would use when unzipping, nor would you access the file system with it.

It sounds like your teacher is confused.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kayaman
  • 72,141
  • 5
  • 83
  • 121
  • 2
    As JEE does not allow the direct access of the file system, JCA connectors are used to access files. Depending on the connector you use you even have XA-transaction support (see https://xadisk.java.net/) – Thomas Stets Nov 20 '14 at 10:11
1

JCA is the connector architecture that resource implementers should use to integrate their resource adapter (RA) into a Java EE application server.

What your architect is asking is to make an RA for your resource management. It's clean, but it can be overkill.

The main benefit of using a resource adapter is to be cleanly integrated in the application server transaction workflow.

Look Understanding Resource Adapters for more information.

But if you just read a ZIP file without any modification, it's not worth the effort.

Note that some have already written a generic filesystem RA that you could use File Resource Adapter. Maybe it can help as is or at least it's a good start at understanding how to make an RA.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
nomoa
  • 1,043
  • 6
  • 18
  • We also use java xatransaction support. We persist some data in our database. If the persistence fails the unzip should rollback. So ahould we use jca while connecting to legacy systems and which include xa transactions? Besides the location of the file system we are using to unzip is a mounted file system. I think that is the reason our architect suggested to use jca. – Krishna Chaitanya Nov 20 '14 at 10:05
  • XA is mandatory whenever 2 or more resources are modified in a single transaction. So you have to write a RA for your zip file which supports XA (http://en.wikipedia.org/wiki/Two-phase_commit_protocol) which is pretty hard to achieve on filesystem. See Thomas Stets comment on https://xadisk.java.net/ it looks promising. – nomoa Nov 20 '14 at 10:20
  • Is there any good tutorial which explains the development form start to end. The interfaces we have to implement in jca. The above link does not have a tutorial kind of thing. – Krishna Chaitanya Nov 20 '14 at 10:27
  • This one maybe : http://www.mastertheboss.com/jboss-frameworks/ironjacamar/create-your-first-jca-connector-tutorial . But you should really try to use an existing one. – nomoa Nov 20 '14 at 10:34
  • We already have one now. But I dont understand anything. I am just using it without any through knowledge. I have already gone through the jboss tutorial but did not understand much. Besides the link to download the code is broken. – Krishna Chaitanya Nov 20 '14 at 10:42
  • It's a complex task even more if you're not familiar with J2EE internals (XA/JTA). I suggest you to use xadisk as a RA (see xadisk doc) leave your zip manipulation code in the application but instead of using FileInputStream/FileOutputStream use the xadisk @Resource to read and write the zip to filesystem. – nomoa Nov 20 '14 at 10:51