org.glassfish.examples.http
Class RequestContext

java.lang.Object
  extended by org.glassfish.examples.http.RequestContext
All Implemented Interfaces:
Context<RequestScope>

@Singleton
public class RequestContext
extends Object
implements Context<RequestScope>

This is the request scope context. It houses all request scope objects. This is a proxiable scope, so care must be taken that all objects from this scope are proxiable

Author:
jwells

Constructor Summary
RequestContext()
           
 
Method Summary
 boolean containsKey(ActiveDescriptor<?> descriptor)
          Determines if this context has a value for the given key
<U> U
findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
          Creates a contextual instance of this ActiveDescriptor by calling its create method if there is no other matching contextual instance.
 Class<? extends Annotation> getScope()
          The scope for which this is the context
 boolean isActive()
          True if this context is active, false otherwise
 void shutdown()
          Shut down this context.
 void startRequest()
          Starts a request
 void stopRequest()
          Stops a request (including properly disposing all the previous request objects)
 boolean supportsNullCreation()
          Returns true if the findOrCreate method can return null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestContext

public RequestContext()
Method Detail

startRequest

public void startRequest()
Starts a request


stopRequest

public void stopRequest()
Stops a request (including properly disposing all the previous request objects)


getScope

public Class<? extends Annotation> getScope()
Description copied from interface: Context
The scope for which this is the context

Specified by:
getScope in interface Context<RequestScope>
Returns:
may not return null, must return the scope for which this is a context

findOrCreate

public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor,
                          ServiceHandle<?> root)
Description copied from interface: Context
Creates a contextual instance of this ActiveDescriptor by calling its create method if there is no other matching contextual instance. If there is already a contextual instance it is returned. If parent is null then this must work like the find call

Specified by:
findOrCreate in interface Context<RequestScope>
Parameters:
activeDescriptor - The descriptor to use when creating instances
root - The extended provider for the outermost parent being created
Returns:
A context instance. This value may NOT be null

containsKey

public boolean containsKey(ActiveDescriptor<?> descriptor)
Description copied from interface: Context
Determines if this context has a value for the given key

Specified by:
containsKey in interface Context<RequestScope>
Parameters:
descriptor - The descriptor to look for in this context
Returns:
true if this context has a value associated with this descriptor

isActive

public boolean isActive()
Description copied from interface: Context
True if this context is active, false otherwise

Specified by:
isActive in interface Context<RequestScope>
Returns:
true if this context is active, false otherwise

supportsNullCreation

public boolean supportsNullCreation()
Description copied from interface: Context
Returns true if the findOrCreate method can return null

Specified by:
supportsNullCreation in interface Context<RequestScope>
Returns:
true if null is a legal value from the findOrCreate method

shutdown

public void shutdown()
Description copied from interface: Context
Shut down this context.

Specified by:
shutdown in interface Context<RequestScope>


Copyright © 2013 Oracle Corporation. All Rights Reserved.