You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Resin 3.1.5 includes Wicket plugins to support full WebBeans (JSR-299) integration for the Wicket application object, and dependency injection for component objects.

The Application object can use the following capabilities:

  • Injection using @In, @Named, and custom @BindingType injection for both application services and components and app-server resources (databases, jms, ejb, etc)
  • Predefined aspects such as EJB's @TransactionAttribute and @RolesAllowed
  • Both WebBeans and EJB interception using @Interceptors or @InterceptionType
  • WebBeans @Observes for listening for application events

The components get @In and @Named injection, but not the other capabilities, since interception conflicts with the Wicket style of allowing components to use "new" for easy instantiation.

The three plugin classes are

  • com.caucho.wicket.ResinApplicationFactory - for creating applications
  • com.caucho.wicket.ResinComponentInjector - for injecting component resources
  • com.caucho.wicket.ResinWebApplication - as a convenience for injecting resources

The application factory is configured in Wicket's <filter> definition as the applicationFactoryClassName. The sample WEB-INF/resin-web.xml might look like the following:

<pre><code>
<web-app xmlns="http://caucho.com/ns/resin">

<filter filter-name="wicket"
filter-class="org.apache.wicket.protocol.http.WicketFilter">
<init-param
applicationClassName="demo.HelloWorldApplication"
applicationFactoryClassName="com.caucho.wicket.ResinApplicationFactory"/>
</filter>

<filter-mapping url-pattern="/*" filter-name="wicket"/>

</web-app>
</code></pre>

The component injector is registered with your Application object and looks like the following:

<pre><code>
import com.caucho.wicket.*;

public MyApplication extends WebApplication {
public MyApplication()

Unknown macro: { addComponentInstantiationListener(new ResinComponentInjector()); }

...
}
</code></pre>

The Resin wiki page at http://wiki.caucho.com/Wicket also provides an up-to-date documentation of the integration.

  • No labels