org.apache.cocoon.environment.internal
Class EnvironmentHelper

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.environment.internal.EnvironmentHelper
All Implemented Interfaces:
Disposable, Serviceable, SourceResolver, org.apache.cocoon.environment.SourceResolver

public class EnvironmentHelper
extends org.apache.cocoon.util.AbstractLogEnabled
implements org.apache.cocoon.environment.SourceResolver, Serviceable, Disposable

Helper class for maintaining the environment stack. This is an internal class, and it might change in an incompatible way over time. For developing your own components/applications based on Cocoon, you shouldn't really need it. INTERNAL CLASS. Do not use this, can be removed without warning or deprecation cycle.

Since:
2.2
Version:
$Id: EnvironmentHelper.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Nested Class Summary
static class EnvironmentHelper.AbstractCocoonRunnable
          A runnable wrapper that inherits the environment stack of the thread it is created in.
 
Field Summary
protected  String context
          The Context path
protected static ThreadLocal environmentStack
          The environment information
protected  String lastPrefix
          The last prefix, which is stripped off from the request uri
protected  ServiceManager manager
          The service manager
protected  String prefix
          The complete prefix
protected  SourceResolver resolver
          The real source resolver
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Constructor Summary
EnvironmentHelper(EnvironmentHelper parent)
          Constructor
EnvironmentHelper(URL context)
          Constructor
 
Method Summary
 void changeContext(org.apache.cocoon.environment.Environment env)
          Change the context of the environment.
 void changeContext(Source newSource, String newPrefix)
          Adds an prefix to the overall stripped off prefix from the request uri
static void checkEnvironment(int depth)
          INTERNAL METHOD.
static org.apache.cocoon.xml.XMLConsumer createEnvironmentAwareConsumer(org.apache.cocoon.xml.XMLConsumer consumer)
          Create an environment aware xml consumer for the cocoon protocol.
static org.apache.cocoon.xml.XMLConsumer createPopEnvironmentConsumer(org.apache.cocoon.xml.XMLConsumer consumer)
          Create an environment aware xml consumer that pop and save the current environment before calling the consumer.
static org.apache.cocoon.xml.XMLConsumer createPushEnvironmentConsumer(org.apache.cocoon.xml.XMLConsumer consumer, org.apache.cocoon.environment.Environment environment)
          Create an environment aware xml consumer that push an environment before calling the consumer.
 void dispose()
           
static void enterEnvironment(org.apache.cocoon.environment.Environment env)
          This method is used for entering a new environment.
static void enterProcessor(org.apache.cocoon.Processor processor, org.apache.cocoon.environment.Environment env)
          This hook must be called by the sitemap each time a sitemap is entered.
 String getContext()
          Return the current context URI
static org.apache.cocoon.environment.Environment getCurrentEnvironment()
          Return the environment.
static org.apache.cocoon.Processor getCurrentProcessor()
          Return the current processor INTERNAL METHOD.
 String getPrefix()
          Return the prefix
static ServiceManager getSitemapServiceManager()
          Get the current sitemap component manager.
static org.apache.cocoon.environment.Environment leaveEnvironment()
          This method is used for leaving the current environment.
static void leaveProcessor()
          This hook must be called by the sitemap each time a sitemap is left.
static int markEnvironment()
          INTERNAL METHOD.
 void release(Source source)
           
 Source resolveURI(String location)
           
 Source resolveURI(String location, String baseURI, Map parameters)
           
 void service(ServiceManager avalonManager)
           
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

environmentStack

protected static final ThreadLocal environmentStack
The environment information


resolver

protected SourceResolver resolver
The real source resolver


manager

protected ServiceManager manager
The service manager


prefix

protected String prefix
The complete prefix


context

protected String context
The Context path


lastPrefix

protected String lastPrefix
The last prefix, which is stripped off from the request uri

Constructor Detail

EnvironmentHelper

public EnvironmentHelper(URL context)
Constructor


EnvironmentHelper

public EnvironmentHelper(EnvironmentHelper parent)
Constructor

Method Detail

service

public void service(ServiceManager avalonManager)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

dispose

public void dispose()
Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()

release

public void release(Source source)
Specified by:
release in interface SourceResolver
See Also:
SourceResolver.release(org.apache.excalibur.source.Source)

resolveURI

public Source resolveURI(String location,
                         String baseURI,
                         Map parameters)
                  throws IOException
Specified by:
resolveURI in interface SourceResolver
Throws:
IOException
See Also:
SourceResolver.resolveURI(java.lang.String, java.lang.String, java.util.Map)

resolveURI

public Source resolveURI(String location)
                  throws IOException
Specified by:
resolveURI in interface SourceResolver
Throws:
IOException
See Also:
SourceResolver.resolveURI(java.lang.String)

getContext

public String getContext()
Return the current context URI


getPrefix

public String getPrefix()
Return the prefix


changeContext

public void changeContext(org.apache.cocoon.environment.Environment env)
                   throws org.apache.cocoon.ProcessingException
Change the context of the environment.

Parameters:
env - The environment to change
Throws:
org.apache.cocoon.ProcessingException

changeContext

public void changeContext(Source newSource,
                          String newPrefix)
                   throws IOException
Adds an prefix to the overall stripped off prefix from the request uri

Throws:
IOException

enterProcessor

public static void enterProcessor(org.apache.cocoon.Processor processor,
                                  org.apache.cocoon.environment.Environment env)
                           throws org.apache.cocoon.ProcessingException
This hook must be called by the sitemap each time a sitemap is entered.

This method should never raise an exception, except when the parameters are not set!

Throws:
org.apache.cocoon.ProcessingException - if processor is null

leaveProcessor

public static void leaveProcessor()
This hook must be called by the sitemap each time a sitemap is left.

It's the counterpart to the enterProcessor(Processor, Environment) method.


enterEnvironment

public static void enterEnvironment(org.apache.cocoon.environment.Environment env)
                             throws org.apache.cocoon.ProcessingException
This method is used for entering a new environment.

Throws:
org.apache.cocoon.ProcessingException - if there is no current processing environment

leaveEnvironment

public static org.apache.cocoon.environment.Environment leaveEnvironment()
This method is used for leaving the current environment.

It's the counterpart to the enterEnvironment(Environment) method.


markEnvironment

public static int markEnvironment()
INTERNAL METHOD. Do not use, can be removed without warning or deprecation cycle.


checkEnvironment

public static void checkEnvironment(int depth)
                             throws Exception
INTERNAL METHOD. Do not use this, can be removed without warning or deprecation cycle.

Throws:
Exception

getCurrentEnvironment

public static org.apache.cocoon.environment.Environment getCurrentEnvironment()
Return the environment. INTERNAL METHOD. Do not use this, can be removed without warning or deprecation cycle.


getCurrentProcessor

public static org.apache.cocoon.Processor getCurrentProcessor()
Return the current processor INTERNAL METHOD. Do not use this, can be removed without warning or deprecation cycle.


getSitemapServiceManager

public static ServiceManager getSitemapServiceManager()
Get the current sitemap component manager. This method return the current sitemap component manager. This is the manager that holds all the components of the currently processed (sub)sitemap. INTERNAL METHOD. Do not use this, can be removed without warning or deprecation cycle.


createEnvironmentAwareConsumer

public static org.apache.cocoon.xml.XMLConsumer createEnvironmentAwareConsumer(org.apache.cocoon.xml.XMLConsumer consumer)
Create an environment aware xml consumer for the cocoon protocol. INTERNAL METHOD. Do not use this, can be removed without warning or deprecation cycle.


createPushEnvironmentConsumer

public static org.apache.cocoon.xml.XMLConsumer createPushEnvironmentConsumer(org.apache.cocoon.xml.XMLConsumer consumer,
                                                                              org.apache.cocoon.environment.Environment environment)
Create an environment aware xml consumer that push an environment before calling the consumer.


createPopEnvironmentConsumer

public static org.apache.cocoon.xml.XMLConsumer createPopEnvironmentConsumer(org.apache.cocoon.xml.XMLConsumer consumer)
Create an environment aware xml consumer that pop and save the current environment before calling the consumer.



Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.