- All Implemented Interfaces:
IEventSink
,IMetadataContext<Object,
,Application> ISessionStore.UnboundListener
- Direct Known Subclasses:
WebApplication
Application has the following interesting features / attributes:
- Name - The Application's name, which is the same as its class name.
- Home Page - The Application's home Page class. Subclasses must override getHomePage() to provide this property value.
- Settings - Application settings are partitioned into sets of related settings using interfaces in the org.apache.wicket.settings package. These interfaces are returned by the following methods, which should be used to configure framework settings for your application: getApplicationSettings(), getDebugSettings(), getExceptionSettings(), getMarkupSettings(), getPageSettings(), getRequestCycleSettings(), getSecuritySettings and getSessionSettings(). These settings are configured by default through the constructor or internalInit methods. Default the application is configured for DEVELOPMENT. You can configure this globally to DEPLOYMENT or override specific settings by implementing the init() method.
- Shared Resources - Resources added to an Application's SharedResources have
application-wide scope and can be referenced using a logical scope and a name with the
ResourceReference class. ResourceReferences can then be used by multiple components in the same
application without additional overhead (beyond the ResourceReference instance held by each
referee) and will yield a stable URL, permitting efficient browser caching of the resource (even
if the resource is dynamically generated). Resources shared in this manner may also be localized.
See
ResourceReference
for more details. - Custom Session Subclasses- In order to install your own
Session
subclass you must override ApplicationnewSession(Request, Response)
. For subclasses ofWebApplication
you will want to subclassWebSession
.
- Author:
- Jonathan Locke
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
final void
Configures application settings to good defaults.final RequestCycle
createRequestCycle
(Request request, Response response) final IHeaderResponse
decorateHeaderResponse
(IHeaderResponse response) INTERNAL METHOD - You shouldn't need to call this.static boolean
exists()
Checks if theApplication
threadlocal is set in this threadfetchCreateAndSetSession
(RequestCycle requestCycle) static Application
get()
Get Application for current thread.static Application
Gets the Application based on the application key of that application.abstract String
Gets the unique key of this application within a given context (like a web application).Gets the keys of the currently registered Wicket applications for this web application.final ApplicationSettings
abstract RuntimeConfigurationType
Gets the configuration mode to use for configuring the app, eitherRuntimeConfigurationType.DEVELOPMENT
orRuntimeConfigurationType.DEPLOYMENT
.final IConverterLocator
final DebugSettings
Returns a supplier ofIExceptionMapper
that will be used to handle exceptions which were not handled by anyrequest cycle listener
.final ExceptionSettings
final FrameworkSettings
Returns theHeaderResponseDecoratorCollection
used by this application.Application subclasses must specify a home page class by implementing this abstract method.final List<IInitializer>
final IMapperContext
final <T> T
getMetaData
(MetaDataKey<T> key) Gets metadata for this application using the given key.getMimeType
(String fileName) Returns the mime type for given filename.final String
getName()
Gets the name of this application.final IPageFactory
ReturnsIPageFactory
for this application.final IPageManagerProvider
final IPageRendererProvider
final PageSettings
final IRequestCycleProvider
final IRequestLogger
Gets theIRequestLogger
.final RequestLoggerSettings
ReturnsResourceReferenceRegistry
for this application.final ResourceSettings
final IRequestMapper
final ICompoundRequestMapper
Converts the root mapper to aICompoundRequestMapper
if necessary and returns the converted instance.final SecuritySettings
final ISessionStore
Gets the facade object for working getting/ storing session instances.final Supplier<ISessionStore>
final StoreSettings
protected void
init()
Allows for initialization of the application by a subclass.final void
Initialize the applicationvoid
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.protected void
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.void
logEventTarget
(IRequestHandler target) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.void
logResponseTarget
(IRequestHandler requestTarget) THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.protected IConverterLocator
Creates and returns a new instance ofIConverterLocator
.protected IMapperContext
Factory method forIMapperContext
implementations.protected IPageFactory
Override to create customIPageFactory
protected IRequestLogger
creates a new request logger when requests logging is enabled.protected ResourceBundles
newResourceBundles
(ResourceReferenceRegistry registry) protected ResourceReferenceRegistry
Override to create customResourceReferenceRegistry
.abstract Session
newSession
(Request request, Response response) Creates a new session.protected SharedResources
newSharedResources
(ResourceReferenceRegistry registry) protected void
Called when wicket servlet is destroyed.void
Called when an event is sent to this sinkvoid
sessionUnbound
(String sessionId) Informs the listener that session with specific id has been unbound.final Application
setApplicationSettings
(ApplicationSettings applicationSettings) final Application
setDebugSettings
(DebugSettings debugSettings) void
setExceptionMapperProvider
(Supplier<IExceptionMapper> exceptionMapperProvider) final Application
setExceptionSettings
(ExceptionSettings exceptionSettings) final Application
setFrameworkSettings
(FrameworkSettings frameworkSettings) final Application
setJavaScriptLibrarySettings
(JavaScriptLibrarySettings javaScriptLibrarySettings) final Application
setMarkupSettings
(MarkupSettings markupSettings) final <T> Application
setMetaData
(MetaDataKey<T> key, T object) Sets the metadata for this application using the given key.final void
Sets application name.final Application
setPageManagerProvider
(IPageManagerProvider provider) Set the provider of anIPageManager
.final Application
setPageRendererProvider
(IPageRendererProvider pageRendererProvider) final Application
setPageSettings
(PageSettings pageSettings) final Application
setRequestCycleProvider
(IRequestCycleProvider requestCycleProvider) final Application
setRequestCycleSettings
(RequestCycleSettings requestCycleSettings) final Application
setRequestLoggerSettings
(RequestLoggerSettings requestLoggerSettings) final Application
setResourceSettings
(ResourceSettings resourceSettings) final Application
setRootRequestMapper
(IRequestMapper rootRequestMapper) Sets the root request mapperfinal Application
setSecuritySettings
(SecuritySettings securitySettings) final Application
setSessionStoreProvider
(Supplier<ISessionStore> sessionStoreProvider) final Application
setStoreSettings
(StoreSettings storeSettings) final boolean
final boolean
protected void
Gives the Application object a chance to validate if it has been properly initialized
-
Field Details
-
CONFIGURATION
Configuration constant for the 2 types- See Also:
-
-
Constructor Details
-
Application
public Application()Constructor. Useinit()
for any configuration of your application instead of overriding the constructor.
-
-
Method Details
-
exists
Checks if theApplication
threadlocal is set in this thread- Returns:
- true if
get()
can return the instance of application, false otherwise
-
get
Get Application for current thread.- Returns:
- The current thread's Application
-
get
Gets the Application based on the application key of that application. You typically never have to use this method unless you are working on an integration project.- Parameters:
applicationKey
- The unique key of the application within a certain context (e.g. a web application)- Returns:
- The application or
null
if application has not been found
-
getApplicationKeys
Gets the keys of the currently registered Wicket applications for this web application. You typically never have to use this method unless you are working on an integration project.- Returns:
- unmodifiable set with keys that correspond with
getApplicationKey()
. Never null, but possibly empty
-
configure
Configures application settings to good defaults. -
getApplicationKey
Gets the unique key of this application within a given context (like a web application). NOT INTENDED FOR FRAMEWORK CLIENTS.- Returns:
- The unique key of this application
-
getConfigurationType
Gets the configuration mode to use for configuring the app, eitherRuntimeConfigurationType.DEVELOPMENT
orRuntimeConfigurationType.DEPLOYMENT
.The configuration type. Must currently be either DEVELOPMENT or DEPLOYMENT. Currently, if the configuration type is DEVELOPMENT, resources are polled for changes, component usage is checked, wicket tags are not stripped from output and a detailed exception page is used. If the type is DEPLOYMENT, component usage is not checked, wicket tags are stripped from output and a non-detailed exception page is used to display errors.
Note that you should not run Wicket in DEVELOPMENT mode on production servers - the various debugging checks and resource polling is inefficient and may leak resources, particularly on webapp redeploy.
To change the deployment mode, add the following to your web.xml, inside your
mapping (or mapping if you're using 1.3.x): <init-param> <param-name>configuration</param-name> <param-value>deployment</param-value> </init-param>
You can alternatively set this as a <context-param> on the whole context.
Another option is to set the "wicket.configuration" system property to either "deployment" or "development". The value is not case-sensitive.
The system property is checked first, allowing you to add a web.xml param for deployment, and a command-line override when you want to run in development mode during development.
You may also override Application.getConfigurationType() to provide your own custom switch, in which case none of the above logic is used.
IMPORTANT NOTE
THIS METHOD IS CALLED OFTEN FROM MANY DIFFERENT POINTS IN CODE, INCLUDING DURING THE RENDER PROCESS, THEREFORE THE IMPLEMENTATION SHOULD BE FAST - PREFERRABLY USING A FAST-TO-RETRIEVE CACHED VALUE- Returns:
- configuration
- Since:
- 1.2.3 (function existed as a property getter), 1.3.0 (abstract, used to configure things)
-
getHomePage
Application subclasses must specify a home page class by implementing this abstract method.- Returns:
- Home page class for this application
-
getConverterLocator
- Returns:
- The converter locator for this application
-
getMetaData
Gets metadata for this application using the given key.- Specified by:
getMetaData
in interfaceIMetadataContext<Object,
Application> - Type Parameters:
T
-- Parameters:
key
- The key for the data- Returns:
- The metadata
- See Also:
-
getName
Gets the name of this application.- Returns:
- The application name.
-
getRequestLogger
Gets theIRequestLogger
.- Returns:
- The RequestLogger
-
getSessionStore
Gets the facade object for working getting/ storing session instances.- Returns:
- The session facade
-
sessionUnbound
Description copied from interface:ISessionStore.UnboundListener
Informs the listener that session with specific id has been unbound.- Specified by:
sessionUnbound
in interfaceISessionStore.UnboundListener
- See Also:
-
logEventTarget
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.- Parameters:
target
-
-
logResponseTarget
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.- Parameters:
requestTarget
-
-
newSession
Creates a new session. Override this method if you want to provide a custom session.- Parameters:
request
- The request that will create this session.response
- The response to initialize, for example with cookies. This is important to use cases involving unit testing because those use cases might want to be able to sign a user in automatically when the session is created.- Returns:
- The session
- Since:
- 1.3
-
setMetaData
Sets the metadata for this application using the given key. If the metadata object is not of the correct type for the metadata key, an IllegalArgumentException will be thrown. For information on creating MetaDataKeys, seeMetaDataKey
.- Specified by:
setMetaData
in interfaceIMetadataContext<Object,
Application> - Type Parameters:
T
-- Parameters:
key
- The singleton key for the metadataobject
- The metadata object- Throws:
IllegalArgumentException
- See Also:
-
onDestroy
Called when wicket servlet is destroyed. Overrides do not have to call super. -
init
Allows for initialization of the application by a subclass. Use this method for any application setup instead of the constructor. -
internalDestroy
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. -
internalInit
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT OVERRIDE OR CALL. Internal initialization. -
getExceptionMapperProvider
Returns a supplier ofIExceptionMapper
that will be used to handle exceptions which were not handled by anyrequest cycle listener
.- Returns:
- the exception mapper supplier
- See Also:
-
setExceptionMapperProvider
-
getSessionStoreProvider
- Returns:
- Session state provider
-
setSessionStoreProvider
- Parameters:
sessionStoreProvider
-
-
newConverterLocator
Creates and returns a new instance ofIConverterLocator
.- Returns:
- A new
IConverterLocator
instance
-
newRequestLogger
creates a new request logger when requests logging is enabled.- Returns:
- The new request logger
-
getRootRequestMapperAsCompound
Converts the root mapper to aICompoundRequestMapper
if necessary and returns the converted instance.- Returns:
- compound instance of the root mapper
-
getRootRequestMapper
- Returns:
- The root request mapper
-
setRootRequestMapper
Sets the root request mapper- Parameters:
rootRequestMapper
-
-
initApplication
Initialize the application -
validateInit
Gives the Application object a chance to validate if it has been properly initialized -
setName
Sets application name. This method must be called before any other methods are invoked and can only be called once per application instance.- Parameters:
name
- unique application name
-
getMimeType
Returns the mime type for given filename.- Parameters:
fileName
-- Returns:
- mime type
-
onEvent
Called when an event is sent to this sink- Specified by:
onEvent
in interfaceIEventSink
-
getHeaderContributorListeners
- Returns:
- Gets the application's
HeaderContributorListenerCollection
-
getInitializers
- Returns:
- collection of initializers
-
getApplicationListeners
- Returns:
- collection of application listeners
-
getSessionListeners
- Returns:
- collection of session listeners
-
getBehaviorInstantiationListeners
- Returns:
- collection of behavior instantiation listeners
-
getOnComponentTagListeners
- Returns:
- collection of application's on-component-tag listeners
-
getComponentInstantiationListeners
- Returns:
- Gets the application's ComponentInstantiationListenerCollection
-
getComponentInitializationListeners
- Returns:
- Gets the application's ComponentInitializationListeners
-
getComponentOnConfigureListeners
- Returns:
- Gets the application's ComponentOnConfigureListeners
-
getComponentPreOnBeforeRenderListeners
- Returns:
- ComponentOnBeforeRenderListenerCollection
-
getComponentPostOnBeforeRenderListeners
- Returns:
- ComponentOnBeforeRenderListenerCollection
-
getComponentOnAfterRenderListeners
- Returns:
- on after render listeners collection
-
getRequestCycleListeners
- Returns:
- the unmodifiable request list of
IRequestCycleListener
s in this application
-
getApplicationSettings
- Returns:
- Application's application-wide settings
- Since:
- 1.2
-
setApplicationSettings
- Parameters:
applicationSettings
-
-
getJavaScriptLibrarySettings
- Returns:
- Application's JavaScriptLibrary settings
- Since:
- 6.0
-
setJavaScriptLibrarySettings
public final Application setJavaScriptLibrarySettings(JavaScriptLibrarySettings javaScriptLibrarySettings) - Parameters:
javaScriptLibrarySettings
-
-
getDebugSettings
- Returns:
- Application's debug related settings
-
setDebugSettings
- Parameters:
debugSettings
-
-
getExceptionSettings
- Returns:
- Application's exception handling settings
-
setExceptionSettings
- Parameters:
exceptionSettings
-
-
getFrameworkSettings
- Returns:
- Wicket framework settings
-
setFrameworkSettings
- Parameters:
frameworkSettings
-
-
getPageSettings
- Returns:
- Application's page related settings
-
setPageSettings
- Parameters:
pageSettings
-
-
getRequestCycleSettings
- Returns:
- Application's request cycle related settings
-
setRequestCycleSettings
- Parameters:
requestCycleSettings
-
-
getMarkupSettings
- Returns:
- Application's markup related settings
-
setMarkupSettings
- Parameters:
markupSettings
-
-
getRequestLoggerSettings
- Returns:
- Application's request logger related settings
-
setRequestLoggerSettings
- Parameters:
requestLoggerSettings
-
-
getResourceSettings
- Returns:
- Application's resources related settings
-
setResourceSettings
- Parameters:
resourceSettings
-
-
getSecuritySettings
- Returns:
- Application's security related settings
-
setSecuritySettings
- Parameters:
securitySettings
-
-
getStoreSettings
- Returns:
- Application's stores related settings
-
setStoreSettings
- Parameters:
storeSettings
-
-
checkSettingsAvailable
-
getPageManagerProvider
- Returns:
- PageManagerProvider
-
setPageManagerProvider
Set the provider of anIPageManager
.- Parameters:
provider
-- See Also:
-
getPageRendererProvider
- Returns:
- PageRendererProvider
-
setPageRendererProvider
- Parameters:
pageRendererProvider
-
-
newResourceReferenceRegistry
Override to create customResourceReferenceRegistry
.- Returns:
- new
ResourceReferenceRegistry
instance.
-
getResourceReferenceRegistry
ReturnsResourceReferenceRegistry
for this application.- Returns:
- ResourceReferenceRegistry
-
newResourceBundles
-
getResourceBundles
- Returns:
- The registry for resource bundles
-
newPageFactory
Override to create customIPageFactory
- Returns:
- new
IPageFactory
instance.
-
getPageFactory
ReturnsIPageFactory
for this application.- Returns:
- page factory
-
getMapperContext
- Returns:
- mapper context
-
newMapperContext
Factory method forIMapperContext
implementations.DefaultMapperContext
may be a good starting point for custom implementations.- Returns:
- new instance of mapper context to be used in the application
-
fetchCreateAndSetSession
- Parameters:
requestCycle
-- Returns:
- Session
-
getRequestCycleProvider
- Returns:
- RequestCycleProvider
-
setRequestCycleProvider
- Parameters:
requestCycleProvider
-
-
createRequestCycle
- Parameters:
request
-response
-- Returns:
- request cycle
-
getHeaderResponseDecorators
Returns theHeaderResponseDecoratorCollection
used by this application. On this collection you can add additional decorators, which will be nested in the order added.- Returns:
- The
HeaderResponseDecoratorCollection
used by this application.
-
decorateHeaderResponse
INTERNAL METHOD - You shouldn't need to call this. This is called every time Wicket creates an IHeaderResponse. It gives you the ability to incrementally add features to an IHeaderResponse implementation by wrapping it in another implementation. To decorate an IHeaderResponse in your application, set theIHeaderResponseDecorator
on the application.- Parameters:
response
- the response Wicket created- Returns:
- the response Wicket should use in IHeaderContributor traversal
- See Also:
-
usesDevelopmentConfig
- Returns:
- true, of app is in Development mode
-
usesDeploymentConfig
- Returns:
- true, of app is in Deployment mode
-