cmlenz 02/04/20 08:27:15
Modified: src/share/org/apache/slide/content Tag: SLIDE_1_0
ContentImpl.java ContentInterceptor.java
Log:
- Make ContentInterceptor an interface
- Let the ContentInterceptor preXXX()/postXXX() methods throw various
Slide-specific exceptions
- Declare those exceptions also in ContentImpl.invokeInterceptors()
- Add/extend Javadoc comments for ContentInterceptor
- Based on patches by Jean-Philippe Courson <corson at noos.fr>
Revision Changes Path
No revision
No revision
1.29.2.2 +8 -5
jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java
Index: ContentImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v
retrieving revision 1.29.2.1
retrieving revision 1.29.2.2
diff -u -r1.29.2.1 -r1.29.2.2
--- ContentImpl.java 28 Mar 2002 06:41:31 -0000 1.29.2.1
+++ ContentImpl.java 20 Apr 2002 15:27:15 -0000 1.29.2.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v 1.29.2.1
2002/03/28 06:41:31 jericho Exp $
- * $Revision: 1.29.2.1 $
- * $Date: 2002/03/28 06:41:31 $
+ * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentImpl.java,v 1.29.2.2
2002/04/20 15:27:15 cmlenz Exp $
+ * $Revision: 1.29.2.2 $
+ * $Date: 2002/04/20 15:27:15 $
*
* ====================================================================
*
@@ -77,7 +77,7 @@
* Implementation of the content interface.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
- * @version $Revision: 1.29.2.1 $
+ * @version $Revision: 1.29.2.2 $
*/
public final class ContentImpl implements Content {
@@ -1187,7 +1187,10 @@
protected void invokeInterceptors
(SlideToken token, NodeRevisionDescriptors revisionDescriptors,
NodeRevisionDescriptor revisionDescriptor,
- NodeRevisionContent revisionContent, int type) {
+ NodeRevisionContent revisionContent, int type)
+ throws AccessDeniedException, ObjectNotFoundException,
+ LinkedObjectNotFoundException, ObjectLockedException,
+ ServiceAccessException {
ContentInterceptor[] contentInterceptors =
namespace.getContentInterceptors();
for (int i = 0; i < contentInterceptors.length; i++) {
1.3.2.2 +155 -22
jakarta-slide/src/share/org/apache/slide/content/ContentInterceptor.java
Index: ContentInterceptor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentInterceptor.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- ContentInterceptor.java 28 Mar 2002 06:41:31 -0000 1.3.2.1
+++ ContentInterceptor.java 20 Apr 2002 15:27:15 -0000 1.3.2.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentInterceptor.java,v
1.3.2.1 2002/03/28 06:41:31 jericho Exp $
- * $Revision: 1.3.2.1 $
- * $Date: 2002/03/28 06:41:31 $
+ * $Header:
/home/cvs/jakarta-slide/src/share/org/apache/slide/content/ContentInterceptor.java,v
1.3.2.2 2002/04/20 15:27:15 cmlenz Exp $
+ * $Revision: 1.3.2.2 $
+ * $Date: 2002/04/20 15:27:15 $
*
* ====================================================================
*
@@ -64,50 +64,183 @@
package org.apache.slide.content;
import java.util.Hashtable;
+import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.SlideToken;
+import org.apache.slide.common.ServiceAccessException;
+import org.apache.slide.lock.ObjectLockedException;
+import org.apache.slide.security.AccessDeniedException;
+import org.apache.slide.structure.LinkedObjectNotFoundException;
+import org.apache.slide.structure.ObjectNotFoundException;
/**
- * Slide content interceptor class.
+ * An interface that allows custom components to observe and intercept
+ * storage, retrieval and removal of content.
+ *
+ * <p>
+ * Multiple <code>ContentInterceptors</code> can be associated with a single
+ * <code>Namespace</code>. They are typically configured in the
+ * <code><configuration></code> section of the domain configuration
+ * file like this:
+ * </p>
+ * <p><code>
+ * <content-interceptor class="com.acme.MyContentInterceptor">
+ * <br>
+ * <parameter name="myParam1">someValue</parameter>
+ * <br>
+ * <parameter name="myParam2">anotherValue</parameter>
+ * <br>
+ * </content-interceptor>
+ * </code></p>
+ * <p>
+ * As you can see, <code>ContentInterceptors</code> can be configured with
+ * parameters. This is optional, and exactly which parameters are available
+ * depends on the specific <code>ContentInterceptor</code> implementation.
+ * </p>
+ * <p>
+ * <code>ContentInterceptor</code> implementations must provide a public
+ * constructor without arguments, so that instances of the class can be
+ * instantiated at startup. In addition, implementors should pay attention
+ * to this minimal lifecycle definition:
+ * <ul>
+ * <li>When the namespace is being configured, <code>setParameters</code>
+ * will be called with a <code>java.util.Hashtable</code> containing the
+ * parameter names and values as specified in the configuration.</li>
+ * <li>When configuration is completed, <code>setNamespace</code> will be
+ * called, passing in a <code>NamespaceAccessToken</code> than can later
+ * be used by the <code>ContentInterceptor</code> to perform its deeds
+ * (like logging to the namespace logger).</li>
+ * <li>After that, any of the <code>preXXX</code> and <code>postXXX</code>
+ * methods will be called as soon as the associated event occurs.</li>
+ * </ul>
+ * </p>
+ * <p>
+ * The signatures of the <code>preXXX</code> and <code>postXXX</code> specify
+ * a wide range of exceptions that can be thrown. If such an exception is
+ * thrown it will be propagated up to the the API client. In the case of the
+ * <code>preXXX</code> the started operation will be terminated. So be sure
+ * to handle all exceptions that shouldn't be propagated back into the core
+ * core API - and thus possibly influence success of the operation -
+ * yourself.
+ * </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
+ * @author Jean-Philippe Courson
*/
-public class ContentInterceptor {
+public interface ContentInterceptor {
// ---------------------------------------------------------------- Methods
/**
- * That method will be called just before storing content.
+ * This method will be called just before the content of a node is stored.
+ *
+ * @param token the SlideToken
+ * @param revisionDescriptors revision tree of the content to be stored
+ * @param revisionDescriptor revision descriptor of the content to be
+ * stored
+ * @param revisionContent the actual content to be stored
+ * @throws AccessDeniedException if access to a resource has
+ * been denied
+ * @throws ObjectNotFoundException if an object could not be found
+ * @throws LinkedObjectNotFoundException if an object linked to by
+ * another object could not be
+ * found
+ * @throws ObjectLockedException if an object is locked
+ * @throws ServiceAccessException low-level service failure
*/
- public void preStoreContent(SlideToken token,
- NodeRevisionDescriptors revisionDescriptors,
- NodeRevisionDescriptor revisionDescriptor,
- NodeRevisionContent revisionContent) {
- }
+ public void preStoreContent
+ (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
+ NodeRevisionDescriptor revisionDescriptor,
+ NodeRevisionContent revisionContent)
+ throws AccessDeniedException, ObjectNotFoundException,
+ LinkedObjectNotFoundException, ObjectLockedException,
+ ServiceAccessException;
/**
- * That method will be called just after storing content.
+ * This method will be called just after the content of a node was stored.
+ *
+ * @param token the SlideToken
+ * @param revisionDescriptors revision tree of the content that has been
+ * stored
+ * @param revisionDescriptor revision descriptor of the content that
+ * has been stored
+ * @param revisionContent the actual content that has been stored
+ * @throws AccessDeniedException if access to a resource has
+ * been denied
+ * @throws ObjectNotFoundException if an object could not be found
+ * @throws LinkedObjectNotFoundException if an object linked to by
+ * another object could not be
+ * found
+ * @throws ObjectLockedException if an object is locked
+ * @throws ServiceAccessException low-level service failure
*/
- public void postStoreContent(SlideToken token,
- NodeRevisionDescriptors revisionDescriptors,
- NodeRevisionDescriptor revisionDescriptor,
- NodeRevisionContent revisionContent) {
- }
+ public void postStoreContent
+ (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
+ NodeRevisionDescriptor revisionDescriptor,
+ NodeRevisionContent revisionContent)
+ throws AccessDeniedException, ObjectNotFoundException,
+ LinkedObjectNotFoundException, ObjectLockedException,
+ ServiceAccessException;
/**
- * That method will be called just after retrieving content.
+ * This method will be called just after retrieving content, or the
+ * descriptor of a particular revision.
*
- * @param revisionContent null when the descriptor is retrieved
- * @param revisionDescriptors null when the content is retrieved
+ * @param token the SlideToken
+ * @param revisionDescriptors revision tree of the descriptor that has
+ * been retrieved, or <code>null</code> when
+ * the content has been retrieved
+ * @param revisionDescriptor revision descriptor of the content that has
+ * been retrieved, or the descriptor itself
+ * has been retrieved
+ * @param revisionContent the actual content that has been retrieved,
+ * or <code>null</code> when the descriptor
+ * has been retrieved
+ * @throws AccessDeniedException if access to a resource has
+ * been denied
+ * @throws ObjectNotFoundException if an object could not be found
+ * @throws LinkedObjectNotFoundException if an object linked to by
+ * another object could not be
+ * found
+ * @throws ObjectLockedException if an object is locked
+ * @throws ServiceAccessException low-level service failure
*/
public void postRetrieveContent
(SlideToken token, NodeRevisionDescriptors revisionDescriptors,
NodeRevisionDescriptor revisionDescriptor,
- NodeRevisionContent revisionContent) {
- }
+ NodeRevisionContent revisionContent)
+ throws AccessDeniedException, ObjectNotFoundException,
+ LinkedObjectNotFoundException, ObjectLockedException,
+ ServiceAccessException;
+
+
+ /**
+ * The <code>setNamespace</code> method will be called during
+ * initialization of the ContextInterceptor.
+ *
+ * @param nat the access token to the namespace this ContentInterceptor
+ * has been associated with
+ */
+ public void setNamespace
+ (NamespaceAccessToken nat);
+
+
+ /**
+ * This method is called during initialization of the ContentInterceptor
+ * to allow parameterization from the configuration. If no parameters have
+ * been specified, the Hashtable will be empty
+ *
+ * @param parameters Hashtable containing the parameters' names as keys
+ * and the associated parameter values as values,
+ * both of type <code>java.lang.String</code>
+ */
+ public void setParameters
+ (Hashtable parameters);
}
+
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>