package org.apache.wicket;
Base class for all Wicket applications. To create a Wicket application, you generally should
not directly subclass this class. Instead, you will want to subclass some subclass of
Application, like WebApplication, which is appropriate for the protocol and markup type you are
working with.
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(org.apache.wicket.Request,org.apache.wicket.Response). For subclasses of
org.apache.wicket.protocol.http.WebApplication you will want to subclass org.apache.wicket.protocol.http.WebSession.
Configuration constant for the 2 types
Configuration type constant for getting the context path out of the web.xml
Configuration type constant for deployment
Configuration type constant for development
Applications keyed on the
getApplicationKey() so that they can be retrieved even
without being in a request/ being set in the thread local (we need that e.g. for when we are
in a destruction thread).
Thread local holder of the application object.
Checks if the
Application threadlocal is set in this thread
- Returns:
- true if
get() can return the instance of application, false
otherwise
public static boolean exists()
Get Application for current thread.
- Returns:
- The current thread's Application
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
- Throws:
java.lang.IllegalArgumentException
When no application was found with the provided key
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
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
- Parameters:
application
The current application or null for this thread
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
public static void unset()
The converter locator instance.
Application level meta data.
Name of application subclass.
Settings for this application.
can the settings object be set/used.
Shared resources for this application
Constructor.
Use init() for any configuration of your application instead of
overriding the constructor.
Adds a component instantiation listener. This method should typically only be called during
application startup; it is not thread safe.
Note: wicket does not guarantee the execution order of added listeners
- Parameters:
listener
the listener to add
Configures application settings to good defaults.
"'. Must be \"development\" or \"deployment\".");
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
Gets the configuration mode to use for configuring the app, either
DEVELOPMENT or
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.
- Returns:
- configuration
- Since:
- 1.2.3 (function existed as a property getter)
- 1.3.0 (abstract, used to configure things)
- Returns:
- The converter locator for this application
Application subclasses must specify a home page class by implementing this abstract method.
- Returns:
- Home page class for this application
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT.
Gets metadata for this application using the given key.
- Parameters:
key
The key for the data- Returns:
- The metadata
- See also:
MetaDataKey
Gets the name of this application.
- Returns:
- The application name.
Gets the facade object for working getting/ storing session instances.
- Returns:
- The session facade
Gets the shared resources.
- Returns:
- The SharedResources for this application.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
Initializes wicket components.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
Creates a new RequestCycle object. Override this method if you want to provide a custom
request cycle.
- Parameters:
request
The requestresponse
The response- Returns:
- The request cycle
- Since:
- 1.3
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
Removes a component instantiation listener. This method should typicaly only be called during
application startup; it is not thread safe.
- Parameters:
listener
the listener to remove
final int len = listeners.length;
if (listener != null && len > 0)
for (pos = 0; pos < len; pos++)
if (listener == listeners[pos])
listeners[pos] = listeners[len - 1];
System.arraycopy(listeners, 0, newListeners, 0, newListeners.length);
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, see
MetaDataKey.
Construct and add initializer from the provided class name.
Iterate initializers list, calling any
IDestroyer instances found
in it.
Iterate initializers list, calling any instances found in it.
This method is still here for backwards compatibility with 1.1 source code. The
getXXXSettings() methods are now preferred. This method will be removed post 1.2 version.
"Use Application.init() method for configuring your application object");
- Parameters:
properties
Properties map with names of any library initializers in it
Called when wicket servlet is destroyed. Overrides do not have to call super.
Called when wicket servlet is destroyed. Overrides do not have to call super.
Gets the factory for creating session instances.
Allows for initialization of the application by a subclass.
Use this method for any
application setup instead of the constructor.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT OVERRIDE OR CALL.
Internal initialization.
creates a new request logger when requests logging is enabled.
- Returns:
- The new request logger
Creates a new session facade. Is called once per application, and is typically not something
clients reimplement.
- Returns:
- The session facade
Notifies the registered component instantiation listeners of the construction of the provided
component
- Parameters:
component
the component that is being instantiated
for (int i = 0; i < len; i++)
Adds a listener that will be invoked for every header response