On 23/08/2013 13:28, Bob DeRemer wrote:
> 
> 
>> -----Original Message-----
>> From: Mark Thomas [mailto:ma...@apache.org]
>> Sent: Friday, August 23, 2013 8:14 AM
>> To: Tomcat Users List
>> Subject: Re: is it possible to dynamically add servlets and websocket 
>> endpoints
>> during startup based on our own configuration settings?
>>
>> On 22/08/2013 19:32, Bob DeRemer wrote:
>>> I'm in the process of developing a configurable server application
>>> which must handle various protocols, but the respective endpoints must
>>> be configurable.  Specifically, I would like to programmatically add
>>> both HTTP servlet(s) as well as WebSocket Servlets/Endpoints during
>>> the contextInitialized call [based on our own configuration settings],
>>> as opposed to having all servlets in web.xml or annotated classes
>>> loaded automatically.
>>>
>>> Is this possible in Tomcat 7; and, if yes, are there any examples?  I
>>> know the Endpoint aspect of the question depends on JSR-356 being
>>> back-ported.
>>
>> Yes, it is possible.
>>
>> There are some examples in the unit tests:
>>
>> http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/Test
>> StandardContext.java?view=annotate
>>
>> Look for calls to addServlet(...)
> 
> Great!  So, how do I tell Tomcat NOT to load anything in the first place?

Exclude the JARs containing the Servlets with an absolute-ordering in
web.xml

>  Can I still use Annotation on my servlets, or will I have to use an 
> interface-based approach?

I don't believe @WebServlet has any effect when adding Servlets via
addServlet()

> Also, how about for the JSR-356 Endpoints?  Is there an addEndpoint(...) call?

Yes on ServerContainer, as long as you do it before any of them are used.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to