Package org.apache.juneau
Class Context
java.lang.Object
org.apache.juneau.Context
- Direct Known Subclasses:
BeanContext,BeanContextable,Config,ConfigStore,RestContext,RestOpContext
Base class for all Context beans.
Context beans follow the convention of havinTg the following parts:
- A
Context.Builderclass for configuring the context bean.- This bean is non-thread-safe and meant for one-time use.
- A
Context(Builder)constructor that takes in a builder object.- This bean is thread-safe and cacheable/reusable.
- A
ContextSessionclass for doing work.- This bean is non-thread-safe and meant for one-time use.
Notes:
- This class is thread safe and reusable.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Predicate<AnnotationInfo<?>>Predicate for annotations that themselves are annotated withContextApply. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCopy constructor.protectedContext(Context.Builder builder) Constructor for this class. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static Context.BuildercreateBuilder(Class<? extends Context> type) Instantiates a builder of the specified context class.Create a session builder based on the properties defined on this context.Returns the annotation provider for this context.Returns a session to use for this context.protected voidinit(Context.Builder builder) Perform optional initialization on builder before it is used.booleanisDebug()Debug mode.Returns the properties on this bean as a map for debugging.toString()
-
Field Details
-
CONTEXT_APPLY_FILTER
Predicate for annotations that themselves are annotated withContextApply.
-
-
Constructor Details
-
Context
Constructor for this class.- Parameters:
builder- The builder for this class.
Cannot benull .
-
Context
Copy constructor.- Parameters:
copyFrom- The context to copy from.
-
-
Method Details
-
createBuilder
Instantiates a builder of the specified context class.Looks for a public static method called
create that returns an object that can be passed into a public or protected constructor of the class.- Parameters:
type- The builder to create.- Returns:
- A new builder.
-
copy
Creates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
- Returns:
- A new Builder object.
-
createSession
Create a session builder based on the properties defined on this context.Use this method for creating sessions where you want to override basic settings. Otherwise, use
getSession()directly.- Returns:
- A new session builder.
-
getAnnotationProvider
Returns the annotation provider for this context.- Returns:
- The annotation provider for this context.
-
getSession
Returns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session.
- Returns:
- A new session object.
-
isDebug
Debug mode.- Returns:
true if debug mode is enabled.- See Also:
-
toString
-
init
Perform optional initialization on builder before it is used.Default behavior is a no-op.
- Parameters:
builder- The builder to initialize.
-
properties
Returns the properties on this bean as a map for debugging.- Returns:
- The properties on this bean as a map for debugging.
-