public abstract class Application extends Object implements ISessionStore.UnboundListener, IEventSink
Application has the following interesting features / attributes:
ResourceReference
for more details.
Session
subclass you
must override ApplicationnewSession(Request, Response)
. For subclasses of
WebApplication
you will want to subclass WebSession
.
WebApplication
Modifier and Type | Field and Description |
---|---|
static String |
CONFIGURATION
Configuration constant for the 2 types
|
Constructor and Description |
---|
Application()
Constructor.
|
public static final String CONFIGURATION
public Application()
init()
for any configuration of your application instead of
overriding the constructor.public static boolean exists()
Application
threadlocal is set in this threadget()
can return the instance of application, false
otherwisepublic static Application get()
public static Application get(String applicationKey)
applicationKey
- The unique key of the application within a certain context (e.g. a web
application)null
if application has not been foundpublic static Set<String> getApplicationKeys()
getApplicationKey()
. Never
null, but possibly emptypublic final void configure()
public abstract String getApplicationKey()
public abstract RuntimeConfigurationType getConfigurationType()
RuntimeConfigurationType.DEVELOPMENT
or RuntimeConfigurationType.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
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.
<init-param>
<param-name>configuration</param-name>
<param-value>deployment</param-value>
</init-param>
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 VALUEpublic abstract Class<? extends Page> getHomePage()
public final IConverterLocator getConverterLocator()
public final <T> T getMetaData(MetaDataKey<T> key)
T
- key
- The key for the dataMetaDataKey
public final String getName()
public final IRequestLogger getRequestLogger()
IRequestLogger
.public final ISessionStore getSessionStore()
public void sessionUnbound(String sessionId)
ISessionStore.UnboundListener
sessionUnbound
in interface ISessionStore.UnboundListener
ISessionStore.UnboundListener.sessionUnbound(java.lang.String)
public void logEventTarget(IRequestHandler target)
target
- public void logResponseTarget(IRequestHandler requestTarget)
requestTarget
- public abstract Session newSession(Request request, Response response)
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.public final <T> Application setMetaData(MetaDataKey<T> key, Object object)
MetaDataKey
.T
- key
- The singleton key for the metadataobject
- The metadata objectIllegalArgumentException
MetaDataKey
protected void onDestroy()
protected void init()
public void internalDestroy()
protected void internalInit()
public Supplier<IExceptionMapper> getExceptionMapperProvider()
IExceptionMapper
that will be used to
handle exceptions which were not handled by any
request cycle listener
.IRequestCycleListener.onException(RequestCycle, Exception)
public final Supplier<ISessionStore> getSessionStoreProvider()
public final Application setSessionStoreProvider(Supplier<ISessionStore> sessionStoreProvider)
sessionStoreProvider
- protected IConverterLocator newConverterLocator()
IConverterLocator
.IConverterLocator
instanceprotected IRequestLogger newRequestLogger()
public final ICompoundRequestMapper getRootRequestMapperAsCompound()
ICompoundRequestMapper
if necessary and returns the
converted instance.public final IRequestMapper getRootRequestMapper()
public final Application setRootRequestMapper(IRequestMapper rootRequestMapper)
rootRequestMapper
- public final void initApplication()
protected void validateInit()
public final void setName(String name)
name
- unique application namepublic String getMimeType(String fileName)
fileName
- public void onEvent(IEvent<?> event)
onEvent
in interface IEventSink
public final HeaderContributorListenerCollection getHeaderContributorListeners()
HeaderContributorListenerCollection
public final List<IInitializer> getInitializers()
public final ApplicationListenerCollection getApplicationListeners()
public final SessionListenerCollection getSessionListeners()
public final BehaviorInstantiationListenerCollection getBehaviorInstantiationListeners()
public final OnComponentTagListenerCollection getOnComponentTagListeners()
public final ComponentInstantiationListenerCollection getComponentInstantiationListeners()
public final ComponentInitializationListenerCollection getComponentInitializationListeners()
public final ComponentOnConfigureListenerCollection getComponentOnConfigureListeners()
public final ComponentOnBeforeRenderListenerCollection getComponentPreOnBeforeRenderListeners()
public final ComponentOnBeforeRenderListenerCollection getComponentPostOnBeforeRenderListeners()
public final ComponentOnAfterRenderListenerCollection getComponentOnAfterRenderListeners()
public RequestCycleListenerCollection getRequestCycleListeners()
IRequestCycleListener
s in this applicationpublic final ApplicationSettings getApplicationSettings()
public final Application setApplicationSettings(ApplicationSettings applicationSettings)
applicationSettings
- public final JavaScriptLibrarySettings getJavaScriptLibrarySettings()
public final Application setJavaScriptLibrarySettings(JavaScriptLibrarySettings javaScriptLibrarySettings)
javaScriptLibrarySettings
- public final DebugSettings getDebugSettings()
public final Application setDebugSettings(DebugSettings debugSettings)
debugSettings
- public final ExceptionSettings getExceptionSettings()
public final Application setExceptionSettings(ExceptionSettings exceptionSettings)
exceptionSettings
- public final FrameworkSettings getFrameworkSettings()
public final Application setFrameworkSettings(FrameworkSettings frameworkSettings)
frameworkSettings
- public final PageSettings getPageSettings()
public final Application setPageSettings(PageSettings pageSettings)
pageSettings
- public final RequestCycleSettings getRequestCycleSettings()
public final Application setRequestCycleSettings(RequestCycleSettings requestCycleSettings)
requestCycleSettings
- public MarkupSettings getMarkupSettings()
public final Application setMarkupSettings(MarkupSettings markupSettings)
markupSettings
- public final RequestLoggerSettings getRequestLoggerSettings()
public final Application setRequestLoggerSettings(RequestLoggerSettings requestLoggerSettings)
requestLoggerSettings
- public final ResourceSettings getResourceSettings()
public final Application setResourceSettings(ResourceSettings resourceSettings)
resourceSettings
- public final SecuritySettings getSecuritySettings()
public final Application setSecuritySettings(SecuritySettings securitySettings)
securitySettings
- public final StoreSettings getStoreSettings()
public final Application setStoreSettings(StoreSettings storeSettings)
storeSettings
- public final IPageManagerProvider getPageManagerProvider()
public final Application setPageManagerProvider(IPageManagerProvider provider)
provider
- protected IPageManagerContext getPageManagerContext()
public final IPageRendererProvider getPageRendererProvider()
public final Application setPageRendererProvider(IPageRendererProvider pageRendererProvider)
pageRendererProvider
- protected ResourceReferenceRegistry newResourceReferenceRegistry()
ResourceReferenceRegistry
.ResourceReferenceRegistry
instance.public final ResourceReferenceRegistry getResourceReferenceRegistry()
ResourceReferenceRegistry
for this application.protected SharedResources newSharedResources(ResourceReferenceRegistry registry)
registry
- public SharedResources getSharedResources()
protected ResourceBundles newResourceBundles(ResourceReferenceRegistry registry)
public ResourceBundles getResourceBundles()
protected IPageFactory newPageFactory()
IPageFactory
IPageFactory
instance.public final IPageFactory getPageFactory()
IPageFactory
for this application.public final IMapperContext getMapperContext()
protected IMapperContext newMapperContext()
IMapperContext
implementations. DefaultMapperContext
may
be a good starting point for custom implementations.public Session fetchCreateAndSetSession(RequestCycle requestCycle)
requestCycle
- public final IRequestCycleProvider getRequestCycleProvider()
public final Application setRequestCycleProvider(IRequestCycleProvider requestCycleProvider)
requestCycleProvider
- public final RequestCycle createRequestCycle(Request request, Response response)
request
- response
- public final Application setHeaderResponseDecorator(IHeaderResponseDecorator headerResponseDecorator)
IHeaderResponseDecorator
that you want your application to use to decorate
header responses.
Calling this method replaces the default decorator, which utilizes a ResourceAggregator
:
The given implementation should make sure, that it too wraps responses in a ResourceAggregator
,
otherwise no dependencies for HeaderItem
s will be resolved.
headerResponseDecorator
- your custom decorator, must not be nullpublic final IHeaderResponse decorateHeaderResponse(IHeaderResponse response)
IHeaderResponseDecorator
on the application.response
- the response Wicket createdIHeaderResponseDecorator
public final boolean usesDevelopmentConfig()
public final boolean usesDeploymentConfig()
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.