Package org.apache.camel.http.common
Class CamelServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.apache.camel.http.common.CamelServlet
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig,HttpRegistryProvider
A servlet to use as a Camel route as entry.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterProcess(javax.servlet.http.HttpServletResponse res, HttpConsumer consumer, org.apache.camel.Exchange exchange, boolean rethrow) voidconnect(HttpConsumer consumer) voiddisconnect(HttpConsumer consumer) protected voiddoService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) This is the logical implementation to handle request withCamelServletThis is where most exceptions should be handledprotected voiddoServiceAsync(javax.servlet.AsyncContext context) This is used to handle request asynchronouslyprotected ExecutorgetExecutorService(HttpConsumer consumer) protected voidhandleService(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) voidinit(javax.servlet.ServletConfig config) booleanisAsync()protected ClassLoaderoverrideTccl(org.apache.camel.Exchange exchange) Override the Thread Context ClassLoader if need be.protected HttpConsumerresolve(javax.servlet.http.HttpServletRequest request) Deprecated.protected voidrestoreTccl(org.apache.camel.Exchange exchange, ClassLoader oldTccl) Restore the Thread Context ClassLoader if the old TCCL is not null.protected voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voidsetAsync(boolean async) voidsetServletName(String servletName) voidsetServletResolveConsumerStrategy(ServletResolveConsumerStrategy servletResolveConsumerStrategy) Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, serviceMethods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, init, log, log
-
Field Details
-
ASYNC_PARAM
- See Also:
-
FORCE_AWAIT_PARAM
- See Also:
-
EXECUTOR_REF_PARAM
- See Also:
-
METHODS
-
log
protected final org.slf4j.Logger log
-
-
Constructor Details
-
CamelServlet
public CamelServlet()
-
-
Method Details
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException - Specified by:
initin interfacejavax.servlet.Servlet- Overrides:
initin classjavax.servlet.GenericServlet- Throws:
javax.servlet.ServletException
-
service
protected void service(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) - Overrides:
servicein classjavax.servlet.http.HttpServlet
-
handleService
protected void handleService(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException - Throws:
javax.servlet.ServletExceptionIOException
-
getExecutorService
-
doServiceAsync
protected void doServiceAsync(javax.servlet.AsyncContext context) This is used to handle request asynchronously- Parameters:
context- theAsyncContext
-
doService
protected void doService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException This is the logical implementation to handle request withCamelServletThis is where most exceptions should be handled- Parameters:
request- theHttpServletRequestresponse- theHttpServletResponse- Throws:
javax.servlet.ServletExceptionIOException
-
afterProcess
protected void afterProcess(javax.servlet.http.HttpServletResponse res, HttpConsumer consumer, org.apache.camel.Exchange exchange, boolean rethrow) throws IOException, javax.servlet.ServletException - Throws:
IOExceptionjavax.servlet.ServletException
-
resolve
-
connect
- Specified by:
connectin interfaceHttpRegistryProvider
-
disconnect
- Specified by:
disconnectin interfaceHttpRegistryProvider
-
getServletName
- Specified by:
getServletNamein interfaceHttpRegistryProvider- Specified by:
getServletNamein interfacejavax.servlet.ServletConfig- Overrides:
getServletNamein classjavax.servlet.GenericServlet
-
setServletName
-
getServletResolveConsumerStrategy
-
setServletResolveConsumerStrategy
public void setServletResolveConsumerStrategy(ServletResolveConsumerStrategy servletResolveConsumerStrategy) -
isAsync
public boolean isAsync() -
setAsync
public void setAsync(boolean async) -
getConsumers
-
overrideTccl
Override the Thread Context ClassLoader if need be.- Returns:
- old classloader if overridden; otherwise returns null
-
restoreTccl
Restore the Thread Context ClassLoader if the old TCCL is not null.
-
ServletResolveConsumerStrategy.resolve(javax.servlet.http.HttpServletRequest, java.util.Map)