I have a standalone application with embedded Jetty and Wicket.
I'd like to use CDI for injection.
So I've found http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#d0e5286
and now I'm trying to add this programatically, but it's quite complex.
How do I code that?
Other sources I've found are:
- http://osdir.com/ml/java.jetty.support/2007-02/msg00198.html
- http://docs.codehaus.org/display/JETTY/JNDI
So far I have:
Server server = new Server( 8080 );
Context ctx = new Context( server, "/", Context.NO_SECURITY | Context.SESSIONS );
try {
//BeanManager
new org.mortbay.jetty.plus.naming.Resource( ctx, "BeanManager",
new javax.naming.Reference(
"javax.enterprise.inject.spi.BeanManager",
"org.jboss.weld.resources.ManagerObjectFactory", null )
);
} catch ( NamingException ex ) {
log.error(...);
}
// Wicket.
final ServletHolder wicketSH = new ServletHolder( new MyReloadingWicketServlet() );
wicketSH.setInitParameter( "applicationClassName", WicketApplication.class.getName() );
ctx.addServlet( wicketSH, "/*" );