jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r611136 - in /jackrabbit/trunk/jackrabbit-webapp: ./ src/main/java/org/apache/jackrabbit/j2ee/ src/main/webapp/ src/main/webapp/WEB-INF/
Date Fri, 11 Jan 2008 10:55:36 GMT
Author: jukka
Date: Fri Jan 11 02:55:35 2008
New Revision: 611136

URL: http://svn.apache.org/viewvc?rev=611136&view=rev
Log:
JCR-1220: WebApp: Ease first access for new users looking for a WebDAV server
    - Better documentation for both webdav and other access methods
    - Use jackrabbit-jcr-servlet to simplify integration with clients

Added:
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/local.jsp
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remote.jsp
Modified:
    jackrabbit/trunk/jackrabbit-webapp/pom.xml
    jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/header.jsp
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-simple.jsp
    jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/welcome.jsp

Modified: jackrabbit/trunk/jackrabbit-webapp/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/pom.xml?rev=611136&r1=611135&r2=611136&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/pom.xml (original)
+++ jackrabbit/trunk/jackrabbit-webapp/pom.xml Fri Jan 11 02:55:35 2008
@@ -72,6 +72,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-jcr-rmi</artifactId>
     </dependency>
     <dependency>

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java?rev=611136&r1=611135&r2=611136&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
Fri Jan 11 02:55:35 2008
@@ -17,10 +17,12 @@
 package org.apache.jackrabbit.j2ee;
 
 import org.apache.jackrabbit.api.JackrabbitRepository;
+import org.apache.jackrabbit.commons.repository.RepositoryFactory;
 import org.apache.jackrabbit.core.RepositoryImpl;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitServerAdapterFactory;
 import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
+import org.apache.jackrabbit.servlet.AbstractRepositoryServlet;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.InputSource;
@@ -48,7 +50,6 @@
 import javax.naming.NamingException;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -142,7 +143,7 @@
  * a new (or existing) repository home and will copy the templates of the
  * repository.xml and bootstrap.properties to the respective location.
  */
-public class RepositoryStartupServlet extends HttpServlet {
+public class RepositoryStartupServlet extends AbstractRepositoryServlet {
 
     /**
      * the default logger
@@ -289,6 +290,25 @@
      */
     public Repository getRepository() {
         return repository;
+    }
+
+    /**
+     * Returns a repository factory that returns the repository if available
+     * or throws an exception if not.
+     *
+     * @return repository factory
+     */
+    public RepositoryFactory getRepositoryFactory() {
+        return new RepositoryFactory() {
+            public Repository getRepository() throws RepositoryException {
+                Repository r = repository;
+                if (r != null) {
+                    return repository;
+                } else {
+                    throw new RepositoryException("Repository not available");
+                }
+            }
+        };
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml?rev=611136&r1=611135&r2=611136&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml Fri Jan 11 02:55:35
2008
@@ -309,6 +309,14 @@
     </servlet>
 
     <!-- ====================================================================== -->
+    <!-- R M I   B I N D I N G   S E R V L E T                                  -->
+    <!-- ====================================================================== -->
+    <servlet>
+      <servlet-name>RMI</servlet-name>
+      <servlet-class>org.apache.jackrabbit.servlet.remote.RemoteBindingServlet</servlet-class>
+    </servlet>
+
+    <!-- ====================================================================== -->
     <!-- S E R V L E T   M A P P I N G                                          -->
     <!-- ====================================================================== -->
     <servlet-mapping>
@@ -322,6 +330,10 @@
     <servlet-mapping>
         <servlet-name>JCRWebdavServer</servlet-name>
         <url-pattern>/server/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>RMI</servlet-name>
+        <url-pattern>/rmi</url-pattern>
     </servlet-mapping>
 
     <!-- ====================================================================== -->

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/header.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/header.jsp?rev=611136&r1=611135&r2=611136&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/header.jsp (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/header.jsp Fri Jan 11 02:55:35 2008
@@ -49,6 +49,8 @@
               <li><a href="<%= request.getContextPath() %>/">Welcome</a></li>
               <li><a href="<%= request.getContextPath() %>/webdav-simple.jsp">Standard
WebDAV</a></li>
               <li><a href="<%= request.getContextPath() %>/webdav-jcr.jsp">JCR
WebDAV</a></li>
+              <li><a href="<%= request.getContextPath() %>/remote.jsp">Remote
access</a></li>
+              <li><a href="<%= request.getContextPath() %>/local.jsp">Local
access</a></li>
               <li><a href="<%= request.getContextPath() %>/troubleshooting.jsp">Troubleshooting</a></li>
             </ul>
           </li>

Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/local.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/local.jsp?rev=611136&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/local.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/local.jsp Fri Jan 11 02:55:35 2008
@@ -0,0 +1,103 @@
+<%--
+  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.
+--%><%
+request.setAttribute("title", "Local Repository Access");
+%><jsp:include page="header.jsp"/>
+<p>
+  The content repository within this web application can be accessed
+  locally by other web applications within the same servlet container.
+  Local access is much faster than <a href="remote.jsp">remote access</a>.
+</p>
+<p>
+  The content repository is made available both through JNDI and the
+  web application context.
+</p>
+
+<h3>Accessing the repository through JNDI</h3>
+<p>
+  By default the repository is only made available in a dummy JNDI directory
+  local to this web application. However, you can make the repository globally
+  available if your servlet container allows a web application to modify the
+  global JNDI directory or you are using some other JNDI directory that can
+  manage unserializable Java objects.
+</p>
+<p>
+  To bind the the repository to such a JNDI directory, you need to modify
+  the <code>java.naming</code> parameters in either the /WEB-INF/web.xml
+  deployment descriptor or the jackrabbit/bootstrap.properties file. You need
+  to redeploy this web application to activate the changes.
+</p>
+<p>
+  Use the following code to access a repository bound in a JNDI directory:
+</p>
+<pre>
+<b>import</b> javax.jcr.Repository;
+<b>import</b> javax.naming.Context;
+<b>import</b> javax.naming.InitialContext;
+
+Context context = <b>new</b> InitialContext(...);
+Repository repository = (Repository) context.lookup(...);
+</pre>
+
+<h3>Accessing the repository through servlet context</h3>
+<p>
+  This web application makes the repository available as the
+  <code>javax.jcr.Repository</code> attribute in the application context.
+  If your servlet container supports cross-context access, you can
+  access the repository directly using that attribute.
+</p>
+<p>
+  For example in <a href="http://tomcat.apache.org/">Apache Tomcat</a>
+  you can enable cross-context access by setting the <code>crossContext</code>
+  attribute to true in the &lt;Context/&gt; configuration.
+</p>
+<p>
+  Use the following code to access a repository through the servlet context:
+</p>
+<pre>
+<b>import</b> javax.jcr.Repository;
+<b>import</b> javax.servlet.ServletContext;
+
+ServletContext context = ...; // <em>context of your servlet</em>
+ServletContext jackrabbit =
+    context.getContext("<em><%= request.getContextPath() %></em>");
+Repository repository = (Repository)
+    context.getAttribute(Repository.<b>class</b>.getName()).
+</pre>
+
+<h3>Using the jackrabbit-jcr-servlet component</h3>
+<p>
+  The <em>jackrabbit-jcr-servlet</em> component contains utility classes
+  for use within JCR web applications. With that component you can hide
+  both the above and the <a href="remote.jsp">remote access</a> options
+  from your code, and use just the following to access a repository:
+</p>
+<pre>
+<b>import</b> javax.jcr.Repository;
+<b>import</b> org.apache.jackrabbit.servlet.ServletRepository;
+
+<b>public class</b> MyServlet <b>extends</b> HttpServlet {
+
+    <b>private final</b> Repository repository = <b>new</b> ServletRepository(<b>this</b>);
+
+    // ...
+
+}
+</pre>
+<p>
+  See the jackrabbit-jcr-servlet documentation for more details.
+</p>
+<jsp:include page="footer.jsp"/>

Added: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remote.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remote.jsp?rev=611136&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remote.jsp (added)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/remote.jsp Fri Jan 11 02:55:35 2008
@@ -0,0 +1,105 @@
+<%@ page import="java.net.URI"%><%--
+  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.
+--%><%
+request.setAttribute("title", "Remote Repository Access");
+
+URI uri = new URI(request.getRequestURL().toString());
+String base =
+    uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()
+    + request.getContextPath();
+%><jsp:include page="header.jsp"/>
+<p>
+  The content repository within this web application is made available
+  to remote clients through
+  <a href="http://java.sun.com/javase/technologies/core/basic/rmi/">RMI</a>
+  and the <em>jackrabbit-jcr-rmi</em> component.
+<p>
+<p>
+  The remote repository stub is available both in the RMI registry
+  (one is started automatically by this web application if not already running)
+  and as a direct HTTP download. The default URLs for accessing the remote
+  repository are:
+</p>
+<ul>
+  <li>RMI registry: //localhost/jackrabbit.repository</li>
+  <li>HTTP download: <%= base %>/rmi</li>
+</ul>
+<p>
+  Note that the above URLs are the defaults. You can disable or change them
+  by modifying the /WEB-INF/web.xml deployment descriptor.
+</p>
+
+<h3>Accessing the remote repository</h3>
+<p>
+  To access the remote content repository you need to use the
+  <em>jackrabbit-jcr-rmi</em> component in your application. If you use
+  Maven 2, you can declare the JCR and jackrabbit-jcr-rmi dependencies
+  like this:
+</p>
+<pre>&lt;dependency&gt;
+  &lt;groupId&gt;javax.jcr&lt;/groupId&gt;
+  &lt;artifactId&gt;jcr&lt;/artifactId&gt;
+  &lt;version&gt;1.0&lt;/version&gt;
+&lt;/dependency&gt;
+&lt;dependency&gt;
+  &lt;groupId&gt;org.apache.jackrabbit&lt;/groupId&gt;
+  &lt;artifactId&gt;jackrabbit-jcr-rmi&lt;/artifactId&gt;
+  &lt;version&gt;1.4&lt;/version&gt;
+&lt;/dependency&gt;
+</pre>
+<p>
+  With that dependency in place, you can use either the RMI registry or
+  the direct HTTP download to access the repository.
+</p>
+<p>
+  The required code for accessing the repository using the RMI registry is:
+</p>
+<pre>
+<b>import</b> javax.jcr.Repository;
+<b>import</b> org.apache.jackrabbit.rmi.repository.RMIRemoteRepository;
+
+Repository repository =
+    <b>new</b> RMIRemoteRepository("<em>//localhost/jackrabbit.repository</em>");
+</pre>
+<p>
+  The required code for accessing the repository using the RMI registry is:
+</p>
+<pre>
+<b>import</b> javax.jcr.Repository;
+<b>import</b> org.apache.jackrabbit.rmi.repository.URLRemoteRepository;
+
+Repository repository =
+    <b>new</b> URLRemoteRepository("<em><%= base %>/rmi</em>");
+</pre>
+<p>
+  See the <a href="http://jcp.org/en/jsr/detail?id=170">JCR specification</a>
+  and the
+  <a href="http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Repository.html">Repository</a>
+  javadoc for details on what to do with the acquired Repository instance.
+</p>
+
+<h3>Remote access performance</h3>
+<p>
+  Note that the design goal of the current jackrabbit-jcr-rmi component
+  is correct and complete functionality instead of performance, so you should
+  not rely on remote access for performance-critical applications.
+</p>
+<p>
+  You may want to look at the Jackrabbit clustering feature for best
+  performance for concurrently accessing the repository on multiple separate
+  servers.
+</p>
+<jsp:include page="footer.jsp"/>

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-simple.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-simple.jsp?rev=611136&r1=611135&r2=611136&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-simple.jsp (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/webdav-simple.jsp Fri Jan 11 02:55:35
2008
@@ -44,6 +44,11 @@
   <li><a href="<%= href %>"><%= href %></a></li>
 </ul>
 <p>
+  The server asks for authentication, but by default any username and password
+  is accepted. You can modify this security policy in the repository
+  configuration file.
+</p>
+<p>
   To access other workspace than the default one, replace the last part of
   the URL (<code>/default/</code>) with the name of another workspace.
 </p>

Modified: jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/welcome.jsp
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/welcome.jsp?rev=611136&r1=611135&r2=611136&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/welcome.jsp (original)
+++ jackrabbit/trunk/jackrabbit-webapp/src/main/webapp/welcome.jsp Fri Jan 11 02:55:35 2008
@@ -28,27 +28,29 @@
     %><jsp:forward page="bootstrap/missing.jsp"/><%
 }
 
-request.setAttribute("title", "Apache Jackrabbit WebDAV Server");
+request.setAttribute("title", "Apache Jackrabbit JCR Server");
 %><jsp:include page="header.jsp"/>
 <p>
-  Welcome to the Apache Jackrabbit WebDAV Server. This web application
-  contains a JCR content repository and makes it available to both remote
-  and local clients.
+  Welcome to the Apache Jackrabbit JCR Server. This web application
+  contains a JCR content repository and makes it available to clients
+  through WebDAV and other means.
 </p>
 <p>
-  This application proves the following two WebDAV "views" to the content
-  in the JCR content repository.
+  The following two WebDAV views are provided for accessing the
+  content in the JCR content repository.
 </p>
 <ul>
-<li><a href="webdav-simple.jsp">Standard WebDAV</a></li>
-<li><a href="webdav-jcr.jsp">JCR WebDAV</a></li>
+  <li><a href="webdav-simple.jsp">Standard WebDAV</a></li>
+  <li><a href="webdav-jcr.jsp">JCR WebDAV</a></li>
 </ul>
 <p>
-  Other web applications running in the same servlet container can access
-  the content repository through JNDI, and remote clients can use either
-  WebDAV or the standard JCR API through the <code>jackrabbit-jcr-rmi</code>
-  component for accessing content in the repository.
+  Clients can also access the repository using the JCR API. Both local
+  and remote access is supported.
 </p>
+<ul>
+  <li><a href="remote.jsp">Remote repository access</a></li>
+  <li><a href="local.jsp">Local repository access</a></li>
+</ul>
 
 <h3>About Apache Jackrabbit</h3>
 <p>



Mime
View raw message