jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r540521 [1/3] - in /jackrabbit/trunk/contrib/jcrlog: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/jcrlog/ src/main/java/org/apache/jac...
Date Tue, 22 May 2007 10:26:34 GMT
Author: jukka
Date: Tue May 22 03:26:30 2007
New Revision: 540521

URL: http://svn.apache.org/viewvc?view=rev&rev=540521
Log:
JCR-634: Log/trace wrapper contributed by Thomas Mueller.

Added:
    jackrabbit/trunk/contrib/jcrlog/
    jackrabbit/trunk/contrib/jcrlog/LICENSE.txt   (with props)
    jackrabbit/trunk/contrib/jcrlog/maven.xml   (with props)
    jackrabbit/trunk/contrib/jcrlog/project.properties   (with props)
    jackrabbit/trunk/contrib/jcrlog/project.xml   (with props)
    jackrabbit/trunk/contrib/jcrlog/repository.xml   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/
    jackrabbit/trunk/contrib/jcrlog/src/main/
    jackrabbit/trunk/contrib/jcrlog/src/main/java/
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothing.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothingContentHandler.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogInputStream.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryLogger.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/StringUtils.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/package.html   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Arg.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Parser.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Player.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/Statement.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/player/package.html   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/doodle/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/doodle/MyDoodle.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/doodle/MyItemVisitor.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/FirstHop.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/SecondHop.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/ThirdHop.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/samples/test.xml   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/unit/
    jackrabbit/trunk/contrib/jcrlog/src/test/java/org/apache/jackrabbit/jcrlog/test/unit/TestAPI.java   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/resources/
    jackrabbit/trunk/contrib/jcrlog/src/test/resources/log4j.properties   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test/resources/repository.xml   (with props)
    jackrabbit/trunk/contrib/jcrlog/src/test2.sqlpage

Added: jackrabbit/trunk/contrib/jcrlog/LICENSE.txt
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/LICENSE.txt?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/LICENSE.txt (added)
+++ jackrabbit/trunk/contrib/jcrlog/LICENSE.txt Tue May 22 03:26:30 2007
@@ -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: jackrabbit/trunk/contrib/jcrlog/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/maven.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/maven.xml?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/maven.xml (added)
+++ jackrabbit/trunk/contrib/jcrlog/maven.xml Tue May 22 03:26:30 2007
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+  -->
+<project default="jar:jar">
+    <!-- The following is a hack to get xslt work with maven (See: http://maven.apache.org/faq.html#BadXSLT ) -->
+	${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')}
+</project>

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

Added: jackrabbit/trunk/contrib/jcrlog/project.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/project.properties?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/project.properties (added)
+++ jackrabbit/trunk/contrib/jcrlog/project.properties Tue May 22 03:26:30 2007
@@ -0,0 +1,7 @@
+# ------------------------------------------------------------------------
+maven.repo.remote = http://www.ibiblio.org/maven/,http://www.day.com/maven/
+maven.test.skip=false
+
+# force to compile for java 1.4
+maven.compile.source=1.4
+maven.compile.target=1.4

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

Added: jackrabbit/trunk/contrib/jcrlog/project.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/project.xml?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/project.xml (added)
+++ jackrabbit/trunk/contrib/jcrlog/project.xml Tue May 22 03:26:30 2007
@@ -0,0 +1,163 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You 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.
+  -->
+<project>
+    <!-- ====================================================================== -->
+    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
+    <!-- ====================================================================== -->
+    <pomVersion>3</pomVersion>
+    <groupId>org.apache.jackrabbit</groupId>
+    <artifactId>jackrabbit-jcrlog</artifactId>
+    <name>Apache Jackrabbit JCR Log Wrapper</name>
+
+    <id>jcrlog</id>
+    <currentVersion>1.0-SNAPSHOT</currentVersion>
+
+    <!-- ====================================================================== -->
+    <!-- D E P E N D E N C I E S                                                -->
+    <!-- ====================================================================== -->
+    <dependencies>
+
+        <dependency>
+            <!-- util.concurrent -->
+            <groupId>concurrent</groupId>
+            <artifactId>concurrent</artifactId>
+            <version>1.3.4</version>
+            <url>http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html</url>
+            <!--
+                Advanced concurrent programming classes not available
+                in J2SE 1.4.
+            -->
+        </dependency>
+        <dependency>
+            <!-- JUnit -->
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <properties>
+                <scope>test</scope>
+            </properties>
+            <url>http://www.junit.org/</url>
+            <!--
+                The unit testing framework used by the Jackrabbit and JCR
+                test cases.
+            -->
+        </dependency>
+        <dependency>
+            <!-- Commons Collections -->
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.1</version>
+            <url>http://jakarta.apache.org/commons/collections/</url>
+            <!--
+                Advanced collection classes, utilities and data structures
+                used internally by Jackrabbit.
+            -->
+        </dependency>
+        <dependency>
+            <!-- The Java Transaction API (JTA) -->
+            <groupId>geronimo-spec</groupId>
+            <artifactId>geronimo-spec-jta</artifactId>
+            <version>1.0-M1</version>
+            <url>http://java.sun.com/products/jta/</url>
+            <!--
+                The Java Transaction API (JTA) classes not available
+                in J2SE 1.4.
+            -->
+        </dependency>
+        <dependency>
+            <!-- Content Repository for Java(TM) Technology API (JCR) -->
+            <groupId>jsr170</groupId>
+            <artifactId>jcr</artifactId>
+            <version>1.0</version>
+            <url>http://jcp.org/en/jsr/detail?id=170</url>
+            <!--
+                The Content Repository for Java(TM) Technology API (JCR)
+                interfaces implemented by Jackrabbit.
+            -->
+        </dependency>
+        <dependency>
+            <!-- slf4j-log4j12 -->
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.0</version>
+            <url>http://www.slf4j.org/download.html</url>
+            <!--
+                SLF4J adapter for log4j.
+            -->
+        </dependency>
+        <dependency>
+            <!-- log4j -->
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.8</version>
+            <url>http://logging.apache.org/log4j</url>
+            <!--
+                The logging framework used to output messages of varying
+                importance during runtime.
+            -->
+        </dependency>
+        <dependency>
+            <!-- Apache Lucene -->
+            <groupId>lucene</groupId>
+            <artifactId>lucene</artifactId>
+            <version>1.4.3</version>
+            <url>http://lucene.apache.org/java/</url>
+            <!--
+                The full text search engine library used to implement much
+                of the query features of Jackrabbit.
+            -->
+        </dependency>
+        <dependency>
+            <!-- Apache Derby -->
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>10.1.3.1</version>
+            <url>http://db.apache.org/derby/</url>
+            <!--
+                The pure Java database implementation used by Jackrabbit
+                as the default backend for the database persistence manager.
+            -->
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-core</artifactId>
+            <version>1.0.1</version>
+        </dependency>
+
+     </dependencies>
+
+    <!-- ====================================================================== -->
+    <!-- B U I L D  D E S C R I P T I O N                                       -->
+    <!-- ====================================================================== -->
+
+    <build>
+        <sourceDirectory>src/main/java</sourceDirectory>
+        <unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
+        <unitTest>
+            <includes>
+                <include>**/Test*.java</include>
+            </includes>
+            <resources>
+                <resource>
+                    <directory>src/test/resources</directory>
+                </resource>
+            </resources>
+		</unitTest>
+    </build>
+</project>

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

Added: jackrabbit/trunk/contrib/jcrlog/repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/repository.xml?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/repository.xml (added)
+++ jackrabbit/trunk/contrib/jcrlog/repository.xml Tue May 22 03:26:30 2007
@@ -0,0 +1,224 @@
+<?xml version="1.0"?>
+<!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 Versioning element that is used for configuring
+            versioning-related settings
+
+            a SearchIndex element that is used for configuring Indexing-related
+            settings on the /jcr:system tree.
+    -->
+    <!ELEMENT Repository (FileSystem,Security,Workspaces,Workspace,Versioning,SearchIndex?)>
+
+    <!--
+        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"/>
+           <!--
+              default user name to be used instead of the anonymous user
+              when no login credentials are provided (unset by default)
+           -->
+           <!-- <param name="defaultUserId" value="superuser"/> -->
+        </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="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.db.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+          <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+        </PersistenceManager>
+        <!--
+            Search index and the file system it uses.
+            class: FQN of class implementing the QueryHandler interface
+        -->
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <!--
+            Configures the filesystem to use for versioning for the respective
+            persistence manager
+        -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+        
+        <!--
+            Configures the persistence 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.db.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
+          <param name="schemaObjectPrefix" value="version_"/>
+        </PersistenceManager>
+    </Versioning>
+
+    <!--
+        Search index for content that is shared repository wide
+        (/jcr:system tree, contains mainly versions)
+    -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index"/>
+    </SearchIndex>
+</Repository>

Propchange: jackrabbit/trunk/contrib/jcrlog/repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothing.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothing.java?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothing.java (added)
+++ jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothing.java Tue May 22 03:26:30 2007
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcrlog;
+
+import javax.jcr.ItemVisitor;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+
+/**
+ * This empty visitor / listener is used as a replacement for the visitor /
+ * listener defined by the application.
+ *
+ * @author Thomas Mueller
+ */
+public class DoNothing implements ItemVisitor, EventListener {
+
+    /**
+     * Does nothing.
+     *
+     * @param node - ignored
+     */
+    public void visit(Property node) {
+        // do nothing
+    }
+
+    /**
+     * Does nothing.
+     *
+     * @param property - ignored
+     */
+    public void visit(Node property) {
+        // do nothing
+    }
+
+    /**
+     * Does nothing.
+     *
+     * @param events - ignored
+     */
+    public void onEvent(EventIterator events) {
+        // do nothing
+    }
+}

Propchange: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothing.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothingContentHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothingContentHandler.java?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothingContentHandler.java (added)
+++ jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothingContentHandler.java Tue May 22 03:26:30 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcrlog;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * This empty content handler is used as a replacement for the content handler defined by the application.
+ *
+ * @author Thomas Mueller
+ */
+public class DoNothingContentHandler implements ContentHandler {
+
+    public void characters(char[] ch, int start, int length) throws SAXException {
+    }
+
+    public void endDocument() throws SAXException {
+    }
+
+    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+    }
+
+    public void endPrefixMapping(String prefix) throws SAXException {
+    }
+
+    public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+    }
+
+    public void processingInstruction(String target, String data) throws SAXException {
+    }
+
+    public void setDocumentLocator(Locator locator) {
+    }
+
+    public void skippedEntity(String name) throws SAXException {
+    }
+
+    public void startDocument() throws SAXException {
+    }
+
+    public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
+    }
+
+    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+    }
+
+}

Propchange: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/DoNothingContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java (added)
+++ jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java Tue May 22 03:26:30 2007
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcrlog;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import javax.jcr.Credentials;
+import javax.jcr.ItemVisitor;
+import javax.jcr.RepositoryException;
+import javax.jcr.SimpleCredentials;
+import javax.jcr.Value;
+import javax.jcr.Workspace;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.observation.EventListener;
+
+import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.api.JackrabbitWorkspace;
+import org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException;
+import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
+
+/**
+ * A collection of utility methods for the JCR API.
+ * This class is mainly used when replaying a log file.
+ *
+ * @author Thomas Mueller
+ *
+ */
+public class JcrUtils {
+
+    static final String CLASSNAME = JcrUtils.class.getName();
+
+    /**
+     * Register a node type.
+     * This is a utility method used while playing back a log file.
+     */
+    public static void registerNodeTypes(NodeTypeManager manager,
+            Collection coll) throws InvalidNodeTypeDefException,
+            RepositoryException {
+        if (manager instanceof NodeTypeManagerImpl) {
+            NodeTypeManagerImpl mgr = (NodeTypeManagerImpl) manager;
+            mgr.getNodeTypeRegistry().registerNodeTypes(coll);
+        } else if (manager instanceof LogObject) {
+            LogObject proxy = (LogObject) manager;
+            NodeTypeManagerImpl mgr = (NodeTypeManagerImpl)proxy.getObject();
+            mgr.getNodeTypeRegistry().registerNodeTypes(coll);
+            try {
+                String s = StringUtils.serializeToString(coll);
+                proxy.log(
+                        "registerNodeTypes(StringUtils.deserializeFromString(\""
+                                + s + "\"))", null);
+            } catch (Throwable t) {
+                proxy.log("Can't serialize collection: " + coll, t);
+            }
+        }
+    }
+
+    /**
+     * Cast a NodeTypeManager to a JackrabbitNodeTypeManager.
+     * This is a utility method used while playing back a log file.
+     *
+     * @param ntMgr
+     * @return the casted object
+     */
+    public static JackrabbitNodeTypeManager cast(NodeTypeManager ntMgr) {
+        return (JackrabbitNodeTypeManager)ntMgr;
+    }
+
+    /**
+     * Cast a NodeTypeManager to a JackrabbitNodeTypeManager.
+     * This is a utility method used while playing back a log file.
+     */
+    public static JackrabbitWorkspace cast(Workspace ws) {
+        return (JackrabbitWorkspace)ws;
+    }
+
+    /**
+     * Call a method via reflection.
+     * This is a utility method used while playing back a log file.
+     *
+     * @param obj the object
+     * @param methodName the method to call
+     * @param params the parameter list
+     * @return the value returned
+     * @throws Exception
+     */
+    public static Object callViaReflection(Object obj, String methodName,
+            Object[] params) throws Exception {
+        Method[] methods = obj.getClass().getMethods();
+        Method method = null;
+        for (int i = 0; i < methods.length; i++) {
+            Method m = methods[i];
+            if (!Modifier.isPublic(m.getModifiers())) {
+                continue;
+            }
+            if (m.getParameterTypes().length == params.length) {
+                if (method != null) {
+                    throw new Exception(
+                            "More than one method with this number of parameters: "
+                                    + obj.getClass().getName() + " "
+                                    + methodName + " " + params.length);
+                }
+                method = m;
+            }
+        }
+        return method.invoke(obj, params);
+    }
+
+    /**
+     * Create a new dummy event listener.
+     */
+    public static EventListener createDoNothingEventListener() {
+        return new DoNothing();
+    }
+
+    /**
+     * Create a new dummy item visitor.
+     */
+    public static ItemVisitor createDoNothingItemVisitor() {
+        return new DoNothing();
+    }
+
+    /**
+     * Create a calendar from a string.
+     * Timezones are not supported.
+     */
+    public static Calendar getCalendar(String s) {
+        return StringUtils.parseCalendar(s);
+    }
+
+    /**
+     * Create an input stream from a string.
+     * This is a utility method used while playing back a log file.
+     */
+    public static InputStream getInputStream(String data) {
+        StringTokenizer tokenizer = new StringTokenizer(data, ": ");
+        Properties prop = new Properties();
+        while (tokenizer.hasMoreTokens()) {
+            prop.put(tokenizer.nextToken(), tokenizer.nextToken());
+        }
+        String d = prop.getProperty("data");
+        if (d != null) {
+            return new ByteArrayInputStream(StringUtils.convertStringToBytes(d));
+        }
+        String s = prop.getProperty("size");
+        if (s != null) {
+            int size = Integer.parseInt(s);
+            byte[] buff = new byte[size];
+            String a = prop.getProperty("adler32");
+            if (a != null) {
+                Arrays.fill(buff, (byte)'-');
+                byte[] adler32 = a.getBytes();
+                System.arraycopy(adler32, 0, buff, 0, Math.min(adler32.length, buff.length));
+            }
+            return new ByteArrayInputStream(buff);
+        }
+        return new ByteArrayInputStream(data.getBytes());
+    }
+
+    /**
+     * Create an output stream from a string.
+     * This is a utility method used while playing back a log file.
+     */
+    public static OutputStream getOutputStream() {
+        return new ByteArrayOutputStream();
+    }
+
+    /**
+     * Get a value from an array.
+     * This is a utility method used while playing back a log file.
+     */
+    public static Value getValue(Value[] array, int id) {
+        return array[id];
+    }
+
+    /**
+     * Create a credentials object.
+     * This is a utility method used while playing back a log file.
+     */
+    public static Credentials createSimpleCredentials(String username) {
+        return new SimpleCredentials(username, "".toCharArray());
+    }
+
+    /**
+     * Deserialize a Java object from a String.
+     * This is a utility method used while playing back a log file.
+     */
+    public static Object deserializeFromString(String s) throws IOException, ClassNotFoundException {
+        byte[] bytes = StringUtils.convertStringToBytes(s);
+        return deserialize(bytes);
+    }
+
+    /**
+     * Print something to System.out. This can be used for debugging.
+     */
+    public static void debug(Object o) {
+        System.out.println(o == null ? "null" : o.toString());
+    }
+
+    private static Object deserialize(byte[] data) throws IOException, ClassNotFoundException {
+        ByteArrayInputStream in = new ByteArrayInputStream(data);
+        ObjectInputStream is = new ObjectInputStream(in);
+        Object obj = is.readObject();
+        return obj;
+    }
+
+}

Propchange: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/JcrUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java (added)
+++ jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java Tue May 22 03:26:30 2007
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcrlog;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * This class writes the log output to System.out and / or to a file. A simple
+ * implementation, could be replaced with log4j or whatever.
+ *
+ * @author Thomas Mueller
+ */
+class Log {
+
+    private long lastLogTime;
+
+    private String fileName;
+
+    private SimpleDateFormat dateFormat;
+
+    private FileWriter fileWriter;
+
+    private PrintWriter printWriter;
+
+    private boolean systemOut;
+
+    private String lineEnd;
+
+    private boolean logReturn = true;
+    private boolean logTime = false;
+    private boolean logCaller = true;
+    private boolean castToRealApi = false;
+    private boolean logStream = false;
+
+    private static void createDirs(String fileName) throws IOException {
+        File f = new File(fileName);
+        if (!f.exists()) {
+            String parent = f.getParent();
+            if (parent == null) {
+                return;
+            }
+            File dir = new File(parent);
+            if (dir.exists() || dir.mkdirs()) {
+                return;
+            }
+            throw new IOException("Directory creation failed: " + fileName);
+        }
+    }
+
+    private void print(String s, Throwable t) {
+        System.out.println(s);
+        if (t != null) {
+            t.printStackTrace();
+        }
+    }
+
+    private String format(String s) {
+        long time = System.currentTimeMillis();
+        if (time > lastLogTime + 1000) {
+            lastLogTime = time;
+            s = "//" + dateFormat.format(new Date()) + lineEnd + s;
+        }
+        return s;
+    }
+
+    void write(String s, Throwable t) {
+        s = format(s);
+        if (systemOut) {
+            System.out.println(s);
+            if (t != null) {
+                t.printStackTrace();
+            }
+        }
+        if (printWriter != null) {
+            writeFile(s, t);
+        }
+    }
+
+    private synchronized void writeFile(String s, Throwable t) {
+        try {
+            printWriter.println(s);
+            if (t != null) {
+                t.printStackTrace(printWriter);
+            }
+            printWriter.flush();
+        } catch (Exception e) {
+            print("Error writing to log file", e);
+        }
+    }
+
+    Log(String fileName, boolean systemOut) {
+        this.fileName = fileName;
+        this.systemOut = systemOut;
+        dateFormat = new SimpleDateFormat("MM-dd HH:mm:ss ");
+        lineEnd = System.getProperty("line.separator");
+        if (fileName != null) {
+            try {
+                createDirs(fileName);
+                File f = new File(fileName);
+                if (f.exists() && !f.canWrite()) {
+                    // file is read only - don't log
+                    print("The file is read only, logging is disabled: "
+                            + fileName, null);
+                }
+                fileWriter = new FileWriter(fileName);
+                printWriter = new PrintWriter(fileWriter, true);
+            } catch (IOException e) {
+                print("Can not create or open log file: " + fileName, e);
+            }
+        }
+    }
+
+    private synchronized void closeWriter() {
+        if (printWriter != null) {
+            printWriter.flush();
+            printWriter.close();
+            printWriter = null;
+        }
+        if (fileWriter != null) {
+            try {
+                fileWriter.close();
+            } catch (IOException e) {
+                // ignore exception
+            }
+            fileWriter = null;
+        }
+    }
+
+    void close() {
+        closeWriter();
+    }
+
+    public void finalize() {
+        close();
+    }
+
+    String getFileName() {
+        return fileName;
+    }
+
+    boolean getLogReturn() {
+        return logReturn;
+    }
+
+    void setLogCaller(boolean logCaller) {
+        this.logCaller = logCaller;
+    }
+
+    boolean getLogCaller() {
+        return logCaller;
+    }
+
+    boolean getLogTime() {
+        return logTime;
+    }
+
+    void setLogReturn(boolean b) {
+        this.logReturn = b;
+    }
+
+    void setCastToRealApi(boolean b) {
+        this.castToRealApi = b;
+    }
+
+    boolean getCastToRealApi() {
+        return castToRealApi;
+    }
+
+    void setLogStream(boolean b) {
+        this.logStream = b;
+    }
+
+    boolean getLogStream() {
+        return logStream;
+    }
+
+}

Propchange: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/Log.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogInputStream.java?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogInputStream.java (added)
+++ jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogInputStream.java Tue May 22 03:26:30 2007
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcrlog;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.Adler32;
+
+/**
+ * Input Stream wrapper for user input streams.
+ *
+ * @author Thomas Mueller
+ *
+ */
+class LogInputStream extends InputStream {
+    private IOException throwThis;
+    private ByteArrayInputStream in;
+    private byte[] data;
+    private int size;
+    private long adler;
+    private boolean logStream;
+
+    public static LogInputStream wrapStream(InputStream in, boolean logData) {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        int bufferSize = 4 * 1024;
+        IOException throwThis = null;
+        Adler32 adler = new Adler32();
+        try {
+            byte[] buffer = new byte[bufferSize];
+            while (true) {
+                int l = in.read(buffer, 0, bufferSize);
+                if (l < 0) {
+                    break;
+                }
+                adler.update(buffer, 0, l);
+                out.write(buffer, 0, l);
+            }
+        } catch (IOException e) {
+            throwThis = e;
+        }
+        return new LogInputStream(out.toByteArray(), throwThis, adler
+                .getValue(), logData);
+    }
+
+    private LogInputStream(byte[] buffer, IOException throwThis, long adler, boolean logStream) {
+        this.throwThis = throwThis;
+        this.size = buffer.length;
+        this.adler = adler;
+        this.data = buffer;
+        this.logStream = logStream;
+        this.in = new ByteArrayInputStream(buffer);
+    }
+
+    private void throwOnceIfRequired() throws IOException {
+        if (throwThis != null) {
+            IOException t = throwThis;
+            throwThis = null;
+            throw t;
+        }
+    }
+
+    public int read() throws IOException {
+        throwOnceIfRequired();
+        return in.read();
+    }
+
+    public int available() throws IOException {
+        throwOnceIfRequired();
+        return in.available();
+    }
+
+    public void close() throws IOException {
+        throwOnceIfRequired();
+        in.close();
+    }
+
+    public void mark(int readlimit) {
+        in.mark(readlimit);
+    }
+
+    public boolean markSupported() {
+        return in.markSupported();
+    }
+
+    public int read(byte[] b, int off, int len) throws IOException {
+        throwOnceIfRequired();
+        return in.read(b, off, len);
+    }
+
+    public int read(byte[] b) throws IOException {
+        throwOnceIfRequired();
+        return in.read(b);
+    }
+
+    public void reset() throws IOException {
+        throwOnceIfRequired();
+        in.reset();
+    }
+
+    public long skip(long n) throws IOException {
+        throwOnceIfRequired();
+        return in.skip(n);
+    }
+
+
+    public String toString() {
+        StringBuffer buff = new StringBuffer();
+        buff.append("size:");
+        buff.append(size);
+        buff.append(" adler32:0x");
+        buff.append(Long.toHexString(adler));
+        if (logStream) {
+            buff.append(" data:");
+            buff.append(StringUtils.convertBytesToString(data));
+        }
+        return buff.toString();
+    }
+
+}

Propchange: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java (added)
+++ jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java Tue May 22 03:26:30 2007
@@ -0,0 +1,451 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcrlog;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import javax.jcr.Item;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RangeIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.Workspace;
+import javax.jcr.lock.Lock;
+import javax.jcr.nodetype.ItemDefinition;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeIterator;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.observation.Event;
+import javax.jcr.observation.EventIterator;
+import javax.jcr.observation.EventListener;
+import javax.jcr.observation.EventListenerIterator;
+import javax.jcr.observation.ObservationManager;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+import javax.jcr.version.VersionIterator;
+
+import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
+import org.apache.jackrabbit.api.JackrabbitWorkspace;
+
+/**
+ * Logging is implemented using java.lang.reflect.Proxy. For each JCR 'object'
+ * there is a LogObject. The main 'invocation handler' is always called when a
+ * public method on the JCR object is called.
+ *
+ * @author Thomas Mueller
+ */
+
+public class LogObject implements InvocationHandler {
+
+    private final static String CLASS_NAME = LogObject.class.getName();
+
+    /**
+     * The package name of this class.
+     * It is not hardcoded because this would break refactoring.
+     */
+    public final static String MY_PACKAGE_DOT = CLASS_NAME.substring(0, CLASS_NAME.lastIndexOf('.') + 1);
+
+    private volatile boolean processing;
+
+    private final static long SLOW_METHOD_MS = 100;
+
+    private long start;
+
+    private String name;
+
+    private static int nextArrayId;
+
+    private static final ArrayList INTERFACES = new ArrayList();
+
+    private static final HashSet PREFIXES = new HashSet();
+
+    private static final HashMap INTERFACE_MAP = new HashMap();
+
+    static final InterfaceDef INTERFACE_DEF_REPOSITORY, INTERFACE_DEF_SESSION;
+
+    static {
+        addInterface("e", Event.class);
+        addInterface("ei", EventIterator.class);
+        addInterface("el", EventListener.class);
+        addInterface("eli", EventListenerIterator.class);
+        addInterface("im", Item.class);
+        addInterface("imd", ItemDefinition.class);
+        addInterface("lc", Lock.class);
+        addInterface("nsr", NamespaceRegistry.class);
+        addInterface("n", Node.class);
+        addInterface("nd", NodeDefinition.class);
+        addInterface("ni", NodeIterator.class);
+        addInterface("nt", NodeType.class);
+        addInterface("nti", NodeTypeIterator.class);
+        addInterface("jntm", JackrabbitNodeTypeManager.class);
+        addInterface("ntm", NodeTypeManager.class);
+        addInterface("om", ObservationManager.class);
+        addInterface("p", Property.class);
+        addInterface("pd", PropertyDefinition.class);
+        addInterface("pi", PropertyIterator.class);
+        addInterface("q", Query.class);
+        addInterface("qm", QueryManager.class);
+        addInterface("qr", QueryResult.class);
+        addInterface("rgi", RangeIterator.class);
+        INTERFACE_DEF_REPOSITORY = addInterface("rp", Repository.class);
+        addInterface("rw", Row.class);
+        addInterface("ri", RowIterator.class);
+        INTERFACE_DEF_SESSION = addInterface("s", Session.class);
+        addInterface("v", Value.class);
+        addInterface("vf", ValueFactory.class);
+        addInterface("vs", Version.class);
+        addInterface("vsh", VersionHistory.class);
+        addInterface("vsi", VersionIterator.class);
+        addInterface("jws", JackrabbitWorkspace.class);
+        addInterface("ws", Workspace.class);
+    }
+
+    static InterfaceDef addInterface(String prefix, Class clazz) {
+        if (PREFIXES.contains(prefix)) {
+            throw new Error("Internal error: duplicate interface prefix "
+                    + prefix);
+        }
+        PREFIXES.add(prefix);
+        InterfaceDef idef = new InterfaceDef();
+        idef.prefix = prefix;
+        String name = clazz.getName();
+        name = name.substring(name.lastIndexOf('.') + 1);
+        idef.className = name;
+        idef.interfaceClass = clazz;
+        idef.type = INTERFACES.size();
+        INTERFACES.add(idef);
+        INTERFACE_MAP.put(clazz, idef);
+        return idef;
+    }
+
+    private Log log;
+
+    private int assignType;
+
+    private Object obj;
+
+    Object getObject() {
+        return obj;
+    }
+
+    String getObjectName() {
+        return name;
+    }
+
+    protected RepositoryException logAndConvert(Throwable t) {
+        logReturn();
+        if (t instanceof RepositoryException) {
+            RepositoryException r = (RepositoryException) t;
+            logException("RepositoryException", r);
+            return r;
+        } else if (t instanceof RuntimeException) {
+            RuntimeException r = (RuntimeException) t;
+            logException("RuntimeException", r);
+            throw r;
+        } else if (t instanceof Error) {
+            Error r = (Error) t;
+            logException("Error", r);
+            throw r;
+        } else {
+            logException("Internal", t);
+            throw new Error("Internal exception: " + t.toString());
+        }
+    }
+
+    protected RuntimeException logRuntimeException(Throwable t) {
+        logReturn();
+        if (t instanceof RuntimeException) {
+            RuntimeException r = (RuntimeException) t;
+            logException("RuntimeException", r);
+            return r;
+        } else if (t instanceof Error) {
+            Error r = (Error) t;
+            logException("Error", r);
+            throw r;
+        } else {
+            logException("LoggerException", t);
+            throw new Error("Internal exception: " + t.toString());
+        }
+    }
+
+    protected int logStart(int assignType, boolean array, String method,
+            String parameters) {
+        this.start = System.currentTimeMillis();
+        this.assignType = assignType;
+        int nextId = -1;
+        String s = name + "." + method + "(" + parameters + ");";
+        if (array && assignType >= 0) {
+            nextId = nextArrayId++;
+            InterfaceDef idef = getInterfaceDef(assignType);
+            s = idef.className + "[] array" + nextId + " = " + s;
+        } else if (assignType >= 0) {
+            nextId = getNextId(assignType);
+            s = getAssign(assignType, nextId, s);
+        }
+        logStartCall(s);
+        return nextId;
+    }
+
+    private String getCaller() {
+        Throwable t = new Throwable();
+        StackTraceElement[] st = t.getStackTrace();
+        for (int i = 0; i < st.length; i++) {
+            StackTraceElement e = st[i];
+            String className = e.getClassName();
+            if (className.startsWith("$Proxy")) {
+                continue;
+            }
+            if (className.startsWith(MY_PACKAGE_DOT)) {
+                if (className.substring(MY_PACKAGE_DOT.length()).indexOf('.') < 0) {
+                    // don't ignore sub-packages
+                    continue;
+                }
+            }
+            String s = className + "." + e.getMethodName() + "("
+                    + e.getFileName() + ":" + e.getLineNumber() + ")";
+            return s;
+        }
+        return "unknown caller";
+    }
+
+    protected void logStartCall(String s) {
+        if (log.getLogCaller()) {
+            log.write("//> " + getCaller(), null);
+        }
+        logJava(s);
+        if (processing) {
+            log.write("//Concurrent Access", null);
+        }
+    }
+
+    private void logJava(String s) {
+        log.write("/**/" + s, null);
+    }
+
+    protected String getAssign(int type, int id, String call) {
+        InterfaceDef idef = getInterfaceDef(type);
+        return idef.className + " " + idef.prefix + id + " = " + call;
+    }
+
+    private static InterfaceDef getInterfaceDef(int type) {
+        return (InterfaceDef) INTERFACES.get(type);
+    }
+
+    protected void setLog(Log log, int type, int id) {
+        this.log = log;
+        InterfaceDef idef = getInterfaceDef(type);
+        this.name = idef.prefix + id;
+    }
+
+    protected int getNextId(int type) {
+        InterfaceDef idef = getInterfaceDef(type);
+        return idef.nextId++;
+    }
+
+    protected void logReturn() {
+        processing = false;
+        long time = System.currentTimeMillis() - start;
+        if (time > SLOW_METHOD_MS) {
+            log.write("//time: " + time + " ms", null);
+        }
+    }
+
+    private void logException(String title, Throwable e) {
+        log.write("//" + title + ": " + e.toString(), e);
+    }
+
+    protected void logReturn(Class clazz, Object result) {
+        logReturn();
+        if (clazz == String.class && StringUtils.isUUID((String)result)) {
+            log.write("//return " + StringUtils.quote(clazz, result) + "; // UUID", null);
+        } else if (log.getLogReturn()) {
+            log.write("//return " + StringUtils.quote(clazz, result) + ";", null);
+        }
+    }
+
+    public String toString() {
+        return name;
+    }
+
+    protected Object wrap(Object obj, boolean array, Class clazz,
+            int assignType, int id) {
+        if (array) {
+            Object[] list = (Object[]) obj;
+            for (int i = 0; i < list.length; i++) {
+                if (list[i] != null) {
+                    int nextId = getNextId(assignType);
+                    InterfaceDef idef = getInterfaceDef(assignType);
+                    logJava(getAssign(assignType, nextId,
+                            JcrUtils.CLASSNAME + ".get"
+                                    + idef.className + "(array" + id + ", " + i
+                                    + ");"));
+                    list[i] = wrapObject(list[i], clazz, nextId);
+                }
+            }
+            return list;
+        } else {
+            return wrapObject(obj, clazz, id);
+        }
+    }
+
+    private Object wrapObject(Object obj, Class clazz, int id) {
+        LogObject handler = new LogObject();
+        handler.setLog(log, assignType, id);
+        handler.obj = obj;
+        InterfaceDef idef = getInterfaceDef(assignType);
+
+        Class proxyClass = idef.proxyClass;
+        if (proxyClass == null) {
+            proxyClass = Proxy.getProxyClass(clazz.getClassLoader(),
+                    new Class[] { clazz });
+            idef.proxyClass = proxyClass;
+        }
+        try {
+            Object o2 = proxyClass.getConstructor(
+                    new Class[] { InvocationHandler.class }).newInstance(
+                    new Object[] { handler });
+            return o2;
+        } catch (Exception e) {
+            logException("InvocationTargetException", e);
+            throw new Error("Internal exception: " + e.toString());
+        }
+    }
+
+    public Object invoke(Object proxy, Method method, Object[] args)
+            throws Throwable {
+        Object result;
+        try {
+            if (method.getName().equals("toString")) {
+                return result = method.invoke(obj, args);
+            }
+            Class returnClass = method.getReturnType();
+            int returnType = -1;
+            InterfaceDef idef = (InterfaceDef) INTERFACE_MAP.get(returnClass);
+            boolean array = false;
+            if (idef != null) {
+                returnType = idef.type;
+            } else if (returnClass.isArray()) {
+                array = true;
+                returnClass = returnClass.getComponentType();
+                idef = LogObject.getInterface(returnClass);
+                if (idef != null) {
+                    returnType = idef.type;
+                }
+            }
+            wrapStreams(method.getParameterTypes(), args);
+            int nextId = logStart(returnType, array, method.getName(),
+                    StringUtils.quoteArgs(method.getParameterTypes(), args));
+            result = method.invoke(obj, args);
+            if (log.getCastToRealApi() && result != null && idef != null) {
+                InterfaceDef idef2 = LogObject.getInterface(result.getClass());
+                if (idef2 != null && idef2 != idef) {
+                    // if the return value was of a more specific type
+                    // (for example JackrabbitNodeTypeManager instead of just a NodeTypeManager), cast it
+                    logJava(getAssign(idef2.type, nextId,
+                            JcrUtils.CLASSNAME + ".cast("
+                                    + idef.prefix + nextId + ");"));
+                    returnType = idef2.type;
+                    returnClass = idef2.interfaceClass;
+                }
+            }
+            if (returnType >= 0) {
+                result = wrap(result, array, returnClass, returnType, nextId);
+            }
+            logReturn(returnClass, result);
+            return result;
+        } catch (IllegalArgumentException e) {
+            logException("IllegalArgumentException", e);
+            throw new Error("Internal exception: " + e.toString());
+        } catch (IllegalAccessException e) {
+            logException("IllegalAccessException", e);
+            throw new Error("Internal exception: " + e.toString());
+        } catch (InvocationTargetException e) {
+            Throwable t = e.getTargetException();
+            throw t;
+        }
+    }
+
+    private void wrapStreams(Class[] parameterTypes, Object[] args) {
+        for (int i = 0; args != null && i < args.length; i++) {
+            Object o = args[i];
+            if (o == null || !(o instanceof InputStream)) {
+                continue;
+            }
+            InputStream in = (InputStream) o;
+            in = LogInputStream.wrapStream(in, log.getLogStream());
+            args[i] = in;
+        }
+    }
+
+    static InterfaceDef getInterface(Class clazz) {
+        InterfaceDef idef = (InterfaceDef) INTERFACE_MAP.get(clazz);
+        if (idef != null) {
+            return idef;
+        }
+        Class[] interfaces = clazz.getInterfaces();
+        InterfaceDef best = null;
+        for (int i = 0; i < interfaces.length; i++) {
+            idef = (InterfaceDef) INTERFACE_MAP.get(interfaces[i]);
+            if (idef != null) {
+                if (best == null || idef.className.length() > best.className.length()) {
+                    best = idef;
+                }
+            }
+        }
+        return best;
+    }
+
+    void log(String string, Throwable t) {
+        // TODO currently used for node type registration only
+        log.write("// ### " + string, t);
+    }
+
+    /**
+     * Internally used information about a wrapped interface.
+     */
+    static class InterfaceDef {
+
+        String className;
+        Class interfaceClass;
+        String prefix;
+        int nextId;
+        Class proxyClass;
+        int type;
+    }
+
+}

Propchange: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/LogObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java?view=auto&rev=540521
==============================================================================
--- jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java (added)
+++ jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java Tue May 22 03:26:30 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jcrlog;
+
+import java.io.IOException;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.core.TransientRepository;
+
+/**
+ * This is an idea how opening a repository could be made vendor-independent.
+ * Only one conrecte class (this one) needs to be provided by the JCR API. The
+ * mechanism is similar to java.sql.DriverManager
+ *
+ * @author Thomas Mueller
+ *
+ */
+public class RepositoryFactory {
+    static final String CLASSNAME = RepositoryFactory.class.getName();
+
+    /**
+     * Open a repository using a repository URL.
+     *
+     * @param url the URL
+     * @return the repository
+     * @throws RepositoryException
+     */
+    public static Repository open(String url) throws RepositoryException {
+        if (url.startsWith("apache/jackrabbit/")) {
+            url = url.substring("apache/jackrabbit/".length());
+            if (url.equals("transient")) {
+                try {
+                    return new TransientRepository();
+                } catch (IOException e) {
+                    RepositoryException re = new RepositoryException(
+                            "Error creating TransientRepository");
+                    re.initCause(e);
+                    throw re;
+                }
+            } else if (url.startsWith("logger/")) {
+                url = url.substring("logger/".length());
+                return RepositoryLogger.open(url);
+            } else {
+                throw new RepositoryException("unknown repository type: " + url);
+            }
+        } else {
+            throw new RepositoryException("unknown provider: " + url);
+        }
+    }
+}

Propchange: jackrabbit/trunk/contrib/jcrlog/src/main/java/org/apache/jackrabbit/jcrlog/RepositoryFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message