You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2006/03/19 23:17:51 UTC

svn commit: r387045 - in /incubator/jackrabbit/trunk/contrib/examples: ./ src/java/ src/java/org/apache/jackrabbit/examples/ src/site/ src/site/xdoc/ src/webapp/ src/webapp/META-INF/ src/webapp/WEB-INF/

Author: jukka
Date: Sun Mar 19 14:17:49 2006
New Revision: 387045

URL: http://svn.apache.org/viewcvs?rev=387045&view=rev
Log:
JCR-319: Added example web application contributed by Mark Slater.

Added:
    incubator/jackrabbit/trunk/contrib/examples/HEADER.txt   (with props)
    incubator/jackrabbit/trunk/contrib/examples/LICENSE.txt   (with props)
    incubator/jackrabbit/trunk/contrib/examples/jaas.config
    incubator/jackrabbit/trunk/contrib/examples/repository_model2.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/java/log4j.properties   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/JackrabbitTest.java   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/site/
    incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/
    incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/index.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model1notes.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model2notes.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/navigation.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/webapp/
    incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/
    incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/context.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/repository_model1.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/webapp/WEB-INF/
    incubator/jackrabbit/trunk/contrib/examples/src/webapp/WEB-INF/web.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/webapp/index.html   (with props)
Modified:
    incubator/jackrabbit/trunk/contrib/examples/README.txt
    incubator/jackrabbit/trunk/contrib/examples/project.xml

Added: incubator/jackrabbit/trunk/contrib/examples/HEADER.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/HEADER.txt?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/HEADER.txt (added)
+++ incubator/jackrabbit/trunk/contrib/examples/HEADER.txt Sun Mar 19 14:17:49 2006
@@ -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/examples/HEADER.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/LICENSE.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/LICENSE.txt?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/LICENSE.txt (added)
+++ incubator/jackrabbit/trunk/contrib/examples/LICENSE.txt Sun Mar 19 14:17:49 2006
@@ -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/examples/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/examples/README.txt
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/README.txt?rev=387045&r1=387044&r2=387045&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/README.txt (original)
+++ incubator/jackrabbit/trunk/contrib/examples/README.txt Sun Mar 19 14:17:49 2006
@@ -1,6 +1,53 @@
 README - JCR examples
 ---------------------
 
+=======================================================================
+Welcome to Jackrabbit Deployment Test
+=======================================================================
+
+License (see also LICENSE.txt)
+==============================
+
+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.
+
+
+Getting Started
+===============
+
+The Jackrabbit Deployment Test is a webapp designed to demonstrate and
+test the configuration of two styles of Jackrabbit deployment:
+
+- Model 1, Embedded: This style of deployment embeds a Jackrabbit
+                     repository within a web application.
+- Model 2, Shared:   This style of deployment makes a Jackrabbit repository
+                     available to all web applications in the application
+                     server.
+
+Prerequisites
+-------------
+
+In order to build the web application and create the documentation that
+accompanies it, you will need to have Maven (version 1.x should work, but
+1.0.2 is known to work) installed on your computer. If you want to run
+the application, you will also need a working installation of Tomcat 5.5.x
+(version 5.5.15 is known to work).
+
+Follow the links for these two programs in the "More Information" section
+at the end of this document to learn how to download and install them.
+
 Requirements
 ------------
 
@@ -11,3 +58,43 @@
   maven jar:install
 
 which will build and copy Jackrabbit into ~/.maven/repository/jackrabbit/jars
+
+
+Building the web application
+----------------------------
+
+Maven's "war" goal will build the web application .war file for the project.
+From the root directory of the projecct, run maven with the following
+command:
+
+    maven war
+
+The web application will be created at
+
+    target/jackrabbit_deployment_test.war
+
+After you have followed the configuration instructions in the project's
+documentation site, copy this file into Tomcat's webapps/ directory to
+install it into the application server. Once installed, you should be able
+to access it at
+
+    http://localhost:8080/jackrabbit_deployment_test/index.html
+
+This assumes you have left Tomcat's port configured at 8080. If you changed
+the port, you should replace "8080" in the URL above with the port you
+assigned to Tomcat.
+
+More Information
+================
+
+Jackrabbit:         http://incubator.apache.org/jackrabbit/
+Tomcat:             http://tomcat.apache.org
+Maven:              http://maven.apache.org
+Maven 1.x Download: http://maven.apache.org/maven-1.x/start/download.html
+
+Credits
+=======
+
+who                     what
+--------------------    -----------------------------------------------
+Mark Slater             initial development and documentation
\ No newline at end of file

Added: incubator/jackrabbit/trunk/contrib/examples/jaas.config
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/jaas.config?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/jaas.config (added)
+++ incubator/jackrabbit/trunk/contrib/examples/jaas.config Sun Mar 19 14:17:49 2006
@@ -0,0 +1,3 @@
+Jackrabbit {
+    org.apache.jackrabbit.core.security.SimpleLoginModule required;
+};

Modified: incubator/jackrabbit/trunk/contrib/examples/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/project.xml?rev=387045&r1=387044&r2=387045&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/examples/project.xml Sun Mar 19 14:17:49 2006
@@ -105,6 +105,11 @@
       <artifactId>xmlParserAPIs</artifactId>
       <version>2.0.2</version>
     </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.4</version>
+    </dependency>
   </dependencies>
 
   <build>

Added: incubator/jackrabbit/trunk/contrib/examples/repository_model2.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/repository_model2.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/repository_model2.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/repository_model2.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<Repository>
+
+    <!-- Virtual file system where the repository stores global state -->
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+    
+    
+    <!-- Security configuration -->
+    <Security appName="Jackrabbit">
+        <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+        
+        </AccessManager>
+        
+        <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+        
+        </LoginModule>
+    </Security>
+    
+    
+    <!-- Location of workspaces root directory and the name of the default worksapce -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" />
+    
+    
+    <!-- Workspace configuration template. This is used to create the initial workspace. -->
+    <Workspace name="${wsp.name}">
+    
+        <!-- Virtual file system for the workspace -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        
+        
+        <!-- Persistence Manager for the workspace -->
+        <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+        
+        
+        <!-- Search index and its file system -->
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+            <param name="useCompoundFile" value="true"/>
+            <param name="minMergeDocs" value="100"/>
+            <param name="volatileIdleTime" value="3"/>
+            <param name="maxMergeDocs" value="100000"/>
+            <param name="mergeFactor" value="10"/>
+            <param name="bufferSize" value="10"/>
+            <param name="cacheSize" value="1000"/>
+            <param name="forceConsistencyCheck" value="false"/>
+            <param name="autoRepair" value="true"/>
+            <param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
+            <param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl"/>
+            <param name="idleTime" value="-1"/>
+            <param name="respectDocumentOrder" value="true"/>
+        </SearchIndex>
+        
+    </Workspace>
+    
+    
+    <!-- Versioning configuration -->
+    <Versioning rootPath="${rep.home}/version">
+    
+        <!-- Virtual file system for versioning -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+        
+        <!-- Persistence Manager for versioning -->
+        <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+
+    </Versioning>
+    
+    <!-- Repository wide search index -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index" />
+    </SearchIndex>
+</Repository>

Propchange: incubator/jackrabbit/trunk/contrib/examples/repository_model2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/java/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/java/log4j.properties?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/java/log4j.properties (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/java/log4j.properties Sun Mar 19 14:17:49 2006
@@ -0,0 +1,14 @@
+# Use the INFO logging level for stdout.
+log4j.rootCategory=INFO
+
+# Output pattern (shared)
+# date priority [category] - <message>line_separator
+
+# STDOUT properties
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
+
+log4j.logger.org.apache.jackrabbit=ALL, stdout
+log4j.logger.javax.jcr=ALL, stdout
+

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/java/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/JackrabbitTest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/JackrabbitTest.java?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/JackrabbitTest.java (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/JackrabbitTest.java Sun Mar 19 14:17:49 2006
@@ -0,0 +1,263 @@
+/*
+   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.examples;
+
+import java.io.*;
+
+import javax.naming.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+import javax.jcr.*;
+
+public class JackrabbitTest
+    extends HttpServlet
+{
+    Repository ownedRepository = null;
+    Repository sharedRepository = null;
+    
+    public void doGet( HttpServletRequest request, HttpServletResponse response )
+        throws IOException, ServletException
+    {
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        out.println("<html>");
+        out.println("<head>");
+        out.println("<title>Jackrabbit Deployment Testing</title>");
+        out.println("</head>");
+        out.println("<body>");
+        
+        getRepositoriesFromJNDI( out );
+        
+        if( ownedRepository != null )
+        {
+            out.println( "<hr>" );
+            out.println( "<h3>Testing the embedded repository</h3>" );
+            
+            try
+            {
+                testRepository( ownedRepository, out );
+            }
+            catch( IllegalStateException e )
+            {
+                out.println(
+                    "<p><b>IllegalStateException thrown logging into ownedRepository</b>."
+                    + "This is likely due to the repository having been shut down. You will "
+                    + "need to restart Tomcat before the repository will be accessible again."
+                    + "</p>" );
+            }
+        }
+        
+        if( sharedRepository != null )
+        {
+            out.println( "<hr>" );
+            out.println( "<h3>Testing the shared repository</h3>" );
+            testRepository( sharedRepository, out );
+        }
+        
+        out.println("</body>");
+        out.println("</html>");
+    }
+    
+    private void getRepositoriesFromJNDI( PrintWriter out )
+    {
+        out.println("<h3>Getting the Jackrabbit reference via JNDI</h3>");
+            
+        try
+        {
+        // Get the initial context
+            Context initialContext = new InitialContext();
+            
+            out.println( "<p>Got initial context</p>" );
+            
+            listContextEntries( out, initialContext, "java:comp/env" );
+            listContextEntries( out, initialContext, "java:comp/env/jcr" );
+            
+        // Get the environment context
+            Context environmentContext = (Context) initialContext.lookup( "java:comp/env" );
+            
+            out.println( "<p>Got environment context</p>" );
+            
+            listContextEntries( out, environmentContext, "/" );
+            listContextEntries( out, environmentContext, "/jcr" );
+            
+        // get values out of the context.
+            
+            ownedRepository = (Repository) getObjectFromContext(
+                out, environmentContext, "jcr/model1Repository" );
+            out.println( "<p>ownedRepository = " + ownedRepository + "</p>" );
+            
+            try
+            {
+                sharedRepository = (Repository) getObjectFromContext(
+                    out, environmentContext, "sharedJCRRepository" );
+                out.println( "<p>sharedJCRRepository = " + sharedRepository + "</p>" );
+            }
+            catch( ClassCastException e )
+            {
+                out.println(
+                    "<p><b>ClassCastException thrown setting testObj to sharedRepository</b>."
+                    + "This is likely a class loader issue. Since the repository is shared "
+                    + "between all webapps, you need to have jcr-1.0.jar in "
+                    + "<code>$TOMCAT_HOME/common/lib</code>. If you also include jcr-1.0.jar "
+                    + "in your webapp's <code>WEB-INF/lib</code>, that instance of the "
+                    + "Repository.class will take precedence within the webapp. But Tomcat's "
+                    + "instance was created with the Repository.class in the global jar file "
+                    + "leading to the ClassCastException.</p>" );
+                
+                sharedRepository = null;
+            }
+        }
+        catch( Exception e )
+        {
+            out.println( "<p>Exception thrown: <pre>" );
+            e.printStackTrace( out );
+            out.println( "</pre></p>" );
+        }
+    }
+    
+    private Object getObjectFromContext( PrintWriter out, Context context, String path )
+    {
+        Object o = null;
+        
+        try
+        {
+            o = context.lookup( path );
+        }
+        catch( NameNotFoundException e )
+        {
+            out.println( "<p>Could not load " + path + " from the context.<pre>" );
+            e.printStackTrace( out );
+            out.println( "</pre></p>" );
+        }
+        catch( NamingException e )
+        {
+            out.println( "<p>Naming exception:<pre>" );
+            e.printStackTrace( out );
+            out.println( "</pre></p>" );
+        }
+        
+        return( o );
+    }
+    
+    private void listContextEntries( PrintWriter out, Context context, String path )
+    {
+        if( ( out == null ) || ( context == null ) || ( path == null ) )
+        {
+            throw new IllegalArgumentException( "parameters must not be null: out = "
+                + out + ", context = " + context + ", path = " + path );
+        }
+        
+        try
+        {
+            NamingEnumeration contextEntries = context.list( path );
+            
+            out.println( "<p>Entries at <code>" + path + "</code>:" );
+            
+            while( contextEntries.hasMore() )
+            {
+                NameClassPair entry = (NameClassPair) contextEntries.next();
+                out.println( "<li><code>" + entry + "</code></li>" );
+            }
+        
+            out.println( "</p>" );
+        }
+        catch( NamingException e )
+        {
+            out.println(
+                "<p>Exception thrown printing contents of <code>" + path + "</code>: <pre>" );
+            e.printStackTrace( out );
+            out.println( "</pre></p>" );
+        }
+    }
+    
+    private void testRepository( Repository repository, PrintWriter out )
+    {
+        Session session = null;
+        
+        try
+        {
+            session = repository.login(
+                new SimpleCredentials( "username", "password".toCharArray() ) );
+        }
+        catch( LoginException e )
+        {
+            out.println( "<p>LoginException thrown: <pre>" );
+            e.printStackTrace( out );
+            out.println( "</pre></p>" );
+        }
+        catch( RepositoryException e )
+        {
+            out.println( "<p>Exception logging into repository: <pre>" );
+            e.printStackTrace( out );
+            out.println( "</pre></p>" );
+        }
+        
+        if( session != null )
+        {
+            try
+            {
+                out.println( "<p>Login complete, session = " + session + "</p>" );
+                
+                Node root = session.getRootNode();
+                out.println( "<p>Root node is type: "
+                    + root.getPrimaryNodeType().getName() + "</p>" );
+                
+                Node node = null;
+                
+                if( !root.hasNode( "testnode" ) )
+                {
+                    out.println( "<p>Creating \"testnode\".</p>" );
+                    
+                    node = root.addNode( "testnode", "nt:unstructured" );
+                    
+                    out.println( "<p>Adding \"testprop\" to new node.</p>" );
+                    
+                    node.setProperty( "testprop", "Hello, World!" );
+                    
+                    out.println( "<p>Saving changes.</p>" );
+                    
+                    session.save();
+                }
+                else
+                {
+                    out.println( "<p>You've done this before. \"testnode\" already exists.</p>" );
+                    
+                    out.println( "<p>Getting previously created \"testnode\".</p>" );
+                    node = (Node) root.getNode( "testnode" );
+                }
+                
+                out.println( "<p>Getting \"testprop\" via the root node.</p>" );
+                Property propViaRoot = root.getProperty( "testnode/testprop" );
+                out.println( "<p>Property = " + propViaRoot.getString() + "</p>" );
+                
+                out.println( "<p>Getting \"testprop\" via the test node.</p>" );
+                Property propViaNode = node.getProperty( "testprop" );
+                out.println( "<p>Property = " + propViaNode.getString() + "</p>" );
+                
+                session.logout();
+            }
+            catch( Exception e )
+            {
+                out.println( "<p>Exception while using repository: <pre>" );
+                e.printStackTrace( out );
+                out.println( "</pre></p>" );
+            }
+        }
+    }
+}

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

Added: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/index.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/index.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/index.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/index.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,171 @@
+<?xml version="1.0"?>
+<!--
+   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.
+  -->
+<document>
+    <properties>
+        <title>Welcome to Jackrabbit Deployment Test</title>
+    </properties>
+    <body>
+        <section name="About Jackrabbit Deployment Test">
+            <p>
+                As described in the Jackrabbit documentation, there are three deployment models:
+                <ul>
+                    <li><a href="http://incubator.apache.org/jackrabbit/doc/deploy/howto-model1.html">Model 1 (Embedded)</a>
+                     - Embed the Jackrabbit repository in your webapp. This gives your app full
+                     responsibility for managing the repository, and does not allow other webapps
+                     to use it.</li>
+                    <li><a href="http://incubator.apache.org/jackrabbit/doc/deploy/howto-model2.html">Model 2 (Shared)</a>
+                    - Share a repository with all webapps in the application server. This provides
+                    a repository managed by the application server that is accessible by all webapps
+                    in the server.</li>
+                    <li><a href="http://incubator.apache.org/jackrabbit/doc/deploy/howto-model3.html">Model 3 (Server)</a>
+                    - Run the repository as a stand-alone server, or on an external application
+                    server. The repository is accessed using JCR-RMI or WebDAV.</li>
+                </ul>
+                This project provides guidance and an example deployment for Model 1 and Model 2
+                using Tomcat 5.5.x.
+            </p>
+            <p>
+                If you run the webapp, it will attempt to access both an Embedded (Model 1)
+                repository and a Shared (Model 2) repository. For each repository it is able to
+                access through JNDI, it tries to log into the repository and create a single test
+                node. It then prints the contents of that node to the HTML output of the servlet.
+                Along the way, it prints status information and any exceptions thrown that may be
+                helpful in debugging configuration issues.
+            </p>
+            <p>
+                Follow the instructions on this page to first configure Tomcat and the repositories
+                and then build and install the webapp itself.
+            </p>
+        </section>
+        <section name="Configuring Tomcat (5.5.x)">
+            <p>
+                Before getting started, you will need to do some configuration to Tomcat itself.
+                This webapp uses both repositories, one embedded and one shared. This is important
+                to note because where you put the jar files for Jackrabbit and its dependencies
+                can change depending on which model you use.
+            </p>
+            <subsection name="Jackrabbit JAR locations">
+                <p>
+                    If your webapp is using an embedded repository only, you can place the jars for
+                    Jackrabbit and its dependencies in your <code>WEB-INF/lib/</code> directory. If
+                    your webapp is using a shared repository, the jars should be placed in the
+                    application server's common JAR library; for Tomcat that location is
+                    <code>$CATALINA_HOME/common/lib/</code>.
+                </p>
+            </subsection>
+            <subsection name="Logging">
+                <p>
+                    You should configure Log4J so that Jackrabbit can report errors and other
+                    status information. The configuration should go in the
+                    <code>$CATALINA_HOME/common/class/log4j.properties</code> file. Here is a sample
+                    Log4J configuration, which only specifies logging parameters for Jackrabbit and
+                    JCR.
+                </p>
+                <source><![CDATA[
+# Use the INFO logging level for stdout.
+log4j.rootCategory=INFO
+
+# Output pattern (shared)
+# date priority [category] - <message>line_separator
+
+# STDOUT properties
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
+
+log4j.logger.org.apache.jackrabbit=ALL, stdout
+log4j.logger.javax.jcr=ALL, stdout
+]]></source>
+                <p>
+                    This configuration will log as much information as possible to the main
+                    Tomcat log file, <code>$CATALINA_HOME/logs/catalina.out</code>. You can reduce
+                    the amount of information by changing the logging level from <code>ALL</code>
+                    to <code>DEBUG</code>, <code>INFO</code>, <code>WARN</code>,
+                    <code>ERROR</code>, or <code>FATAL</code> (there may be very little difference
+                    between <code>ALL</code> and <code>DEBUG</code>). While you are developing your
+                    webapp, you may find it useful to keep the Jackrabbit logging somewhere
+                    between <code>ALL</code> and <code>INFO</code> so you can watch it process
+                    calls you make to the repository.
+                </p>
+            </subsection>
+            <subsection name="JAAS Security">
+                <p>
+                    In order for the webapp to login to the repository, you need to configure
+                    JAAS. Fortunately, the Jackrabbit project comes with a login module that
+                    allows minimal setup. The example <code>jaas.config</code> configuration is
+                    included at the root of the web application's source directory; it should be
+                    copied to <code>$CATALINA_HOME/conf/jaas.config</code>. If you already have
+                    a JAAS configuration file for your Tomcat installation, you should merge the
+                    settings below.
+                </p>
+                <source><![CDATA[
+Jackrabbit {
+    org.apache.jackrabbit.core.security.SimpleLoginModule required;
+};
+]]></source>
+                <p>
+                    Now you should set the <code>JAVA_OPTS</code> environment variable to the
+                    following value so Tomcat knows where to find the configuration file.
+                </p>
+                <source><![CDATA[
+-Djava.security.auth.login.config=$CATALINA_HOME/conf/jaas.config
+]]></source>
+                <p>
+                    Make sure you start Tomcat from the environment where <code>JAVA_OPTS</code>
+                    has been set. If the Tomcat starts without JAAS configured properly, when
+                    you run the webapp, it will report a <code>LoginException</code> for each
+                    repository that is configured and accessible.
+                </p>
+            </subsection>
+        </section>
+        <section name="Configuring the repositories">
+            <p>
+                This webapp contains a sample repository configuration for the Embedded (Model 1)
+                repository in <code>META-INF/repository_model1.xml</code>. The configuration for
+                the Shared (Model 2) repository is at the root level of the web application's
+                source directory; it should be copied to
+                <code>$CATALINA_HOME/conf/repository_model2.xml</code>.
+            </p>
+            <p>
+                For details on the repository configuration file, see the
+                <a href="http://incubator.apache.org/jackrabbit/doc/firststeps.html">First Hops</a>
+                tutorial.
+            </p>
+        </section>
+        <section name="Building this webapp">
+            <p>
+                Before you build the webapp, you should follow the
+                <a href="http://incubator.apache.org/jackrabbit/doc/building.html">build
+                instructions</a> on the main Jackrabbit website to build the
+                <code>jackrabbit-1.0-SNAPSHOT.jar</code>. To build the webapp, you will need to use
+                Maven's <code>war</code> goal.
+            </p>
+                <source><![CDATA[
+user$ maven war
+]]></source>
+            <p>
+                Once the webapp is built, you should copy the
+                <code>target/jackrabbit_deployment_test.war</code> file to
+                <code>$CATALINA_HOME/webapps/</code> and then start Tomcat. You should then be able
+                to run the servlet by clicking on the link in the application's
+                <a href="http://localhost:8080/jackrabbit_deployment_test/index.html">welcome
+                page</a>.
+            </p>
+        </section>
+    </body>
+</document>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/index.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model1notes.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model1notes.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model1notes.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model1notes.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,155 @@
+<?xml version="1.0"?>
+<!--
+   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.
+  -->
+<document>
+    <properties>
+        <title>Model 1 Deployment Notes</title>
+    </properties>
+    
+    <body>
+        <section name="Model 1 Basics">
+            <p>
+                A Model 1, or Embedded, deployment gives your webapp sole access and control
+                of the repository. You are responsible for starting the repository and for shutting
+                it down. Other webapps in the application server will not have access to the
+                repository.
+            </p>
+            <p>
+                There are two methods of accessing the repository: coding it directly into your
+                application, and using a JNDI Resource configuration for your webapp. As the first
+                approach ties your code very tightly to Jackrabbit (as opposed to the JCR API), we
+                will not cover it here and instead focus on using JNDI to configure and access the
+                repository. If you want more information about coding the repository's creation
+                and management directly, see the
+                <a href="http://incubator.apache.org/jackrabbit/doc/firststeps.html">First Hops</a>
+                tutorial in the main Jackrabbit documentation.
+            </p>
+        </section>
+        
+        <section name="Context locations">
+            <p>
+                There are three locations where you can place webapp specific context information.
+                The first, which is strongly discouraged, is inside Tomcat's <code>server.xml</code>
+                file under the Host tag; this approach is far from ideal because you must restart
+                the whole server for changes to your context to take effect. The second location
+                is in <code>$CATALINA_HOME/conf/Catalina/localhost/[webapp].xml</code>, where
+                <code>[webapp]</code> is the name of the root directory of your web application
+                (i.e. the name of your webapp's war file, without the <code>.war</code> extension).
+                The third location is within your war's directory structure, in a file called
+                <code>META-INF/context.xml</code> (note this is not <code>WEB-INF</code>).
+            </p>
+            <p>
+                Putting the context information inside your application's war is the preferred
+                method because it is the easiest to manage. Tomcat will copy that file to
+                <code>$CATALINA_HOME/conf/Catalina/localhost/[webapp].xml</code> when it deploys
+                your application. This is the approach taken in this example.
+            </p>
+        </section>
+        <section name="Jackrabbit as an embedded JNDI Resources">
+            <p>
+                The Resource specification for a Model 1 deployment is relatively simple.
+            </p>
+            <source><![CDATA[
+<Context>
+    
+    <Resource name="jcr/model1Repository"
+        auth="Container"
+        type="javax.jcr.Repository"
+        factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
+        configFilePath="${catalina.home}/webapps/jackrabbit_deployment_test/META-INF/repository_model1.xml"
+        repHomeDir="${catalina.home}/shared/jackrabbit_model1" />
+
+</Context>
+]]></source>
+            <p>
+                The Resource is first given a <code>name</code>, which we will use inside the
+                webapp to access the repository. Jackrabbit uses container authorization, specified
+                in the <code>auth</code> attribute. When you access the repository, you will be
+                getting back an object that implements the <code>javax.jcr.Repository</code>
+                interface. The <code>factory</code> attribute gives the fully qualified class name
+                of the repository factory object, which creates the Repository instance you will
+                be using. You specify the location of your repository's configuration file in the
+                <code>configFilePath</code> attribute; for this example, the repository
+                configuration lives in the <code>META-INF</code> directory, alongside
+                <code>context.xml</code>. The location of the repository within the file system
+                is specified with the <code>repHomeDir</code> directory. Remember that Tomcat
+                must have full permissions on this location.
+            </p>
+            <p>
+                You must also add a resource reference to your webapp's <code>WEB-INF/web.xml</code>
+                file.
+            </p>
+            <source><![CDATA[
+<web-app>
+    ...
+    <resource-ref>
+        <description>Jackrabbit Model 1 Repository</description>
+        <res-ref-name>jcr/model1Repository</res-ref-name>
+        <res-type>javax.jcr.Repository</res-type>
+        <res-auth>Container</res-auth>
+    </resource-ref>
+    ...
+</web-app>
+]]></source>
+            <p>
+                You'll notice that many of the values here are the same as in the
+                <code>META-INF/context.xml</code>. They are also less likely to change. You can
+                change how the repository is created (the factory used or the parameters used by
+                the factory) and you won't need to change anything in your
+                <code>WEB-INF/web.xml</code> or the source code.
+            </p>
+        </section>
+        <section name="Accessing your repository">
+            <p>
+                To access your repository within the servlet, you extract it from the context
+                just like any other JNDI resource.
+            </p>
+            <source><![CDATA[
+Context initialContext = new InitialContext();
+Context environmentContext = (Context) initialContext.lookup( "java:comp/env" );
+Repository embeddedRepository =
+    (Repository) environmentContext.lookup( "jcr/model1Repository" );
+]]></source>
+            <p>
+                Note that the same string used in the <code>name</code> attribute is passed to the
+                environment context's <code>lookup()</code> method.
+            </p>
+        </section>
+        <section name="Model 1 Considerations">
+            <p>
+                The
+                <a href="http://incubator.apache.org/jackrabbit/doc/deploy/howto-model1.html">Model
+                1 documentation</a> stresses the importance of shutting down the repository when
+                your webapp is un-deployed. Unfortunately, this is currently impossible. The
+                object created by the <code>BindableRepositoryFactory</code> is an instance of
+                <code>BindableRepository</code> which is scoped to its package and therefore cannot
+                be instantiated; you cannot even cast the repository object to its type within your
+                webapp. The <code>javax.jcr.Repository</code> interface does not have a
+                <code>shutdown()</code> method. This means that, currently, there is no way for
+                a webapp to shut down a repository created using the JNDI mechanism detailed here.
+                If you directly code the creation of your repository, this is not a problem (you'll
+                create a <code>TransientRepository</code> instead of a
+                <code>BindableRepository</code>). Fortunately, one of the benefits of using the
+                JNDI mechanism to configure and access your repository is that its easy to switch
+                between an embedded (Model 1) and shared (Model 2) repository configuration.
+                Therefore, until the issue with shutting down a repository is addressed (the
+                developers are aware of it), I recommend configuring your repository as a shared
+                repository as described in the <a href="model2notes.html">Model 2 Notes</a>.
+            </p>
+        </section>
+    </body>
+</document>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model1notes.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model2notes.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model2notes.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model2notes.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model2notes.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,165 @@
+<?xml version="1.0"?>
+<!--
+   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.
+  -->
+<document>
+    <properties>
+        <title>Model 2 Deployment Notes</title>
+    </properties>
+    
+    <body>
+        <section name="Model 2 Basics">
+            <p>
+                A Model 2, or Shared, deployment allows Tomcat to manage the lifecycle of the
+                repository and makes it available to all the webapps deployed on the server. When
+                Tomcat starts, it will create the repository and initialize it if it does not
+                already exist. When the server shuts down, it will also shut down the repository.
+                To access a shared repository, you must configure it as a JNDI resource in the
+                global context.
+            </p>
+        </section>
+        <section name="Shared repository configuration">
+            <p>
+                For this webapp to work, you must add the following code to Tomcat's
+                <code>$CATALINA_HOME/conf/server.xml</code> file under the
+                <code>GlobalNamingResources</code> section.
+            </p>
+            <source><![CDATA[
+<Server ...>
+  ...
+  <GlobalNamingResources>
+    ...
+    <Resource name="jcr/model2Repository"
+        auth="Container"
+        type="javax.jcr.Repository"
+        factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
+        configFilePath="${catalina.home}/conf/repository_model2.xml"
+        repHomeDir="${catalina.home}/shared/jackrabbit_model2" />
+    ...
+  </GlobalNamingResources>
+  ...
+</Server>
+]]></source>
+            <p>
+                You can change the location of the repository's directory (the
+                <code>repHomeDir</code> attribute) as long as you ensure it is not the same
+                directory specified by any other repository in your system (embedded, shared,
+                or otherwise). Trying to share the same repository between two instances of
+                Jackrabbit will lead to corrupted data and other bad things.
+            </p>
+            <p>
+                For a more in depth discussion of the Resource attributes, see the discussion in the
+                <a href="model1notes.html#Jackrabbit_as_an_embedded_JNDI_Resources">Model 1
+                Notes</a>.
+            </p>
+            <p>
+                After creating the Resource in <code>server.xml</code>, you must add a link to
+                it in Tomcat's <code>$CATALINA_HOME/conf/context.xml</code>. While you
+                <em>could</em> put this line inside <code>server.xml</code> (a Context section
+                is allowed inside the Host tag), using <code>server.xml</code> for context
+                information is discouraged because when the information changes you must restart
+                the server. By keeping the information in a separate file, Tomcat is able to
+                simply redeploy the webapps with their new context information while still
+                running.
+            </p>
+            <source><![CDATA[
+<Context>
+  ...
+  <ResourceLink
+      glabal="sharedJCRRepository"
+      name="jcr/model2Repository"
+      type="javax.jcr.Repository" />
+  ...
+</Context>
+]]></source>
+            <p>
+                This link will give all the installed webapps access to the repository.
+                If you don't want all webapps to have access to the repository automatically,
+                you can place the <code>ResourceLink</code> tag in your webapp's private
+                <code>context.xml</code> in the same manner the Model 1 repository is
+                configured there. See the <a href="model1notes.html">Model 1 notes</a> for more
+                information on your webapp's private <code>context.xml</code> file. Note that
+                no matter the location, the value of the <code>global</code> attribute must be
+                different than the value of the <code>name</code> attribute. Also, the
+                <code>name</code> attribute must match the value of the Resource
+                <code>name</code> attribute.
+            </p>
+            <p>
+                You must also add a resource reference to your webapp's <code>WEB-INF/web.xml</code>
+                file.
+            </p>
+            <source><![CDATA[
+<web-app>
+    ...
+    <resource-env-ref>
+        <description>Jackrabbit Model 2 Repository</description>
+        <resource-env-ref-name>sharedJCRRepository</resource-env-ref-name>
+        <resource-env-ref-type>javax.jcr.Repository</resource-env-ref-type>
+    </resource-env-ref>
+    ...
+</web-app>
+]]></source>
+            <p>
+                Note that the <code>resource-env-ref-name</code> value matches the
+                <code>name</code> attribute of the ResourceLink in the Context, not the
+                <code>name</code> attribute of the Resource in the
+                <name>GlobalNamingResources</name>.
+            </p>
+        </section>
+        <section name="Accessing your repository">
+            <p>
+                To access your repository within the servlet, you extract it from the context
+                just like any other JNDI resource (and just like you would a Model 1 JNDI
+                configured repository).
+            </p>
+            <source><![CDATA[
+Context initialContext = new InitialContext();
+Context environmentContext = (Context) initialContext.lookup( "java:comp/env" );
+Repository sharedRepository =
+    (Repository) environmentContext.lookup( "sharedJCRRepository" );
+]]></source>
+            <p>
+                Note that the same string in the <code>resource-env-ref-name</code> value is
+                passed to the environment context's <code>lookup()</code> method.
+            </p>
+        </section>
+        <section name="Model 2 Considerations">
+            <p>
+                Currently, the Shared (Model 2) repository deployment seems to be the best approach
+                to using Jackrabbit and JCR in your webapp. It is more flexible than directly coding
+                the Repository creation in your code, and the shutdown process is managed by Tomcat.
+                And when the load on your server becomes too great, you can migrate to a Server
+                (Model 3) deployment somewhat more easily than you could from an Embedded
+                deployment.
+            </p>
+            <p>
+                A potential pitfall to this deployment model involves class loading. If you are
+                accessing a shared repository, you must not include the <code>jcr-1.0.jar</code>
+                or <code>jackrabbit-1.0-SNAPSHOT.jar</code> libraries in your webapp's
+                <code>WEB-INF/lib/</code> directory. Instead both of those jars, and Jackrabbit's
+                dependencies, should be placed in <code>$CATALINA_HOME/common/lib/</code> where
+                they are made available to both Tomcat and web applications. If you include the
+                jars in your webapp, you will cause a <code>ClassCastException</code> to be thrown
+                when you try to cast the <code>Object</code> returned by the <code>lookup()</code>
+                method to a <code>Repository</code>. This will happen because Tomcat created that
+                object using the <code>javax/jcr/Repository.class</code> contained in
+                <code>$CATALINA_HOME/common/lib/jcr-1.0.jar</code> and your webapp is trying to
+                cast it to the <code>javax/jcr/Repository.class</code> in
+                <code>WEB-INF/lib/jcr-1.0.jar</code>.
+            </p>
+        </section>
+    </body>
+</document>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/model2notes.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/navigation.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/navigation.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/navigation.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/navigation.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,31 @@
+<!--
+   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.
+  -->
+
+<project name="Jackrabbit Deployment Test">
+ <title>Jackrabbit Deployment Test</title>
+ <body>
+    <links>
+        <item name="Jackrabbit Home" href="http://incubator.apache.org/jackrabbit/" />
+        <item name="Jackrabbit Wiki" href="http://wiki.apache.org/jackrabbit/" />
+    </links>
+    <menu name="Jackrabbit Deployment Test">
+        <item name="Home"                           href="/index.html" />
+        <item name="Model 1 Notes"                  href="/model1notes.html" />
+        <item name="Model 2 Notes"                  href="/model2notes.html" />
+    </menu>
+  </body>
+</project>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/site/xdoc/navigation.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/context.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/context.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/context.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,10 @@
+<Context>
+    
+    <Resource name="jcr/model1Repository"
+        auth="Container"
+        type="javax.jcr.Repository"
+        factory="org.apache.jackrabbit.core.jndi.BindableRepositoryFactory"
+        configFilePath="${catalina.home}/webapps/jackrabbit_deployment_test/META-INF/repository_model1.xml"
+        repHomeDir="${catalina.home}/shared/jackrabbit_model1" />
+
+</Context>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/repository_model1.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/repository_model1.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/repository_model1.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/repository_model1.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<Repository>
+
+    <!-- Virtual file system where the repository stores global state -->
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+    
+    
+    <!-- Security configuration -->
+    <Security appName="Jackrabbit">
+        <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager">
+        
+        </AccessManager>
+        
+        <LoginModule class="org.apache.jackrabbit.core.security.SimpleLoginModule">
+        
+        </LoginModule>
+    </Security>
+    
+    
+    <!-- Location of workspaces root directory and the name of the default worksapce -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" />
+    
+    
+    <!-- Workspace configuration template. This is used to create the initial workspace. -->
+    <Workspace name="${wsp.name}">
+    
+        <!-- Virtual file system for the workspace -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        
+        
+        <!-- Persistence Manager for the workspace -->
+        <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+        
+        
+        <!-- Search index and its file system -->
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+            <param name="useCompoundFile" value="true"/>
+            <param name="minMergeDocs" value="100"/>
+            <param name="volatileIdleTime" value="3"/>
+            <param name="maxMergeDocs" value="100000"/>
+            <param name="mergeFactor" value="10"/>
+            <param name="bufferSize" value="10"/>
+            <param name="cacheSize" value="1000"/>
+            <param name="forceConsistencyCheck" value="false"/>
+            <param name="autoRepair" value="true"/>
+            <param name="analyzer" value="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
+            <param name="queryClass" value="org.apache.jackrabbit.core.query.QueryImpl"/>
+            <param name="idleTime" value="-1"/>
+            <param name="respectDocumentOrder" value="true"/>
+        </SearchIndex>
+        
+    </Workspace>
+    
+    
+    <!-- Versioning configuration -->
+    <Versioning rootPath="${rep.home}/version">
+    
+        <!-- Virtual file system for versioning -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+        
+        <!-- Persistence Manager for versioning -->
+        <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager" />
+    </Versioning>
+    
+    <!-- Repository wide search index -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index" />
+    </SearchIndex>
+</Repository>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/webapp/META-INF/repository_model1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/webapp/WEB-INF/web.xml?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/webapp/WEB-INF/web.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/webapp/WEB-INF/web.xml Sun Mar 19 14:17:49 2006
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
+    'http://java.sun.com/dtd/web-app_2_3.dtd'>
+
+<web-app>
+    <display-name>Jackrabbit Deployment Test App</display-name>
+    
+    <servlet>
+        <servlet-name>JackrabbitTest</servlet-name>
+        <servlet-class>org.apache.jackrabbit.deployment_test.JackrabbitTest</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    
+    <!-- Although all content from the server will be dynamic, since we're running in a web
+         container, we can pretend that it's static web pages. Therefore, we will use .html as our
+         default extension for all request "pages" in the application. -->
+    <servlet-mapping>
+        <servlet-name>JackrabbitTest</servlet-name>
+        <url-pattern>*.do</url-pattern>
+    </servlet-mapping>
+    
+    <welcome-file-list>
+        <!-- Use the .htm extension because .html is mapped to the Whisper servlet -->
+        <welcome-file>index.html</welcome-file>
+    </welcome-file-list>
+    
+    <resource-ref>
+        <description>Jackrabbit Model 1 Repository</description>
+        <res-ref-name>jcr/model1Repository</res-ref-name>
+        <res-type>javax.jcr.Repository</res-type>
+        <res-auth>Container</res-auth>
+    </resource-ref>
+    
+    <resource-env-ref>
+        <description>Jackrabbit Model 2 Repository</description>
+        <resource-env-ref-name>sharedJCRRepository</resource-env-ref-name>
+        <resource-env-ref-type>javax.jcr.Repository</resource-env-ref-type>
+    </resource-env-ref>
+    
+</web-app>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/webapp/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/webapp/index.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/webapp/index.html?rev=387045&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/webapp/index.html (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/webapp/index.html Sun Mar 19 14:17:49 2006
@@ -0,0 +1,8 @@
+<html>
+<head>
+<title>Jackrabbit Configuration Testing</title>
+</head>
+<body>
+<a href="test.do">Test the configuration</a>
+</body>
+</html>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/webapp/index.html
------------------------------------------------------------------------------
    svn:eol-style = native