org.apache.myfaces.orchestra.frameworkAdapter.local
Class LocalFrameworkAdapter

java.lang.Object
  extended by org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter
      extended by org.apache.myfaces.orchestra.frameworkAdapter.local.LocalFrameworkAdapter
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware

public class LocalFrameworkAdapter
extends FrameworkAdapter
implements org.springframework.context.ApplicationContextAware

A FrameworkAdapter which uses local maps to simulate a servlet environment.

This is intended when Orchestra functionality is desired outside of any real request/response type system. One example is where a job scheduler (eg quartz) is used to execute background threads that want to execute the same beans that can also be used. In this case:

  1. Create a new Thread object
  2. Create a new LocalFrameworkAdapter instance
  3. Within the new thread, call FrameworkAdapter.setInstance.
When Orchestra methods are invoked from within the new thread, calls made to the framework adapter will be handled by the created LocalFrameworkAdapter instance, and will not interact with the user session, the original request or response. Because the session is new, no conversations will be inherited from the environment in which that new thread was created.

This class is not expected to be used very often.

Note that this adapter relies on Spring and thus you have to ensure setApplicationContext(org.springframework.context.ApplicationContext) is called.

Note also that because this is intended for use only without a real request and response, there is no corresponding Filter class.

This class does not override the inherited createConversationMessager method, so it is mandatory for anyone using this class to explicitly call method setConversationMessager before using an instance of this adapter.


Constructor Summary
LocalFrameworkAdapter()
           
 
Method Summary
 void clearRequestMap()
           
 boolean containsRequestAttribute(String key)
           
 boolean containsRequestParameterAttribute(String key)
           
 boolean containsSessionAttribute(String key)
           
protected  org.springframework.context.ConfigurableApplicationContext getApplicationContext()
           
 Object getBean(String name)
          Return the variable with the specified name, or null if no such bean exists.
 String getInitParameter(String key)
          Return the global init parameter with the specified name.
 Object getRequestAttribute(String key)
          Get a request-scope variable.
 Object getRequestParameterAttribute(String key)
          Get a value from the set of input parameters sent by the user as part of the request.
 Object getSessionAttribute(String key)
          Get a variable from the session-scope of the current user.
 void invokeNavigation(String navigationName)
          Navigate to the specified logical destination.
 void redirect(String url)
          Instruct the remote browser to fetch the specified URL.
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 void setApplicationContext(org.springframework.context.ConfigurableApplicationContext configurableApplicationContext)
           
 void setRequestAttribute(String key, Object value)
           
 void setRequestParameterAttribute(String key, Object value)
           
 void setSessionAttribute(String key, Object value)
           
 
Methods inherited from class org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter
createConversationMessager, getConversationMessager, getCurrentInstance, getCurrentViewId, prepare, setConversationMessager, setCurrentInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalFrameworkAdapter

public LocalFrameworkAdapter()
Method Detail

getInitParameter

public String getInitParameter(String key)
Description copied from class: FrameworkAdapter
Return the global init parameter with the specified name. In most cases this is expected to return data from the ServletContext.

Specified by:
getInitParameter in class FrameworkAdapter

getRequestParameterAttribute

public Object getRequestParameterAttribute(String key)
Description copied from class: FrameworkAdapter
Get a value from the set of input parameters sent by the user as part of the request.

Specified by:
getRequestParameterAttribute in class FrameworkAdapter

containsRequestParameterAttribute

public boolean containsRequestParameterAttribute(String key)
Specified by:
containsRequestParameterAttribute in class FrameworkAdapter

setRequestParameterAttribute

public void setRequestParameterAttribute(String key,
                                         Object value)

getRequestAttribute

public Object getRequestAttribute(String key)
Description copied from class: FrameworkAdapter
Get a request-scope variable.

Specified by:
getRequestAttribute in class FrameworkAdapter

setRequestAttribute

public void setRequestAttribute(String key,
                                Object value)
Specified by:
setRequestAttribute in class FrameworkAdapter

clearRequestMap

public void clearRequestMap()

containsRequestAttribute

public boolean containsRequestAttribute(String key)
Specified by:
containsRequestAttribute in class FrameworkAdapter

getSessionAttribute

public Object getSessionAttribute(String key)
Description copied from class: FrameworkAdapter
Get a variable from the session-scope of the current user.

Specified by:
getSessionAttribute in class FrameworkAdapter

setSessionAttribute

public void setSessionAttribute(String key,
                                Object value)
Specified by:
setSessionAttribute in class FrameworkAdapter

containsSessionAttribute

public boolean containsSessionAttribute(String key)
Specified by:
containsSessionAttribute in class FrameworkAdapter

getApplicationContext

protected org.springframework.context.ConfigurableApplicationContext getApplicationContext()

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

setApplicationContext

public void setApplicationContext(org.springframework.context.ConfigurableApplicationContext configurableApplicationContext)

redirect

public void redirect(String url)
              throws IOException
Description copied from class: FrameworkAdapter
Instruct the remote browser to fetch the specified URL.

Specified by:
redirect in class FrameworkAdapter
Throws:
IOException

getBean

public Object getBean(String name)
Description copied from class: FrameworkAdapter
Return the variable with the specified name, or null if no such bean exists.

In frameworks that support "managed beans", ie creation of objects on demand then this may trigger the creation of the specified object. In frameworks that do not support this, then the lookup may just return null if no object with the specified name currently exists.

Note that no "property traversal" is required or expected; a name of "a.b.c" is NOT evaluated as "property c of property b of bean a", but as the bean with name 'a.b.c'.

Specified by:
getBean in class FrameworkAdapter

invokeNavigation

public void invokeNavigation(String navigationName)
Description copied from class: FrameworkAdapter
Navigate to the specified logical destination.

For frameworks that have a built-in navigation system, that system should be invoked.

For frameworks with no logical navigation system, the navigationName is treated as a plain URL. Whether a FORWARD or a REDIRECT to this URL is perfomed is determined by the subclass.

Specified by:
invokeNavigation in class FrameworkAdapter


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.