org.picocontainer.web
Class StringFromHeader

java.lang.Object
  extended by org.picocontainer.injectors.ProviderAdapter
      extended by org.picocontainer.web.StringFromHeader
All Implemented Interfaces:
Serializable, org.picocontainer.ComponentAdapter, org.picocontainer.Injector, org.picocontainer.injectors.Provider, org.picocontainer.LifecycleStrategy

public class StringFromHeader
extends org.picocontainer.injectors.ProviderAdapter
implements Serializable

Use this to make a request level component that pulls information from HTTP request header. If a header of the supplied name is not available for the current HttpServletRequest, then a NotFound exception will be thrown.

Headers with dashes:

Many standard request headers have hyphens in them, (see Wikipedia List of Headers

To handle that, this class translates all hyphens to underscores ('_'). The end result is that you can construct a class that takes the User-Agent as a constructor argument like so:

        public static class Integration {
                public Integration(String User_Agent) {
                        //Does nothing.
                }
        }  
 

See Also:
Serialized Form

Nested Class Summary
static class StringFromHeader.HeaderNotFound
           
 
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter
org.picocontainer.ComponentAdapter.NOTHING
 
Constructor Summary
StringFromHeader(String headername)
          Constructs a new String From Header
 
Method Summary
 Class getComponentImplementation()
           
 Object getComponentKey()
           
 String provide(javax.servlet.http.HttpServletRequest request)
          
 String toString()
           
 
Methods inherited from class org.picocontainer.injectors.ProviderAdapter
accept, decorateComponentInstance, dispose, findAdapterOfType, getComponentInstance, getComponentInstance, getDelegate, getDescriptor, getProvideMethod, hasLifecycle, isLazy, start, stop, useNames, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringFromHeader

public StringFromHeader(String headername)
Constructs a new String From Header

Method Detail

getComponentImplementation

public Class getComponentImplementation()
Specified by:
getComponentImplementation in interface org.picocontainer.ComponentAdapter
Overrides:
getComponentImplementation in class org.picocontainer.injectors.ProviderAdapter

getComponentKey

public Object getComponentKey()
Specified by:
getComponentKey in interface org.picocontainer.ComponentAdapter
Overrides:
getComponentKey in class org.picocontainer.injectors.ProviderAdapter

provide

public String provide(javax.servlet.http.HttpServletRequest request)

Provides the header as specified by the header name.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010. All Rights Reserved.