{title:'General Design', created:'9.0.0'}
The Juneau framework uses the design pattern of builders, context, and session objects:
This is a general design pattern used throughout the framework including the REST client and server APIs.
The following shows the general pattern for creating sessions:
|
Typically developers will not deal with session objects and will just use convenience methods on the context classes themselves that handle creation of sessions:
|
Most context objects also have static default instances that can be used in leu of creating new contexts as well:
|
Most context classes also have the ability to clone and modify existing context objects:
|
The default values of many context settings can also be set via system properties and environment variables. The javadocs on these settings will identify when this is possible.
The framework makes heavy use of caching of existing context objects with the same builder settings. This is a critical reason why Juneau achieve impressive performance. Using Java reflection to find out all information about a bean type is expensive. By caching context objects, we only need to reflect that bean type once and store that information in the context for reuse by all serializers and parsers that share the same bean context configuration settings.