You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by dp...@apache.org on 2005/08/08 10:11:35 UTC

svn commit: r230772 [1/2] - in /incubator/jackrabbit/trunk/contrib/jca: ./ applications/ applications/test/ deploy/ deploy/jboss/ deploy/jboss/4.x/ src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jackrabbit/ src/java/org/apache/ja...

Author: dpfister
Date: Mon Aug  8 01:11:09 2005
New Revision: 230772

URL: http://svn.apache.org/viewcvs?rev=230772&view=rev
Log:
Adding JCA contribution by Sten Roger Sandvik

Added:
    incubator/jackrabbit/trunk/contrib/jca/
    incubator/jackrabbit/trunk/contrib/jca/HEADER.txt   (with props)
    incubator/jackrabbit/trunk/contrib/jca/LICENSE.txt   (with props)
    incubator/jackrabbit/trunk/contrib/jca/README.txt   (with props)
    incubator/jackrabbit/trunk/contrib/jca/applications/
    incubator/jackrabbit/trunk/contrib/jca/applications/test/
    incubator/jackrabbit/trunk/contrib/jca/applications/test/jaas.config
    incubator/jackrabbit/trunk/contrib/jca/applications/test/log4j.properties   (with props)
    incubator/jackrabbit/trunk/contrib/jca/applications/test/repository.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jca/deploy/
    incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/
    incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/4.x/
    incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/4.x/jcr-ds.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jca/maven.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jca/project.properties   (with props)
    incubator/jackrabbit/trunk/contrib/jca/project.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/
    incubator/jackrabbit/trunk/contrib/jca/src/java/
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionManager.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnection.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCASessionHandle.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/rar/
    incubator/jackrabbit/trunk/contrib/jca/src/rar/META-INF/
    incubator/jackrabbit/trunk/contrib/jca/src/rar/META-INF/ra.xml   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/test/
    incubator/jackrabbit/trunk/contrib/jca/src/test/org/
    incubator/jackrabbit/trunk/contrib/jca/src/test/org/apache/
    incubator/jackrabbit/trunk/contrib/jca/src/test/org/apache/jackrabbit/
    incubator/jackrabbit/trunk/contrib/jca/src/test/org/apache/jackrabbit/jca/
    incubator/jackrabbit/trunk/contrib/jca/src/test/org/apache/jackrabbit/jca/test/
    incubator/jackrabbit/trunk/contrib/jca/src/test/org/apache/jackrabbit/jca/test/AbstractTestCase.java   (with props)
    incubator/jackrabbit/trunk/contrib/jca/src/test/org/apache/jackrabbit/jca/test/ConnectionFactoryTest.java   (with props)

Added: incubator/jackrabbit/trunk/contrib/jca/HEADER.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/HEADER.txt?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/HEADER.txt (added)
+++ incubator/jackrabbit/trunk/contrib/jca/HEADER.txt Mon Aug  8 01:11:09 2005
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jca/HEADER.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/LICENSE.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/LICENSE.txt?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/LICENSE.txt (added)
+++ incubator/jackrabbit/trunk/contrib/jca/LICENSE.txt Mon Aug  8 01:11:09 2005
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Propchange: incubator/jackrabbit/trunk/contrib/jca/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/README.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/README.txt?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/README.txt (added)
+++ incubator/jackrabbit/trunk/contrib/jca/README.txt Mon Aug  8 01:11:09 2005
@@ -0,0 +1,32 @@
+=======================================================================
+Jackrabbit JCA 1.0 Resource Adapter
+=======================================================================
+
+Overview
+--------
+
+This package includes a JCA resource adapter for Jackrabbit. It's
+following the JCA 1.0 specification and can be deployed on a wide
+range of application servers. 
+
+Jackrabbit is embedded into the JCA package and is started when
+first accessed by the client. If re-deployed, the old repository
+configuration will shutdown to minimize alot of opened inactive
+repository instances.
+
+
+Building
+--------
+
+To build the resource archive (RAR), use the rar:rar goal in
+maven.
+
+  maven rar:rar
+  
+
+Deployment
+----------
+
+Example deployment configurations are located under ./deploy
+directory. 
+

Propchange: incubator/jackrabbit/trunk/contrib/jca/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/applications/test/jaas.config
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/applications/test/jaas.config?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/applications/test/jaas.config (added)
+++ incubator/jackrabbit/trunk/contrib/jca/applications/test/jaas.config Mon Aug  8 01:11:09 2005
@@ -0,0 +1,3 @@
+Jackrabbit {
+  org.apache.jackrabbit.core.security.SimpleLoginModule required anonymousId="anonymous";
+};
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/jca/applications/test/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/applications/test/log4j.properties?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/applications/test/log4j.properties (added)
+++ incubator/jackrabbit/trunk/contrib/jca/applications/test/log4j.properties Mon Aug  8 01:11:09 2005
@@ -0,0 +1,21 @@
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.rootLogger=INFO, file
+#log4j.rootLogger=DEBUG, stdout, file
+#log4j.rootLogger=ERROR, stdout, file
+
+log4j.logger.org.apache.jackrabbit.test=DEBUG
+
+# 'stdout' is set to be a ConsoleAppender.
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+
+# 'stdout' uses PatternLayout
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n
+
+# 'file' is set to be a FileAppender.
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=jcr.log
+
+# 'file' uses PatternLayout.
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n

Propchange: incubator/jackrabbit/trunk/contrib/jca/applications/test/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/applications/test/repository.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/applications/test/repository.xml?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/applications/test/repository.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jca/applications/test/repository.xml Mon Aug  8 01:11:09 2005
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE Repository [
+    <!--
+        the Repository element configures a repository instance;
+        individual workspaces of the repository are configured through
+        separate configuration files called workspace.xml which are
+        located in a subfolder of the workspaces root directory
+        (see Workspaces element).
+
+        it consists of
+
+            a FileSystem element (the virtual file system
+            used by the repository to persist global state such as
+            registered namespaces, custom node types, etc..
+
+            a Security element that specifies the name of the app-entry
+            in the JAAS config and the access manager
+
+            a Workspaces element that specifies to the location of
+            workspaces root directory and the name of default workspace
+
+            a Workspace element that is used as a workspace configuration
+            template; it is used to create the initial workspace if there's
+            no workspace yet and for creating additional workspaces through
+            the api
+
+            a SearchIndex element that is used for configuring per workspace
+            Indexing-related settings
+
+            a Versioning element that is used for configuring
+            versioning-related settings
+    -->
+    <!ELEMENT Repository (FileSystem,Security,Workspaces,Workspace,Versioning)>
+
+    <!--
+        a virtual file system
+    -->
+    <!ELEMENT FileSystem (param*)>
+    <!ATTLIST FileSystem
+      class CDATA #REQUIRED>
+
+    <!--
+        the Security element specifies the name (appName attribute)
+        of the JAAS configuration app-entry for this repository. 
+
+        it also specifies the access manager to be used (AccessManager element).
+    -->
+    <!ELEMENT Security (AccessManager, LoginModule?)>
+    <!ATTLIST Security
+      appName CDATA #REQUIRED>
+
+    <!--
+        the AccessManager element configures the access manager to be used by
+        this repository instance; the class attribute specifies the FQN of the
+        class implementing the AccessManager interface
+    -->
+    <!ELEMENT AccessManager (param*)>
+    <!ATTLIST AccessManager
+      class CDATA #REQUIRED>
+
+    <!--
+        generic parameter (name/value pair)
+    -->
+    <!ELEMENT param EMPTY>
+    <!ATTLIST param
+      name CDATA #REQUIRED
+      value CDATA #REQUIRED>
+
+     <!--
+        the LoginModule element optionally specifies a JAAS login module to
+        authenticate users. This feature allows the use of Jackrabbit in a
+        non-JAAS environment.
+    -->
+    <!ELEMENT LoginModule (param*)>
+    <!ATTLIST LoginModule
+      class CDATA #REQUIRED>
+
+   <!--
+        the Workspaces element specifies the workspaces root directory
+        (rootPath attribute) and the name of the default workspace
+        (defaultWorkspace attribute).
+
+        individual workspaces are configured through individual workspace.xml
+        files located in a subfolder each of the workspaces root directory.
+    -->
+    <!ELEMENT Workspaces EMPTY>
+    <!ATTLIST Workspaces
+      rootPath CDATA #REQUIRED
+      defaultWorkspace CDATA #REQUIRED>
+
+    <!--
+        the Workspace element serves as a workspace configuration template;
+        it is used to create the initial workspace if there's no workspace yet
+        and for creating additional workspaces through the api
+    -->
+    <!ELEMENT Workspace (FileSystem,PersistenceManager,SearchIndex?)>
+    <!ATTLIST Workspace
+      name CDATA #REQUIRED>
+
+    <!--
+        the PersistenceManager element configures the persistence manager
+        to be used for the workspace; the class attribute specifies the
+        FQN of the class implementing the PersistenceManager interface
+    -->
+    <!ELEMENT PersistenceManager (param*)>
+    <!ATTLIST PersistenceManager
+      class CDATA #REQUIRED>
+
+    <!--
+        the SearchIndex element specifies the locaction of the search index
+        (used by the QueryHandler); the class attribute specifies the
+        FQN of the class implementing the QueryHandler interface.
+    -->
+    <!ELEMENT SearchIndex (param*,FileSystem)>
+    <!ATTLIST SearchIndex
+      class CDATA #REQUIRED>
+
+    <!--
+        the Versioning element configures the persistence manager
+        to be used for persisting version state
+    -->
+    <!ELEMENT Versioning (FileSystem, PersistenceManager)>
+    <!ATTLIST Versioning
+      rootPath CDATA #REQUIRED
+    >
+]>
+<!-- Example Repository Configuration File -->
+<Repository>
+    <!--
+        virtual file system where the repository stores global state
+        (e.g. registered namespaces, custom node types, etc.)
+    -->
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+
+    <!--
+        security configuration
+    -->
+    <Security appName="Jackrabbit">
+        <!--
+            access manager:
+            class: FQN of class implementing the AccessManager interface
+        -->
+        <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+            <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+        </AccessManager>
+
+        <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+           <!-- anonymous user name ('anonymous' is the default value) -->
+           <param name="anonymousId" value="anonymous"/>
+        </LoginModule>
+    </Security>
+
+    <!--
+        location of workspaces root directory and name of default workspace
+    -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+    <!--
+        workspace configuration template:
+        used to create the initial workspace if there's no workspace yet
+    -->
+    <Workspace name="${wsp.name}">
+        <!--
+            virtual file system of the workspace:
+            class: FQN of class implementing the FileSystem interface
+        -->
+        <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+            <param name="path" value="${wsp.home}/wspStore.dat"/>
+            <param name="autoRepair" value="false"/>
+            <param name="blockSize" value="128"/>
+            <param name="autoSync" value="false"/>
+        </FileSystem>
+        <!--
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        -->
+        <!--
+            persistence manager of the workspace:
+            class: FQN of class implementing the PersistenceManager interface
+        -->
+        <!--
+        <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"/>
+        -->
+        <!--
+        <PersistenceManager class="org.apache.jackrabbit.core.state.mem.InMemPersistenceManager">
+            <param name="initialCapacity" value="100000"/>
+            <param name="loadFactor" value="0.3"/>
+            <param name="persistent" value="true"/>
+        </PersistenceManager>
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
+        <!--
+            Search index and the file system it uses.
+            class: FQN of class implementing the QueryHandler interface
+
+            Supported parameters for lucene search index:
+            - useCompoundFile: advises lucene to use compound files for the index files
+            - minMergeDocs: minimum number of nodes in an index until segments are merged
+            - maxMergeDocs: maximum number of nodes in segments that will be merged
+            - mergeFactor: determines how often segment indices are merged
+            - bufferSize: maximum number of documents that are held in a pending
+              queue until added to the index
+            - forceConsistencyCheck: runs a consistency check on every startup. If
+              false, a consistency check is only performed when the search index
+              detects a prior forced shutdown.
+            - autoRepair: errors detected by a consistency check are automatically
+              repaired. If false, errors are only written to the log.
+        -->
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="useCompoundFile" value="true"/>
+            <param name="minMergeDocs" value="1000"/>
+            <param name="maxMergeDocs" value="100000"/>
+            <param name="mergeFactor" value="10"/>
+            <param name="bufferSize" value="10"/>
+            <param name="forceConsistencyCheck" value="false"/>
+            <param name="autoRepair" value="true"/>
+            <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+                <param name="path" value="${wsp.home}/index"/>
+            </FileSystem>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <!--
+            Configures the filesystem to use for versioning for the respective
+            persistence manager
+        -->
+        <FileSystem class="com.day.jackrabbit.fs.cq.CQFileSystem">
+            <param name="path" value="${rep.home}/version/version.dat"/>
+            <param name="autoRepair" value="false"/>
+            <param name="blockSize" value="128"/>
+            <param name="autoSync" value="false"/>
+        </FileSystem>
+    
+        <!--
+            <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+                <param name="path" value="${rep.home}/version"/>
+            </FileSystem>
+        -->
+        
+        <!--
+            Configures the perisistence manager to be used for persisting version state.
+            Please note that the current versioning implementation is based on
+            a 'normal' persistence manager, but this could change in future
+            implementations.
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.state.obj.ObjectPersistenceManager"/>
+
+    </Versioning>
+</Repository>

Propchange: incubator/jackrabbit/trunk/contrib/jca/applications/test/repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/4.x/jcr-ds.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/4.x/jcr-ds.xml?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/4.x/jcr-ds.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/4.x/jcr-ds.xml Mon Aug  8 01:11:09 2005
@@ -0,0 +1,13 @@
+<connection-factories> 
+    <tx-connection-factory>
+	<jndi-name>jcr</jndi-name> 
+	<adapter-display-name>JCR Adapter</adapter-display-name>
+	<rar-name>jackrabbit-jca.rar</rar-name>
+	<connection-definition>javax.jcr.Session</connection-definition>
+	<xa-transaction/>
+	
+	<!-- Configuration properties. -->
+	<config-property name="homeDir">\dev\jcr</config-property>
+	<config-property name="configFile">\dev\jcr\repository.xml</config-property>
+    </tx-connection-factory>
+</connection-factories> 

Propchange: incubator/jackrabbit/trunk/contrib/jca/deploy/jboss/4.x/jcr-ds.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/maven.xml?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/maven.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jca/maven.xml Mon Aug  8 01:11:09 2005
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="default">
+	<goal name="default" prereqs="rar:install"/>
+    <preGoal name="rar:rar">
+        <attainGoal name="jar:install"/>
+    </preGoal>
+    <preGoal name="rar:deploy">
+        <attainGoal name="jar:deploy"/>
+    </preGoal>
+</project>

Propchange: incubator/jackrabbit/trunk/contrib/jca/maven.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/project.properties?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/project.properties (added)
+++ incubator/jackrabbit/trunk/contrib/jca/project.properties Mon Aug  8 01:11:09 2005
@@ -0,0 +1,106 @@
+#  Copyright 2003-2005 The Apache Software Foundation or its licensors,
+#                      as applicable
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+######################################################################
+# Apache Central Repository
+######################################################################
+maven.repo.central=www.apache.org
+maven.repo.central.directory=/www/www.apache.org/dist/java-repository
+maven.remote.group=apcvs
+maven.changelog.factory = org.apache.maven.svnlib.SvnChangeLogFactory
+
+######################################################################
+# JUnit Testing
+######################################################################
+maven.test.failure = false
+maven.junit.fork=true
+#maven.junit.sysproperties=org.xml.sax.driver java.security.auth.login.config
+maven.junit.sysproperties=org.xml.sax.driver
+org.xml.sax.driver=org.apache.xerces.parsers.SAXParser
+#java.security.auth.login.config=applications/test/jaas.config
+
+
+#If you wish to skip tests when doing builds, uncomment
+#maven.test.skip = true
+
+######################################################################
+# Checkstyle
+######################################################################
+maven.checkstyle.properties= checkstyle.xml
+maven.linkcheck.enable=false 
+
+######################################################################
+# JavaDoc
+#
+# javadoc urls can be added here, multiple urls are appended using a comma
+#
+# maven.javadoc.links = http://foo/bar/api,\
+#                       http://flim/flam/api/
+######################################################################
+maven.javadoc.links=http://java.sun.com/j2se/1.4.2/docs/api/,http://www.day.com/maven/jsr170/javadocs/jcr-0.16.4.1/
+maven.javadoc.author=false
+maven.javadoc.version=false
+
+######################################################################
+# Other opts
+######################################################################
+# uncomment the next line to work in offline mode (no jar download & no linkcheck)
+#maven.mode.online=
+
+maven.compile.debug=on
+maven.compile.deprecation=off
+maven.compile.optimize=off
+maven.compile.source=1.4
+maven.compile.target=1.4
+
+maven.jarResources.basedir=src/java
+maven.jar.excludes=**/package.html
+
+# Location of the generated query language parsers. Needed for
+# the Maven Eclipse plugin to automatically locate the generated
+# source files. Note that this value matches the hardcoded path
+# in the Maven JavaCC plugin. Therefore, do not change this value!
+maven.gen.src=${maven.build.dir}/generated-src/main
+
+# specifying additional remote repository for downloading dependencies 
+# not available at www.ibiblio.org/maven/
+maven.repo.remote = http://www.ibiblio.org/maven/,http://www.day.com/maven/
+
+######################################################################
+# Site L&F
+######################################################################
+# maven.xdoc.jsl=
+maven.xdoc.date=
+maven.xdoc.poweredby.image=maven-feather.png
+maven.xdoc.version=${pom.currentVersion}
+maven.xdoc.developmentProcessUrl=http://incubator.apache.org/projects/jackrabbit.html
+maven.changelog.range=60
+maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
+maven.multiproject.overviewPage.title=Jackrabbit components
+
+# ------------------------------------------------------------------------
+# M A V E N  J A R  O V E R R I D E
+# ------------------------------------------------------------------------
+#maven.jar.override = on
+#maven.jar.jcr = ${basedir}/lib/jcr.jar
+
+######################################################################
+# Site Deploy (into ../jackrabbit-site for checkout on incubator.apache.org)
+######################################################################
+maven.site.deploy.method=fs
+
+# IDE settings
+maven.eclipse.resources.addtoclasspath=true
+

Propchange: incubator/jackrabbit/trunk/contrib/jca/project.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/project.xml?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/project.xml (added)
+++ incubator/jackrabbit/trunk/contrib/jca/project.xml Mon Aug  8 01:11:09 2005
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+    <pomVersion>3</pomVersion>    
+    <groupId>jackrabbit</groupId>
+    <artifactId>jackrabbit-jca</artifactId>
+    <name>Jackrabbit JCA</name>
+    <currentVersion>1.0-SNAPSHOT</currentVersion>   
+    <organization>
+	<name>The Apache Software Foundation</name>
+	<url>http://incubator.apache.org/projects/jackrabbit.html</url>
+	<logo>http://incubator.apache.org/images/apache-incubator-logo.png</logo>
+    </organization>
+    <inceptionYear>2005</inceptionYear>
+    <package>org.apache.jackrabbit.jca</package>
+    <description>
+	A resource adapter for Jackrabbit as specified by JCA 1.0.
+    </description>
+    <dependencies>
+	<dependency>
+	    <groupId>jackrabbit</groupId>
+	    <artifactId>jackrabbit-api</artifactId>
+	    <version>${pom.currentVersion}</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>
+	<dependency>
+	    <groupId>jackrabbit</groupId>
+	    <artifactId>jackrabbit-commons</artifactId>
+	    <version>${pom.currentVersion}</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>
+	<dependency>
+	    <groupId>jackrabbit</groupId>
+	    <artifactId>jackrabbit-core</artifactId>
+	    <version>${pom.currentVersion}</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>
+	<dependency>
+	    <id>concurrent</id>
+	    <version>1.3.4</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>  
+	<dependency>
+	    <id>commons-collections</id>
+	    <version>3.1</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency> 
+	<dependency>
+	    <groupId>jsr170</groupId>
+	    <artifactId>jcr</artifactId>
+	    <version>1.0</version>
+	    <url>http://jcp.org/en/jsr/detail?id=170</url>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency> 
+	<dependency>
+	    <id>log4j</id>
+	    <version>1.2.8</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>
+	<dependency>
+	    <groupId>lucene</groupId>
+	    <artifactId>lucene</artifactId>
+	    <version>1.4.3</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>
+	<dependency>
+	    <groupId>xerces</groupId>
+	    <artifactId>xercesImpl</artifactId>
+	    <version>2.6.2</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>
+	<dependency>
+	    <groupId>xml-apis</groupId>
+	    <artifactId>xmlParserAPIs</artifactId>
+	    <version>2.0.2</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency> 
+	<dependency>
+	    <id>commons-logging</id>
+	    <version>1.0</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>     
+	<dependency>
+	    <groupId>cqfs</groupId>
+	    <artifactId>cqfs-jackrabbit</artifactId>
+	    <version>3.5.6-SNAPSHOT</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>
+	<dependency>
+	    <groupId>cqfs</groupId>
+	    <artifactId>cqfs</artifactId>
+	    <version>3.5.6-SNAPSHOT</version>
+	    <properties>
+		<rar.bundle>true</rar.bundle>
+	    </properties>	    
+	</dependency>    
+	<dependency>
+	    <groupId>geronimo-spec</groupId>
+	    <artifactId>geronimo-spec-j2ee-connector</artifactId>
+	    <version>1.0-M1</version>
+	    <properties>
+		<rar.bundle>false</rar.bundle>
+	    </properties>	    
+	</dependency>					      
+    </dependencies>	
+	  
+    <build>
+	<sourceDirectory>src/java</sourceDirectory>
+	<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
+	<unitTest>
+	    <includes>
+		<include>**/*Test.java</include>
+	    </includes>
+	    <excludes>
+		<exclude>**/init/*</exclude>
+	    </excludes>
+	    <resources>
+		<resource>
+		    <directory>applications/test</directory>
+		    <includes>
+			<include>*.properties</include>
+			<include>*.xml</include>
+		    </includes>
+		</resource>
+		<resource>
+		    <directory>src/test</directory>
+		    <includes>
+			<include>**/*.xml</include>
+			<include>**/*.txt</include>
+		    </includes>
+		</resource>
+	    </resources>
+	</unitTest>	
+    </build>		
+</project>

Propchange: incubator/jackrabbit/trunk/contrib/jca/project.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionManager.java?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionManager.java (added)
+++ incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionManager.java Mon Aug  8 01:11:09 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jca;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+
+/**
+ * This class implements the default connection manager.
+ */
+public final class JCAConnectionManager
+        implements ConnectionManager {
+    
+    /**
+     * The method allocateConnection gets called by the resource adapter's
+     * connection factory instance.
+     */
+    public Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo cri)
+            throws ResourceException {
+        ManagedConnection mc = mcf.createManagedConnection(null, cri);
+        return mc.getConnection(null, cri);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java (added)
+++ incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java Mon Aug  8 01:11:09 2005
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jca;
+
+import javax.jcr.Credentials;
+import javax.jcr.SimpleCredentials;
+import javax.resource.spi.ConnectionRequestInfo;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class encapsulates the credentials for creating a
+ * session from the repository.
+ */
+public final class JCAConnectionRequestInfo
+        implements ConnectionRequestInfo {
+    
+    /**
+     * Credentials.
+     */
+    private final Credentials creds;
+
+    /**
+     * Workspace.
+     */
+    private final String workspace;
+
+    /**
+     * Construct the request info.
+     */
+    public JCAConnectionRequestInfo(JCAConnectionRequestInfo cri) {
+        this(cri.creds, cri.workspace);
+    }
+
+    /**
+     * Construct the request info.
+     */
+    public JCAConnectionRequestInfo(Credentials creds, String workspace) {
+        this.creds = creds;
+        this.workspace = workspace;
+    }
+
+    /**
+     * Return the workspace.
+     */
+    public String getWorkspace() {
+        return workspace;
+    }
+
+    /**
+     * Return the credentials.
+     */
+    public Credentials getCredentials() {
+        return creds;
+    }
+
+    /**
+     * Return the hash code.
+     */
+    public int hashCode() {
+        int hash1 = workspace != null ? workspace.hashCode() : 0;
+        int hash2 = creds != null ? creds.hashCode() : 0;
+        return hash1 ^ hash2;
+    }
+
+    /**
+     * Return true if equals.
+     */
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        } else if (o instanceof JCAConnectionRequestInfo) {
+            return equals((JCAConnectionRequestInfo) o);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Return true if equals.
+     */
+    private boolean equals(JCAConnectionRequestInfo o) {
+        return equals(workspace, o.workspace) &&
+                equals(creds, o.creds);
+    }
+
+    /**
+     * Return true if equals.
+     */
+    private boolean equals(Object o1, Object o2) {
+        if (o1 == o2) {
+            return true;
+        } else if ((o1 != null) && (o2 != null)) {
+            return o1.equals(o2);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Return true if equals.
+     */
+    private boolean equals(char[] o1, char[] o2) {
+        if (o1 == o2) {
+            return true;
+        } else if ((o1 != null) && (o2 != null)) {
+            return equals(new String(o1), new String(o2));
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Return true if equals.
+     */
+    private boolean equals(Credentials o1, Credentials o2) {
+        if (o1 == o2) {
+            return true;
+        } else if ((o1 != null) && (o2 != null)) {
+            if ((o1 instanceof SimpleCredentials) && (o2 instanceof SimpleCredentials)) {
+                return equals((SimpleCredentials) o1, (SimpleCredentials) o2);
+            } else {
+                return o1.equals(o2);
+            }
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * This method compares two simple credentials.
+     */
+    private boolean equals(SimpleCredentials o1, SimpleCredentials o2) {
+        if (!equals(o1.getUserID(), o2.getUserID())) {
+            return false;
+        }
+
+        if (!equals(o1.getPassword(), o2.getPassword())) {
+            return false;
+        }
+
+        Map m1 = getAttributeMap(o1);
+        Map m2 = getAttributeMap(o2);
+        return m1.equals(m2);
+    }
+
+    /**
+     * Return the credentials attributes.
+     */
+    private Map getAttributeMap(SimpleCredentials creds) {
+        HashMap map = new HashMap();
+        String[] keys = creds.getAttributeNames();
+
+        for (int i = 0; i < keys.length; i++) {
+            map.put(keys[i], creds.getAttribute(keys[i]));
+        }
+
+        return map;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAConnectionRequestInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnection.java?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnection.java (added)
+++ incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnection.java Mon Aug  8 01:11:09 2005
@@ -0,0 +1,390 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jca;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.XASession;
+
+import javax.jcr.Repository;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * This class implements the managed connection for
+ * this resource adapter.
+ */
+public final class JCAManagedConnection
+        implements ManagedConnection, ManagedConnectionMetaData {
+    
+    /**
+     * Managed connection factory.
+     */
+    private final JCAManagedConnectionFactory mcf;
+
+    /**
+     * Connection request info.
+     */
+    private final JCAConnectionRequestInfo cri;
+
+    /**
+     * Session instance.
+     */
+    private final XASession session;
+
+    /**
+     * Listeners.
+     */
+    private final LinkedList listeners;
+
+    /**
+     * Handles.
+     */
+    private final LinkedList handles;
+
+    /**
+     * Log writer.
+     */
+    private PrintWriter logWriter;
+
+    /**
+     * Construct the managed connection.
+     */
+    public JCAManagedConnection(JCAManagedConnectionFactory mcf, JCAConnectionRequestInfo cri, XASession session) {
+        this.mcf = mcf;
+        this.cri = cri;
+        this.session = session;
+        this.listeners = new LinkedList();
+        this.handles = new LinkedList();
+    }
+
+    /**
+     * Return the repository.
+     */
+    private RepositoryImpl getRepository() {
+        return mcf.getRepository();
+    }
+
+    /**
+     * Return the managed connection factory.
+     */
+    public JCAManagedConnectionFactory getManagedConnectionFactory() {
+        return mcf;
+    }
+
+    /**
+     * Return the connection request info.
+     */
+    public JCAConnectionRequestInfo getConnectionRequestInfo() {
+        return cri;
+    }
+
+    /**
+     * Get the log writer.
+     */
+    public PrintWriter getLogWriter() {
+        return logWriter;
+    }
+
+    /**
+     * Set the log writer.
+     */
+    public void setLogWriter(PrintWriter logWriter)
+            throws ResourceException {
+        this.logWriter = logWriter;
+    }
+
+    /**
+     * Creates a new connection handle for the underlying physical
+     * connection represented by the ManagedConnection instance.
+     */
+    public Object getConnection(Subject subject, ConnectionRequestInfo cri)
+            throws ResourceException {
+        JCASessionHandle handle = new JCASessionHandle(this);
+        addHandle(handle);
+        return handle;
+    }
+
+    /**
+     * Destroys the physical connection to the underlying resource manager.
+     */
+    public void destroy()
+            throws ResourceException {
+        cleanup();
+        session.logout();
+    }
+
+    /**
+     * Application server calls this method to force any cleanup on
+     * the ManagedConnection instance.
+     */
+    public void cleanup()
+            throws ResourceException {
+        closeHandles();
+    }
+
+    /**
+     * Used by the container to change the association of an
+     * application-level connection handle with a ManagedConneciton instance.
+     */
+    public void associateConnection(Object connection)
+            throws ResourceException {
+        JCASessionHandle handle = (JCASessionHandle) connection;
+        if (handle.getManagedConnection() != this) {
+            handle.getManagedConnection().removeHandle(handle);
+            handle.setManagedConnection(this);
+            addHandle(handle);
+        }
+    }
+
+    /**
+     * Returns an javax.transaction.xa.XAresource instance.
+     */
+    public XAResource getXAResource()
+            throws ResourceException {
+        return session.getXAResource();
+    }
+
+    /**
+     * Returns an javax.resource.spi.LocalTransaction instance.
+     */
+    public LocalTransaction getLocalTransaction()
+            throws ResourceException {
+        throw new UnsupportedOperationException("Local transaction is not supported");
+    }
+
+    /**
+     * Gets the metadata information for this connection's underlying
+     * EIS resource manager instance.
+     */
+    public ManagedConnectionMetaData getMetaData()
+            throws ResourceException {
+        return this;
+    }
+
+    /**
+     * Close the handle.
+     */
+    public void closeHandle(JCASessionHandle handle) {
+        if (handle != null) {
+            removeHandle(handle);
+            sendClosedEvent(handle);
+        }
+    }
+
+    /**
+     * Return the session.
+     */
+    public XASession getSession(JCASessionHandle handle) {
+        synchronized (handles) {
+            if ((handles.size() > 0) && (handles.get(0) == handle)) {
+                return session;
+            } else {
+                throw new java.lang.IllegalStateException("Inactive logical session handle called");
+            }
+        }
+    }
+
+    /**
+     * Return the product name.
+     */
+    public String getEISProductName()
+            throws ResourceException {
+        return getRepository().getDescriptor(Repository.REP_NAME_DESC);
+    }
+
+    /**
+     * Return the product version.
+     */
+    public String getEISProductVersion()
+            throws ResourceException {
+        return getRepository().getDescriptor(Repository.REP_VERSION_DESC);
+    }
+
+    /**
+     * Return number of max connections.
+     */
+    public int getMaxConnections()
+            throws ResourceException {
+        return Integer.MAX_VALUE;
+    }
+
+    /**
+     * Return the user name.
+     */
+    public String getUserName()
+            throws ResourceException {
+        return session.getUserID();
+    }
+
+    /**
+     * Log a message.
+     */
+    public void log(String message) {
+        log(message, null);
+    }
+
+    /**
+     * Log a message.
+     */
+    public void log(String message, Throwable exception) {
+        if (logWriter != null) {
+            logWriter.println(message);
+
+            if (exception != null) {
+                exception.printStackTrace(logWriter);
+            }
+        }
+    }
+
+    /**
+     * Adds a listener.
+     */
+    public void addConnectionEventListener(ConnectionEventListener listener) {
+        synchronized (listeners) {
+            if (!listeners.contains(listener)) {
+                listeners.add(listener);
+            }
+        }
+    }
+
+    /**
+     * Remove a listener.
+     */
+    public void removeConnectionEventListener(ConnectionEventListener listener) {
+        synchronized (listeners) {
+            listeners.remove(listener);
+        }
+    }
+
+    /**
+     * Send event.
+     */
+    private void sendEvent(ConnectionEvent event) {
+        synchronized (listeners) {
+            for (Iterator i = listeners.iterator(); i.hasNext();) {
+                ConnectionEventListener listener = (ConnectionEventListener) i.next();
+
+                switch (event.getId()) {
+                    case ConnectionEvent.CONNECTION_CLOSED:
+                        listener.connectionClosed(event);
+                        break;
+                    case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
+                        listener.connectionErrorOccurred(event);
+                        break;
+                    case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
+                        listener.localTransactionCommitted(event);
+                        break;
+                    case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
+                        listener.localTransactionRolledback(event);
+                        break;
+                    case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
+                        listener.localTransactionStarted(event);
+                        break;
+                }
+            }
+        }
+    }
+
+    /**
+     * Send event.
+     */
+    private void sendEvent(int type, Object handle, Exception cause) {
+        ConnectionEvent event = new ConnectionEvent(this, type, cause);
+        if (handle != null) {
+            event.setConnectionHandle(handle);
+        }
+
+        sendEvent(event);
+    }
+
+    /**
+     * Send connection closed event.
+     */
+    private void sendClosedEvent(JCASessionHandle handle) {
+        sendEvent(ConnectionEvent.CONNECTION_CLOSED, handle, null);
+    }
+
+    /**
+     * Send connection error event.
+     */
+    public void sendrrorEvent(JCASessionHandle handle, Exception cause) {
+        sendEvent(ConnectionEvent.CONNECTION_ERROR_OCCURRED, handle, cause);
+    }
+
+    /**
+     * Send transaction committed event.
+     */
+    public void sendTxCommittedEvent(JCASessionHandle handle) {
+        sendEvent(ConnectionEvent.LOCAL_TRANSACTION_COMMITTED, handle, null);
+    }
+
+    /**
+     * Send transaction rolledback event.
+     */
+    public void sendTxRolledbackEvent(JCASessionHandle handle) {
+        sendEvent(ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK, handle, null);
+    }
+
+    /**
+     * Send transaction started event.
+     */
+    public void sendTxStartedEvent(JCASessionHandle handle) {
+        sendEvent(ConnectionEvent.LOCAL_TRANSACTION_STARTED, handle, null);
+    }
+
+    /**
+     * Add a session handle.
+     */
+    private void addHandle(JCASessionHandle handle) {
+        synchronized (handles) {
+            handles.addFirst(handle);
+        }
+    }
+
+    /**
+     * Remove a session handle.
+     */
+    private void removeHandle(JCASessionHandle handle) {
+        synchronized (handles) {
+            handles.remove(handle);
+        }
+    }
+
+    /**
+     * Release handles.
+     */
+    private void closeHandles() {
+        synchronized (handles) {
+            for (Iterator i = handles.iterator(); i.hasNext();) {
+                JCASessionHandle handle = (JCASessionHandle) i.next();
+                closeHandle(handle);
+            }
+
+            handles.clear();
+        }
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java (added)
+++ incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java Mon Aug  8 01:11:09 2005
@@ -0,0 +1,290 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jca;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.XASession;
+
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Implements the JCA ManagedConnectionFactory contract.
+ */
+public final class JCAManagedConnectionFactory
+        implements ManagedConnectionFactory {
+
+    /**
+     * Home directory.
+     */
+    private String homeDir;
+
+    /**
+     * Config file.
+     */
+    private String configFile;
+
+    /**
+     * Repository.
+     */
+    private transient RepositoryImpl repository;
+
+    /**
+     * Log writer.
+     */
+    private transient PrintWriter logWriter;
+
+    /**
+     * Return the repository home directory.
+     */
+    public String getHomeDir() {
+        return homeDir;
+    }
+
+    /**
+     * Set the repository home directory.
+     */
+    public void setHomeDir(String homeDir) {
+        this.homeDir = homeDir;
+    }
+
+    /**
+     * Return the repository configuration file.
+     */
+    public String getConfigFile() {
+        return configFile;
+    }
+
+    /**
+     * Set the repository configuration file.
+     */
+    public void setConfigFile(String configFile) {
+        this.configFile = configFile;
+    }
+
+    /**
+     * Get the log writer.
+     */
+    public PrintWriter getLogWriter() {
+        return logWriter;
+    }
+
+    /**
+     * Set the log writer.
+     */
+    public void setLogWriter(PrintWriter logWriter)
+            throws ResourceException {
+        this.logWriter = logWriter;
+    }
+
+    /**
+     * Creates a Connection Factory instance.
+     */
+    public Object createConnectionFactory()
+            throws ResourceException {
+        return createConnectionFactory(new JCAConnectionManager());
+    }
+
+    /**
+     * Creates a Connection Factory instance.
+     */
+    public Object createConnectionFactory(ConnectionManager cm)
+            throws ResourceException {
+        createRepository();
+        JCARepositoryHandle handle = new JCARepositoryHandle(this, cm);
+        log("Created repository handle (" + handle + ")");
+        return handle;
+    }
+
+    /**
+     * Create a new session.
+     */
+    private XASession openSession(JCAConnectionRequestInfo cri)
+            throws ResourceException {
+        createRepository();
+        Credentials creds = cri.getCredentials();
+        String workspace = cri.getWorkspace();
+
+        try {
+            XASession session = (XASession) getRepository().login(creds, workspace);
+            log("Created session (" + session + ")");
+            return session;
+        } catch (RepositoryException e) {
+            log("Failed to create session", e);
+            throw new ResourceException(e);
+        }
+    }
+
+    /**
+     * Creates a new physical connection to the underlying EIS resource manager.
+     */
+    public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri)
+            throws ResourceException {
+        return createManagedConnection((JCAConnectionRequestInfo) cri);
+    }
+
+    /**
+     * Creates a new physical connection to the underlying EIS resource manager.
+     */
+    private ManagedConnection createManagedConnection(JCAConnectionRequestInfo cri)
+            throws ResourceException {
+        return new JCAManagedConnection(this, cri, openSession(cri));
+    }
+
+    /**
+     * Returns a matched connection from the candidate set of connections.
+     */
+    public ManagedConnection matchManagedConnections(Set set, Subject subject, ConnectionRequestInfo cri)
+            throws ResourceException {
+        for (Iterator i = set.iterator(); i.hasNext();) {
+            Object next = i.next();
+
+            if (next instanceof JCAManagedConnection) {
+                JCAManagedConnection mc = (JCAManagedConnection) next;
+                if (equals(mc.getManagedConnectionFactory())) {
+                    JCAConnectionRequestInfo otherCri = mc.getConnectionRequestInfo();
+                    if (equals(cri, otherCri)) {
+                        return mc;
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Return the repository.
+     */
+    public RepositoryImpl getRepository() {
+        return repository;
+    }
+
+    /**
+     * Log a message.
+     */
+    public void log(String message) {
+        log(message, null);
+    }
+
+    /**
+     * Log a message.
+     */
+    public void log(String message, Throwable exception) {
+        if (logWriter != null) {
+            logWriter.println(message);
+
+            if (exception != null) {
+                exception.printStackTrace(logWriter);
+            }
+        }
+    }
+
+    /**
+     * Return the hash code.
+     */
+    public int hashCode() {
+        int result = homeDir != null ? homeDir.hashCode() : 0;
+        result = 37 * result + (configFile != null ? configFile.hashCode() : 0);
+        return result;
+    }
+
+    /**
+     * Return true if equals.
+     */
+    public boolean equals(Object o) {
+        if (o == this) {
+            return true;
+        } else if (o instanceof JCAManagedConnectionFactory) {
+            return equals((JCAManagedConnectionFactory) o);
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Return true if equals.
+     */
+    private boolean equals(JCAManagedConnectionFactory o) {
+        return equals(homeDir, o.homeDir) &&
+               equals(configFile, o.configFile);
+    }
+
+    /**
+     * Return true if equals.
+     */
+    private boolean equals(Object o1, Object o2) {
+        if (o1 == o2) {
+            return true;
+        } else if ((o1 == null) || (o2 == null)) {
+            return false;
+        } else {
+            return o1.equals(o2);
+        }
+    }
+
+    /**
+     * Shutdown the repository.
+     */
+    protected void finalize() {
+        shutdownRepository();
+    }
+
+    /**
+     * Create repository.
+     */
+    private void createRepository()
+            throws ResourceException {
+        if (repository == null) {
+            // Check the home directory
+            if ((homeDir == null) || homeDir.equals("")) {
+                throw new ResourceException("Property 'homeDir' not set");
+            }
+
+            // Check the config file
+            if ((configFile == null) || configFile.equals("")) {
+                throw new ResourceException("Property 'configFile' not set");
+            }
+
+            try {
+                JCARepositoryManager mgr = JCARepositoryManager.getInstance();
+                repository = mgr.createRepository(homeDir, configFile);
+                log("Created repository (" + repository + ")");
+            } catch (RepositoryException e) {
+                log("Failed to create repository", e);
+                throw new ResourceException(e);
+            }
+        }
+    }
+
+    /**
+     * Shutdown the repository.
+     */
+    private void shutdownRepository() {
+        JCARepositoryManager mgr = JCARepositoryManager.getInstance();
+        mgr.shutdownRepository(homeDir, configFile);
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCAManagedConnectionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java (added)
+++ incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java Mon Aug  8 01:11:09 2005
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jca;
+
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.naming.Reference;
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import java.io.Serializable;
+
+/**
+ * This class implements the JCA implementation of repository.
+ */
+public final class JCARepositoryHandle
+        implements Repository, Referenceable, Serializable {
+
+    /**
+     * Managed connection factory.
+     */
+    private final JCAManagedConnectionFactory mcf;
+
+    /**
+     * Connection manager.
+     */
+    private final ConnectionManager cm;
+
+    /**
+     * Reference.
+     */
+    private Reference reference;
+
+    /**
+     * Construct the repository.
+     */
+    public JCARepositoryHandle(JCAManagedConnectionFactory mcf, ConnectionManager cm) {
+        this.mcf = mcf;
+        this.cm = cm;
+    }
+
+    /**
+     * Creates a new session.
+     */
+    public Session login()
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        return login(null, null);
+    }
+
+    /**
+     * Creates a new session.
+     */
+    public Session login(Credentials creds)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        return login(creds, null);
+    }
+
+    /**
+     * Creates a new session.
+     */
+    public Session login(String workspace)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        return login(null, workspace);
+    }
+
+    /**
+     * Creates a new session.
+     */
+    public Session login(Credentials creds, String workspace)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        return login(new JCAConnectionRequestInfo(creds, workspace));
+    }
+
+    /**
+     * Creates a new session.
+     */
+    private Session login(JCAConnectionRequestInfo cri)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        try {
+            return (Session) cm.allocateConnection(mcf, cri);
+        } catch (ResourceException e) {
+            Throwable cause = e.getCause();
+
+            if (cause instanceof LoginException) {
+                throw (LoginException) cause;
+            } else if (cause instanceof NoSuchWorkspaceException) {
+                throw (NoSuchWorkspaceException) cause;
+            } else if (cause instanceof RepositoryException) {
+                throw (RepositoryException) cause;
+            } else if (cause != null) {
+                throw new RepositoryException(cause);
+            } else {
+                throw new RepositoryException(e);
+            }
+        }
+    }
+
+    /**
+     * Return the descriptor keys.
+     */
+    public String[] getDescriptorKeys() {
+        return mcf.getRepository().getDescriptorKeys();
+    }
+
+    /**
+     * Return the descriptor for key.
+     */
+    public String getDescriptor(String key) {
+        return mcf.getRepository().getDescriptor(key);
+    }
+
+    /**
+     * Return the reference.
+     */
+    public Reference getReference() {
+        return reference;
+    }
+
+    /**
+     * Set the reference.
+     */
+    public void setReference(Reference reference) {
+        this.reference = reference;
+    }
+}

Propchange: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryHandle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java?rev=230772&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java (added)
+++ incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java Mon Aug  8 01:11:09 2005
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.jca;
+
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+
+import javax.jcr.RepositoryException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class implements the repository manager.
+ */
+public final class JCARepositoryManager {
+
+    /**
+     * Instance of manager.
+     */
+    private final static JCARepositoryManager INSTANCE =
+            new JCARepositoryManager();
+
+    /**
+     * References.
+     */
+    private final Map references;
+
+    /**
+     * Construct the manager.
+     */
+    private JCARepositoryManager() {
+        this.references = new HashMap();
+    }
+
+    /**
+     * Create repository.
+     */
+    public RepositoryImpl createRepository(String homeDir, String configFile)
+            throws RepositoryException {
+        Reference ref = getReference(homeDir, configFile);
+        return ref.create();
+    }
+
+    /**
+     * Shutdown the repository.
+     */
+    public void shutdownRepository(String homeDir, String configFile) {
+        Reference ref = getReference(homeDir, configFile);
+        ref.shutdown();
+    }
+
+    /**
+     * Return the reference.
+     */
+    private synchronized Reference getReference(String homeDir, String configFile) {
+        Reference ref = new Reference(homeDir, configFile);
+        Reference other = (Reference) references.get(ref);
+
+        if (other == null) {
+            references.put(ref, ref);
+            return ref;
+        } else {
+            return other;
+        }
+    }
+
+    /**
+     * Return the instance.
+     */
+    public static JCARepositoryManager getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * Repository reference implementation.
+     */
+    private final class Reference {
+        /**
+         * Home directory.
+         */
+        private final String homeDir;
+
+        /**
+         * Configuration file.
+         */
+        private final String configFile;
+
+        /**
+         * Repository instance.
+         */
+        private RepositoryImpl repository;
+
+        /**
+         * Reference count.
+         */
+        private int count;
+
+        /**
+         * Construct the manager.
+         */
+        private Reference(String homeDir, String configFile) {
+            this.homeDir = homeDir;
+            this.configFile = configFile;
+            this.repository = null;
+            this.count = 0;
+        }
+
+        /**
+         * Return the repository.
+         */
+        public RepositoryImpl create()
+                throws RepositoryException {
+            if (repository == null) {
+                RepositoryConfig config = RepositoryConfig.create(configFile, homeDir);
+                repository = RepositoryImpl.create(config);
+            }
+
+            count++;
+            return repository;
+        }
+
+        /**
+         * Shutdown the repository.
+         */
+        public void shutdown() {
+            if (count > 0) {
+                count--;
+
+                if (count == 0) {
+                    repository.shutdown();
+                    repository = null;
+                }
+            }
+        }
+
+        /**
+         * Return the hash code.
+         */
+        public int hashCode() {
+            int result = homeDir != null ? homeDir.hashCode() : 0;
+            result = 37 * result + (configFile != null ? configFile.hashCode() : 0);
+            return result;
+        }
+
+        /**
+         * Return true if equals.
+         */
+        public boolean equals(Object o) {
+            if (o == this) {
+                return true;
+            } else if (o instanceof Reference) {
+                return equals((Reference) o);
+            } else {
+                return false;
+            }
+        }
+
+        /**
+         * Return true if equals.
+         */
+        private boolean equals(Reference o) {
+            return equals(homeDir, o.homeDir) &&
+                   equals(configFile, o.configFile);
+        }
+
+        /**
+         * Return true if equals.
+         */
+        private boolean equals(String s1, String s2) {
+            if (s1 == s2) {
+                return true;
+            } else if ((s1 == null) || (s2 == null)) {
+                return false;
+            } else {
+                return s1.equals(s2);
+            }
+        }
+    }
+}
+

Propchange: incubator/jackrabbit/trunk/contrib/jca/src/java/org/apache/jackrabbit/jca/JCARepositoryManager.java
------------------------------------------------------------------------------
    svn:eol-style = native