<chapter id="Configuring_Individual_Jakarta_REST_Resource_Beans">
<title>Configuring Individual &REST-API; Resource Beans</title>

<para>


</para>
<para>

If you are scanning your path for &REST-API; annotated resource beans, your beans will be registered in per-request mode.  This means an instance will be created per HTTP request served.  Generally, you will need information from your environment.  If you are running within a servlet container using the WAR-file distribution, in 1.0.0.Beta-2 and lower, you can only use the JNDI lookups to obtain references to Jakarta EE resources and configuration information.  In this case, define your Jakarta EE configuration (i.e. ejb-ref, env-entry, persistence-context-ref, etc...) within web.xml of the resteasy WAR file.  Then within your code do jndi lookups in the java:comp namespace.  For example:
</para>
<para>

web.xml
<programlisting>

&lt;ejb-ref&gt;
  &lt;ejb-ref-name&gt;ejb/foo&lt;/ejb-ref-name&gt;
  ...
&lt;/ejb-ref&gt;

</programlisting>
</para>
<para>

resource code:
<programlisting>
@Path("/")
public class MyBean {

   public Object getSomethingFromJndi() {
      new InitialContext.lookup("java:comp/ejb/foo");
   }
...
}
</programlisting>
</para>
<para>


</para>
<para>

You can also manually configure and register your beans through the Registry.  To do this in a WAR-based deployment, you need to write a specific ServletContextListener to do this.  Within the listener, you can obtain a reference to the registry as follows:
</para>
<para>

<programlisting>

public class MyManualConfig implements ServletContextListener
{
   public void contextInitialized(ServletContextEvent event)
   {

      Registry registry = (Registry) event.getServletContext().getAttribute(Registry.class.getName());

   }
...
}

</programlisting>
</para>
<para>

Please also take a look at our Spring Integration as well as the Embedded Container's Spring Integration
</para>
<para>

</para>
<para>


</para>
</chapter>
