| 1 | | | <body> |
| 2 | | | <section> |
| 3 | | | <title>Overview</title> |
| 4 | | | The File System Connector is intended to provide access to a file system from an |
| 5 | | | application running on a J2EE application server. The File Connector |
| 6 | | | implements the Java Connector Architecture (JCA) 1.0 specification. |
| 7 | | | |
| 8 | | | <p> |
| 9 | | | The most important features of the container are |
| 10 | | | <ul> |
| 11 | | | <li>Directory operations, such as list, create or delete a directory.</li> |
| 12 | | | <li>File operations: create, delete, rename, move or check file's existence</li> |
| 13 | | | <li>Operations to read/write the file's content</li> |
| 14 | | | </ul> |
| 15 | | | </p> |
| 16 | | | <section> |
| 17 | | | <title>Restrictions</title> |
| 18 | | | <ul> |
| 19 | | | <li>This connector does not provide the javax.resource.cci</li> |
| 20 | | | <li>The resource's reauthentication is not supported</li> |
| 21 | | | </ul> |
| 22 | | | </section> |
| 23 | | | </section> |
| 24 | | | <section> |
| 25 | | | <title>Logical View</title> |
| 26 | | | |
| 27 | | | <p> |
| 28 | | | The JCA 1.0 defines three major components involved in the |
| 29 | | | Connector Architecture: |
| 30 | | | <ul> |
| 31 | | | <li>J2EE Application Server</li> |
| 32 | | | <li>Application running on a J2EE Server (the Client)</li> |
| 33 | | | <li>Connector (JCA) provider</li> |
| 34 | | | </ul> |
| 35 | | | </p> |
| 36 | | | <para/> |
| 37 | | | <p> |
| 38 | | | Following contracts should be met by these components: |
| 39 | | | <ul> |
| 40 | | | <li>System Contract (between JCA provider and J2EE Server)</li> |
| 41 | | | <li>Container-Component Contract (between Application and J2EE Server)</li> |
| 42 | | | <li>Client API (between JCA provider and Application)</li> |
| 43 | | | <li>Security Contract (between all components)</li> |
| 44 | | | </ul> |
| 45 | | | </p> |
| 46 | | | <p> |
| 47 | | | The File Connector implements three of these contracts: |
| 48 | | | <ul> |
| 49 | | | <li>Container-Component Contract by providing |
| 50 | | | <ul> |
| 51 | | | <li>managed connection factory FsManagedConnectionFactoryImpl</li> |
| 52 | | | <li>managed connection FsManagedConnectionImpl</li> |
| 53 | | | </ul> |
| 54 | | | </li> |
| 55 | | | <li>Client API by providing |
| 56 | | | <ul> |
| 57 | | | <li>connection factory interface FsConnectionFactory</li> |
| 58 | | | <li>connection interface FsConnection</li> |
| 59 | | | <li>connection factory's implementation FsConnectionFactoryImpl</li> |
| 60 | | | <li>connection's implementation FsConnectionImpl</li> |
| 61 | | | </ul> |
| 62 | | | </li> |
| 63 | | | <li>Security Contract by providing User/Password base authentication |
| 64 | | | mechanism and supporting the security context JAAS Subject with |
| 65 | | | principal and credentials. |
| 66 | | | </li> |
| 67 | | | </ul> |
| 68 | | | </p> |
| 69 | | | <section> |
| 70 | | | <title>Managed Connection Factory</title> |
| 71 | | | The Managed Connection Factory FsManagedConnectionFactoryImpl |
| 72 | | | implements the javax.resource.spi.ManagedConnectionFactory interface. |
| 73 | | | This class is as well a factory for managed connections as a factory |
| 74 | | | for FsConnectionFactory's. This class is the main entry point for |
| 75 | | | the underlying Application Server for interactions with the File |
| 76 | | | System Connector. An instance of this class will be instantiated by the |
| 77 | | | application server immediately after deployment. The |
| 78 | | | FsManagedConnectionFactoryImpl provides some connector specific |
| 79 | | | attributes (for more details see the section 'Connector's Attributes'). |
| 80 | | | <diagram type="class" name="FsManagedConnectionFactoryImpl"> |
| 81 | | | <class name="org.jcoderz.commons.connector.ManagedConnectionFactoryBase"/> |
| 82 | | | <class name="org.jcoderz.commons.connector.file.FsManagedConnectionFactoryImpl"/> |
| 83 | | | <description> |
| 84 | | | The Managed Connection Factory FsManagedConnectionFactoryImpl. |
| 85 | | | </description> |
| 86 | | | </diagram> |
| 87 | | | </section> |
| 88 | | | <section> |
| 89 | | | <title>Managed Connection</title> |
| 90 | | | The main task of the FsManagedConnectionImpl class is to manage |
| 91 | | | FsConnection's instances. |
| 92 | | | |
| 93 | | | <diagram type="class" name="FsManagedConnectionImpl"> |
| 94 | | | <class name="org.jcoderz.commons.connector.file.FsManagedConnectionImpl"/> |
| 95 | | | <description> |
| 96 | | | The Managed Connection FsManagedConnectionImpl. |
| 97 | | | </description> |
| 98 | | | </diagram> |
| 99 | | | </section> |
| 100 | | | <section> |
| 101 | | | <title>Connection Factory</title> |
| 102 | | | The FsConnectionFactory interface specifies the methods to retrieve a |
| 103 | | | FsConnection. The File System Connector does not provide the |
| 104 | | | javax.resource.cci interface. A connector's client should use the |
| 105 | | | FsConnectionFactory to obtain a connection to the File System instead. |
| 106 | | | <diagram type="class" name="FsConnectionFactory"> |
| 107 | | | <class name="org.jcoderz.commons.connector.file.FsConnectionFactoryImpl"/> |
| 108 | | | <description> |
| 109 | | | The Connection Factory. |
| 110 | | | </description> |
| 111 | | | </diagram> |
| 112 | | | </section> |
| 113 | | | |
| 114 | | | <section> |
| 115 | | | <title>Connection</title> |
| 116 | | | The FsConnection provides the interface between a connector's client and |
| 117 | | | the file system(s). |
| 118 | | | <diagram type="class" name="FsConnectionImpl"> |
| 119 | | | <class name="org.jcoderz.commons.connector.file.FsConnectionImpl"/> |
| 120 | | | <description> |
| 121 | | | The FsConnection. |
| 122 | | | </description> |
| 123 | | | </diagram> |
| 124 | | | </section> |
| 125 | | | </section> |
| 126 | | | <section> |
| 127 | | | <title>Packaging and Deployment</title> |
| 128 | | | <section> |
| 129 | | | <title>Deployment Descriptor</title> |
| 130 | | | The deployment descriptor of the File Connector consists of two |
| 131 | | | components: |
| 132 | | | <ul> |
| 133 | | | <li>standard deployment descriptor ra.xml, that specifies the |
| 134 | | | common and connector specific properties</li> |
| 135 | | | <li>application server specific deployment descriptor, that specify |
| 136 | | | server relevant configuration and settings for an resource |
| 137 | | | adapter.</li> |
| 138 | | | </ul> |
| 139 | | | The FawkeZ module delivers modules for the WebLogic Application |
| 140 | | | Server, thus the File System Connector includes the WebLogic specific |
| 141 | | | deployment descriptor weblogic-ra.xml |
| 142 | | | </section> |
| 143 | | | <section> |
| 144 | | | <title>Packaging</title> |
| 145 | | | <p> |
| 146 | | | The File System Connector is packaged in to the filesystem.rar |
| 147 | | | archive. This archive contains |
| 148 | | | <ul> |
| 149 | | | <li>the deployment descriptors |
| 150 | | | <ul> |
| 151 | | | <li>ra.xml - standard deployment descriptor</li> |
| 152 | | | <li>weblogic-ra.xml - the WebLogic specific deployment descriptor</li> |
| 153 | | | </ul> |
| 154 | | | </li> |
| 155 | | | <li>the implementation classes included in the filesystem.jar</li> |
| 156 | | | <li>and the client.jar archive containing the client interfaces.</li> |
| 157 | | | </ul> |
| 158 | | | </p> |
| 159 | | | |
| 160 | | | <p> |
| 161 | | | The following shows the structure of the filesystem.rar: |
| 162 | | | <pre> |
| 163 | | | META-INF/MANIFEST.MF |
| 164 | | | VERSION |
| 165 | | | META-INF/ra.xml |
| 166 | | | META-INF/weblogic-ra.xml |
| 167 | | | filesystem-client.jar |
| 168 | | | filesystem.jar |
| 169 | | | </pre> |
| 170 | | | </p> |
| 171 | | | </section> |
| 172 | | | <section> |
| 173 | | | <title>Deployment</title> |
| 174 | | | The File System Connector can be deployed either: |
| 175 | | | <ul> |
| 176 | | | <li>Directly into an application server as a stand-alone unit, or,</li> |
| 177 | | | <li>Deployed with a J2EE application that consists of one or |
| 178 | | | more J2EE modules in addition to the File System Connector |
| 179 | | | module |
| 180 | | | </li> |
| 181 | | | </ul> |
| 182 | | | </section> |
| 183 | | | <section> |
| 184 | | | <title>Connector Client Archive</title> |
| 185 | | | To prevent the connector's client to use the File System Connector's |
| 186 | | | implementation classes directly, the client archive file is supplied |
| 187 | | | on the client side. This archive provide connector's interfaces |
| 188 | | | only and should be included in the client classpath. |
| 189 | | | </section> |
| 190 | | | </section> |
| 191 | | | <section> |
| 192 | | | <title>Implementation View</title> |
| 193 | | | <section> |
| 194 | | | <title>Connection handling</title> |
| 195 | | | Unlike the strict JCA architecture an instance of |
| 196 | | | FsManagedConnection does not hold any physical connection itself. |
| 197 | | | Because of the file connector's operations are file based, there is no |
| 198 | | | point to hold the physical connection to a particular file over the |
| 199 | | | whole lifetime of the managed connection. Typically, a particular file |
| 200 | | | is created, manipulated and never touched again. Therefore the physical |
| 201 | | | handle is holden by the underlying FsConnection and is closed as soon |
| 202 | | | as the client closes the FsConnection. |
| 203 | | | </section> |
| 204 | | | <section> |
| 205 | | | <title>Usage</title> |
| 206 | | | <section> |
| 207 | | | <title>Base Path</title> |
| 208 | | | A connector's client is required to look up a connection |
| 209 | | | factory instance using the JNDI interface. The client then uses |
| 210 | | | the connection factory instance to get a connection to the |
| 211 | | | underlying file system. |
| 212 | | | A connection client is required to close the connection after the |
| 213 | | | connection is no more in use. |
| 214 | | | <pre> |
| 215 | | | // Create initial context |
| 216 | | | final InitialContext ctx = new InitialContext(); |
| 217 | | | // Lookup the connection factory |
| 218 | | | final FsConnectionFactory cf = (FsConnectionFactory) ctx.lookup("java:comp/env/eis/FileSystemConnector"); |
| 219 | | | // Retrieve conection |
| 220 | | | final FsConnection con = cf.getConnection(); |
| 221 | | | // perform some file operations |
| 222 | | | con.moveFile("/tmp/a", "/tmp/b"); |
| 223 | | | ... |
| 224 | | | // close connection |
| 225 | | | con.close(); |
| 226 | | | </pre> |
| 227 | | | </section> |
| 228 | | | <section> |
| 229 | | | <title>Modifying the connector's attributes</title> |
| 230 | | | When the client wish to alter the connector specific attribute, |
| 231 | | | it pass a property object while retrieving a connection. |
| 232 | | | The new attributes are in effect only for the retrieved |
| 233 | | | connection. |
| 234 | | | <pre> |
| 235 | | | // Create a Properties object |
| 236 | | | final Properties props = new Properties(); |
| 237 | | | // Set the new temp directory to use. |
| 238 | | | props.setProperty(FsConnectionFactory.PROP_TEMP_DIR, "/opt/app/temp"); |
| 239 | | | // Set the new chunk size |
| 240 | | | props.setProperty(FsConnectionFactory.PROP_FILE_TRANSFER_CHUNK_SIZE, 0xFFFF); |
| 241 | | | // Retrieve conection |
| 242 | | | final FsConnection con = cf.getConnection(props); |
| 243 | | | </pre> |
| 244 | | | </section> |
| 245 | | | </section> |
| 246 | | | |
| 247 | | | <section> |
| 248 | | | <title>Connector Attributes</title> |
| 249 | | | <p>The File Connector provides following attributes: |
| 250 | | | <ul> |
| 251 | | | <li>TempDir</li> |
| 252 | | | <li>FileTransferChunkSize</li> |
| 253 | | | <li>UserName</li> |
| 254 | | | <li>Password</li> |
| 255 | | | </ul> |
| 256 | | | These attributes may be specified in the deployment descriptor within |
| 257 | | | of the section 'config-property'. The Application Server |
| 258 | | | instantiates an instance of the FsManagedConnectionFactoryImpl class |
| 259 | | | immediately after deployment and tries to set the connector specific |
| 260 | | | properties defined in the deployment descriptor. |
| 261 | | | </p> |
| 262 | | | <section> |
| 263 | | | <title>TempDir</title> |
| 264 | | | Specifies the temporary directory to be used by this connector. |
| 265 | | | The default value will be retrieved from the system property |
| 266 | | | 'java.io.tmpdir'. A connection client can overwrite this value |
| 267 | | | by passing the property while retrieving a connection |
| 268 | | | by calling the method FsConnection.getConnection(Properties). |
| 269 | | | </section> |
| 270 | | | <section> |
| 271 | | | <title>FileTransferChunkSize</title> |
| 272 | | | This property specifies the chunk size used while file transferring. |
| 273 | | | If a file size exceeds the chunk size, the file will be transfered |
| 274 | | | chunk by chunk until all bytes will have been transfered. If this |
| 275 | | | property is not defined in the deployment descriptor the file |
| 276 | | | connector will use the default value. Too small value will probably |
| 277 | | | slow the performance down, and too large value may cause a |
| 278 | | | resource's allocation problem. The value of this property should be |
| 279 | | | adjusted to the underlying os, file system and available memory. |
| 280 | | | A connection client can overwrite this value by passing a property |
| 281 | | | object while retrieving a connection by calling the method |
| 282 | | | FsConnection.getConnection(Properties). |
| 283 | | | </section> |
| 284 | | | <section> |
| 285 | | | <title>UserName and Password</title> |
| 286 | | | When the file system connector is required to authenticate the |
| 287 | | | caller, the UserName and Password properties should be defined |
| 288 | | | in the deployment descriptor. The connector's client has to specify |
| 289 | | | the UserName and Password by passing a property object while |
| 290 | | | retrieving a connection by calling the method |
| 291 | | | FsConnection.getConnection(Properties). |
| 292 | | | </section> |
| 293 | | | </section> |
| 294 | | | |
| 295 | | | <section> |
| 296 | | | <title>File transferring on different file systems.</title> |
| 297 | | | The FsConnection provides some methods, that internally use the |
| 298 | | | standard Java API method java.io.File.renameTo(). This method is the |
| 299 | | | best way, for example, to move a particular file from its location to |
| 300 | | | another one. Unfortunately, the Java Native Implementation on AIX |
| 301 | | | platform does not support renameTo on different file systems. |
| 302 | | | Therefore, the connector performs the 'rename' operation doing |
| 303 | | | following steps: |
| 304 | | | <ul> |
| 305 | | | <li>Invokes the java.io.File.renameTo method, and checks the result</li> |
| 306 | | | <li>If the file could not be renamed, the connector performs a file's |
| 307 | | | transferring by using the New IO features. The connector transfers |
| 308 | | | the file's content chunk by chunk, |
| 309 | | | until all bytes have been transfered. The size of a chunk is |
| 310 | | | affected by the attribute <b>FileTransferChunkSize</b>. |
| 311 | | | </li> |
| 312 | | | </ul> |
| 313 | | | |
| 314 | | | </section> |
| 315 | | | <section> |
| 316 | | | <title>Handling of large files (>2GB)</title> |
| 317 | | | <p> |
| 318 | | | To keep the connector's implementation as simple as possible, the |
| 319 | | | connector uses the standard Java IO API to perform operation on |
| 320 | | | file system components. The Java Runtime applies the native code, that |
| 321 | | | depends on the underlying operation system. |
| 322 | | | </p> |
| 323 | | | <p> |
| 324 | | | On the AIX 5.2 platform the java.oi.File.exists() method returns a wrong |
| 325 | | | result if an existing file to be checked is larger as 2 GB. |
| 326 | | | To solve this problem, the connector does following steps: |
| 327 | | | <ul> |
| 328 | | | <li>Invokes the java.io.File.exists() method, and checks the result</li> |
| 329 | | | <li>If the result is <code>false</code>, the File Connector retrieves |
| 330 | | | the list of files from the parent directory of the file to be checked. |
| 331 | | | Then the connector checks the requested file in this list.</li> |
| 332 | | | </ul> |
| 333 | | | </p> |
| 334 | | | </section> |
| 335 | | | </section> |
| 336 | | | <section> |
| 337 | | | <title>API</title> |
| 338 | | | <apidoc name="file system connector"> |
| 339 | | | <class name="org.jcoderz.commons.connector.file.FsManagedConnectionFactoryImpl"/> |
| 340 | | | <class name="org.jcoderz.commons.connector.file.FsConnection"/> |
| 341 | | | <class name="org.jcoderz.commons.connector.file.FsConnectionFactory"/> |
| 342 | | | </apidoc> |
| 343 | | | </section> |
| 344 | | | </body> |