Skip to content

Commit

Permalink
GuiceResteasyBootstrapServletContextListener#getStage(ServletContext)
Browse files Browse the repository at this point in the history
can be overridden.
  • Loading branch information
mwanji committed Jun 7, 2013
1 parent b66b4db commit c98307e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion jaxrs/docbook/reference/en/en-US/modules/Guice.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,18 @@ public class MyClass
<title>Custom Injector creation</title>
<para>
GuiceResteasyBootstrapServletContextListener can be extended to allow more flexibility in the way the Injector and Modules
are created. Two methods can be overridden: getModules() and withInjector() Register your subclass as the listener in the web.xml.
are created. Three methods can be overridden: getModules(), withInjector() and getStage(). Register your subclass as the
listener in the web.xml.
</para>
<para>
Override getModules() when you need to pass arguments to your modules' constructor or perform more complex operations.
</para>
<para>
Override withInjector(Injector) when you need to interact with the Injector after it has been created.
</para>
<para>
Override getStage(ServletContext) to set the Stage yourself.
</para>
<programlisting>
<![CDATA[
<web-app>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ public void contextInitialized(final ServletContextEvent event)
}

/**
* Override this method to interact with the {@link Injector} after it has been created.
* Override this method to interact with the {@link Injector} after it has been created. The default is no-op.
*
* @param injector
*/
protected void withInjector(Injector injector)
{
}

private Stage getStage(ServletContext context)
/**
* Override this method to set the Stage. By default it is taken from resteasy.guice.stage context param.
*
* @param context
* @return Guice Stage
*/
protected Stage getStage(ServletContext context)
{
final String stageAsString = context.getInitParameter("resteasy.guice.stage");
if (stageAsString == null)
Expand Down

0 comments on commit c98307e

Please sign in to comment.