I got some big help from others who took the time to post ideas about
integrating Wicket and Restlet [1] [2], so I figured I'd share
something I figured out. The missing link for me was to get the
SpringBean's in the Restlet Resource's working in unit tests and thus
getting the Wicket Application set on the thread used to handle the
Restlet Resource request.
In short, you just override Restlet#handle and set the Wicket
Application prior to the rest of the handle call. Note that I use
'WebApplication' below only to differentiate from the same-named
Restlet Application. Also, this is example code; in my real code I
use a Template Method to get a custom Router w/webapp, much like some
people override their spring injector for unit tests.
import org.apache.wicket.protocol.http.WebApplication;
import org.restlet.Application;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Router;
import org.restlet.data.Request;
import org.restlet.data.Response;
public class TestApplication extends Application
{
private WebApplication webapp;
public TestApplication( Context parentContext, WebApplication webapp )
{
super( parentContext );
this.webapp = webapp;
}
@Override
public synchronized Restlet createRoot()
{
Router router = new Router( getContext() )
{
public void handle( Request request, Response response )
{
WebApplication.set( webapp ); // <-- set
webapp before handle
super.handle( request, response );
}
};
router.attach( "/test", TestResource.class );
return router;
}
}
HTH,
Enrique
[1]
http://www.nabble.com/Re%3A-Feature-request%3A-using-%40SpringBean-outside-Wicket-request-p16582239.html
[2] http://blog.ehour.nl/index.php/archives/21
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]