com.arsdigita.cms
Class CMSExcursion

java.lang.Object
  extended bycom.arsdigita.cms.CMSExcursion

public abstract class CMSExcursion
extends Object

A CMS excursion is a way of making your code execute under an alternative environment (context). Override the excurse method to create a CMSExcursion. For example:

      CMSExcursion excursion = new CMSExcursion() {
              public void excurse() {
                  // Set up specific context variables.
                  setContentItem(ItemDispatcher.getContentItem());

                  // Execute code in new context.

              }};

      excursion.run();
 

Author:
Daniel Berrange
See Also:
CMS, KernelExcursion

Field Summary
static String versionId
           
 
Constructor Summary
CMSExcursion()
           
 
Method Summary
protected abstract  void excurse()
          When this method is called the current CMSContext is copied and the code inside the excurse() method is given the opportunity to modify the new context.
 void run()
          Begins execution of the excursion.
protected  void setContentItem(ContentItem item)
          Sets the current content item.
protected  void setContentSection(ContentSection section)
          Sets the current content section.
protected  void setSecurityManager(SecurityManager security)
          Sets the current security manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

CMSExcursion

public CMSExcursion()
Method Detail

run

public final void run()
               throws javax.servlet.ServletException,
                      IOException
Begins execution of the excursion. This locks the pending context, sets it to be the current context and invokes the excuse method. The original context is restored upon termination of the excurse method

Throws:
javax.servlet.ServletException
IOException

excurse

protected abstract void excurse()
                         throws javax.servlet.ServletException,
                                IOException

When this method is called the current CMSContext is copied and the code inside the excurse() method is given the opportunity to modify the new context. Any code then called from within the excurse() method is executed in this new context. After the excurse() method completes the old context is restored exactly as it was before. This makes it unnecessary to write error prone code like this:

   ContentItem oldItem = context.getContentItem();
   context.setContentItem(newItem);
   ...
   // do something
   ...
   context.setCOntentItem(oldItem); // If this is forgotten, bad
                               // things can happen.
 

Throws:
javax.servlet.ServletException
IOException

setContentSection

protected final void setContentSection(ContentSection section)
Sets the current content section.

Parameters:
section - the new content section

setContentItem

protected final void setContentItem(ContentItem item)
Sets the current content item.

Parameters:
item - the new content item

setSecurityManager

protected final void setSecurityManager(SecurityManager security)
Sets the current security manager.

Parameters:
security - the new SecurityManager


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 19 2004:2352 UTC