-
Notifications
You must be signed in to change notification settings - Fork 16
Servlets Integration
Integration EverRest framework and servlet container
EverRest framework contains all components required to integrate it with servlet container. You need add following lines in your web.xml
:
<context-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.everrest.example.MyApplication</param-value>
</context-param>
<listener>
<listener-class>org.everrest.core.servlet.EverrestInitializedListener</listener-class>
</listener>
<servlet>
<servlet-name>EverrestServlet</servlet-name>
<servlet-class>org.everrest.core.servlet.EverrestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EverrestServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Context parameter javax.ws.rs.Application
contains full qualified name of sub-class of javax.ws.rs.core.Application
that should deliver classes or instances of JAX-RS components in EverRest framework.
public class MyApplication extends Application
{
@Override
public Set<Class<?>> getClasses()
{
Set<Class<?>> cls = new HashSet<Class<?>>(1);
cls.add(MyResource.class);
return cls;
}
@Override
public Set<Object> getSingletons()
{
Set<Object> objs = new HashSet<Object>(1);
objs.add(new MyProvider());
return objs;
}
}
If parameter javax.ws.rs.Application
is not configured in web.xml then EverRest can be set up to scan all components in your web application and register it. The table summarizes context parameter that can be used to manage behavior of EverRest.
Parameter name | Default value | Description |
---|---|---|
javax.ws.rs.Application | none | Full qualified name of sub-class of javax.ws.rs.core.Application that should deliver classes or instances JAX-RS components |
org.everrest.scan.components | false | If true then EverRest will look up classes which annotated with @Path , @Provider and @org.everrest.core.Filter annotations and register it. Note: This parameter will be ignored if javax.ws.rs.Application is set up. |
org.everrest.scan.skip.packages | org.everrest.core,javax.ws.rs | Packages which should be skipped for scanning. This parameter has sence only if parameter org.everrest.scan.components is true
|
org.everrest.core.servlet.EverrestInitializedListener
initialize components of EverRest framework.
org.everrest.core.servlet.EverrestServlet
deliver HTTP request to EverRest.
Example of using EverRest in servlet environment can be found at subversion repository, see project everrest/everrest-samples/book-service
. You can simple run it with command: mvn jetty:run
. See details how-to try example in README.html in correspond project.
There is special project everrest-project-template-war
. This project can help to developer easier to create own wars projects. It can be used as template or dependency for own maven projects. About using as dependency see here for details.