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
public class CamelServlet extends javax.servlet.http.HttpServlet implements HttpRegistryProvider
A servlet to use as a Camel route as entry.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ASYNC_PARAM
static String
EXECUTOR_REF_PARAM
static String
FORCE_AWAIT_PARAM
protected org.slf4j.Logger
log
static List<String>
METHODS
-
Constructor Summary
Constructors Constructor Description CamelServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
afterProcess(javax.servlet.http.HttpServletResponse res, HttpConsumer consumer, org.apache.camel.Exchange exchange, boolean rethrow)
void
connect(HttpConsumer consumer)
void
disconnect(HttpConsumer consumer)
protected void
doService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
This is the logical implementation to handle request withCamelServlet
This is where most exceptions should be handledprotected void
doServiceAsync(javax.servlet.AsyncContext context)
This is used to handle request asynchronouslyMap<String,HttpConsumer>
getConsumers()
protected Executor
getExecutorService(HttpConsumer consumer)
String
getServletName()
ServletResolveConsumerStrategy
getServletResolveConsumerStrategy()
void
init(javax.servlet.ServletConfig config)
boolean
isAsync()
protected ClassLoader
overrideTccl(org.apache.camel.Exchange exchange)
Override the Thread Context ClassLoader if need be.protected HttpConsumer
resolve(javax.servlet.http.HttpServletRequest request)
protected void
restoreTccl(org.apache.camel.Exchange exchange, ClassLoader oldTccl)
Restore the Thread Context ClassLoader if the old TCCL is not null.protected void
service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
void
setAsync(boolean async)
void
setServletName(String servletName)
void
setServletResolveConsumerStrategy(ServletResolveConsumerStrategy servletResolveConsumerStrategy)
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
-
-
-
Field Detail
-
ASYNC_PARAM
public static final String ASYNC_PARAM
- See Also:
- Constant Field Values
-
FORCE_AWAIT_PARAM
public static final String FORCE_AWAIT_PARAM
- See Also:
- Constant Field Values
-
EXECUTOR_REF_PARAM
public static final String EXECUTOR_REF_PARAM
- See Also:
- Constant Field Values
-
log
protected final org.slf4j.Logger log
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
- Specified by:
init
in interfacejavax.servlet.Servlet
- Overrides:
init
in classjavax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException
-
service
protected void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException
- Overrides:
service
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
IOException
-
getExecutorService
protected Executor getExecutorService(HttpConsumer consumer)
-
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 withCamelServlet
This is where most exceptions should be handled- Parameters:
request
- theHttpServletRequest
response
- theHttpServletResponse
- Throws:
javax.servlet.ServletException
IOException
-
afterProcess
protected void afterProcess(javax.servlet.http.HttpServletResponse res, HttpConsumer consumer, org.apache.camel.Exchange exchange, boolean rethrow) throws IOException, javax.servlet.ServletException
- Throws:
IOException
javax.servlet.ServletException
-
resolve
@Deprecated protected HttpConsumer resolve(javax.servlet.http.HttpServletRequest request)
-
connect
public void connect(HttpConsumer consumer)
- Specified by:
connect
in interfaceHttpRegistryProvider
-
disconnect
public void disconnect(HttpConsumer consumer)
- Specified by:
disconnect
in interfaceHttpRegistryProvider
-
getServletName
public String getServletName()
- Specified by:
getServletName
in interfaceHttpRegistryProvider
- Specified by:
getServletName
in interfacejavax.servlet.ServletConfig
- Overrides:
getServletName
in classjavax.servlet.GenericServlet
-
setServletName
public void setServletName(String servletName)
-
getServletResolveConsumerStrategy
public ServletResolveConsumerStrategy getServletResolveConsumerStrategy()
-
setServletResolveConsumerStrategy
public void setServletResolveConsumerStrategy(ServletResolveConsumerStrategy servletResolveConsumerStrategy)
-
isAsync
public boolean isAsync()
-
setAsync
public void setAsync(boolean async)
-
getConsumers
public Map<String,HttpConsumer> getConsumers()
-
overrideTccl
protected ClassLoader overrideTccl(org.apache.camel.Exchange exchange)
Override the Thread Context ClassLoader if need be.- Returns:
- old classloader if overridden; otherwise returns null
-
restoreTccl
protected void restoreTccl(org.apache.camel.Exchange exchange, ClassLoader oldTccl)
Restore the Thread Context ClassLoader if the old TCCL is not null.
-
-