Class OsgiWebApplicationFactory

  • All Implemented Interfaces:
    IWebApplicationFactory

    public class OsgiWebApplicationFactory
    extends Object
    implements IWebApplicationFactory
    An IWebApplicationFactory which looks up a WebApplication from the OSGi service registry.

    In an OSGi context, classes from client bundles cannot be loaded by name in general. This factory loads a WebApplication service from the OSGi service registry, using a property with key APPLICATION_NAME_KEY for disambiguation.

    To bootstrap your Wicket Application when running under OSGi, configure the WicketFilter in your web.xml deployment descriptor as follows:

       <filter>
         <filter-name>Wicket</filter-name>
         <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
         <init-param>
           <param-name>applicationFactoryClassName</param-name>
           <param-value>org.wicketstuff.osgi.OsgiWebApplicationFactory</param-value>
         </init-param>
         <init-param>
           <param-name>wicket.osgi.application.name</param-name>
           <param-value>someUniqueApplicationName</param-value>
         </init-param>
       </filter>
     
    The implementation uses a ServiceTracker waiting for a given period for the service to become available.

    You need to register your WebApplication class in the OSGi service registry by any method of your choice, e.g. programmatically in a BundleActivator, or using Declarative Services or Blueprint.

    Author:
    Harald Wellmann